You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicemix.apache.org by js...@apache.org on 2006/06/30 19:19:37 UTC
svn commit: r418334 -
/incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/client/DefaultDestination.java
Author: jstrachan
Date: Fri Jun 30 10:19:36 2006
New Revision: 418334
URL: http://svn.apache.org/viewvc?rev=418334&view=rev
Log:
removed the experimental Client API for now (we can bring it back later if we think its a good idea) - and instead merged the Destination feature into the existing ServiceMixClient so that you can create a Destination for a URI to act as a factory of exchanges so that Destinations can be used kinda like in JMS
Added:
incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/client/DefaultDestination.java (with props)
Added: incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/client/DefaultDestination.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/client/DefaultDestination.java?rev=418334&view=auto
==============================================================================
--- incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/client/DefaultDestination.java (added)
+++ incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/client/DefaultDestination.java Fri Jun 30 10:19:36 2006
@@ -0,0 +1,84 @@
+/**
+ *
+ * Copyright 2005-2006 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.servicemix.client;
+
+import org.apache.servicemix.jbi.resolver.URIResolver;
+import org.w3c.dom.DocumentFragment;
+
+import javax.jbi.messaging.InOnly;
+import javax.jbi.messaging.InOptionalOut;
+import javax.jbi.messaging.InOut;
+import javax.jbi.messaging.MessageExchange;
+import javax.jbi.messaging.MessagingException;
+import javax.jbi.messaging.RobustInOnly;
+import javax.jbi.servicedesc.ServiceEndpoint;
+
+/**
+ *
+ * @version $Revision$
+ */
+public class DefaultDestination implements Destination {
+
+ private ServiceMixClient client;
+ private ServiceEndpoint endpoint;
+ private String destinationUri;
+
+ public static ServiceEndpoint resolveEndpoint(ServiceMixClient client, String destinationUri) throws MessagingException {
+ DocumentFragment epr = URIResolver.createWSAEPR(destinationUri);
+ ServiceEndpoint endpoint = client.getContext().resolveEndpointReference(epr);
+ if (endpoint == null) {
+ throw new MessagingException("Could not resolve uri '" + destinationUri + "' into a ServiceEndpoint");
+ }
+ return endpoint;
+ }
+
+ public DefaultDestination(ServiceMixClient client, String destinationUri) throws MessagingException {
+ this.client = client;
+ this.destinationUri = destinationUri;
+ }
+
+ public InOnly createInOnlyExchange() throws MessagingException {
+ InOnly answer = client.createInOnlyExchange();
+ configure(answer);
+ return answer;
+ }
+
+ public InOptionalOut createInOptionalOutExchange() throws MessagingException {
+ InOptionalOut answer = client.createInOptionalOutExchange();
+ configure(answer);
+ return answer;
+ }
+
+ public InOut createInOutExchange() throws MessagingException {
+ InOut answer = client.createInOutExchange();
+ configure(answer);
+ return answer;
+ }
+
+ public RobustInOnly createRobustInOnlyExchange() throws MessagingException {
+ RobustInOnly answer = client.createRobustInOnlyExchange();
+ configure(answer);
+ return answer;
+ }
+
+ protected void configure(MessageExchange exchange) throws MessagingException {
+ if (endpoint == null) {
+ endpoint = resolveEndpoint(client, destinationUri);
+ }
+ exchange.setEndpoint(endpoint);
+ }
+}
Propchange: incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/client/DefaultDestination.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/client/DefaultDestination.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange: incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/client/DefaultDestination.java
------------------------------------------------------------------------------
svn:mime-type = text/plain