[jboss-svn-commits] JBL Code SVN: r12170 - in labs/jbossesb/workspace/rearch2/core/src: main/java/org/jboss/internal/soa/esb/api/local and 11 other directories.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Mon May 28 06:47:59 EDT 2007
Author: mark.little at jboss.com
Date: 2007-05-28 06:47:59 -0400 (Mon, 28 May 2007)
New Revision: 12170
Added:
labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/internal/soa/esb/api/local/
labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/internal/soa/esb/api/local/SenderImpl.java
labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/internal/soa/esb/api/local/SenderPluginImpl.java
labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/internal/soa/esb/api/local/TwoWaySenderImpl.java
labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/internal/soa/esb/api/local/TwoWaySenderPluginImpl.java
labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/internal/soa/esb/spi/local/
labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/internal/soa/esb/spi/local/ReceiverImpl.java
labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/internal/soa/esb/spi/local/ReceiverPluginImpl.java
labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/internal/soa/esb/spi/local/TwoWayReceiverImpl.java
labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/internal/soa/esb/spi/local/TwoWayReceiverPluginImpl.java
labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/soa/esb/domain/
labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/soa/esb/domain/Domain.java
labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/soa/esb/domain/DomainManager.java
labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/soa/esb/domain/LifecycleException.java
labs/jbossesb/workspace/rearch2/core/src/test/java/org/jboss/soa/esb/domain/
labs/jbossesb/workspace/rearch2/core/src/test/java/org/jboss/soa/esb/domain/DomainUnitTest.java
Modified:
labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/internal/soa/esb/api/remoting/SenderImpl.java
labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/soa/esb/api/SenderFactory.java
labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/soa/esb/message/Body.java
labs/jbossesb/workspace/rearch2/core/src/test/java/org/jboss/soa/esb/infrastructure/DummyDispatcher.java
labs/jbossesb/workspace/rearch2/core/src/test/java/org/jboss/soa/esb/infrastructure/NullReceiverDispatcher.java
labs/jbossesb/workspace/rearch2/core/src/test/java/org/jboss/soa/esb/infrastructure/NullSenderDispatcher.java
labs/jbossesb/workspace/rearch2/core/src/test/java/org/jboss/soa/esb/infrastructure/tests/DispatcherUnitTest.java
Log:
Started to add domain model.
Added: labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/internal/soa/esb/api/local/SenderImpl.java
===================================================================
--- labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/internal/soa/esb/api/local/SenderImpl.java (rev 0)
+++ labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/internal/soa/esb/api/local/SenderImpl.java 2007-05-28 10:47:59 UTC (rev 12170)
@@ -0,0 +1,97 @@
+package org.jboss.internal.soa.esb.api.local;
+
+/*
+ * 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,
+ * @author mark.little at jboss.com
+ */
+
+import org.jboss.internal.soa.esb.message.format.xml.MessageImpl;
+import org.jboss.internal.soa.esb.message.format.xml.remoting.MarshalPlugin;
+import org.jboss.internal.soa.esb.message.format.xml.remoting.UnMarshalPlugin;
+import org.jboss.remoting.Client;
+import org.jboss.remoting.InvokerLocator;
+import org.jboss.remoting.marshal.MarshalFactory;
+import org.jboss.soa.esb.ProtocolNotSupportedException;
+import org.jboss.soa.esb.SendFailedException;
+import org.jboss.soa.esb.api.Sender;
+import org.jboss.soa.esb.message.Message;
+
+public class SenderImpl implements Sender
+{
+ private static final String DATA_TYPE = "/?datatype=xml";
+
+ public SenderImpl()
+ {
+ MarshalFactory.addMarshaller("xml", MarshalPlugin.getInstance(),
+ UnMarshalPlugin.getInstance());
+ }
+
+ /**
+ * Start to assemble the ESBCore message that we will then pass down into
+ * the Dispatcher hierarchy.
+ */
+
+ public void send(Message msg) throws ProtocolNotSupportedException,
+ SendFailedException
+ {
+ if (msg == null)
+ throw new IllegalArgumentException("message is null!");
+
+ try
+ {
+ String locatorUri = msg.getHeader().getCall().getTo().getAddr().getAddress();
+
+ if (msg instanceof MessageImpl)
+ locatorUri = locatorUri + DATA_TYPE;
+
+ InvokerLocator locator = new InvokerLocator(locatorUri);
+
+ System.out.println("Calling remoting server with locator uri of: "
+ + locatorUri);
+
+ Client remotingClient = new Client(locator);
+ remotingClient.connect();
+
+ remotingClient.invokeOneway(msg);
+
+ remotingClient.disconnect();
+ }
+ catch (Throwable ex)
+ {
+ ex.printStackTrace();
+
+ throw new SendFailedException(ex);
+ }
+ }
+
+ public void sendAsync(Message msg) throws ProtocolNotSupportedException
+ {
+ throw new ProtocolNotSupportedException();
+ }
+
+ /*
+ * public void sendAsync (EPR addr, Body msg, Callback cb) throws
+ * ProtocolNotSupportedException { throw new
+ * ProtocolNotSupportedException(); }
+ */
+ public void sendReliable(Message msg) throws ProtocolNotSupportedException
+ {
+ throw new ProtocolNotSupportedException();
+ }
+}
Added: labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/internal/soa/esb/api/local/SenderPluginImpl.java
===================================================================
--- labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/internal/soa/esb/api/local/SenderPluginImpl.java (rev 0)
+++ labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/internal/soa/esb/api/local/SenderPluginImpl.java 2007-05-28 10:47:59 UTC (rev 12170)
@@ -0,0 +1,38 @@
+package org.jboss.internal.soa.esb.api.local;
+
+import org.jboss.soa.esb.api.Sender;
+import org.jboss.soa.esb.api.plugin.SenderPlugin;
+
+/*
+ * 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,
+ * @author mark.little at jboss.com
+ */
+
+public class SenderPluginImpl implements SenderPlugin
+{
+ public Sender create ()
+ {
+ return new SenderImpl();
+ }
+
+ public boolean isTwoWay ()
+ {
+ return false;
+ }
+}
Added: labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/internal/soa/esb/api/local/TwoWaySenderImpl.java
===================================================================
--- labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/internal/soa/esb/api/local/TwoWaySenderImpl.java (rev 0)
+++ labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/internal/soa/esb/api/local/TwoWaySenderImpl.java 2007-05-28 10:47:59 UTC (rev 12170)
@@ -0,0 +1,105 @@
+package org.jboss.internal.soa.esb.api.local;
+
+/*
+ * 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,
+ * @author mark.little at jboss.com
+ */
+
+import org.jboss.internal.soa.esb.message.format.xml.MessageImpl;
+import org.jboss.internal.soa.esb.message.format.xml.remoting.MarshalPlugin;
+import org.jboss.internal.soa.esb.message.format.xml.remoting.UnMarshalPlugin;
+import org.jboss.remoting.Client;
+import org.jboss.remoting.InvokerLocator;
+import org.jboss.remoting.marshal.MarshalFactory;
+import org.jboss.soa.esb.ProtocolNotSupportedException;
+import org.jboss.soa.esb.SendFailedException;
+import org.jboss.soa.esb.api.TwoWaySender;
+import org.jboss.soa.esb.message.Message;
+
+public class TwoWaySenderImpl implements TwoWaySender
+{
+ private static final String DATA_TYPE = "/?datatype=xml";
+
+ public TwoWaySenderImpl()
+ {
+ MarshalFactory.addMarshaller("xml", MarshalPlugin.getInstance(),
+ UnMarshalPlugin.getInstance());
+ }
+
+ /**
+ * Start to assemble the ESBCore message that we will then pass down into
+ * the Dispatcher hierarchy.
+ */
+
+ public Message invoke (Message msg) throws ProtocolNotSupportedException,
+ SendFailedException
+ {
+ if (msg == null)
+ throw new IllegalArgumentException("message is null!");
+
+ try
+ {
+ String locatorUri = msg.getHeader().getCall().getTo().getAddr().getAddress();
+
+ if (msg instanceof MessageImpl)
+ locatorUri = locatorUri + DATA_TYPE;
+
+ InvokerLocator locator = new InvokerLocator(locatorUri);
+
+ System.out.println("Calling remoting server with locator uri of: "
+ + locatorUri);
+
+ Client remotingClient = new Client(locator);
+ remotingClient.connect();
+
+ Object response = remotingClient.invoke(msg);
+
+ remotingClient.disconnect();
+
+ return (Message) response;
+ }
+ catch (Throwable ex)
+ {
+ ex.printStackTrace();
+
+ throw new SendFailedException(ex);
+ }
+ }
+
+ public void send (Message msg) throws ProtocolNotSupportedException
+ {
+ throw new ProtocolNotSupportedException();
+ }
+
+ public void sendAsync(Message msg) throws ProtocolNotSupportedException
+ {
+ throw new ProtocolNotSupportedException();
+ }
+
+ /*
+ * public void sendAsync (EPR addr, Body msg, Callback cb) throws
+ * ProtocolNotSupportedException { throw new
+ * ProtocolNotSupportedException(); }
+ */
+
+ public void sendReliable(Message msg) throws ProtocolNotSupportedException
+ {
+ throw new ProtocolNotSupportedException();
+ }
+}
Added: labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/internal/soa/esb/api/local/TwoWaySenderPluginImpl.java
===================================================================
--- labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/internal/soa/esb/api/local/TwoWaySenderPluginImpl.java (rev 0)
+++ labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/internal/soa/esb/api/local/TwoWaySenderPluginImpl.java 2007-05-28 10:47:59 UTC (rev 12170)
@@ -0,0 +1,38 @@
+package org.jboss.internal.soa.esb.api.local;
+
+import org.jboss.soa.esb.api.Sender;
+import org.jboss.soa.esb.api.plugin.SenderPlugin;
+
+/*
+ * 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,
+ * @author mark.little at jboss.com
+ */
+
+public class TwoWaySenderPluginImpl implements SenderPlugin
+{
+ public Sender create ()
+ {
+ return new TwoWaySenderImpl();
+ }
+
+ public boolean isTwoWay ()
+ {
+ return true;
+ }
+}
Modified: labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/internal/soa/esb/api/remoting/SenderImpl.java
===================================================================
--- labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/internal/soa/esb/api/remoting/SenderImpl.java 2007-05-28 10:14:52 UTC (rev 12169)
+++ labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/internal/soa/esb/api/remoting/SenderImpl.java 2007-05-28 10:47:59 UTC (rev 12170)
@@ -24,22 +24,23 @@
import org.jboss.internal.soa.esb.message.format.xml.MessageImpl;
import org.jboss.internal.soa.esb.message.format.xml.remoting.MarshalPlugin;
import org.jboss.internal.soa.esb.message.format.xml.remoting.UnMarshalPlugin;
-import org.jboss.remoting.Client;
-import org.jboss.remoting.InvokerLocator;
-import org.jboss.remoting.marshal.MarshalFactory;
import org.jboss.soa.esb.ProtocolNotSupportedException;
import org.jboss.soa.esb.SendFailedException;
import org.jboss.soa.esb.api.Sender;
import org.jboss.soa.esb.message.Message;
+/**
+ * Local (in-VM) transport.
+ *
+ * @author marklittle
+ *
+ */
+
public class SenderImpl implements Sender
{
- private static final String DATA_TYPE = "/?datatype=xml";
public SenderImpl()
{
- MarshalFactory.addMarshaller("xml", MarshalPlugin.getInstance(),
- UnMarshalPlugin.getInstance());
}
/**
@@ -52,32 +53,6 @@
{
if (msg == null)
throw new IllegalArgumentException("message is null!");
-
- try
- {
- String locatorUri = msg.getHeader().getCall().getTo().getAddr().getAddress();
-
- if (msg instanceof MessageImpl)
- locatorUri = locatorUri + DATA_TYPE;
-
- InvokerLocator locator = new InvokerLocator(locatorUri);
-
- System.out.println("Calling remoting server with locator uri of: "
- + locatorUri);
-
- Client remotingClient = new Client(locator);
- remotingClient.connect();
-
- remotingClient.invokeOneway(msg);
-
- remotingClient.disconnect();
- }
- catch (Throwable ex)
- {
- ex.printStackTrace();
-
- throw new SendFailedException(ex);
- }
}
public void sendAsync(Message msg) throws ProtocolNotSupportedException
Added: labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/internal/soa/esb/spi/local/ReceiverImpl.java
===================================================================
--- labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/internal/soa/esb/spi/local/ReceiverImpl.java (rev 0)
+++ labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/internal/soa/esb/spi/local/ReceiverImpl.java 2007-05-28 10:47:59 UTC (rev 12170)
@@ -0,0 +1,146 @@
+package org.jboss.internal.soa.esb.spi.local;
+
+import javax.management.MBeanServer;
+
+import org.jboss.internal.soa.esb.message.format.xml.remoting.MarshalPlugin;
+import org.jboss.internal.soa.esb.message.format.xml.remoting.UnMarshalPlugin;
+import org.jboss.remoting.InvocationRequest;
+import org.jboss.remoting.InvokerLocator;
+import org.jboss.remoting.ServerInvocationHandler;
+import org.jboss.remoting.ServerInvoker;
+import org.jboss.remoting.callback.InvokerCallbackHandler;
+import org.jboss.remoting.marshal.MarshalFactory;
+import org.jboss.remoting.transport.Connector;
+import org.jboss.soa.esb.message.Message;
+import org.jboss.soa.esb.spi.Receiver;
+import org.jboss.soa.esb.spi.Service;
+
+/*
+ * 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,
+ * @author mark.little at jboss.com
+ */
+
+public class ReceiverImpl implements Receiver
+{
+
+ public ReceiverImpl (String locatorURI, Service receiver) throws Exception
+ {
+ MarshalFactory.addMarshaller("xml", MarshalPlugin.getInstance(), UnMarshalPlugin.getInstance());
+
+ InvokerLocator locator = new InvokerLocator(locatorURI);
+ System.out.println("Starting remoting server with locator uri of: "
+ + locatorURI);
+ Connector connector = new Connector(locator);
+ // creates all the connector's needed resources, such as the server
+ // invoker
+ connector.create();
+
+ // create the handler to receive the invocation request from the client
+ // for processing
+ RosettaInvocationHandler invocationHandler = new RosettaInvocationHandler(receiver);
+ // first parameter is sub-system name. can be any String value.
+ connector.addInvocationHandler("rosetta", invocationHandler);
+
+ // start with a new non daemon thread so
+ // server will wait for request and not exit
+ connector.start();
+ }
+
+ public void listen ()
+ {
+ for (;;);
+ }
+
+ /**
+ * Simple invocation handler implementation. This is the code that will be
+ * called with the invocation payload from the client.
+ */
+ public static class RosettaInvocationHandler implements
+ ServerInvocationHandler
+ {
+ public RosettaInvocationHandler (Service svc)
+ {
+ _service = svc;
+ }
+
+ /**
+ * called to handle a specific invocation
+ *
+ * @param invocation
+ * @return
+ * @throws Throwable
+ */
+ public Object invoke(InvocationRequest invocation) throws Throwable
+ {
+ // Print out the invocation request
+ System.out.println("Invocation request is: "
+ + invocation.getParameter());
+
+ if (_service != null)
+ _service.doWork((Message) invocation.getParameter());
+
+ return null;
+ }
+
+ /**
+ * Adds a callback handler that will listen for callbacks from the
+ * server invoker handler.
+ *
+ * @param callbackHandler
+ */
+ public void addListener(InvokerCallbackHandler callbackHandler)
+ {
+ // NO OP as do not handling callback listeners in this example
+ }
+
+ /**
+ * Removes the callback handler that was listening for callbacks from
+ * the server invoker handler.
+ *
+ * @param callbackHandler
+ */
+ public void removeListener(InvokerCallbackHandler callbackHandler)
+ {
+ // NO OP as do not handling callback listeners in this example
+ }
+
+ /**
+ * set the mbean server that the handler can reference
+ *
+ * @param server
+ */
+ public void setMBeanServer(MBeanServer server)
+ {
+ // NO OP as do not need reference to MBeanServer for this handler
+ }
+
+ /**
+ * set the invoker that owns this handler
+ *
+ * @param invoker
+ */
+ public void setInvoker(ServerInvoker invoker)
+ {
+ // NO OP as do not need reference back to the server invoker
+ }
+
+ private Service _service;
+ }
+
+}
Added: labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/internal/soa/esb/spi/local/ReceiverPluginImpl.java
===================================================================
--- labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/internal/soa/esb/spi/local/ReceiverPluginImpl.java (rev 0)
+++ labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/internal/soa/esb/spi/local/ReceiverPluginImpl.java 2007-05-28 10:47:59 UTC (rev 12170)
@@ -0,0 +1,60 @@
+package org.jboss.internal.soa.esb.spi.local;
+
+import java.net.URI;
+
+import org.jboss.soa.esb.addressing.EPR;
+import org.jboss.soa.esb.spi.Receiver;
+import org.jboss.soa.esb.spi.Service;
+import org.jboss.soa.esb.spi.plugin.ReceiverPlugin;
+
+/*
+ * 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,
+ * @author mark.little at jboss.com
+ */
+
+public class ReceiverPluginImpl implements ReceiverPlugin
+{
+ public static final String REMOTING_DATATYPE = "/?datatype=xml";
+
+ public Receiver create (EPR epr, Service svc)
+ {
+ if (epr == null)
+ throw new IllegalArgumentException();
+
+ if (svc == null)
+ throw new IllegalArgumentException();
+
+ try
+ {
+ return new ReceiverImpl(epr.getAddr().getAddress()+REMOTING_DATATYPE, svc);
+ }
+ catch (Exception ex)
+ {
+ // TODO exceptions!!
+
+ return null;
+ }
+ }
+
+ public boolean isTwoWay ()
+ {
+ return false;
+ }
+
+}
Added: labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/internal/soa/esb/spi/local/TwoWayReceiverImpl.java
===================================================================
--- labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/internal/soa/esb/spi/local/TwoWayReceiverImpl.java (rev 0)
+++ labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/internal/soa/esb/spi/local/TwoWayReceiverImpl.java 2007-05-28 10:47:59 UTC (rev 12170)
@@ -0,0 +1,154 @@
+package org.jboss.internal.soa.esb.spi.local;
+
+import javax.management.MBeanServer;
+
+import org.jboss.internal.soa.esb.message.format.xml.remoting.MarshalPlugin;
+import org.jboss.internal.soa.esb.message.format.xml.remoting.UnMarshalPlugin;
+import org.jboss.remoting.InvocationRequest;
+import org.jboss.remoting.InvokerLocator;
+import org.jboss.remoting.ServerInvocationHandler;
+import org.jboss.remoting.ServerInvoker;
+import org.jboss.remoting.callback.InvokerCallbackHandler;
+import org.jboss.remoting.marshal.MarshalFactory;
+import org.jboss.remoting.transport.Connector;
+import org.jboss.soa.esb.message.Message;
+import org.jboss.soa.esb.spi.Receiver;
+import org.jboss.soa.esb.spi.Service;
+
+/*
+ * 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,
+ * @author mark.little at jboss.com
+ */
+
+public class TwoWayReceiverImpl implements Receiver
+{
+
+ public TwoWayReceiverImpl (String locatorURI, Service work) throws Exception
+ {
+ if ((locatorURI == null) || (work == null))
+ throw new IllegalArgumentException();
+
+ MarshalFactory.addMarshaller("xml", MarshalPlugin.getInstance(), UnMarshalPlugin.getInstance());
+
+ InvokerLocator locator = new InvokerLocator(locatorURI);
+ System.out.println("Starting remoting server with locator uri of: "
+ + locatorURI);
+ Connector connector = new Connector(locator);
+ // creates all the connector's needed resources, such as the server
+ // invoker
+ connector.create();
+
+ // create the handler to receive the invocation request from the client
+ // for processing
+ RosettaInvocationHandler invocationHandler = new RosettaInvocationHandler(work);
+ // first parameter is sub-system name. can be any String value.
+ connector.addInvocationHandler("rosetta", invocationHandler);
+
+ // start with a new non daemon thread so
+ // server will wait for request and not exit
+ connector.start();
+ }
+
+ public void listen ()
+ {
+ while (!_terminate)
+ {
+ }
+ }
+
+ private boolean _terminate = false;
+
+ /**
+ * Simple invocation handler implementation. This is the code that will be
+ * called with the invocation payload from the client.
+ */
+
+ public static class RosettaInvocationHandler implements
+ ServerInvocationHandler
+ {
+ public RosettaInvocationHandler (Service work)
+ {
+ _worker = work;
+ }
+
+ /**
+ * called to handle a specific invocation
+ *
+ * @param invocation
+ * @return
+ * @throws Throwable
+ */
+
+ public Object invoke(InvocationRequest invocation) throws Throwable
+ {
+ Message msg = (Message) invocation.getParameter();
+
+ // could check msg to see if it's for the service (e.g., shutdown).
+
+ Message response = _worker.doWork(msg);
+
+ return response;
+ }
+
+ /**
+ * Adds a callback handler that will listen for callbacks from the
+ * server invoker handler.
+ *
+ * @param callbackHandler
+ */
+ public void addListener(InvokerCallbackHandler callbackHandler)
+ {
+ // NO OP as do not handling callback listeners in this example
+ }
+
+ /**
+ * Removes the callback handler that was listening for callbacks from
+ * the server invoker handler.
+ *
+ * @param callbackHandler
+ */
+ public void removeListener(InvokerCallbackHandler callbackHandler)
+ {
+ // NO OP as do not handling callback listeners in this example
+ }
+
+ /**
+ * set the mbean server that the handler can reference
+ *
+ * @param server
+ */
+ public void setMBeanServer(MBeanServer server)
+ {
+ // NO OP as do not need reference to MBeanServer for this handler
+ }
+
+ /**
+ * set the invoker that owns this handler
+ *
+ * @param invoker
+ */
+ public void setInvoker(ServerInvoker invoker)
+ {
+ // NO OP as do not need reference back to the server invoker
+ }
+
+ private Service _worker;
+ }
+
+}
Added: labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/internal/soa/esb/spi/local/TwoWayReceiverPluginImpl.java
===================================================================
--- labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/internal/soa/esb/spi/local/TwoWayReceiverPluginImpl.java (rev 0)
+++ labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/internal/soa/esb/spi/local/TwoWayReceiverPluginImpl.java 2007-05-28 10:47:59 UTC (rev 12170)
@@ -0,0 +1,57 @@
+package org.jboss.internal.soa.esb.spi.local;
+
+import org.jboss.soa.esb.addressing.EPR;
+import org.jboss.soa.esb.spi.Receiver;
+import org.jboss.soa.esb.spi.Service;
+import org.jboss.soa.esb.spi.plugin.ReceiverPlugin;
+
+/*
+ * 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,
+ * @author mark.little at jboss.com
+ */
+
+public class TwoWayReceiverPluginImpl implements ReceiverPlugin
+{
+ public static final String REMOTING_DATATYPE = "/?datatype=xml";
+
+ public Receiver create (EPR epr, Service svc)
+ {
+ if (epr == null)
+ throw new IllegalArgumentException();
+
+ if (svc == null)
+ throw new IllegalArgumentException();
+
+ try
+ {
+ return new TwoWayReceiverImpl(epr.getAddr().getAddress()+REMOTING_DATATYPE, svc);
+ }
+ catch (Exception ex)
+ {
+ // TODO exceptions!!
+
+ return null;
+ }
+ }
+
+ public boolean isTwoWay ()
+ {
+ return true;
+ }
+}
Modified: labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/soa/esb/api/SenderFactory.java
===================================================================
--- labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/soa/esb/api/SenderFactory.java 2007-05-28 10:14:52 UTC (rev 12169)
+++ labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/soa/esb/api/SenderFactory.java 2007-05-28 10:47:59 UTC (rev 12170)
@@ -63,6 +63,11 @@
{
return _instance;
}
+
+ public Sender getSender (String senderLogicalName) // throws ServiceNotFoundException
+ {
+ return null;
+ }
/**
* Get the client API implementation that can deal with the specified
Added: labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/soa/esb/domain/Domain.java
===================================================================
--- labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/soa/esb/domain/Domain.java (rev 0)
+++ labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/soa/esb/domain/Domain.java 2007-05-28 10:47:59 UTC (rev 12170)
@@ -0,0 +1,217 @@
+package org.jboss.soa.esb.domain;
+
+import java.net.URI;
+import java.util.concurrent.ConcurrentHashMap;
+
+/*
+ * 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,
+ * @author mark.little at jboss.com
+ */
+
+/**
+ * Services are deployed into domains. A given VM may have multiple
+ * domains within it. Each domain may be associated with different dispatchers
+ * (domain wide). Therefore, the domain within which the service is deployed
+ * will dictate the type of dispatcher hierarchy it is associated with. Any
+ * number of services may be deployed within a domain, including just one.
+ */
+
+public class Domain
+{
+ public static final int CREATED = 0;
+ public static final int ACTIVE = 1;
+ public static final int SUSPENDED = 2;
+ public static final int RESUMED = 3;
+ public static final int TERMINATED = 4;
+
+ class ServiceManager
+ {
+ public ServiceManager (Object service)
+ {
+ _service = service;
+ _status = ACTIVE;
+ }
+
+ public Object getService ()
+ {
+ return _service;
+ }
+
+ public int status ()
+ {
+ return _status;
+ }
+
+ public void suspend ()
+ {
+ _status = SUSPENDED;
+ }
+
+ public void resume ()
+ {
+ _status = ACTIVE;
+ }
+
+ private Object _service;
+ private int _status;
+ }
+
+ public void activateService (Object service, URI name) throws LifecycleException, IllegalStateException
+ {
+ if ((service == null) || (name == null))
+ throw new IllegalArgumentException();
+
+ if (_status != ACTIVE)
+ throw new IllegalStateException();
+
+ /*
+ * Make sure the name is unique within the domain.
+ */
+
+ if (_objects.get(name) != null)
+ throw new LifecycleException("Service already within domain.");
+
+ _objects.put(name, new ServiceManager(service));
+ }
+
+ public void deactivateService (URI serviceName) throws LifecycleException, IllegalStateException
+ {
+ if (serviceName == null)
+ throw new IllegalArgumentException();
+
+ if (_status != ACTIVE)
+ throw new IllegalStateException();
+
+ /*
+ * Synchronize on the domain so that we don't remove a service
+ * that is being used.
+ */
+
+ synchronized (_objects)
+ {
+ Object service = _objects.remove(serviceName);
+
+ if (service == null)
+ throw new LifecycleException("Service not present within domain.");
+ }
+ }
+
+ public void suspendService (URI serviceName) throws LifecycleException, IllegalStateException
+ {
+ if (serviceName == null)
+ throw new IllegalArgumentException();
+
+ if (_status != ACTIVE)
+ throw new IllegalStateException();
+
+ /*
+ * It is ok to suspend a service that is inflight. All existing calls will
+ * be completed and no subsequent calls will be allowed.
+ */
+
+ ServiceManager wrapper = _objects.get(serviceName);
+
+ if (wrapper == null)
+ throw new LifecycleException("Service not registered with domain.");
+
+ wrapper.suspend();
+ }
+
+ public void resumeService (URI serviceName) throws LifecycleException, IllegalStateException
+ {
+ if (serviceName == null)
+ throw new IllegalArgumentException();
+
+ if (_status != ACTIVE)
+ throw new IllegalStateException();
+
+ ServiceManager wrapper = _objects.get(serviceName);
+
+ if (wrapper == null)
+ throw new LifecycleException("Service not registered with domain.");
+
+ wrapper.resume();
+ }
+
+ public URI getName ()
+ {
+ return _name;
+ }
+
+ public final int status ()
+ {
+ return _status;
+ }
+
+ public final void suspend () throws IllegalStateException
+ {
+ synchronized (this)
+ {
+ if (_status != TERMINATED)
+ _status = SUSPENDED;
+ else
+ throw new IllegalStateException();
+ }
+ }
+
+ public final void resume () throws IllegalStateException
+ {
+ synchronized (this)
+ {
+ if (_status != TERMINATED)
+ _status = ACTIVE;
+ else
+ throw new IllegalStateException();
+ }
+ }
+
+ public final void activate () throws IllegalStateException
+ {
+ synchronized (this)
+ {
+ if (_status != TERMINATED)
+ _status = ACTIVE;
+ else
+ throw new IllegalStateException();
+ }
+ }
+
+ public final void terminate () throws IllegalStateException
+ {
+ // ok to assume idempotent operation
+
+ synchronized (this)
+ {
+ _status = TERMINATED;
+
+ // TODO deal with registered services
+ }
+ }
+
+ protected Domain (URI name)
+ {
+ _name = name;
+ _status = CREATED;
+ }
+
+ private URI _name;
+ private ConcurrentHashMap<URI, ServiceManager> _objects = new ConcurrentHashMap<URI, ServiceManager>();
+ private int _status;
+
+}
Added: labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/soa/esb/domain/DomainManager.java
===================================================================
--- labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/soa/esb/domain/DomainManager.java (rev 0)
+++ labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/soa/esb/domain/DomainManager.java 2007-05-28 10:47:59 UTC (rev 12170)
@@ -0,0 +1,106 @@
+package org.jboss.soa.esb.domain;
+
+import java.net.URI;
+import java.util.Enumeration;
+import java.util.concurrent.ConcurrentHashMap;
+
+/*
+ * 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,
+ * @author mark.little at jboss.com
+ */
+
+/**
+ * Services are deployed into domains. A given VM may have multiple
+ * domains within it. Each domain may be associated with different dispatchers
+ * (domain wide). Plus, each service may have its own dispatcher hierarchy that
+ * overrides the domain specific aspects.
+ */
+
+public class DomainManager
+{
+ public static final DomainManager getInstance ()
+ {
+ return _theInstance;
+ }
+
+ public final Domain createDomain (URI domainName)
+ {
+ if (domainName == null)
+ throw new IllegalArgumentException();
+
+ // if already present then throw an exception
+
+ if (_domains.get(domainName) != null)
+ throw new IllegalArgumentException("Domain already present.");
+
+ // not created in active state
+
+ Domain domain = new Domain(domainName);
+
+ _domains.put(domainName, domain);
+
+ return domain;
+ }
+
+ public final Domain getDomain (URI domainName)
+ {
+ if (domainName == null)
+ throw new IllegalArgumentException();
+
+ return _domains.get(domainName);
+ }
+
+ public final void removeDomain (URI domainName)
+ {
+ if (domainName == null)
+ throw new IllegalArgumentException();
+
+ Domain domain = _domains.remove(domainName);
+
+ if (domain == null)
+ throw new IllegalArgumentException("No such domain name: "+domainName);
+
+ domain.terminate();
+ }
+
+ public final void reset ()
+ {
+ synchronized (_domains)
+ {
+ Enumeration<URI> keys = _domains.keys();
+
+ while (keys.hasMoreElements())
+ {
+ URI key = keys.nextElement();
+ Domain domain = _domains.remove(key);
+
+ domain.terminate();
+ }
+ }
+ }
+
+ private DomainManager ()
+ {
+ }
+
+ private ConcurrentHashMap<URI, Domain> _domains = new ConcurrentHashMap<URI, Domain>();
+
+ private static final DomainManager _theInstance = new DomainManager();
+
+}
Added: labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/soa/esb/domain/LifecycleException.java
===================================================================
--- labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/soa/esb/domain/LifecycleException.java (rev 0)
+++ labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/soa/esb/domain/LifecycleException.java 2007-05-28 10:47:59 UTC (rev 12170)
@@ -0,0 +1,66 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY 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 along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.soa.esb.domain;
+
+import org.jboss.soa.esb.BaseException;
+
+public class LifecycleException extends BaseException
+{
+
+ private static final long serialVersionUID = 1L;
+
+ /**
+ * Construct an exception instance.
+ *
+ * @param message
+ * Exception message.
+ */
+ public LifecycleException(String message)
+ {
+ super(message);
+ }
+
+ /**
+ * Construct an exception instance.
+ *
+ * @param message
+ * Exception message.
+ * @param cause
+ * Exception cause.
+ */
+ public LifecycleException(String message, Throwable cause)
+ {
+ super(message, cause);
+ }
+
+ /**
+ * Construct an exception instance.
+ *
+ * @param cause
+ * Exception cause.
+ */
+ public LifecycleException(Throwable cause)
+ {
+ super(cause);
+ }
+}
Modified: labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/soa/esb/message/Body.java
===================================================================
--- labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/soa/esb/message/Body.java 2007-05-28 10:14:52 UTC (rev 12169)
+++ labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/soa/esb/message/Body.java 2007-05-28 10:47:59 UTC (rev 12170)
@@ -1,14 +1,9 @@
package org.jboss.soa.esb.message;
-import java.net.URI;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
-import org.jboss.soa.esb.addressing.Call;
-import org.jboss.soa.esb.addressing.EPR;
-import org.jboss.soa.esb.addressing.XMLUtil;
-
/*
* JBoss, Home of Professional Open Source
* Copyright 2006, JBoss Inc., and others contributors as indicated
Added: labs/jbossesb/workspace/rearch2/core/src/test/java/org/jboss/soa/esb/domain/DomainUnitTest.java
===================================================================
--- labs/jbossesb/workspace/rearch2/core/src/test/java/org/jboss/soa/esb/domain/DomainUnitTest.java (rev 0)
+++ labs/jbossesb/workspace/rearch2/core/src/test/java/org/jboss/soa/esb/domain/DomainUnitTest.java 2007-05-28 10:47:59 UTC (rev 12170)
@@ -0,0 +1,97 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY 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 along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.soa.esb.domain;
+
+import java.net.URI;
+
+import junit.framework.TestCase;
+
+/**
+ * Unit tests for the Dispatchers.
+ *
+ * @author Mark Little
+ */
+
+public class DomainUnitTest extends TestCase
+{
+ public void testNullDomainName ()
+ {
+ try
+ {
+ DomainManager.getInstance().createDomain(null);
+
+ fail();
+ }
+ catch (Exception ex)
+ {
+ }
+ }
+
+ public void testCreateDomain () throws Exception
+ {
+ URI domainName = new URI("urn:domain1");
+ Domain domain1 = DomainManager.getInstance().createDomain(domainName);
+ Domain domain2 = DomainManager.getInstance().getDomain(domainName);
+
+ assertEquals(domain1.getName(), domain2.getName());
+
+ try
+ {
+ DomainManager.getInstance().createDomain(domainName);
+
+ fail();
+ }
+ catch (Exception ex)
+ {
+ }
+ }
+
+ public void testResetAndRemoveDomain () throws Exception
+ {
+ URI domainName = new URI("urn:domain2");
+
+ DomainManager.getInstance().createDomain(domainName);
+
+ DomainManager.getInstance().reset();
+
+ assertNull(DomainManager.getInstance().getDomain(domainName));
+
+ DomainManager.getInstance().createDomain(domainName);
+
+ assertNotNull(DomainManager.getInstance().getDomain(domainName));
+
+ DomainManager.getInstance().removeDomain(domainName);
+
+ assertNull(DomainManager.getInstance().getDomain(domainName));
+
+ try
+ {
+ DomainManager.getInstance().removeDomain(domainName);
+
+ fail();
+ }
+ catch (Exception ex)
+ {
+ }
+ }
+}
Modified: labs/jbossesb/workspace/rearch2/core/src/test/java/org/jboss/soa/esb/infrastructure/DummyDispatcher.java
===================================================================
--- labs/jbossesb/workspace/rearch2/core/src/test/java/org/jboss/soa/esb/infrastructure/DummyDispatcher.java 2007-05-28 10:14:52 UTC (rev 12169)
+++ labs/jbossesb/workspace/rearch2/core/src/test/java/org/jboss/soa/esb/infrastructure/DummyDispatcher.java 2007-05-28 10:47:59 UTC (rev 12170)
@@ -52,7 +52,11 @@
public Message dispatch (Message msg)
{
- System.err.println("DUMMY DISPATCHER");
+ if (msg != null)
+ {
+ if (msg.getBody().get("foo").equals("qwerty"))
+ msg.getBody().add("foo", "foobar");
+ }
return msg;
}
Modified: labs/jbossesb/workspace/rearch2/core/src/test/java/org/jboss/soa/esb/infrastructure/NullReceiverDispatcher.java
===================================================================
--- labs/jbossesb/workspace/rearch2/core/src/test/java/org/jboss/soa/esb/infrastructure/NullReceiverDispatcher.java 2007-05-28 10:14:52 UTC (rev 12169)
+++ labs/jbossesb/workspace/rearch2/core/src/test/java/org/jboss/soa/esb/infrastructure/NullReceiverDispatcher.java 2007-05-28 10:47:59 UTC (rev 12170)
@@ -71,12 +71,18 @@
public Message dispatch (Message msg)
{
- System.err.println("NULL RECEIVER");
+ if (msg != null)
+ {
+ if (msg.getBody().get("foo").equals("bar"))
+ {
+ msg.getBody().add("foo", "abc");
+
+ if (_link != null)
+ return _link.dispatch(msg);
+ }
+ }
- if (_link != null)
- return _link.dispatch(msg);
- else
- return null;
+ return null;
}
private Dispatcher _link;
Modified: labs/jbossesb/workspace/rearch2/core/src/test/java/org/jboss/soa/esb/infrastructure/NullSenderDispatcher.java
===================================================================
--- labs/jbossesb/workspace/rearch2/core/src/test/java/org/jboss/soa/esb/infrastructure/NullSenderDispatcher.java 2007-05-28 10:14:52 UTC (rev 12169)
+++ labs/jbossesb/workspace/rearch2/core/src/test/java/org/jboss/soa/esb/infrastructure/NullSenderDispatcher.java 2007-05-28 10:47:59 UTC (rev 12170)
@@ -71,12 +71,18 @@
public Message dispatch (Message msg)
{
- System.err.println("NULL SENDER");
+ if (msg != null)
+ {
+ if (msg.getBody().get("foo").equals("abc"))
+ {
+ msg.getBody().add("foo", "qwerty");
+
+ if (_link != null)
+ return _link.dispatch(msg);
+ }
+ }
- if (_link != null)
- return _link.dispatch(msg);
- else
- return null;
+ return null;
}
private Dispatcher _link;
Modified: labs/jbossesb/workspace/rearch2/core/src/test/java/org/jboss/soa/esb/infrastructure/tests/DispatcherUnitTest.java
===================================================================
--- labs/jbossesb/workspace/rearch2/core/src/test/java/org/jboss/soa/esb/infrastructure/tests/DispatcherUnitTest.java 2007-05-28 10:14:52 UTC (rev 12169)
+++ labs/jbossesb/workspace/rearch2/core/src/test/java/org/jboss/soa/esb/infrastructure/tests/DispatcherUnitTest.java 2007-05-28 10:47:59 UTC (rev 12170)
@@ -32,6 +32,8 @@
import org.jboss.soa.esb.infrastructure.DummyDispatcherPlugin;
import org.jboss.soa.esb.infrastructure.NullReceiverDispatcherPlugin;
import org.jboss.soa.esb.infrastructure.NullSenderDispatcherPlugin;
+import org.jboss.soa.esb.message.Message;
+import org.jboss.soa.esb.message.format.MessageFactory;
/**
* Unit tests for the Dispatchers.
@@ -110,7 +112,17 @@
Dispatcher root = DispatcherFactory.getFactory().getDispatcherHierarchy(theContract.getRootContract());
- root.dispatch(null);
+ Message msg = MessageFactory.getInstance().getMessage();
+
+ msg.getBody().add("foo", "bar");
+
+ // next tie dispatchers into sender
+
+ Message result = root.dispatch(msg);
+
+ assertNotNull(result);
+
+ assertEquals(result.getBody().get("foo"), "foobar");
}
catch (Exception ex)
{
More information about the jboss-svn-commits
mailing list