| Commit in servicemix/tooling/servicemix-client/src/main/java/org/servicemix/client on MAIN | |||
| ServiceContext.java | +133 | -20 | 1.1 -> 1.2 |
Added the rest of the exchange create helpers to the ServiceContext
servicemix/tooling/servicemix-client/src/main/java/org/servicemix/client
diff -u -r1.1 -r1.2 --- ServiceContext.java 18 Aug 2005 17:19:36 -0000 1.1 +++ ServiceContext.java 18 Aug 2005 19:23:36 -0000 1.2 @@ -21,9 +21,12 @@
import javax.jbi.messaging.DeliveryChannel; import javax.jbi.messaging.ExchangeStatus; import javax.jbi.messaging.InOnly;
+import javax.jbi.messaging.InOptionalOut; +import javax.jbi.messaging.InOut;
import javax.jbi.messaging.MessageExchange; import javax.jbi.messaging.MessageExchangeFactory; import javax.jbi.messaging.MessagingException;
+import javax.jbi.messaging.RobustInOnly;
import javax.xml.namespace.QName; /**
@@ -51,13 +54,78 @@
this.endPointRegistry = registry; }
- public MessageExchangeFactory getMessageExchangeFactory()
+ /**
+ * Creates an InOnly exchange by looking up the defined interface as a
+ * 'Consumes' interface and picking up the service name, not that if the
+ * interface is not registered as a <i>consumes</i> in the services section
+ * of the deployment component or service unit then we will return null
+ *
+ * @param targetInterface
+ * The qualified name of the target interface
+ * @return An InOnly exception if the interface is found or null
+ * @throws MessagingException
+ */
+ public InOnly createInOnly(QName targetInterface) throws MessagingException {
+ EndPointDefinition endPointDef = endPointRegistry
+ .getEndPointDefinition(targetInterface);
+ if (endPointDef != null) {
+ InOnly inOnly = getMessageExchangeFactory().createInOnlyExchange();
+ inOnly.setInterfaceName(targetInterface);
+ inOnly.setService(endPointDef.getServiceName());
+ return inOnly;
+ } else {
+ return null;
+ }
+ }
+
+ /**
+ * Creates an InOptionalOut exchange by looking up the defined interface as
+ * a 'Consumes' interface and picking up the service name, not that if the
+ * interface is not registered as a <i>consumes</i> in the services section
+ * of the deployment component or service unit then we will return null
+ *
+ * @param targetInterface
+ * The qualified name of the target interface
+ * @return An InOptionalOut exception if the interface is found or null
+ * @throws MessagingException
+ */
+ public InOptionalOut createInOptionalOut(QName targetInterface)
throws MessagingException {
- return getDeliveryChannel().createExchangeFactory();
+ EndPointDefinition endPointDef = endPointRegistry
+ .getEndPointDefinition(targetInterface);
+ if (endPointDef != null) {
+ InOptionalOut inOptionalOut = getMessageExchangeFactory()
+ .createInOptionalOutExchange();
+ inOptionalOut.setInterfaceName(targetInterface);
+ inOptionalOut.setService(endPointDef.getServiceName());
+ return inOptionalOut;
+ } else {
+ return null;
+ }
}
- public DeliveryChannel getDeliveryChannel() throws MessagingException {
- return getComponentContext().getDeliveryChannel();
+ /**
+ * Creates an InOptionalOut exchange by looking up the defined interface as
+ * a 'Consumes' interface and picking up the service name, not that if the
+ * interface is not registered as a <i>consumes</i> in the services section
+ * of the deployment component or service unit then we will return null
+ *
+ * @param targetInterface
+ * The qualified name of the target interface
+ * @return An InOptionalOut exception if the interface is found or null
+ * @throws MessagingException
+ */
+ public InOut createInOut(QName targetInterface) throws MessagingException {
+ EndPointDefinition endPointDef = endPointRegistry
+ .getEndPointDefinition(targetInterface);
+ if (endPointDef != null) {
+ InOut inOut = getMessageExchangeFactory().createInOutExchange();
+ inOut.setInterfaceName(targetInterface);
+ inOut.setService(endPointDef.getServiceName());
+ return inOut;
+ } else {
+ return null;
+ }
} public MessageExchangeFactory createMessageExchangeFactory()
@@ -65,12 +133,30 @@
return getDeliveryChannel().createExchangeFactory(); }
- public ComponentContext getComponentContext() {
- return componentContext;
- }
-
- public ClientEndPointRegistry getEndPointRegistry() {
- return endPointRegistry;
+ /**
+ * Creates an RobustInOnly exchange by looking up the defined interface as a
+ * 'Consumes' interface and picking up the service name, not that if the
+ * interface is not registered as a <i>consumes</i> in the services section
+ * of the deployment component or service unit then we will return null
+ *
+ * @param targetInterface
+ * The qualified name of the target interface
+ * @return An RobustInOnly exception if the interface is found or null
+ * @throws MessagingException
+ */
+ public RobustInOnly createRobustInOnly(QName targetInterface)
+ throws MessagingException {
+ EndPointDefinition endPointDef = endPointRegistry
+ .getEndPointDefinition(targetInterface);
+ if (endPointDef != null) {
+ RobustInOnly robustInOnly = getMessageExchangeFactory()
+ .createRobustInOnlyExchange();
+ robustInOnly.setInterfaceName(targetInterface);
+ robustInOnly.setService(endPointDef.getServiceName());
+ return robustInOnly;
+ } else {
+ return null;
+ }
} /**
@@ -87,18 +173,45 @@
} /**
- * Creates an InOnly exchange by looking up the defined interface as a - * 'Consumes' interface and picking up the service name
+ * Returns the JBI ComponentContext (@see ComponentContext) for the + * component under which this service has been deployed
*
- * @param targetInterface - * @return
+ * @return The ComponentContext
+ */
+ public ComponentContext getComponentContext() {
+ return componentContext;
+ }
+
+ /**
+ * Returns the JBI Delivery Channel (@see DeliveryChannel) for the componnt
+ * under which this service has been deployed
+ *
+ * @return The DeliveryChannel
* @throws MessagingException */
- public InOnly createInOnly(QName targetInterface) throws MessagingException {
- InOnly inOnly = getMessageExchangeFactory().createInOnlyExchange();
- EndPointDefinition endPointDef = endPointRegistry
- .getEndPointDefinition(targetInterface);
- inOnly.setService(endPointDef.getServiceName());
- return inOnly;
+ public DeliveryChannel getDeliveryChannel() throws MessagingException {
+ return getComponentContext().getDeliveryChannel();
+ }
+
+ /**
+ * Returns the ClientEndPointRegistry for this service deployment, which can
+ * be used to lookup service names and interfaces that have been activated
+ *
+ * @return The ClientEndPointRegistry for the service
+ */
+ public ClientEndPointRegistry getEndPointRegistry() {
+ return endPointRegistry;
+ }
+
+ /**
+ * Returns the JBI Message Exchange Factory (@see MessageExchangeFactory)
+ *
+ * @return The MessageExchangeFactory
+ *
+ * @throws MessagingException
+ */
+ public MessageExchangeFactory getMessageExchangeFactory()
+ throws MessagingException {
+ return getDeliveryChannel().createExchangeFactory();
} }
