[jboss-svn-commits] JBL Code SVN: r22240 - in labs/jbossesb/workspace/skeagh/runtime/src: main/java/org/jboss/esb/deploy and 4 other directories.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Fri Aug 29 12:20:21 EDT 2008
Author: tfennelly
Date: 2008-08-29 12:20:21 -0400 (Fri, 29 Aug 2008)
New Revision: 22240
Added:
labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/dispatch/
labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/dispatch/LocalDispatcher.java
labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/dispatch/package.html
labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/dispatch/
labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/dispatch/HelloInboundRouter.java
labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/dispatch/HelloOutboundRouter.java
labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/dispatch/HelloWorldService.java
labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/dispatch/LocalDispatcherTest.java
labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/dispatch/RestStringTransformer.java
labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/dispatch/jbossesb-dispatch-no-service.xml
labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/dispatch/jbossesb-dispatch-with-intransform.xml
labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/dispatch/jbossesb-dispatch-with-outtransform.xml
labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/dispatch/jbossesb-dispatch-with-service.xml
Modified:
labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/deploy/DeploymentRuntime.java
labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/deploy/config/ConfigurationUnit.java
Log:
OK... something that runs now... something to argue about...
Modified: labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/deploy/DeploymentRuntime.java
===================================================================
--- labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/deploy/DeploymentRuntime.java 2008-08-29 13:58:49 UTC (rev 22239)
+++ labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/deploy/DeploymentRuntime.java 2008-08-29 16:20:21 UTC (rev 22240)
@@ -30,7 +30,9 @@
import org.jboss.esb.deploy.config.ServiceConfig;
import org.jboss.esb.message.MessageTransformer;
import org.jboss.esb.service.ServiceName;
+import org.jboss.esb.service.Service;
import org.jboss.esb.util.AssertArgument;
+import org.jboss.esb.dispatch.LocalDispatcher;
import java.util.*;
import java.io.IOException;
@@ -58,7 +60,7 @@
/**
* Deployment Name.
*/
- private String deploymentName;
+ private String deploymentName = "$UNKNOWN$";
/**
* The list of configurations associated with this deployment instance.
*/
@@ -147,6 +149,7 @@
{
assertConfigurationsAdded();
+ logger.info("Starting JBoss ESB deployment: '" + deploymentName + "'.");
try
{
// Deploy everything in order...
@@ -163,6 +166,7 @@
undeploy();
throw new DeploymentException("Unexpected deployment error.", t);
}
+ logger.info("JBoss ESB deployment completed successfully: '" + deploymentName + "'.");
}
/**
@@ -172,6 +176,7 @@
*/
public final void undeploy() throws DeploymentException
{
+ logger.info("Starting JBoss ESB undeployment: '" + deploymentName + "'.");
if (!deployedObjects.isEmpty())
{
Map.Entry<Object, Object> deploymentSet[] = new Map.Entry[deployedObjects.size()];
@@ -188,6 +193,7 @@
}
}
}
+ logger.info("JBoss ESB undeployment completed successfully: '" + deploymentName + "'.");
}
/**
@@ -259,6 +265,8 @@
for (Map.Entry<ServiceName, List<InboundRouterConfig>> routerConfigMap : routers)
{
+ ServiceName serviceName = routerConfigMap.getKey();
+
List<InboundRouterConfig> routerList = routerConfigMap.getValue();
for (InboundRouterConfig routerConfig : routerList)
{
@@ -267,6 +275,15 @@
// Deploy the transformers first...
deployTransformers(routerConfig.getTransformers(), routerConfig.getName());
+ // Create a dispatcher and hook it into the inRouter...
+ LocalDispatcher dispatcher = new LocalDispatcher();
+ dispatcher.setServiceName(serviceName);
+ dispatcher.setService(getService(configurationUnit, serviceName));
+ dispatcher.setTransformers(routerConfig.getTransformers());
+ dispatcher.setOutboundRouters(configurationUnit.getOutboundRouters().get(serviceName));
+ dispatcher.initialize();
+ routerConfig.getRouter().setDispatcher(dispatcher);
+
// Now deploy the router...
ClassUtil.execAnnotatedMethod(routerConfig.getRouter(), Initialize.class);
logger.debug("Deployed InboundRouter '" + routerConfig.getName() + "' (" + routerConfig.getRouter().getClass().getName() + ").");
@@ -283,6 +300,15 @@
}
}
+ private Service getService(ConfigurationUnit configurationUnit, ServiceName serviceName)
+ {
+ ServiceConfig serviceConfig = configurationUnit.getServices().get(serviceName);
+ if(serviceConfig != null) {
+ return serviceConfig.getService();
+ }
+ return null;
+ }
+
private void deployOutboundRouters() throws DeploymentException
{
for (ConfigurationUnit configurationUnit : configurationUnits)
Modified: labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/deploy/config/ConfigurationUnit.java
===================================================================
--- labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/deploy/config/ConfigurationUnit.java 2008-08-29 13:58:49 UTC (rev 22239)
+++ labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/deploy/config/ConfigurationUnit.java 2008-08-29 16:20:21 UTC (rev 22240)
@@ -19,16 +19,12 @@
*/
package org.jboss.esb.deploy.config;
-import org.jboss.esb.routing.InboundRouter;
-import org.jboss.esb.routing.OutboundRouter;
-import org.jboss.esb.service.Service;
import org.jboss.esb.service.ServiceName;
import org.jboss.esb.util.AssertArgument;
import java.util.LinkedHashMap;
+import java.util.List;
import java.util.Map;
-import java.util.List;
-import java.util.ArrayList;
/**
* JBoss ESB Deployment Configuration Unit.
@@ -57,8 +53,8 @@
/**
* Add an inbounder router for a service.
*
- * @param id The resource ID.
- * @param resource The resource.
+ * @param id The resource ID.
+ * @param resource The resource.
*/
public final void addResource(final String id, final Object resource)
{
@@ -69,6 +65,7 @@
/**
* Get the list of resources associated with this deployment configuration unit (mapped by id).
+ *
* @return The list of resources associated with this deployment configuration unit.
*/
public final Map<String, Object> getResources()
@@ -87,6 +84,32 @@
}
/**
+ * Get the named InboundRouterConfig from the specified service.
+ *
+ * @param service The service name.
+ * @param configName The configuration name.
+ * @return The router configuration, or null if no such router is
+ * specified.
+ */
+ public InboundRouterConfig getInboundRouter(final ServiceName service, final String configName)
+ {
+ List<InboundRouterConfig> inboundRouterList = inboundRouters.get(service);
+
+ if (inboundRouterList != null)
+ {
+ for (InboundRouterConfig inboundRouterConfig : inboundRouterList)
+ {
+ if (configName.equals(inboundRouterConfig.getName()))
+ {
+ return inboundRouterConfig;
+ }
+ }
+ }
+
+ return null;
+ }
+
+ /**
* Get the List of Inbound routers defined in the configuration (mapped by ServiceName).
*
* @param inboundRouters The List of Inbound routers defined in the configuration.
@@ -127,6 +150,32 @@
}
/**
+ * Get the named OutboundRouterConfig from the specified service.
+ *
+ * @param service The service name.
+ * @param configName The configuration name.
+ * @return The router configuration, or null if no such router is
+ * specified.
+ */
+ public OutboundRouterConfig getOutboundRouter(final ServiceName service, final String configName)
+ {
+ List<OutboundRouterConfig> outboundRouterList = outboundRouters.get(service);
+
+ if (outboundRouterList != null)
+ {
+ for (OutboundRouterConfig outboundRouterConfig : outboundRouterList)
+ {
+ if (configName.equals(outboundRouterConfig.getName()))
+ {
+ return outboundRouterConfig;
+ }
+ }
+ }
+
+ return null;
+ }
+
+ /**
* Set the List of Outbound routers defined in the configuration (mapped by ServiceName).
*
* @param outboundRouters The List of Outbound routers defined in the configuration.
Added: labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/dispatch/LocalDispatcher.java
===================================================================
--- labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/dispatch/LocalDispatcher.java (rev 0)
+++ labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/dispatch/LocalDispatcher.java 2008-08-29 16:20:21 UTC (rev 22240)
@@ -0,0 +1,265 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., 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-2006, JBoss Inc.
+ */
+package org.jboss.esb.dispatch;
+
+import org.jboss.esb.deploy.config.OutboundRouterConfig;
+import org.jboss.esb.message.Message;
+import org.jboss.esb.message.MessageTransformationException;
+import org.jboss.esb.message.MessageTransformer;
+import org.jboss.esb.routing.MessageDispatcher;
+import org.jboss.esb.routing.RoutingException;
+import org.jboss.esb.service.Service;
+import org.jboss.esb.service.ServiceException;
+import org.jboss.esb.service.ServiceName;
+
+import java.util.List;
+
+/**
+ * Local message dispatcher.
+ *
+ * @author <a href="mailto:tom.fennelly at jboss.com">tom.fennelly at jboss.com</a>
+ */
+public class LocalDispatcher implements MessageDispatcher
+{
+ /**
+ * Inbound transformers to be applied before invoking
+ * the service (can be null).
+ */
+ private List<MessageTransformer> transformers;
+ /**
+ * The service name.
+ */
+ private ServiceName serviceName;
+ /**
+ * The Service instance (can be null).
+ */
+ private Service service;
+ /**
+ * The outbound routers, to which the message is passed after
+ * Service invocation (can be null).
+ */
+ private List<OutboundRouterConfig> outboundRouters;
+ /**
+ * Clone outbound routing transforms.
+ */
+ private boolean cloneOnOutboundTransforms = false;
+
+ /**
+ * Initialize the dispatcher.
+ */
+ public void initialize() {
+ if(outboundRouters != null && !outboundRouters.isEmpty()) {
+ int numTransformationSets = 0;
+ for (OutboundRouterConfig outboundRouterConfig : outboundRouters)
+ {
+ if(outboundRouterConfig.getTransformers() != null) {
+ numTransformationSets++;
+ }
+ }
+ // If we have multiple outbound routers performing transforms
+ // on the message before routing, we need to clone the message,
+ // otherwise the message will be corrupted...
+ cloneOnOutboundTransforms = (numTransformationSets > 1);
+ }
+ }
+
+ /**
+ * Dispatch method.
+ * <p/>
+ * Receives a message, applies the set of transforms to it, passes it to
+ * the Service, takes back the Service result and passes to the
+ * outbound routers.
+ *
+ * @param message The message to be dispatched.
+ * @throws RoutingException Error dispatching message.
+ */
+ public void dispatch(final Message message) throws RoutingException
+ {
+ Message outMessage;
+
+ applyInboundTransforms(message);
+ outMessage = dispatchToService(message);
+ applyOutboundRouters(outMessage);
+ }
+
+ /**
+ * Apply the inbound transform set.
+ *
+ * @param message The message.
+ * @throws RoutingException Error applying transformer.
+ */
+ private void applyInboundTransforms(Message message)
+ throws RoutingException
+ {
+ if (transformers != null && !transformers.isEmpty())
+ {
+ for (MessageTransformer transformer : transformers)
+ {
+ try
+ {
+ transformer.transform(message);
+ } catch (MessageTransformationException e)
+ {
+ throw new RoutingException("Error applying inbound transformer.", e);
+ }
+ }
+ }
+ }
+
+ /**
+ * Dispatch the message to the Service instance.
+ * @param theMessage The message.
+ * @return The processed message. Can be a new Message instance.
+ * @throws RoutingException Error processing message message in the Service.
+ */
+ private Message dispatchToService(Message theMessage) throws RoutingException
+ {
+ if (service != null)
+ {
+ try
+ {
+ return service.process(theMessage);
+ } catch (ServiceException e)
+ {
+ throw new RoutingException("Error processing message.", e);
+ }
+ }
+
+ return theMessage;
+ }
+
+ /**
+ * Apply the outbound routers to the message.
+ * @param outMessage The message.
+ * @throws RoutingException Error routing message.
+ */
+ private void applyOutboundRouters(Message outMessage) throws RoutingException
+ {
+ if (outboundRouters != null && !outboundRouters.isEmpty())
+ {
+ for (OutboundRouterConfig outboundRouter : outboundRouters)
+ {
+ applyOutboundTransformers(outMessage, outboundRouter.getTransformers());
+ outboundRouter.getRouter().route(outMessage);
+ }
+ }
+ }
+
+ /**
+ * Apply the supplied set of transformers on the supplied message.
+ * @param outMessage The message.
+ * @param transformers The transformers to be applied.
+ * @throws RoutingException Error applying transformer.
+ */
+ private void applyOutboundTransformers(Message outMessage, List<MessageTransformer> transformers) throws RoutingException
+ {
+ if (transformers != null && !transformers.isEmpty())
+ {
+ for (MessageTransformer transformer : transformers)
+ {
+ try
+ {
+ transformer.transform(outMessage);
+ } catch (MessageTransformationException e)
+ {
+ throw new RoutingException("Error applying outbound transformer.", e);
+ }
+ }
+ }
+ }
+
+ /**
+ * Set the ServiceName.
+ * @return The ServiceName.
+ */
+ public ServiceName getServiceName()
+ {
+ return serviceName;
+ }
+
+ /**
+ * Get the ServiceName.
+ * @param serviceName The ServiceName.
+ */
+ public void setServiceName(ServiceName serviceName)
+ {
+ this.serviceName = serviceName;
+ }
+
+ /**
+ * Get inbound transformers.
+ *
+ * @return The inbound transformers.
+ */
+ public List<MessageTransformer> getTransformers()
+ {
+ return transformers;
+ }
+
+ /**
+ * Set inbound transformers.
+ *
+ * @param transformers The inbound transformers.
+ */
+ public void setTransformers(List<MessageTransformer> transformers)
+ {
+ this.transformers = transformers;
+ }
+
+ /**
+ * Get the Service.
+ *
+ * @return The Service.
+ */
+ public Service getService()
+ {
+ return service;
+ }
+
+ /**
+ * Set the Service.
+ *
+ * @return The Service.
+ */
+ public void setService(Service service)
+ {
+ this.service = service;
+ }
+
+ /**
+ * Set the Outbound Routers.
+ *
+ * @return The Outbound Routers.
+ */
+ public List<OutboundRouterConfig> getOutboundRouters()
+ {
+ return outboundRouters;
+ }
+
+ /**
+ * Get the Outbound Routers.
+ *
+ * @param outboundRouters The Outbound Routers.
+ */
+ public void setOutboundRouters(List<OutboundRouterConfig> outboundRouters)
+ {
+ this.outboundRouters = outboundRouters;
+ }
+}
Property changes on: labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/dispatch/LocalDispatcher.java
___________________________________________________________________
Name: svn:eol-style
+ native
Added: labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/dispatch/package.html
===================================================================
--- labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/dispatch/package.html (rev 0)
+++ labs/jbossesb/workspace/skeagh/runtime/src/main/java/org/jboss/esb/dispatch/package.html 2008-08-29 16:20:21 UTC (rev 22240)
@@ -0,0 +1,8 @@
+<html>
+<head></head>
+<body>
+ESB Message Dispatch.
+
+<h2>Package Specification</h2>
+</body>
+</html>
\ No newline at end of file
Added: labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/dispatch/HelloInboundRouter.java
===================================================================
--- labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/dispatch/HelloInboundRouter.java (rev 0)
+++ labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/dispatch/HelloInboundRouter.java 2008-08-29 16:20:21 UTC (rev 22240)
@@ -0,0 +1,45 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., 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-2006, JBoss Inc.
+ */
+package org.jboss.esb.dispatch;
+
+import org.jboss.esb.routing.InboundRouter;
+import org.jboss.esb.routing.MessageDispatcher;
+import org.jboss.esb.routing.RoutingException;
+import org.jboss.esb.message.Message;
+
+/**
+ * @author <a href="mailto:tom.fennelly at jboss.com">tom.fennelly at jboss.com</a>
+ */
+public class HelloInboundRouter implements InboundRouter
+{
+ private MessageDispatcher dispatcher;
+
+ public void setDispatcher(MessageDispatcher dispatcher)
+ {
+ this.dispatcher = dispatcher;
+ }
+
+ public void sendHello(String message) throws RoutingException
+ {
+ Message esbMessage = new Message();
+ esbMessage.setPayload(message);
+ dispatcher.dispatch(esbMessage);
+ }
+}
Property changes on: labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/dispatch/HelloInboundRouter.java
___________________________________________________________________
Name: svn:eol-style
+ native
Added: labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/dispatch/HelloOutboundRouter.java
===================================================================
--- labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/dispatch/HelloOutboundRouter.java (rev 0)
+++ labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/dispatch/HelloOutboundRouter.java 2008-08-29 16:20:21 UTC (rev 22240)
@@ -0,0 +1,44 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., 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-2006, JBoss Inc.
+ */
+package org.jboss.esb.dispatch;
+
+import org.jboss.esb.routing.InboundRouter;
+import org.jboss.esb.routing.MessageDispatcher;
+import org.jboss.esb.routing.RoutingException;
+import org.jboss.esb.routing.OutboundRouter;
+import org.jboss.esb.message.Message;
+
+/**
+ * @author <a href="mailto:tom.fennelly at jboss.com">tom.fennelly at jboss.com</a>
+ */
+public class HelloOutboundRouter implements OutboundRouter
+{
+ private String helloMessage;
+
+ public void route(Message message) throws RoutingException
+ {
+ helloMessage = (String) message.getPayload();
+ }
+
+ public String getHelloMessage()
+ {
+ return helloMessage;
+ }
+}
\ No newline at end of file
Property changes on: labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/dispatch/HelloOutboundRouter.java
___________________________________________________________________
Name: svn:eol-style
+ native
Added: labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/dispatch/HelloWorldService.java
===================================================================
--- labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/dispatch/HelloWorldService.java (rev 0)
+++ labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/dispatch/HelloWorldService.java 2008-08-29 16:20:21 UTC (rev 22240)
@@ -0,0 +1,43 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., 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-2006, JBoss Inc.
+ */
+package org.jboss.esb.dispatch;
+
+import org.jboss.esb.service.Service;
+import org.jboss.esb.service.ServiceException;
+import org.jboss.esb.message.Message;
+
+/**
+ * @author <a href="mailto:tom.fennelly at jboss.com">tom.fennelly at jboss.com</a>
+ */
+public class HelloWorldService implements Service
+{
+ private String helloMessage;
+
+ public Message process(Message message) throws ServiceException
+ {
+ helloMessage = (String) message.getPayload();
+ return message;
+ }
+
+ public String getHelloMessage()
+ {
+ return helloMessage;
+ }
+}
Property changes on: labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/dispatch/HelloWorldService.java
___________________________________________________________________
Name: svn:eol-style
+ native
Added: labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/dispatch/LocalDispatcherTest.java
===================================================================
--- labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/dispatch/LocalDispatcherTest.java (rev 0)
+++ labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/dispatch/LocalDispatcherTest.java 2008-08-29 16:20:21 UTC (rev 22240)
@@ -0,0 +1,143 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., 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-2006, JBoss Inc.
+ */
+package org.jboss.esb.dispatch;
+
+import junit.framework.TestCase;
+import org.jboss.esb.deploy.DeploymentRuntime;
+import org.jboss.esb.deploy.DeploymentException;
+import org.jboss.esb.deploy.config.ConfigurationUnit;
+import org.jboss.esb.deploy.config.digest.DefaultConfigurationDigester;
+import org.jboss.esb.service.ServiceName;
+import org.jboss.esb.routing.RoutingException;
+
+import java.io.IOException;
+
+/**
+ * @author <a href="mailto:tom.fennelly at jboss.com">tom.fennelly at jboss.com</a>
+ */
+public class LocalDispatcherTest extends TestCase
+{
+ public void test_no_service_processor() throws DeploymentException, IOException, RoutingException
+ {
+ ServiceName service = new ServiceName("hello", "hello");
+ DeploymentRuntime runtime = new DeploymentRuntime();
+ DefaultConfigurationDigester digester = new DefaultConfigurationDigester();
+ ConfigurationUnit configUnit = digester.digest(getClass().getResourceAsStream("jbossesb-dispatch-no-service.xml"));
+
+ runtime.add(configUnit);
+
+ runtime.deploy();
+ try {
+ HelloInboundRouter inRouter = (HelloInboundRouter) configUnit.getInboundRouter(service, "inrouter1").getRouter();
+ HelloOutboundRouter outRouter = (HelloOutboundRouter) configUnit.getOutboundRouter(service, "outrouter1").getRouter();
+
+ assertEquals(null, outRouter.getHelloMessage());
+ inRouter.sendHello("Hey there");
+ assertEquals("Hey there", outRouter.getHelloMessage());
+ } finally {
+ runtime.undeploy();
+ }
+ }
+
+ public void test_with_service_processor() throws DeploymentException, IOException, RoutingException
+ {
+ ServiceName service = new ServiceName("hello", "hello");
+ DeploymentRuntime runtime = new DeploymentRuntime();
+ DefaultConfigurationDigester digester = new DefaultConfigurationDigester();
+ ConfigurationUnit configUnit = digester.digest(getClass().getResourceAsStream("jbossesb-dispatch-with-service.xml"));
+
+ runtime.add(configUnit);
+
+ runtime.deploy();
+ try {
+ HelloInboundRouter inRouter = (HelloInboundRouter) configUnit.getInboundRouter(service, "inrouter1").getRouter();
+ HelloWorldService helloService = (HelloWorldService) configUnit.getServices().get(service).getService();
+ HelloOutboundRouter outRouter = (HelloOutboundRouter) configUnit.getOutboundRouter(service, "outrouter1").getRouter();
+
+ assertEquals(null, helloService.getHelloMessage());
+ assertEquals(null, outRouter.getHelloMessage());
+
+ inRouter.sendHello("Hey there");
+
+ assertEquals("Hey there", helloService.getHelloMessage());
+ assertEquals("Hey there", outRouter.getHelloMessage());
+ } finally {
+ runtime.undeploy();
+ }
+ }
+
+ public void test_with_intransform() throws DeploymentException, IOException, RoutingException
+ {
+ ServiceName service = new ServiceName("hello", "hello");
+ DeploymentRuntime runtime = new DeploymentRuntime();
+ DefaultConfigurationDigester digester = new DefaultConfigurationDigester();
+ ConfigurationUnit configUnit = digester.digest(getClass().getResourceAsStream("jbossesb-dispatch-with-intransform.xml"));
+
+ runtime.add(configUnit);
+
+ runtime.deploy();
+ try {
+ HelloInboundRouter inRouter = (HelloInboundRouter) configUnit.getInboundRouter(service, "inrouter1").getRouter();
+ HelloWorldService helloService = (HelloWorldService) configUnit.getServices().get(service).getService();
+ HelloOutboundRouter outRouter = (HelloOutboundRouter) configUnit.getOutboundRouter(service, "outrouter1").getRouter();
+
+ assertEquals(null, outRouter.getHelloMessage());
+ assertEquals(null, helloService.getHelloMessage());
+
+ inRouter.sendHello("Hey there");
+
+ // Make sure it was transformed before hitting the service...
+ assertEquals("Goodbye World!", helloService.getHelloMessage());
+ // Passed thru to the outrouter untransformed......
+ assertEquals("Goodbye World!", outRouter.getHelloMessage());
+ } finally {
+ runtime.undeploy();
+ }
+ }
+
+ public void test_with_outtransform() throws DeploymentException, IOException, RoutingException
+ {
+ ServiceName service = new ServiceName("hello", "hello");
+ DeploymentRuntime runtime = new DeploymentRuntime();
+ DefaultConfigurationDigester digester = new DefaultConfigurationDigester();
+ ConfigurationUnit configUnit = digester.digest(getClass().getResourceAsStream("jbossesb-dispatch-with-outtransform.xml"));
+
+ runtime.add(configUnit);
+
+ runtime.deploy();
+ try {
+ HelloInboundRouter inRouter = (HelloInboundRouter) configUnit.getInboundRouter(service, "inrouter1").getRouter();
+ HelloWorldService helloService = (HelloWorldService) configUnit.getServices().get(service).getService();
+ HelloOutboundRouter outRouter = (HelloOutboundRouter) configUnit.getOutboundRouter(service, "outrouter1").getRouter();
+
+ assertEquals(null, outRouter.getHelloMessage());
+ assertEquals(null, helloService.getHelloMessage());
+
+ inRouter.sendHello("Hey there");
+
+ // Make sure it was transformed before hitting the service...
+ assertEquals("Goodbye World!", helloService.getHelloMessage());
+ // Make sure it was transformed again before hitting the outrouter...
+ assertEquals("Some other form of googbye!", outRouter.getHelloMessage());
+ } finally {
+ runtime.undeploy();
+ }
+ }
+}
Property changes on: labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/dispatch/LocalDispatcherTest.java
___________________________________________________________________
Name: svn:eol-style
+ native
Added: labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/dispatch/RestStringTransformer.java
===================================================================
--- labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/dispatch/RestStringTransformer.java (rev 0)
+++ labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/dispatch/RestStringTransformer.java 2008-08-29 16:20:21 UTC (rev 22240)
@@ -0,0 +1,37 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., 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-2006, JBoss Inc.
+ */
+package org.jboss.esb.dispatch;
+
+import org.jboss.esb.message.MessageTransformer;
+import org.jboss.esb.message.Message;
+import org.jboss.esb.message.MessageTransformationException;
+
+/**
+ * @author <a href="mailto:tom.fennelly at jboss.com">tom.fennelly at jboss.com</a>
+ */
+public class RestStringTransformer implements MessageTransformer
+{
+ private String newString;
+
+ public void transform(Message message) throws MessageTransformationException
+ {
+ message.setPayload(newString);
+ }
+}
Property changes on: labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/dispatch/RestStringTransformer.java
___________________________________________________________________
Name: svn:eol-style
+ native
Copied: labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/dispatch/jbossesb-dispatch-no-service.xml (from rev 22235, labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/deploy/config/jbossesb-deploy-01.xml)
===================================================================
--- labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/dispatch/jbossesb-dispatch-no-service.xml (rev 0)
+++ labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/dispatch/jbossesb-dispatch-no-service.xml 2008-08-29 16:20:21 UTC (rev 22240)
@@ -0,0 +1,12 @@
+<jbossesb xmlns="http://www.jboss.org/jbossesb/xsd/jbossesb-5.0.xsd" xmlns:xprot="http://www.jboss.org/jbossesb/xsd/xprot/xprot.xsd">
+
+ <routing>
+ <inRouters serviceCategory="hello" serviceName="hello">
+ <inRouter name="inrouter1" class="org.jboss.esb.dispatch.HelloInboundRouter" />
+ </inRouters>
+ <outRouters serviceCategory="hello" serviceName="hello">
+ <outRouter name="outrouter1" class="org.jboss.esb.dispatch.HelloOutboundRouter" />
+ </outRouters>
+ </routing>
+
+</jbossesb>
\ No newline at end of file
Property changes on: labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/dispatch/jbossesb-dispatch-no-service.xml
___________________________________________________________________
Name: svn:mime-type
+ text/xml
Name: svn:eol-style
+ native
Added: labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/dispatch/jbossesb-dispatch-with-intransform.xml
===================================================================
--- labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/dispatch/jbossesb-dispatch-with-intransform.xml (rev 0)
+++ labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/dispatch/jbossesb-dispatch-with-intransform.xml 2008-08-29 16:20:21 UTC (rev 22240)
@@ -0,0 +1,21 @@
+<jbossesb xmlns="http://www.jboss.org/jbossesb/xsd/jbossesb-5.0.xsd" xmlns:xprot="http://www.jboss.org/jbossesb/xsd/xprot/xprot.xsd">
+
+ <services>
+ <service serviceCategory="hello" serviceName="hello" serviceDescription="A Service" class="org.jboss.esb.dispatch.HelloWorldService" />
+ </services>
+
+ <routing>
+ <inRouters serviceCategory="hello" serviceName="hello">
+ <inRouter name="inrouter1" class="org.jboss.esb.dispatch.HelloInboundRouter">
+ <transformers>
+ <transformer class="org.jboss.esb.dispatch.RestStringTransformer">
+ <property name="newString">Goodbye World!</property>
+ </transformer>
+ </transformers>
+ </inRouter>
+ </inRouters>
+ <outRouters serviceCategory="hello" serviceName="hello">
+ <outRouter name="outrouter1" class="org.jboss.esb.dispatch.HelloOutboundRouter" />
+ </outRouters>
+ </routing>
+</jbossesb>
\ No newline at end of file
Property changes on: labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/dispatch/jbossesb-dispatch-with-intransform.xml
___________________________________________________________________
Name: svn:mime-type
+ text/xml
Name: svn:eol-style
+ native
Added: labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/dispatch/jbossesb-dispatch-with-outtransform.xml
===================================================================
--- labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/dispatch/jbossesb-dispatch-with-outtransform.xml (rev 0)
+++ labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/dispatch/jbossesb-dispatch-with-outtransform.xml 2008-08-29 16:20:21 UTC (rev 22240)
@@ -0,0 +1,27 @@
+<jbossesb xmlns="http://www.jboss.org/jbossesb/xsd/jbossesb-5.0.xsd" xmlns:xprot="http://www.jboss.org/jbossesb/xsd/xprot/xprot.xsd">
+
+ <services>
+ <service serviceCategory="hello" serviceName="hello" serviceDescription="A Service" class="org.jboss.esb.dispatch.HelloWorldService" />
+ </services>
+
+ <routing>
+ <inRouters serviceCategory="hello" serviceName="hello">
+ <inRouter name="inrouter1" class="org.jboss.esb.dispatch.HelloInboundRouter">
+ <transformers>
+ <transformer class="org.jboss.esb.dispatch.RestStringTransformer">
+ <property name="newString">Goodbye World!</property>
+ </transformer>
+ </transformers>
+ </inRouter>
+ </inRouters>
+ <outRouters serviceCategory="hello" serviceName="hello">
+ <outRouter name="outrouter1" class="org.jboss.esb.dispatch.HelloOutboundRouter">
+ <transformers>
+ <transformer class="org.jboss.esb.dispatch.RestStringTransformer">
+ <property name="newString">Some other form of googbye!</property>
+ </transformer>
+ </transformers>
+ </outRouter>
+ </outRouters>
+ </routing>
+</jbossesb>
\ No newline at end of file
Property changes on: labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/dispatch/jbossesb-dispatch-with-outtransform.xml
___________________________________________________________________
Name: svn:mime-type
+ text/xml
Name: svn:eol-style
+ native
Added: labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/dispatch/jbossesb-dispatch-with-service.xml
===================================================================
--- labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/dispatch/jbossesb-dispatch-with-service.xml (rev 0)
+++ labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/dispatch/jbossesb-dispatch-with-service.xml 2008-08-29 16:20:21 UTC (rev 22240)
@@ -0,0 +1,15 @@
+<jbossesb xmlns="http://www.jboss.org/jbossesb/xsd/jbossesb-5.0.xsd" xmlns:xprot="http://www.jboss.org/jbossesb/xsd/xprot/xprot.xsd">
+
+ <services>
+ <service serviceCategory="hello" serviceName="hello" serviceDescription="A Service" class="org.jboss.esb.dispatch.HelloWorldService" />
+ </services>
+
+ <routing>
+ <inRouters serviceCategory="hello" serviceName="hello">
+ <inRouter name="inrouter1" class="org.jboss.esb.dispatch.HelloInboundRouter" />
+ </inRouters>
+ <outRouters serviceCategory="hello" serviceName="hello">
+ <outRouter name="outrouter1" class="org.jboss.esb.dispatch.HelloOutboundRouter" />
+ </outRouters>
+ </routing>
+</jbossesb>
\ No newline at end of file
Property changes on: labs/jbossesb/workspace/skeagh/runtime/src/test/java/org/jboss/esb/dispatch/jbossesb-dispatch-with-service.xml
___________________________________________________________________
Name: svn:mime-type
+ text/xml
Name: svn:eol-style
+ native
More information about the jboss-svn-commits
mailing list