[jboss-svn-commits] JBL Code SVN: r23474 - in labs/jbossesb/workspace/skeagh: api/service/src/main/java/org/jboss/esb/service and 14 other directories.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Thu Oct 16 08:55:14 EDT 2008


Author: tfennelly
Date: 2008-10-16 08:55:13 -0400 (Thu, 16 Oct 2008)
New Revision: 23474

Added:
   labs/jbossesb/workspace/skeagh/container/osgi/api/osgi.bnd
   labs/jbossesb/workspace/skeagh/container/osgi/api/pom.xml
   labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/invoke/
   labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/invoke/ServiceInvoker.java
   labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/invoke/ServiceRouter.java
   labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/invoke/package.html
Removed:
   labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/osgi/
   labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/routing/
Modified:
   labs/jbossesb/workspace/skeagh/api/service/pom.xml
   labs/jbossesb/workspace/skeagh/api/service/src/main/java/org/jboss/esb/service/ServiceName.java
   labs/jbossesb/workspace/skeagh/container/osgi/pom.xml
   labs/jbossesb/workspace/skeagh/container/osgi/runtime/osgi.bnd
   labs/jbossesb/workspace/skeagh/examples/helloworld/osgi.bnd
   labs/jbossesb/workspace/skeagh/examples/helloworld/pom.xml
   labs/jbossesb/workspace/skeagh/performance/src/test/java/org/jboss/esb/deployment-01.xml
   labs/jbossesb/workspace/skeagh/performance/src/test/java/org/jboss/esb/deployment-02.xml
   labs/jbossesb/workspace/skeagh/performance/src/test/java/org/jboss/esb/deployment-03.xml
   labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/dispatch/AbstractDispatcher.java
   labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/federate/DeploymentMonitor.java
   labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/deploy/lifecycle/02-serviceA-config.xml
   labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/routing/scenario_002/02-service-config.xml
   labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/routing/scenario_003/02-serviceA-config.xml
   labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/routing/scenario_006/01-deployment.xml
   labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/routing/scenario_006/02-deployment.xml
   labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/routing/scenario_007/01-deployment.xml
   labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/routing/scenario_007/02-deployment.xml
   labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/routing/scenario_007/03-deployment.xml
Log:
Introduced the api osgi bundle.
Moved the ServiceInvoker and ServiceRouter into the invoke package.

Modified: labs/jbossesb/workspace/skeagh/api/service/pom.xml
===================================================================
--- labs/jbossesb/workspace/skeagh/api/service/pom.xml	2008-10-16 10:32:18 UTC (rev 23473)
+++ labs/jbossesb/workspace/skeagh/api/service/pom.xml	2008-10-16 12:55:13 UTC (rev 23474)
@@ -14,12 +14,4 @@
     <url>http://www.jboss.org/jbossesb/</url>
 	<packaging>jar</packaging>
 
-    <dependencies>
-        <dependency>
-            <groupId>jboss.jbossesb</groupId>
-            <artifactId>jbossesb-commons</artifactId>
-            <version>${jboss.esb.version}</version>
-        </dependency>
-    </dependencies>
-
 </project>

Modified: labs/jbossesb/workspace/skeagh/api/service/src/main/java/org/jboss/esb/service/ServiceName.java
===================================================================
--- labs/jbossesb/workspace/skeagh/api/service/src/main/java/org/jboss/esb/service/ServiceName.java	2008-10-16 10:32:18 UTC (rev 23473)
+++ labs/jbossesb/workspace/skeagh/api/service/src/main/java/org/jboss/esb/service/ServiceName.java	2008-10-16 12:55:13 UTC (rev 23474)
@@ -20,7 +20,6 @@
 package org.jboss.esb.service;
 
 import org.jboss.esb.annotations.Property;
-import org.jboss.esb.util.AssertArgument;
 
 import java.io.Serializable;
 
@@ -65,8 +64,9 @@
      */
     public ServiceName(final String category, final String name)
     {
-        AssertArgument.isNotNullAndNotEmpty(category, "category");
-        AssertArgument.isNotNullAndNotEmpty(name, "name");
+        isNotNullAndNotEmpty(category, "category");
+        isNotNullAndNotEmpty(name, "name");
+
         this.category = category;
         this.name = name;
     }
@@ -135,4 +135,21 @@
     {
         return toString().hashCode();
     }
+
+    /**
+     * Assert that the argument is neither null nor empty.
+     *
+     * @param arg     Argument.
+     * @param argName Argument name.
+     * @return The supplied "arg" argument.
+     * @throws IllegalArgumentException Argument is null or empty.
+     */
+    private void isNotNullAndNotEmpty(final String arg, final String argName) throws IllegalArgumentException
+    {
+        if (arg == null || arg.trim().equals(""))
+        {
+            throw new IllegalArgumentException("null or empty '" + argName
+                    + "' arg in method call.");
+        }
+    }
 }

Added: labs/jbossesb/workspace/skeagh/container/osgi/api/osgi.bnd
===================================================================
--- labs/jbossesb/workspace/skeagh/container/osgi/api/osgi.bnd	                        (rev 0)
+++ labs/jbossesb/workspace/skeagh/container/osgi/api/osgi.bnd	2008-10-16 12:55:13 UTC (rev 23474)
@@ -0,0 +1,7 @@
+Import-Package: !org.jboss.esb.* 
+Export-Package: org.jboss.esb.annotations, \
+                org.jboss.esb.context, \
+                org.jboss.esb.exception, \
+                org.jboss.esb.message, \
+                org.jboss.esb.routing, \
+                org.jboss.esb.service

Added: labs/jbossesb/workspace/skeagh/container/osgi/api/pom.xml
===================================================================
--- labs/jbossesb/workspace/skeagh/container/osgi/api/pom.xml	                        (rev 0)
+++ labs/jbossesb/workspace/skeagh/container/osgi/api/pom.xml	2008-10-16 12:55:13 UTC (rev 23474)
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>jboss.jbossesb</groupId>
+        <artifactId>jbossesb-osgi</artifactId>
+        <version>5.0-SNAPSHOT</version>
+    </parent>
+    <groupId>jboss.jbossesb</groupId>
+    <artifactId>jbossesb-osgi-api</artifactId>
+    <packaging>bundle</packaging>
+	<version>${jboss.esb.version}</version>
+    <name>JBoss ESB OSGi API</name>
+    <url>http://www.jboss.org/jbossesb/</url>
+
+    <dependencies>
+        <dependency>
+            <groupId>jboss.jbossesb</groupId>
+            <artifactId>jbossesb-api-service</artifactId>
+            <version>${jboss.esb.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>jboss.jbossesb</groupId>
+            <artifactId>jbossesb-api-routing</artifactId>
+            <version>${jboss.esb.version}</version>
+        </dependency>
+    </dependencies>
+
+</project>


Property changes on: labs/jbossesb/workspace/skeagh/container/osgi/api/pom.xml
___________________________________________________________________
Name: svn:mime-type
   + text/xml
Name: svn:eol-style
   + native

Modified: labs/jbossesb/workspace/skeagh/container/osgi/pom.xml
===================================================================
--- labs/jbossesb/workspace/skeagh/container/osgi/pom.xml	2008-10-16 10:32:18 UTC (rev 23473)
+++ labs/jbossesb/workspace/skeagh/container/osgi/pom.xml	2008-10-16 12:55:13 UTC (rev 23474)
@@ -15,6 +15,7 @@
     <url>http://www.jboss.org/jbossesb/</url>
 
     <modules>
+        <module>api</module>
         <module>runtime</module>
     </modules>
     

Modified: labs/jbossesb/workspace/skeagh/container/osgi/runtime/osgi.bnd
===================================================================
--- labs/jbossesb/workspace/skeagh/container/osgi/runtime/osgi.bnd	2008-10-16 10:32:18 UTC (rev 23473)
+++ labs/jbossesb/workspace/skeagh/container/osgi/runtime/osgi.bnd	2008-10-16 12:55:13 UTC (rev 23474)
@@ -1,24 +1,8 @@
-#-----------------------------------------------------------------
-# Use this file to add customized Bnd instructions for the bundle
-#
-# We need to sort out a package clash with the routing package.  It's
-# in both the api and runtime modules.  Rename the runtime package
-# to "invoke".
-#
-#-----------------------------------------------------------------
-
-# TODO: Create an API bundle and export these packages from there.
-Export-Package: org.jboss.esb.test,\
-                org.jboss.esb.annotations, \
-                org.jboss.esb.context, \
-                org.jboss.esb.routing, \
-                org.jboss.esb.exception, \
-                org.jboss.esb.service, \
-                org.jboss.esb.message
+Export-Package: org.jboss.esb.test
 Private-Package: org.jboss.esb.osgi
 
 # TODO: Replace global import with explicit package imports?
-Import-Package: *;resolution:=optional
+Import-Package: org.jboss.esb.*, *;resolution:=optional
 
 Bundle-Activator: org.jboss.esb.osgi.EsbServiceDeploymentActivator
 
@@ -28,8 +12,6 @@
                 freemarker,\
                 hsqldb, \
                 jbossesb-commons, \
-                jbossesb-api-service, \
-                jbossesb-api-routing, \
                 jbossesb-rt, \
                 mvel, \
                 milyn-commons, \

Modified: labs/jbossesb/workspace/skeagh/examples/helloworld/osgi.bnd
===================================================================
--- labs/jbossesb/workspace/skeagh/examples/helloworld/osgi.bnd	2008-10-16 10:32:18 UTC (rev 23473)
+++ labs/jbossesb/workspace/skeagh/examples/helloworld/osgi.bnd	2008-10-16 12:55:13 UTC (rev 23474)
@@ -13,7 +13,7 @@
 
 # TODO: Version imports
 # TODO: Replace global import with explicit package imports?
-Import-Package: org.jboss.esb.jms, *;resolution:=optional
+Import-Package: org.jboss.esb.jms, org.jboss.esb.*, *;resolution:=optional
 
 Embed-Dependency: activemq-core, \
                   backport-util-concurrent, \

Modified: labs/jbossesb/workspace/skeagh/examples/helloworld/pom.xml
===================================================================
--- labs/jbossesb/workspace/skeagh/examples/helloworld/pom.xml	2008-10-16 10:32:18 UTC (rev 23473)
+++ labs/jbossesb/workspace/skeagh/examples/helloworld/pom.xml	2008-10-16 12:55:13 UTC (rev 23474)
@@ -101,6 +101,11 @@
 		</dependency> 
 
 		<!-- JBossESB OSGi bundle -->
+        <dependency>
+            <groupId>jboss.jbossesb</groupId>
+            <artifactId>jbossesb-osgi-api</artifactId>
+            <version>${jboss.esb.version}</version>
+        </dependency>
 		<dependency>
 			<groupId>jboss.jbossesb</groupId>
 			<artifactId>jbossesb-osgi-runtime</artifactId>

Modified: labs/jbossesb/workspace/skeagh/performance/src/test/java/org/jboss/esb/deployment-01.xml
===================================================================
--- labs/jbossesb/workspace/skeagh/performance/src/test/java/org/jboss/esb/deployment-01.xml	2008-10-16 10:32:18 UTC (rev 23473)
+++ labs/jbossesb/workspace/skeagh/performance/src/test/java/org/jboss/esb/deployment-01.xml	2008-10-16 12:55:13 UTC (rev 23474)
@@ -3,13 +3,13 @@
     <services>
         <service serviceCategory="Service" serviceName="A" serviceDescription="A Service" class="org.jboss.esb.TestService">
             <inRouter name="inrouterA" class="org.jboss.esb.TestInRouter" />
-            <outRouter name="A_to_B_router" class="org.jboss.esb.routing.ServiceRouter">
+            <outRouter name="A_to_B_router" class="org.jboss.esb.invoke.ServiceRouter">
                 <property name="toCategory">Service</property>
                 <property name="toService">B</property>
             </outRouter>
         </service>
         <service serviceCategory="Service" serviceName="B" serviceDescription="B Service" class="org.jboss.esb.TestService">
-            <outRouter name="B_to_C_router" class="org.jboss.esb.routing.ServiceRouter">
+            <outRouter name="B_to_C_router" class="org.jboss.esb.invoke.ServiceRouter">
                 <property name="toCategory">Service</property>
                 <property name="toService">C</property>
             </outRouter>
@@ -17,13 +17,13 @@
 
         <service serviceCategory="Service" serviceName="1" serviceDescription="1 Service" class="org.jboss.esb.TestService">
             <inRouter name="inrouter1" class="org.jboss.esb.TestInRouter" />
-            <outRouter name="1_to_2_router" class="org.jboss.esb.routing.ServiceRouter">
+            <outRouter name="1_to_2_router" class="org.jboss.esb.invoke.ServiceRouter">
                 <property name="toCategory">Service</property>
                 <property name="toService">2</property>
             </outRouter>
         </service>
         <service serviceCategory="Service" serviceName="2" serviceDescription="2 Service" class="org.jboss.esb.TestService">
-            <outRouter name="2_to_3_router" class="org.jboss.esb.routing.ServiceRouter">
+            <outRouter name="2_to_3_router" class="org.jboss.esb.invoke.ServiceRouter">
                 <property name="toCategory">Service</property>
                 <property name="toService">3</property>
             </outRouter>

Modified: labs/jbossesb/workspace/skeagh/performance/src/test/java/org/jboss/esb/deployment-02.xml
===================================================================
--- labs/jbossesb/workspace/skeagh/performance/src/test/java/org/jboss/esb/deployment-02.xml	2008-10-16 10:32:18 UTC (rev 23473)
+++ labs/jbossesb/workspace/skeagh/performance/src/test/java/org/jboss/esb/deployment-02.xml	2008-10-16 12:55:13 UTC (rev 23474)
@@ -2,26 +2,26 @@
 
     <services>
         <service serviceCategory="Service" serviceName="C" serviceDescription="C Service" class="org.jboss.esb.TestService">
-            <outRouter name="C_to_D_router" class="org.jboss.esb.routing.ServiceRouter">
+            <outRouter name="C_to_D_router" class="org.jboss.esb.invoke.ServiceRouter">
                 <property name="toCategory">Service</property>
                 <property name="toService">D</property>
             </outRouter>
         </service>
         <service serviceCategory="Service" serviceName="D" serviceDescription="D Service" class="org.jboss.esb.TestService">
-            <outRouter name="D_to_E_router" class="org.jboss.esb.routing.ServiceRouter">
+            <outRouter name="D_to_E_router" class="org.jboss.esb.invoke.ServiceRouter">
                 <property name="toCategory">Service</property>
                 <property name="toService">E</property>
             </outRouter>
         </service>
 
         <service serviceCategory="Service" serviceName="3" serviceDescription="3 Service" class="org.jboss.esb.TestService">
-            <outRouter name="3_to_4_router" class="org.jboss.esb.routing.ServiceRouter">
+            <outRouter name="3_to_4_router" class="org.jboss.esb.invoke.ServiceRouter">
                 <property name="toCategory">Service</property>
                 <property name="toService">4</property>
             </outRouter>
         </service>
         <service serviceCategory="Service" serviceName="4" serviceDescription="4 Service" class="org.jboss.esb.TestService">
-            <outRouter name="4_to_5_router" class="org.jboss.esb.routing.ServiceRouter">
+            <outRouter name="4_to_5_router" class="org.jboss.esb.invoke.ServiceRouter">
                 <property name="toCategory">Service</property>
                 <property name="toService">5</property>
             </outRouter>

Modified: labs/jbossesb/workspace/skeagh/performance/src/test/java/org/jboss/esb/deployment-03.xml
===================================================================
--- labs/jbossesb/workspace/skeagh/performance/src/test/java/org/jboss/esb/deployment-03.xml	2008-10-16 10:32:18 UTC (rev 23473)
+++ labs/jbossesb/workspace/skeagh/performance/src/test/java/org/jboss/esb/deployment-03.xml	2008-10-16 12:55:13 UTC (rev 23474)
@@ -2,7 +2,7 @@
 
     <services>
         <service serviceCategory="Service" serviceName="E" serviceDescription="E Service" class="org.jboss.esb.TestService">
-            <outRouter name="E_to_F_router" class="org.jboss.esb.routing.ServiceRouter">
+            <outRouter name="E_to_F_router" class="org.jboss.esb.invoke.ServiceRouter">
                 <property name="toCategory">Service</property>
                 <property name="toService">F</property>
             </outRouter>
@@ -13,7 +13,7 @@
         </service>
 
         <service serviceCategory="Service" serviceName="5" serviceDescription="5 Service" class="org.jboss.esb.TestService">
-            <outRouter name="5_to_6_router" class="org.jboss.esb.routing.ServiceRouter">
+            <outRouter name="5_to_6_router" class="org.jboss.esb.invoke.ServiceRouter">
                 <property name="toCategory">Service</property>
                 <property name="toService">6</property>
             </outRouter>

Modified: labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/dispatch/AbstractDispatcher.java
===================================================================
--- labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/dispatch/AbstractDispatcher.java	2008-10-16 10:32:18 UTC (rev 23473)
+++ labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/dispatch/AbstractDispatcher.java	2008-10-16 12:55:13 UTC (rev 23474)
@@ -39,7 +39,7 @@
 import org.jboss.esb.routing.MessageDispatcher;
 import org.jboss.esb.routing.OutboundRouter;
 import org.jboss.esb.routing.RoutingException;
-import org.jboss.esb.routing.ServiceInvoker;
+import org.jboss.esb.invoke.ServiceInvoker;
 import org.jboss.esb.serialization.SerializationException;
 import org.jboss.esb.serialization.java.JavaSerializer;
 import org.jboss.esb.service.ServiceException;

Modified: labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/federate/DeploymentMonitor.java
===================================================================
--- labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/federate/DeploymentMonitor.java	2008-10-16 10:32:18 UTC (rev 23473)
+++ labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/federate/DeploymentMonitor.java	2008-10-16 12:55:13 UTC (rev 23474)
@@ -28,7 +28,7 @@
 import org.jboss.esb.history.ProcessingEventLog;
 import org.jboss.esb.history.events.BusRouterProcessingEvent;
 import org.jboss.esb.message.Message;
-import org.jboss.esb.routing.ServiceInvoker;
+import org.jboss.esb.invoke.ServiceInvoker;
 import org.jboss.esb.service.ServiceName;
 import org.jboss.esb.util.AssertArgument;
 

Copied: labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/invoke/ServiceInvoker.java (from rev 23464, labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/routing/ServiceInvoker.java)
===================================================================
--- labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/invoke/ServiceInvoker.java	                        (rev 0)
+++ labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/invoke/ServiceInvoker.java	2008-10-16 12:55:13 UTC (rev 23474)
@@ -0,0 +1,227 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ *
+ * (C) 2005-2008, JBoss Inc.
+ */
+package org.jboss.esb.invoke;
+
+import org.apache.log4j.Logger;
+import org.jboss.esb.context.AddressingContext;
+import org.jboss.esb.context.DeploymentContext;
+import org.jboss.esb.context.InvocationContext;
+import org.jboss.esb.deploy.DeploymentRuntime;
+import org.jboss.esb.deploy.DeploymentUtil;
+import org.jboss.esb.deploy.config.ServiceConfig;
+import org.jboss.esb.federate.DeploymentCoordinator;
+import org.jboss.esb.federate.DeploymentMonitor;
+import org.jboss.esb.federate.bus.BusInboundRouter;
+import org.jboss.esb.federate.bus.BusMessage;
+import org.jboss.esb.federate.bus.BusRoutingContext;
+import org.jboss.esb.message.Message;
+import org.jboss.esb.service.ServiceName;
+import org.jboss.esb.util.AssertArgument;
+import org.jboss.esb.history.ProcessingEventLog;
+import org.jboss.esb.serialization.java.JavaSerializer;
+import org.jboss.esb.serialization.SerializationException;
+
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * Service Invoker.
+ *
+ * @author <a href="mailto:Kevin.Conner at jboss.com">Kevin Conner</a>
+ * @author <a href="mailto:tcunning at redhat.com">Tom Cunningham</a>
+ * @author <a href="mailto:dbevenius at redhat.com">Daniel Bevenius</a>
+ * @author <a href="mailto:tom.fennelly at jboss.com">Tom Fennelly</a>
+ */
+public class ServiceInvoker
+{
+    /**
+     * Logger.
+     */
+    private static Logger logger = Logger.getLogger(ServiceInvoker.class);
+    /**
+     * Deployment context.
+     */
+    private DeploymentContext deploymentContext;
+    /**
+     * Deployment runtime.
+     */
+    private DeploymentRuntime deploymentRuntime;
+
+    /**
+     * Public constructor.
+     * @param deploymentContext The deployment context associated with this invoker instance.
+     */
+    public ServiceInvoker(final DeploymentContext deploymentContext)
+    {
+        AssertArgument.isNotNull(deploymentContext, "deploymentContext");
+        this.deploymentContext = deploymentContext;
+        deploymentRuntime = DeploymentRuntime.getRuntime(deploymentContext);
+    }
+
+    /**
+     * Send the supplied message to the specified Service.
+     *
+     * @param message The message to be sent.
+     * @param to Target Service.
+     * @return true If the message was sucessfully sent.
+     */
+    public final boolean send(final Message message, final ServiceName to)
+    {
+        AddressingContext addressing = new AddressingContext();
+
+        addressing.setTo(to);
+
+        return send(message, addressing);
+    }
+
+    /**
+     * Send the supplied message to the specified Service.
+     *
+     * @param message The message to be sent.
+     * @param addressing Addressing data.
+     * @return true If the message was sucessfully sent.
+     */
+    public final boolean send(final Message message, final AddressingContext addressing)
+    {
+        if (addressing.getTo() == null)
+        {
+            logger.error("Invalid AddressingContext configuration.  The 'to' service name must be specified.");
+            return false;
+        }
+
+        // The "to" service name should not be this service...
+        if (addressing.getTo().equals(addressing.getFrom()))
+        {
+            logger.error("Invalid AddressingContext configuration.  The 'to' and 'from' service names (" + addressing.getTo() + ") cannot be the same.");
+            return false;
+        }
+
+        // Work out whether or not the target service is local,
+        // or on another deployment...
+        ServiceConfig localServiceDeployment = DeploymentUtil.getService(addressing.getTo(), deploymentRuntime);
+        if (localServiceDeployment != null && localServiceDeployment.isRoutable())
+        {
+            return routeLocal(message, addressing);
+        }
+        else
+        {
+            return routeByBus(message, addressing);
+        }
+    }
+
+    /**
+     * Route the message to a local Service.
+     * @param message The message.
+     * @param dispatchAddressingContext The {@link org.jboss.esb.context.AddressingContext} for the dispatch.
+     * @return true If the routing succeeded.
+     */
+    private boolean routeLocal(final Message message, final AddressingContext dispatchAddressingContext)
+    {
+        InvocationContext thisInvocationContext = InvocationContext.getContext();
+        AddressingContext thisAddressingContext = AddressingContext.getContext();
+        ProcessingEventLog eventLog = ProcessingEventLog.getEventLog();
+
+        // Set the Addressing context for the new Service Invocation...
+        AddressingContext.setContext(dispatchAddressingContext);
+        try
+        {
+            try
+            {
+                BusRoutingContext routingContext = BusRoutingContext.getContext(deploymentContext);
+                BusInboundRouter inRouter = routingContext.getBusInRouters().get(dispatchAddressingContext.getTo());
+                InvocationContext dispatchInvocationContext = new InvocationContext(thisInvocationContext.getInvocationParameters());
+
+                if (eventLog.propagate())
+                {
+                    ProcessingEventLog.setEventLog(eventLog, dispatchInvocationContext);
+                }
+
+                // Create a clone of the message in this case.  We don't want the local
+                // invocation messing with anything else that might be going on...
+                Message clone;
+                try
+                {
+                    // TODO: Make this optional i.e. on by default, but can be turned off for performance reasons if required.
+                    clone = JavaSerializer.copy(message);
+                }
+                catch (SerializationException e)
+                {
+                    throw new RuntimeException("Cannot route message.  Unable to copy message.", e);
+                }
+
+                // And dispatch the message clone...
+                inRouter.dispatch(clone, dispatchInvocationContext);
+
+                return dispatchInvocationContext.getFaultContext().getFault() == null;
+            }
+            finally
+            {
+                // Make sure the invocation context is still set on the
+                // local thread...
+                InvocationContext.setContext(thisInvocationContext);
+            }
+        }
+        finally
+        {
+            // Reset the addressing context...
+            AddressingContext.setContext(thisAddressingContext);
+        }
+    }
+
+    /**
+     * Route the message to a Service by a Bus.
+     * @param message The message.
+     * @param invokeAddressingContext The {@link AddressingContext} for the invocation.
+     * @return true If routing succeeded. Otherwise false.
+     */
+    private boolean routeByBus(final Message message, final AddressingContext invokeAddressingContext)
+    {
+        InvocationContext thisInvocationContext = InvocationContext.getContext();
+        List<DeploymentCoordinator.BusDeployment> busDeployments = deploymentRuntime.getDeploymentCoordinator().getBusDeployments();
+        BusMessage busMessage = new BusMessage();
+
+        busMessage.setMessage(message);
+        busMessage.setInvocationParameters(thisInvocationContext.getInvocationParameters());
+        busMessage.setAddressingContext(invokeAddressingContext);
+
+        // Iterate over all the Bus deployments looking for a deployment that
+        // is online and is hosting the target service...
+        for (DeploymentCoordinator.BusDeployment busDeployment : busDeployments)
+        {
+            Iterator<Map.Entry<String,DeploymentMonitor>> monitors = busDeployment.getDeploymentMonitors().entrySet().iterator();
+
+            while (monitors.hasNext())
+            {
+                Map.Entry<String, DeploymentMonitor> entry = monitors.next();
+                String deploymentId = entry.getKey();
+                DeploymentMonitor monitor = entry.getValue();
+
+                // Is the deployment online and does it host the target service...
+                if (monitor.isOnline() && monitor.hasService(invokeAddressingContext.getTo()))
+                {
+                    return monitor.send(busMessage, deploymentId, !monitors.hasNext());
+                }
+            }
+        }
+
+        return false;
+    }
+}


Property changes on: labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/invoke/ServiceInvoker.java
___________________________________________________________________
Name: svn:eol-style
   + native

Copied: labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/invoke/ServiceRouter.java (from rev 23464, labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/routing/ServiceRouter.java)
===================================================================
--- labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/invoke/ServiceRouter.java	                        (rev 0)
+++ labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/invoke/ServiceRouter.java	2008-10-16 12:55:13 UTC (rev 23474)
@@ -0,0 +1,133 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ *
+ * (C) 2005-2008, JBoss Inc.
+ */
+package org.jboss.esb.invoke;
+
+import org.jboss.esb.annotations.Initialize;
+import org.jboss.esb.annotations.Property;
+import org.jboss.esb.context.AddressingContext;
+import org.jboss.esb.context.DeploymentContext;
+import org.jboss.esb.deploy.DeploymentException;
+import org.jboss.esb.message.Message;
+import org.jboss.esb.service.ServiceName;
+import org.jboss.esb.routing.OutboundRouter;
+import org.jboss.esb.routing.RoutingException;
+
+/**
+ * Service Message {@link org.jboss.esb.routing.OutboundRouter}.
+ * <p/>
+ * Allows routing of an ESB message to another Service instance.
+ *
+ * @author <a href="mailto:tom.fennelly at jboss.com">tom.fennelly at jboss.com</a>
+ */
+public class ServiceRouter implements OutboundRouter
+{
+    /**
+     * The service name i.e. the "from" service. Injected by the framework.
+     */
+    private ServiceName serviceName;
+    /**
+     * Deployment context.
+     */
+    private DeploymentContext deploymentContext;
+    /**
+     * The Category name of the "to" service.
+     */
+    @Property
+    private String toCategory;
+    /**
+     * The name of the "to" service.
+     */
+    @Property
+    private String toService;
+    /**
+     * The qualified "to" service name.
+     */
+    private ServiceName toServiceName;
+    /**
+     * The Category name of the "fault" service.
+     */
+    @Property(use = Property.Use.OPTIONAL)
+    private String faultToCategory;
+    /**
+     * The name of the "fault" service.
+     */
+    @Property(use = Property.Use.OPTIONAL)
+    private String faultToService;
+    /**
+     * The qualified "fault" service name.
+     */
+    private ServiceName faultToServiceName;
+    /**
+     * The Category name of the "replyTo" service.
+     */
+    @Property(use = Property.Use.OPTIONAL)
+    private String replyToCategory;
+    /**
+     * The name of the "replyTo" service.
+     */
+    @Property(use = Property.Use.OPTIONAL)
+    private String replyToService;
+    /**
+     * The qualified "replyTo" service name.
+     */
+    private ServiceName replyToServiceName;
+    /**
+     * Service Invoker.
+     */
+    private ServiceInvoker serviceInvoker;
+
+    /**
+     * Initialize the router.
+     * @throws DeploymentException If an error occurs during initialization.
+     */
+    @Initialize
+    public final void initialize() throws DeploymentException
+    {
+        serviceInvoker = new ServiceInvoker(deploymentContext);
+
+        toServiceName = new ServiceName(toCategory, toService);
+        if (faultToCategory != null && faultToService != null)
+        {
+            faultToServiceName = new ServiceName(faultToCategory, faultToService);
+        }
+        if (replyToCategory != null && replyToService != null)
+        {
+            replyToServiceName = new ServiceName(replyToCategory, replyToService);
+        }
+    }
+
+    /**
+     * Route the message.
+     *
+     * @param message The message to be routed.
+     * @throws org.jboss.esb.routing.RoutingException An exception occured while routing the message.
+     */
+    public final void route(final Message message) throws RoutingException
+    {
+        AddressingContext addressingContext = new AddressingContext();
+
+        addressingContext.setTo(toServiceName);
+        addressingContext.setFrom(serviceName);
+        addressingContext.setReplyTo(replyToServiceName);
+        addressingContext.setFaultTo(faultToServiceName);
+
+        serviceInvoker.send(message, addressingContext);
+    }
+}


Property changes on: labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/invoke/ServiceRouter.java
___________________________________________________________________
Name: svn:eol-style
   + native

Copied: labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/invoke/package.html (from rev 23464, labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/routing/package.html)
===================================================================
--- labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/invoke/package.html	                        (rev 0)
+++ labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/invoke/package.html	2008-10-16 12:55:13 UTC (rev 23474)
@@ -0,0 +1,8 @@
+<html>
+<head></head>
+<body>
+ESB Message Aware Routing (Invocation).
+
+<h2>Package Specification</h2>
+</body>
+</html>
\ No newline at end of file

Modified: labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/deploy/lifecycle/02-serviceA-config.xml
===================================================================
--- labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/deploy/lifecycle/02-serviceA-config.xml	2008-10-16 10:32:18 UTC (rev 23473)
+++ labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/deploy/lifecycle/02-serviceA-config.xml	2008-10-16 12:55:13 UTC (rev 23474)
@@ -9,7 +9,7 @@
             Route the message from A to B....
         -->
         <outRouters serviceCategory="Service" serviceName="A">
-            <outRouter name="A_to_B_router" class="org.jboss.esb.routing.ServiceRouter">
+            <outRouter name="A_to_B_router" class="org.jboss.esb.invoke.ServiceRouter">
                 <property name="toCategory">Service</property>
                 <property name="toService">B</property>
             </outRouter>

Modified: labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/routing/scenario_002/02-service-config.xml
===================================================================
--- labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/routing/scenario_002/02-service-config.xml	2008-10-16 10:32:18 UTC (rev 23473)
+++ labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/routing/scenario_002/02-service-config.xml	2008-10-16 12:55:13 UTC (rev 23474)
@@ -6,7 +6,7 @@
             <!--
                 Route the message from A to B....
             -->
-            <outRouter name="A_to_B_router" class="org.jboss.esb.routing.ServiceRouter">
+            <outRouter name="A_to_B_router" class="org.jboss.esb.invoke.ServiceRouter">
                 <property name="toCategory">Service</property>
                 <property name="toService">B</property>
             </outRouter>

Modified: labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/routing/scenario_003/02-serviceA-config.xml
===================================================================
--- labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/routing/scenario_003/02-serviceA-config.xml	2008-10-16 10:32:18 UTC (rev 23473)
+++ labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/routing/scenario_003/02-serviceA-config.xml	2008-10-16 12:55:13 UTC (rev 23474)
@@ -9,7 +9,7 @@
             Route the message from A to B....
         -->
         <outRouters serviceCategory="Service" serviceName="A">
-            <outRouter name="A_to_B_router" class="org.jboss.esb.routing.ServiceRouter">
+            <outRouter name="A_to_B_router" class="org.jboss.esb.invoke.ServiceRouter">
                 <property name="toCategory">Service</property>
                 <property name="toService">B</property>
             </outRouter>

Modified: labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/routing/scenario_006/01-deployment.xml
===================================================================
--- labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/routing/scenario_006/01-deployment.xml	2008-10-16 10:32:18 UTC (rev 23473)
+++ labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/routing/scenario_006/01-deployment.xml	2008-10-16 12:55:13 UTC (rev 23474)
@@ -6,7 +6,7 @@
             <!--
                 Route the message from A to B....
             -->
-            <outRouter name="A_to_B_router" class="org.jboss.esb.routing.ServiceRouter">
+            <outRouter name="A_to_B_router" class="org.jboss.esb.invoke.ServiceRouter">
                 <property name="toCategory">Service</property>
                 <property name="toService">B</property>
             </outRouter>

Modified: labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/routing/scenario_006/02-deployment.xml
===================================================================
--- labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/routing/scenario_006/02-deployment.xml	2008-10-16 10:32:18 UTC (rev 23473)
+++ labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/routing/scenario_006/02-deployment.xml	2008-10-16 12:55:13 UTC (rev 23474)
@@ -5,7 +5,7 @@
             Route the message from B to C....
         -->
         <outRouters serviceCategory="Service" serviceName="B">
-            <outRouter name="B_to_C_router" class="org.jboss.esb.routing.ServiceRouter">
+            <outRouter name="B_to_C_router" class="org.jboss.esb.invoke.ServiceRouter">
                 <property name="toCategory">Service</property>
                 <property name="toService">C</property>
             </outRouter>

Modified: labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/routing/scenario_007/01-deployment.xml
===================================================================
--- labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/routing/scenario_007/01-deployment.xml	2008-10-16 10:32:18 UTC (rev 23473)
+++ labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/routing/scenario_007/01-deployment.xml	2008-10-16 12:55:13 UTC (rev 23474)
@@ -3,13 +3,13 @@
     <services>
         <service serviceCategory="Service" serviceName="A" serviceDescription="A Service" class="org.jboss.esb.TestService">
             <inRouter name="inrouter" class="org.jboss.esb.TestInboundRouter" />
-            <outRouter name="A_to_B_router" class="org.jboss.esb.routing.ServiceRouter">
+            <outRouter name="A_to_B_router" class="org.jboss.esb.invoke.ServiceRouter">
                 <property name="toCategory">Service</property>
                 <property name="toService">B</property>
             </outRouter>
         </service>
         <service serviceCategory="Service" serviceName="B" serviceDescription="B Service" class="org.jboss.esb.TestService">
-            <outRouter name="B_to_C_router" class="org.jboss.esb.routing.ServiceRouter">
+            <outRouter name="B_to_C_router" class="org.jboss.esb.invoke.ServiceRouter">
                 <property name="toCategory">Service</property>
                 <property name="toService">C</property>
             </outRouter>

Modified: labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/routing/scenario_007/02-deployment.xml
===================================================================
--- labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/routing/scenario_007/02-deployment.xml	2008-10-16 10:32:18 UTC (rev 23473)
+++ labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/routing/scenario_007/02-deployment.xml	2008-10-16 12:55:13 UTC (rev 23474)
@@ -5,7 +5,7 @@
             Route the message from C to D....
         -->
         <outRouters serviceCategory="Service" serviceName="C">
-            <outRouter name="C_to_D_router" class="org.jboss.esb.routing.ServiceRouter">
+            <outRouter name="C_to_D_router" class="org.jboss.esb.invoke.ServiceRouter">
                 <property name="toCategory">Service</property>
                 <property name="toService">D</property>
             </outRouter>
@@ -14,7 +14,7 @@
             Route the message from E to F....
         -->
         <outRouters serviceCategory="Service" serviceName="E">
-            <outRouter name="E_to_F_router" class="org.jboss.esb.routing.ServiceRouter">
+            <outRouter name="E_to_F_router" class="org.jboss.esb.invoke.ServiceRouter">
                 <property name="toCategory">Service</property>
                 <property name="toService">F</property>
             </outRouter>

Modified: labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/routing/scenario_007/03-deployment.xml
===================================================================
--- labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/routing/scenario_007/03-deployment.xml	2008-10-16 10:32:18 UTC (rev 23473)
+++ labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/routing/scenario_007/03-deployment.xml	2008-10-16 12:55:13 UTC (rev 23474)
@@ -9,7 +9,7 @@
             Route the message from D to E....
         -->
         <outRouters serviceCategory="Service" serviceName="D">
-            <outRouter name="D_to_E_router" class="org.jboss.esb.routing.ServiceRouter">
+            <outRouter name="D_to_E_router" class="org.jboss.esb.invoke.ServiceRouter">
                 <property name="toCategory">Service</property>
                 <property name="toService">E</property>
             </outRouter>




More information about the jboss-svn-commits mailing list