You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm@geronimo.apache.org by ch...@apache.org on 2003/08/29 21:16:54 UTC
cvs commit: incubator-geronimo/modules/core/src/java/org/apache/geronimo/remoting/router AbstractInterceptorRouter.java AbstractInterceptorRouterMBean.java AbstractRouterRouter.java AbstractRouterRouterMBean.java InterceptorRegistryRouter.java InterceptorRegistryRouterMBean.java JMXRouter.java JMXRouterMBean.java JMXTargetMBean.java Router.java RouterTargetMBean.java SimpleInterceptorRegistryRouter.java SubsystemRouter.java SubsystemRouterMBean.java
chirino 2003/08/29 12:16:54
Modified: modules/core/src/java/org/apache/geronimo/remoting
MarshalledMethod.java
modules/core/src/java/org/apache/geronimo/remoting/transport
TransportClient.java TransportLoader.java
TransportLoaderMBean.java TransportServer.java
modules/core/src/java/org/apache/geronimo/remoting/transport/async
AbstractServer.java BackChannelServer.java
ChannelPool.java
modules/core/src/java/org/apache/geronimo/remoting/transport/async/bio
BlockingServer.java
modules/core/src/java/org/apache/geronimo/remoting/transport/async/nio
NonBlockingServer.java
modules/core/src/test/org/apache/geronimo/remoting
RemotingInterceptorsTest.java
modules/core/src/test/org/apache/geronimo/remoting/transport
AsyncTransportStress.java AsyncTransportTest.java
Added: modules/core/src/test/org/apache/geronimo/remoting
JMXRemotingTestMain.java
modules/core/src/java/org/apache/geronimo/jmx
MBeanServerStub.java MBeanServerStubMBean.java
RemoteMBeanServerFactory.java
modules/core/src/java/org/apache/geronimo/remoting/router
AbstractInterceptorRouter.java
AbstractInterceptorRouterMBean.java
AbstractRouterRouter.java
AbstractRouterRouterMBean.java
InterceptorRegistryRouter.java
InterceptorRegistryRouterMBean.java JMXRouter.java
JMXRouterMBean.java JMXTargetMBean.java Router.java
RouterTargetMBean.java
SimpleInterceptorRegistryRouter.java
SubsystemRouter.java SubsystemRouterMBean.java
Removed: modules/core/src/java/org/apache/geronimo/remoting/transport
FragmentBasedInterceptorRouter.java Router.java
Log:
Added a few more routers and made MBeans for a few server side components. Created an RemoteMBServerFactory that can create proxies to a remote MBean which go over the remoting later.
Revision Changes Path
1.2 +57 -32 incubator-geronimo/modules/core/src/java/org/apache/geronimo/remoting/MarshalledMethod.java
Index: MarshalledMethod.java
===================================================================
RCS file: /home/cvs/incubator-geronimo/modules/core/src/java/org/apache/geronimo/remoting/MarshalledMethod.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- MarshalledMethod.java 22 Aug 2003 02:23:26 -0000 1.1
+++ MarshalledMethod.java 29 Aug 2003 19:16:53 -0000 1.2
@@ -58,17 +58,19 @@
import java.io.Serializable;
import java.lang.reflect.Method;
import java.util.Collections;
+import java.util.HashMap;
import java.util.Map;
import java.util.WeakHashMap;
+import org.apache.geronimo.common.Classes;
+
/**
* @version $Revision$ $Date$
*/
public class MarshalledMethod implements Serializable {
String declaringClass;
- short methodIndex;
- short methodHash;
+ String signature;
/**
*
@@ -80,30 +82,24 @@
* @param method
*/
public MarshalledMethod(Method method) {
- Class owner = method.getDeclaringClass();
- declaringClass = owner.getName();
- methodHash = hashCode(method);
- Method[] methods = owner.getMethods();
- methodIndex = -1;
- for (short i = 0; i < methods.length; i++) {
- if (methods[i].equals(method)) {
- methodIndex = i;
- break;
- }
- }
- // I don't thing this will EVER happen.
- if (methodIndex == -1)
- throw new RuntimeException("Could not find method in declaring class!");
+ declaringClass = method.getDeclaringClass().getName();
+ signature = getSignature( method );
}
/**
- * TODO: figure out a better hashcode algorithim for the method.
- *
* @param method
* @return
*/
- private static short hashCode(Method method) {
- return (short) method.getName().hashCode();
+ static private String getSignature(Method method) {
+ StringBuffer sb = new StringBuffer();
+ sb.append(method.getName());
+ sb.append(' ');
+ Class[] args = method.getParameterTypes();
+ for (int i = 0; i < args.length; i++) {
+ sb.append(' ');
+ sb.append( Classes.getClassName(args[i]) );
+ }
+ return sb.toString();
}
/**
@@ -111,22 +107,51 @@
*/
public Method getMethod() throws ClassNotFoundException {
Class c = Thread.currentThread().getContextClassLoader().loadClass(declaringClass);
- Method rc = c.getMethods()[methodIndex];
- short lhc = hashCode(rc);
- if (lhc != methodHash)
- throw new ClassNotFoundException("The '" + declaringClass + "' class is incompatible. ");
+ Map sigs = getCachedSignatureMap(c);
+ return (Method) sigs.get(signature);
+ }
+
+ /**
+ * TODO: try to cache the results.
+ * @param clazz
+ * @return
+ */
+ static private Map getSignatureMapFor(Class clazz) {
+ Map rc = new HashMap();
+ Method[] methods = clazz.getDeclaredMethods();
+ for (int i = 0; i < methods.length; i++) {
+ Method method = methods[i];
+ rc.put(getSignature(method), method);
+ }
return rc;
}
- private static Map methodCache = Collections.synchronizedMap(new WeakHashMap());
- public static MarshalledMethod getMarshalledMethod(Method method) {
- Integer cacheKey = new Integer(method.hashCode());
- MarshalledMethod rc = (MarshalledMethod) methodCache.get(cacheKey);
+ private static Map SignatureMapCache= Collections.synchronizedMap(new WeakHashMap());
+ static class CacheValue {
+ Class clazz;
+ Map sigs;
+ }
+
+
+ public static Map getCachedSignatureMap(Class clazz) {
+ String cacheKey = clazz.getName();
+ CacheValue rc = (CacheValue) SignatureMapCache.get(cacheKey);
if (rc == null) {
- rc = new MarshalledMethod(method);
- methodCache.put(cacheKey, rc);
+ rc = new CacheValue();
+ rc.clazz = clazz;
+ rc.sigs = getSignatureMapFor(clazz);
+ SignatureMapCache.put(cacheKey, rc);
+ return rc.sigs;
+ } else if ( rc.clazz.equals( clazz ) ) {
+ return rc.sigs;
+ } else {
+ // the previously cache class name might not be the same class
+ // due to classloader issues.
+ return getSignatureMapFor(clazz);
}
- return rc;
+
}
+
+
}
1.2 +2 -1 incubator-geronimo/modules/core/src/java/org/apache/geronimo/remoting/transport/TransportClient.java
Index: TransportClient.java
===================================================================
RCS file: /home/cvs/incubator-geronimo/modules/core/src/java/org/apache/geronimo/remoting/transport/TransportClient.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- TransportClient.java 22 Aug 2003 02:23:26 -0000 1.1
+++ TransportClient.java 29 Aug 2003 19:16:53 -0000 1.2
@@ -56,6 +56,7 @@
package org.apache.geronimo.remoting.transport;
import org.apache.geronimo.remoting.MarshalledObject;
+import org.apache.geronimo.remoting.router.*;
/**
* @version $Revision$ $Date$
1.3 +37 -11 incubator-geronimo/modules/core/src/java/org/apache/geronimo/remoting/transport/TransportLoader.java
Index: TransportLoader.java
===================================================================
RCS file: /home/cvs/incubator-geronimo/modules/core/src/java/org/apache/geronimo/remoting/transport/TransportLoader.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- TransportLoader.java 28 Aug 2003 05:12:10 -0000 1.2
+++ TransportLoader.java 29 Aug 2003 19:16:53 -0000 1.3
@@ -57,7 +57,12 @@
import java.net.URI;
+import javax.management.MalformedObjectNameException;
+import javax.management.ObjectName;
+
+import org.apache.geronimo.jmx.MBeanProxyFactory;
import org.apache.geronimo.management.AbstractManagedObject;
+import org.apache.geronimo.remoting.router.*;
/**
* @version $Revision$ $Date$
@@ -65,26 +70,41 @@
public class TransportLoader extends AbstractManagedObject implements TransportLoaderMBean {
URI bindURI;
- TransportServer server;
- Router dispatchingRouter = new FragmentBasedInterceptorRouter();
+ TransportServer transportServer;
+ Router dispatchingRouter;
+ private ObjectName routerTarget;
/**
* @see org.apache.geronimo.common.AbstractComponent#doStart()
*/
protected void doStart() throws Exception {
+
+ if (dispatchingRouter == null) {
+ if (routerTarget == null)
+ throw new IllegalStateException("Target router was not set.");
+ RouterTargetMBean target =
+ (RouterTargetMBean) MBeanProxyFactory.getProxy(RouterTargetMBean.class, server, routerTarget);
+ dispatchingRouter = target.getRouter();
+ }
+
TransportFactory tf = TransportFactory.getTransportFactory(bindURI);
- server = tf.createSever();
- server.bind(bindURI, dispatchingRouter);
- server.start();
+ transportServer = tf.createSever();
+ transportServer.bind(bindURI, dispatchingRouter);
+ transportServer.start();
}
/**
* @see org.apache.geronimo.common.AbstractComponent#doStop()
*/
protected void doStop() throws Exception {
- server.stop();
- server.dispose();
- server = null;
+ if (transportServer == null) {
+ log.error("Cannot STOP. This component was never started.");
+ return;
+ }
+ transportServer.stop();
+ transportServer.dispose();
+ transportServer = null;
+
}
/**
* @return
@@ -115,10 +135,16 @@
}
/**
+ * @param dispatchingRouter
+ */
+ public void setRouterTarget(String ob) throws MalformedObjectNameException {
+ this.routerTarget = new ObjectName(ob);
+ }
+
+ /**
* @return
*/
public URI getClientConnectURI() {
- return server.getClientConnectURI();
+ return transportServer.getClientConnectURI();
}
-
}
1.3 +7 -1 incubator-geronimo/modules/core/src/java/org/apache/geronimo/remoting/transport/TransportLoaderMBean.java
Index: TransportLoaderMBean.java
===================================================================
RCS file: /home/cvs/incubator-geronimo/modules/core/src/java/org/apache/geronimo/remoting/transport/TransportLoaderMBean.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- TransportLoaderMBean.java 28 Aug 2003 05:12:10 -0000 1.2
+++ TransportLoaderMBean.java 29 Aug 2003 19:16:53 -0000 1.3
@@ -57,8 +57,11 @@
import java.net.URI;
+import javax.management.MalformedObjectNameException;
+
import org.apache.geronimo.management.ManagedObject;
import org.apache.geronimo.management.StateManageable;
+import org.apache.geronimo.remoting.router.Router;
/**
* @version $Revision$ $Date$
@@ -84,4 +87,7 @@
* @return
*/
public abstract URI getClientConnectURI();
+
+ public void setRouterTarget(String ob) throws MalformedObjectNameException;
+
}
1.2 +2 -1 incubator-geronimo/modules/core/src/java/org/apache/geronimo/remoting/transport/TransportServer.java
Index: TransportServer.java
===================================================================
RCS file: /home/cvs/incubator-geronimo/modules/core/src/java/org/apache/geronimo/remoting/transport/TransportServer.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- TransportServer.java 22 Aug 2003 02:23:26 -0000 1.1
+++ TransportServer.java 29 Aug 2003 19:16:53 -0000 1.2
@@ -58,6 +58,7 @@
import java.net.URI;
import org.apache.geronimo.common.Component;
+import org.apache.geronimo.remoting.router.*;
/**
* @version $Revision$ $Date$
1.2 +2 -2 incubator-geronimo/modules/core/src/java/org/apache/geronimo/remoting/transport/async/AbstractServer.java
Index: AbstractServer.java
===================================================================
RCS file: /home/cvs/incubator-geronimo/modules/core/src/java/org/apache/geronimo/remoting/transport/async/AbstractServer.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- AbstractServer.java 22 Aug 2003 02:23:26 -0000 1.1
+++ AbstractServer.java 29 Aug 2003 19:16:53 -0000 1.2
@@ -60,7 +60,7 @@
import java.util.Iterator;
import org.apache.geronimo.proxy.SimpleContainer;
-import org.apache.geronimo.remoting.transport.Router;
+import org.apache.geronimo.remoting.router.Router;
import org.apache.geronimo.remoting.transport.TransportServer;
import EDU.oswego.cs.dl.util.concurrent.ClockDaemon;
1.2 +2 -2 incubator-geronimo/modules/core/src/java/org/apache/geronimo/remoting/transport/async/BackChannelServer.java
Index: BackChannelServer.java
===================================================================
RCS file: /home/cvs/incubator-geronimo/modules/core/src/java/org/apache/geronimo/remoting/transport/async/BackChannelServer.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- BackChannelServer.java 22 Aug 2003 02:23:26 -0000 1.1
+++ BackChannelServer.java 29 Aug 2003 19:16:53 -0000 1.2
@@ -57,7 +57,7 @@
import java.net.URI;
-import org.apache.geronimo.remoting.transport.Router;
+import org.apache.geronimo.remoting.router.Router;
/**
* @version $Revision$ $Date$
1.2 +2 -2 incubator-geronimo/modules/core/src/java/org/apache/geronimo/remoting/transport/async/ChannelPool.java
Index: ChannelPool.java
===================================================================
RCS file: /home/cvs/incubator-geronimo/modules/core/src/java/org/apache/geronimo/remoting/transport/async/ChannelPool.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- ChannelPool.java 22 Aug 2003 02:23:26 -0000 1.1
+++ ChannelPool.java 29 Aug 2003 19:16:53 -0000 1.2
@@ -64,8 +64,8 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.apache.geronimo.remoting.router.Router;
import org.apache.geronimo.remoting.transport.Msg;
-import org.apache.geronimo.remoting.transport.Router;
import org.apache.geronimo.remoting.transport.TransportException;
import org.apache.geronimo.remoting.transport.async.Correlator.FutureResult;
1.2 +2 -2 incubator-geronimo/modules/core/src/java/org/apache/geronimo/remoting/transport/async/bio/BlockingServer.java
Index: BlockingServer.java
===================================================================
RCS file: /home/cvs/incubator-geronimo/modules/core/src/java/org/apache/geronimo/remoting/transport/async/bio/BlockingServer.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- BlockingServer.java 22 Aug 2003 02:23:26 -0000 1.1
+++ BlockingServer.java 29 Aug 2003 19:16:54 -0000 1.2
@@ -67,7 +67,7 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.apache.geronimo.remoting.transport.Router;
+import org.apache.geronimo.remoting.router.Router;
import org.apache.geronimo.remoting.transport.TransportException;
import org.apache.geronimo.remoting.transport.URISupport;
import org.apache.geronimo.remoting.transport.async.AbstractServer;
1.2 +2 -2 incubator-geronimo/modules/core/src/java/org/apache/geronimo/remoting/transport/async/nio/NonBlockingServer.java
Index: NonBlockingServer.java
===================================================================
RCS file: /home/cvs/incubator-geronimo/modules/core/src/java/org/apache/geronimo/remoting/transport/async/nio/NonBlockingServer.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- NonBlockingServer.java 22 Aug 2003 02:23:27 -0000 1.1
+++ NonBlockingServer.java 29 Aug 2003 19:16:54 -0000 1.2
@@ -67,7 +67,7 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.apache.geronimo.remoting.transport.Router;
+import org.apache.geronimo.remoting.router.Router;
import org.apache.geronimo.remoting.transport.TransportException;
import org.apache.geronimo.remoting.transport.URISupport;
import org.apache.geronimo.remoting.transport.async.AbstractServer;
1.5 +3 -3 incubator-geronimo/modules/core/src/test/org/apache/geronimo/remoting/RemotingInterceptorsTest.java
Index: RemotingInterceptorsTest.java
===================================================================
RCS file: /home/cvs/incubator-geronimo/modules/core/src/test/org/apache/geronimo/remoting/RemotingInterceptorsTest.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- RemotingInterceptorsTest.java 28 Aug 2003 05:12:10 -0000 1.4
+++ RemotingInterceptorsTest.java 29 Aug 2003 19:16:54 -0000 1.5
@@ -67,8 +67,8 @@
import org.apache.geronimo.proxy.ProxyContainer;
import org.apache.geronimo.proxy.ReflexiveInterceptor;
+import org.apache.geronimo.remoting.router.SimpleInterceptorRegistryRouter;
import org.apache.geronimo.remoting.transport.BytesMarshalledObject;
-import org.apache.geronimo.remoting.transport.FragmentBasedInterceptorRouter;
import org.apache.geronimo.remoting.transport.RemoteTransportInterceptor;
import org.apache.geronimo.remoting.transport.TransportFactory;
import org.apache.geronimo.remoting.transport.TransportServer;
@@ -106,7 +106,7 @@
URI bindURI = new URI("async://0.0.0.0:0");
TransportFactory tf = TransportFactory.getTransportFactory(bindURI);
server = tf.createSever();
- server.bind(bindURI,new FragmentBasedInterceptorRouter());
+ server.bind(bindURI,new SimpleInterceptorRegistryRouter());
connectURI = server.getClientConnectURI();
server.start();
1.1 incubator-geronimo/modules/core/src/test/org/apache/geronimo/remoting/JMXRemotingTestMain.java
Index: JMXRemotingTestMain.java
===================================================================
/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2003 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" and
* "Apache Geronimo" must not be used to endorse or promote products
* derived from this software without prior written permission. For
* written permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* "Apache Geronimo", nor may "Apache" appear in their name, without
* prior written permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
* ====================================================================
*/
package org.apache.geronimo.remoting;
import javax.management.MBeanServer;
import org.apache.geronimo.jmx.RemoteMBeanServerFactory;
/**
* this test needs for a geronimo instance to be running and
* so I guess this is really a IntegrationTest and not a Unit test.
* This should move into the Integration test suite once it exists.
*/
public class JMXRemotingTestMain {
public void testCheckClassLoaders() throws Exception {
MBeanServer server = RemoteMBeanServerFactory.create("localhost");
String[] strings = server.getDomains();
for(int i=0; i < strings.length; i++){
System.out.println("domain: "+strings[i]);
}
}
public static void main(String[] args) throws Exception {
new JMXRemotingTestMain().testCheckClassLoaders();
}
}
1.2 +2 -1 incubator-geronimo/modules/core/src/test/org/apache/geronimo/remoting/transport/AsyncTransportStress.java
Index: AsyncTransportStress.java
===================================================================
RCS file: /home/cvs/incubator-geronimo/modules/core/src/test/org/apache/geronimo/remoting/transport/AsyncTransportStress.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- AsyncTransportStress.java 22 Aug 2003 02:23:36 -0000 1.1
+++ AsyncTransportStress.java 29 Aug 2003 19:16:54 -0000 1.2
@@ -61,6 +61,7 @@
import junit.framework.TestCase;
import org.apache.geronimo.remoting.MarshalledObject;
+import org.apache.geronimo.remoting.router.Router;
import EDU.oswego.cs.dl.util.concurrent.CyclicBarrier;
import EDU.oswego.cs.dl.util.concurrent.Semaphore;
1.2 +2 -1 incubator-geronimo/modules/core/src/test/org/apache/geronimo/remoting/transport/AsyncTransportTest.java
Index: AsyncTransportTest.java
===================================================================
RCS file: /home/cvs/incubator-geronimo/modules/core/src/test/org/apache/geronimo/remoting/transport/AsyncTransportTest.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- AsyncTransportTest.java 22 Aug 2003 02:23:36 -0000 1.1
+++ AsyncTransportTest.java 29 Aug 2003 19:16:54 -0000 1.2
@@ -61,6 +61,7 @@
import junit.framework.TestCase;
import org.apache.geronimo.remoting.MarshalledObject;
+import org.apache.geronimo.remoting.router.Router;
import EDU.oswego.cs.dl.util.concurrent.Semaphore;
1.1 incubator-geronimo/modules/core/src/java/org/apache/geronimo/jmx/MBeanServerStub.java
Index: MBeanServerStub.java
===================================================================
/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2003 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" and
* "Apache Geronimo" must not be used to endorse or promote products
* derived from this software without prior written permission. For
* written permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* "Apache Geronimo", nor may "Apache" appear in their name, without
* prior written permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
* ====================================================================
*/
package org.apache.geronimo.jmx;
import org.apache.geronimo.common.Interceptor;
import org.apache.geronimo.management.AbstractManagedObject;
import org.apache.geronimo.proxy.ProxyContainer;
import org.apache.geronimo.proxy.ReflexiveInterceptor;
import org.apache.geronimo.remoting.DeMarshalingInterceptor;
/**
* @version $Revision: 1.1 $ $Date: 2003/08/29 19:16:54 $
*/
public class MBeanServerStub extends AbstractManagedObject implements MBeanServerStubMBean {
private ProxyContainer serverContainer;
private DeMarshalingInterceptor demarshaller;
/**
* @see org.apache.geronimo.management.AbstractManagedObject#doStart()
*/
protected void doStart() throws Exception {
// Setup the server side contianer..
serverContainer = new ProxyContainer();
demarshaller = new DeMarshalingInterceptor();
serverContainer.addInterceptor(demarshaller);
serverContainer.addInterceptor(new ReflexiveInterceptor(server));
// Configure the server side interceptors.
demarshaller.setClassloader(getClass().getClassLoader());
}
/**
* @see org.apache.geronimo.management.AbstractManagedObject#doStop()
*/
protected void doStop() throws Exception {
serverContainer = null;
demarshaller=null;
}
/**
* @see org.apache.geronimo.remoting.router.JMXTargetMBean#getRemotingEndpointInterceptor()
*/
public Interceptor getRemotingEndpointInterceptor() {
return demarshaller;
}
}
1.1 incubator-geronimo/modules/core/src/java/org/apache/geronimo/jmx/MBeanServerStubMBean.java
Index: MBeanServerStubMBean.java
===================================================================
/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2003 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" and
* "Apache Geronimo" must not be used to endorse or promote products
* derived from this software without prior written permission. For
* written permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* "Apache Geronimo", nor may "Apache" appear in their name, without
* prior written permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
* ====================================================================
*/
package org.apache.geronimo.jmx;
import org.apache.geronimo.management.ManagedObject;
import org.apache.geronimo.management.StateManageable;
import org.apache.geronimo.remoting.router.JMXTargetMBean;
/**
* @version $Revision: 1.1 $ $Date: 2003/08/29 19:16:54 $
*/
public interface MBeanServerStubMBean extends ManagedObject, StateManageable, JMXTargetMBean {
}
1.1 incubator-geronimo/modules/core/src/java/org/apache/geronimo/jmx/RemoteMBeanServerFactory.java
Index: RemoteMBeanServerFactory.java
===================================================================
/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2003 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" and
* "Apache Geronimo" must not be used to endorse or promote products
* derived from this software without prior written permission. For
* written permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* "Apache Geronimo", nor may "Apache" appear in their name, without
* prior written permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
* ====================================================================
*/
package org.apache.geronimo.jmx;
import java.net.URI;
import java.net.URISyntaxException;
import javax.management.MBeanServer;
import org.apache.geronimo.proxy.ProxyContainer;
import org.apache.geronimo.remoting.MarshalingInterceptor;
import org.apache.geronimo.remoting.transport.RemoteTransportInterceptor;
/**
* @version $Revision: 1.1 $ $Date: 2003/08/29 19:16:54 $
*/
public class RemoteMBeanServerFactory {
static public MBeanServer create(String host) throws URISyntaxException {
URI target = new URI("async",null,host,3434,"/JMX",null,"geronimo.remoting:target=MBeanServerStub");
// Setup the client side container..
ProxyContainer clientContainer = new ProxyContainer();
clientContainer.addInterceptor(new MarshalingInterceptor());
RemoteTransportInterceptor transport = new RemoteTransportInterceptor();
transport.setRemoteURI(target);
clientContainer.addInterceptor(transport);
return (MBeanServer) clientContainer.createProxy(MBeanServer.class.getClassLoader(), new Class[]{MBeanServer.class});
}
}
1.1 incubator-geronimo/modules/core/src/java/org/apache/geronimo/remoting/router/AbstractInterceptorRouter.java
Index: AbstractInterceptorRouter.java
===================================================================
/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2003 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" and
* "Apache Geronimo" must not be used to endorse or promote products
* derived from this software without prior written permission. For
* written permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* "Apache Geronimo", nor may "Apache" appear in their name, without
* prior written permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
* ====================================================================
*/
package org.apache.geronimo.remoting.router;
import java.net.URI;
import org.apache.geronimo.common.Interceptor;
import org.apache.geronimo.common.InvocationResult;
import org.apache.geronimo.common.SimpleInvocation;
import org.apache.geronimo.management.AbstractManagedObject;
import org.apache.geronimo.remoting.InvocationSupport;
import org.apache.geronimo.remoting.MarshalledObject;
import org.apache.geronimo.remoting.transport.Msg;
import org.apache.geronimo.remoting.transport.TransportException;
import EDU.oswego.cs.dl.util.concurrent.Latch;
import EDU.oswego.cs.dl.util.concurrent.Sync;
import EDU.oswego.cs.dl.util.concurrent.TimeoutSync;
/**
* @version $Revision: 1.1 $ $Date: 2003/08/29 19:16:54 $
*/
abstract public class AbstractInterceptorRouter extends AbstractManagedObject implements Router, AbstractInterceptorRouterMBean {
private long stoppedRoutingTimeout = 1000*60; // 1 min.
/**
* Allows us to pause invocations when in the stopped state.
*/
private Sync routerLock = createNewRouterLock();
/**
* @return
*/
public long getStoppedRoutingTimeout() {
return stoppedRoutingTimeout;
}
/**
* @param stoppedRoutingTimeout
*/
public void setStoppedRoutingTimeout(long stoppedRoutingTimeout) {
this.stoppedRoutingTimeout = stoppedRoutingTimeout;
}
/**
* @return
*/
private Sync createNewRouterLock() {
Latch lock = new Latch();
return new TimeoutSync(lock, stoppedRoutingTimeout);
}
/**
*
*
* @see org.apache.geronimo.remoting.transport.Router#sendRequest(java.net.URI, org.apache.geronimo.remoting.transport.Msg)
*/
public Msg sendRequest(URI to, Msg msg) throws TransportException {
try {
routerLock.acquire();
Interceptor interceptor = lookupInterceptorFrom(to);
SimpleInvocation invocation = new SimpleInvocation();
InvocationSupport.putMarshaledValue(invocation, msg.popMarshaledObject());
InvocationSupport.putRemoteURI(invocation, to);
InvocationResult result = interceptor.invoke(invocation);
msg = msg.createMsg();
msg.pushMarshaledObject((MarshalledObject) result.getResult());
return msg;
} catch (Throwable e) {
e.printStackTrace();
throw new TransportException(e.getMessage());
}
}
/**
* @see org.apache.geronimo.remoting.transport.Router#sendDatagram(java.net.URI, org.apache.geronimo.remoting.transport.Msg)
*/
public void sendDatagram(URI to, Msg msg) throws TransportException {
try {
routerLock.acquire();
Interceptor interceptor = lookupInterceptorFrom(to);
SimpleInvocation invocation = new SimpleInvocation();
InvocationSupport.putMarshaledValue(invocation, msg.popMarshaledObject());
InvocationSupport.putRemoteURI(invocation, to);
InvocationResult result = interceptor.invoke(invocation);
} catch (Throwable e) {
throw new TransportException(e.getMessage());
}
}
/**
* @param to
* @return
*/
abstract protected Interceptor lookupInterceptorFrom(URI to) throws Throwable;
/**
* @see org.apache.geronimo.common.AbstractStateManageable#doStart()
*/
protected void doStart() throws Exception {
routerLock.release();
}
/**
* @see org.apache.geronimo.common.AbstractStateManageable#doStop()
*/
protected void doStop() throws Exception {
routerLock = createNewRouterLock();
}
}
1.1 incubator-geronimo/modules/core/src/java/org/apache/geronimo/remoting/router/AbstractInterceptorRouterMBean.java
Index: AbstractInterceptorRouterMBean.java
===================================================================
/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2003 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" and
* "Apache Geronimo" must not be used to endorse or promote products
* derived from this software without prior written permission. For
* written permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* "Apache Geronimo", nor may "Apache" appear in their name, without
* prior written permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
* ====================================================================
*/
package org.apache.geronimo.remoting.router;
import org.apache.geronimo.management.ManagedObject;
import org.apache.geronimo.management.StateManageable;
/**
* @version $Revision: 1.1 $ $Date: 2003/08/29 19:16:54 $
*/
public interface AbstractInterceptorRouterMBean extends ManagedObject, StateManageable {
public long getStoppedRoutingTimeout();
public void setStoppedRoutingTimeout(long stoppedRoutingTimeout);
}
1.1 incubator-geronimo/modules/core/src/java/org/apache/geronimo/remoting/router/AbstractRouterRouter.java
Index: AbstractRouterRouter.java
===================================================================
/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2003 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" and
* "Apache Geronimo" must not be used to endorse or promote products
* derived from this software without prior written permission. For
* written permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* "Apache Geronimo", nor may "Apache" appear in their name, without
* prior written permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
* ====================================================================
*/
package org.apache.geronimo.remoting.router;
import java.net.URI;
import org.apache.geronimo.management.AbstractManagedObject;
import org.apache.geronimo.remoting.transport.Msg;
import org.apache.geronimo.remoting.transport.TransportException;
import EDU.oswego.cs.dl.util.concurrent.Latch;
import EDU.oswego.cs.dl.util.concurrent.Sync;
import EDU.oswego.cs.dl.util.concurrent.TimeoutSync;
/**
* @version $Revision: 1.1 $ $Date: 2003/08/29 19:16:54 $
*/
abstract public class AbstractRouterRouter
extends AbstractManagedObject
implements Router, AbstractInterceptorRouterMBean {
private long stoppedRoutingTimeout = 1000 * 60; // 1 min.
/**
* Allows us to pause invocations when in the stopped state.
*/
private Sync routerLock = createNewRouterLock();
/**
* @return
*/
public long getStoppedRoutingTimeout() {
return stoppedRoutingTimeout;
}
/**
* @param stoppedRoutingTimeout
*/
public void setStoppedRoutingTimeout(long stoppedRoutingTimeout) {
this.stoppedRoutingTimeout = stoppedRoutingTimeout;
}
/**
* @return
*/
private Sync createNewRouterLock() {
Latch lock = new Latch();
return new TimeoutSync(lock, stoppedRoutingTimeout);
}
/**
*
*
* @see org.apache.geronimo.remoting.transport.Router#sendRequest(java.net.URI, org.apache.geronimo.remoting.transport.Msg)
*/
public Msg sendRequest(URI to, Msg msg) throws TransportException {
try {
routerLock.acquire();
routerLock.acquire();
Router next = lookupRouterFrom(to);
if( next == null )
throw new TransportException("No route is available to: "+to);
return next.sendRequest(to, msg);
} catch (Throwable e) {
e.printStackTrace();
throw new TransportException(e.getMessage());
}
}
/**
* @see org.apache.geronimo.remoting.transport.Router#sendDatagram(java.net.URI, org.apache.geronimo.remoting.transport.Msg)
*/
public void sendDatagram(URI to, Msg msg) throws TransportException {
try {
routerLock.acquire();
Router next = lookupRouterFrom(to);
next.sendDatagram(to, msg);
} catch (Throwable e) {
throw new TransportException(e.getMessage());
}
}
/**
* @param to
* @return
*/
abstract protected Router lookupRouterFrom(URI to);
/**
* @see org.apache.geronimo.common.AbstractStateManageable#doStart()
*/
protected void doStart() throws Exception {
routerLock.release();
}
/**
* @see org.apache.geronimo.common.AbstractStateManageable#doStop()
*/
protected void doStop() throws Exception {
routerLock = createNewRouterLock();
}
}
1.1 incubator-geronimo/modules/core/src/java/org/apache/geronimo/remoting/router/AbstractRouterRouterMBean.java
Index: AbstractRouterRouterMBean.java
===================================================================
/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2003 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" and
* "Apache Geronimo" must not be used to endorse or promote products
* derived from this software without prior written permission. For
* written permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* "Apache Geronimo", nor may "Apache" appear in their name, without
* prior written permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
* ====================================================================
*/
package org.apache.geronimo.remoting.router;
import org.apache.geronimo.management.ManagedObject;
import org.apache.geronimo.management.StateManageable;
/**
* @version $Revision: 1.1 $ $Date: 2003/08/29 19:16:54 $
*/
public interface AbstractRouterRouterMBean extends ManagedObject, StateManageable {
public long getStoppedRoutingTimeout();
public void setStoppedRoutingTimeout(long stoppedRoutingTimeout);
}
1.1 incubator-geronimo/modules/core/src/java/org/apache/geronimo/remoting/router/InterceptorRegistryRouter.java
Index: InterceptorRegistryRouter.java
===================================================================
/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2003 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" and
* "Apache Geronimo" must not be used to endorse or promote products
* derived from this software without prior written permission. For
* written permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* "Apache Geronimo", nor may "Apache" appear in their name, without
* prior written permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
* ====================================================================
*/
package org.apache.geronimo.remoting.router;
import java.net.URI;
import org.apache.geronimo.common.Interceptor;
import org.apache.geronimo.remoting.InterceptorRegistry;
/**
* @version $Revision: 1.1 $ $Date: 2003/08/29 19:16:54 $
*/
public class InterceptorRegistryRouter extends AbstractInterceptorRouter implements Router, InterceptorRegistryRouterMBean {
/**
* @see org.apache.geronimo.remoting.router.AbstractInterceptorRouter#lookupInterceptorFrom(java.net.URI)
*/
protected Interceptor lookupInterceptorFrom(URI to) throws Throwable {
Long x = new Long(to.getFragment());
return InterceptorRegistry.instance.lookup(x);
}
/**
* @see org.apache.geronimo.remoting.router.SubsystemTargetMBean#getRouter()
*/
public Router getRouter() {
return this;
}
}
1.1 incubator-geronimo/modules/core/src/java/org/apache/geronimo/remoting/router/InterceptorRegistryRouterMBean.java
Index: InterceptorRegistryRouterMBean.java
===================================================================
/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2003 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" and
* "Apache Geronimo" must not be used to endorse or promote products
* derived from this software without prior written permission. For
* written permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* "Apache Geronimo", nor may "Apache" appear in their name, without
* prior written permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
* ====================================================================
*/
package org.apache.geronimo.remoting.router;
/**
* @version $Revision: 1.1 $ $Date: 2003/08/29 19:16:54 $
*/
public interface InterceptorRegistryRouterMBean extends AbstractInterceptorRouterMBean, RouterTargetMBean {
}
1.1 incubator-geronimo/modules/core/src/java/org/apache/geronimo/remoting/router/JMXRouter.java
Index: JMXRouter.java
===================================================================
/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2003 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" and
* "Apache Geronimo" must not be used to endorse or promote products
* derived from this software without prior written permission. For
* written permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* "Apache Geronimo", nor may "Apache" appear in their name, without
* prior written permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
* ====================================================================
*/
package org.apache.geronimo.remoting.router;
import java.net.URI;
import javax.management.MalformedObjectNameException;
import javax.management.ObjectName;
import org.apache.geronimo.common.Interceptor;
import org.apache.geronimo.jmx.MBeanProxyFactory;
/**
* Uses JMX Object names to route the request to a JMX object that implements the
* JMXTargetMBean interface.
*
* @version $Revision: 1.1 $ $Date: 2003/08/29 19:16:54 $
*/
public class JMXRouter extends AbstractInterceptorRouter implements JMXRouterMBean {
/**
* @see org.apache.geronimo.remoting.router.AbstractInterceptorRouter#lookupInterceptorFrom(java.net.URI)
*/
protected Interceptor lookupInterceptorFrom(URI to) throws MalformedObjectNameException {
ObjectName on = new ObjectName(to.getFragment());
JMXTargetMBean bean = (JMXTargetMBean)MBeanProxyFactory.getProxy(JMXTargetMBean.class, server, on);
return bean.getRemotingEndpointInterceptor();
}
/**
* @see org.apache.geronimo.remoting.router.SubsystemRouterMBean#getRouter()
*/
public Router getRouter() {
return this;
}
}
1.1 incubator-geronimo/modules/core/src/java/org/apache/geronimo/remoting/router/JMXRouterMBean.java
Index: JMXRouterMBean.java
===================================================================
/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2003 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" and
* "Apache Geronimo" must not be used to endorse or promote products
* derived from this software without prior written permission. For
* written permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* "Apache Geronimo", nor may "Apache" appear in their name, without
* prior written permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
* ====================================================================
*/
package org.apache.geronimo.remoting.router;
/**
* @version $Revision: 1.1 $ $Date: 2003/08/29 19:16:54 $
*/
public interface JMXRouterMBean extends AbstractInterceptorRouterMBean, RouterTargetMBean {
}
1.1 incubator-geronimo/modules/core/src/java/org/apache/geronimo/remoting/router/JMXTargetMBean.java
Index: JMXTargetMBean.java
===================================================================
/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2003 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" and
* "Apache Geronimo" must not be used to endorse or promote products
* derived from this software without prior written permission. For
* written permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* "Apache Geronimo", nor may "Apache" appear in their name, without
* prior written permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
* ====================================================================
*/
package org.apache.geronimo.remoting.router;
import org.apache.geronimo.common.Interceptor;
/**
* @version $Revision: 1.1 $ $Date: 2003/08/29 19:16:54 $
*/
public interface JMXTargetMBean {
Interceptor getRemotingEndpointInterceptor();
}
1.1 incubator-geronimo/modules/core/src/java/org/apache/geronimo/remoting/router/Router.java
Index: Router.java
===================================================================
/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2003 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" and
* "Apache Geronimo" must not be used to endorse or promote products
* derived from this software without prior written permission. For
* written permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* "Apache Geronimo", nor may "Apache" appear in their name, without
* prior written permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
* ====================================================================
*/
package org.apache.geronimo.remoting.router;
import java.net.URI;
import org.apache.geronimo.remoting.transport.Msg;
import org.apache.geronimo.remoting.transport.TransportException;
/**
* @version $Revision: 1.1 $ $Date: 2003/08/29 19:16:54 $
*/
public interface Router {
/**
* Sends a request message to the other end.
*
* @param request
* @return
*/
Msg sendRequest(URI to, Msg request) throws TransportException;
/**
* Sends a datagram message. No response is expected.
*
* @param request
* @return
*/
void sendDatagram(URI to, Msg request) throws TransportException;
}
1.1 incubator-geronimo/modules/core/src/java/org/apache/geronimo/remoting/router/RouterTargetMBean.java
Index: RouterTargetMBean.java
===================================================================
/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2003 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" and
* "Apache Geronimo" must not be used to endorse or promote products
* derived from this software without prior written permission. For
* written permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* "Apache Geronimo", nor may "Apache" appear in their name, without
* prior written permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
* ====================================================================
*/
package org.apache.geronimo.remoting.router;
/**
* @version $Revision: 1.1 $ $Date: 2003/08/29 19:16:54 $
*/
public interface RouterTargetMBean {
Router getRouter();
}
1.1 incubator-geronimo/modules/core/src/java/org/apache/geronimo/remoting/router/SimpleInterceptorRegistryRouter.java
Index: SimpleInterceptorRegistryRouter.java
===================================================================
/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2003 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" and
* "Apache Geronimo" must not be used to endorse or promote products
* derived from this software without prior written permission. For
* written permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* "Apache Geronimo", nor may "Apache" appear in their name, without
* prior written permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
* ====================================================================
*/
package org.apache.geronimo.remoting.router;
import java.net.URI;
import org.apache.geronimo.common.Interceptor;
import org.apache.geronimo.common.InvocationResult;
import org.apache.geronimo.common.SimpleInvocation;
import org.apache.geronimo.remoting.InterceptorRegistry;
import org.apache.geronimo.remoting.InvocationSupport;
import org.apache.geronimo.remoting.MarshalledObject;
import org.apache.geronimo.remoting.transport.Msg;
import org.apache.geronimo.remoting.transport.TransportException;
/**
* @version $Revision: 1.1 $ $Date: 2003/08/29 19:16:54 $
*/
public class SimpleInterceptorRegistryRouter implements Router {
/**
*
*
* @see org.apache.geronimo.remoting.transport.Router#sendRequest(java.net.URI, org.apache.geronimo.remoting.transport.Msg)
*/
public Msg sendRequest(URI to, Msg msg) throws TransportException {
try {
Interceptor interceptor = lookupInterceptorFrom(to);
SimpleInvocation invocation = new SimpleInvocation();
InvocationSupport.putMarshaledValue(invocation, msg.popMarshaledObject());
InvocationSupport.putRemoteURI(invocation, to);
InvocationResult result = interceptor.invoke(invocation);
msg = msg.createMsg();
msg.pushMarshaledObject((MarshalledObject) result.getResult());
return msg;
} catch (Throwable e) {
e.printStackTrace();
throw new TransportException(e.getMessage());
}
}
/**
* @see org.apache.geronimo.remoting.transport.Router#sendDatagram(java.net.URI, org.apache.geronimo.remoting.transport.Msg)
*/
public void sendDatagram(URI to, Msg msg) throws TransportException {
try {
Interceptor interceptor = lookupInterceptorFrom(to);
SimpleInvocation invocation = new SimpleInvocation();
InvocationSupport.putMarshaledValue(invocation, msg.popMarshaledObject());
InvocationSupport.putRemoteURI(invocation, to);
InvocationResult result = interceptor.invoke(invocation);
} catch (Throwable e) {
throw new TransportException(e.getMessage());
}
}
protected Interceptor lookupInterceptorFrom(URI to) throws Throwable {
Long x = new Long(to.getFragment());
return InterceptorRegistry.instance.lookup(x);
}
}
1.1 incubator-geronimo/modules/core/src/java/org/apache/geronimo/remoting/router/SubsystemRouter.java
Index: SubsystemRouter.java
===================================================================
/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2003 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" and
* "Apache Geronimo" must not be used to endorse or promote products
* derived from this software without prior written permission. For
* written permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* "Apache Geronimo", nor may "Apache" appear in their name, without
* prior written permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
* ====================================================================
*/
package org.apache.geronimo.remoting.router;
import java.net.URI;
import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import javax.management.Notification;
import javax.management.NotificationFilter;
import javax.management.ObjectName;
import javax.management.relation.RelationNotification;
import javax.management.relation.RelationServiceMBean;
import org.apache.geronimo.jmx.JMXUtil;
import org.apache.geronimo.jmx.MBeanProxyFactory;
/**
* @version $Revision: 1.1 $ $Date: 2003/08/29 19:16:54 $
*/
public class SubsystemRouter extends AbstractRouterRouter implements SubsystemRouterMBean {
String relationshipID = "Route";
Map currentRoutingMap = new HashMap();
/**
* @see org.apache.geronimo.remoting.router.AbstractRouterRouter#lookupRouterFrom(java.net.URI)
*/
protected Router lookupRouterFrom(URI to) {
String subsystem = to.getPath();
return (Router) currentRoutingMap.get(subsystem);
}
private Map calcRouteMap() {
HashMap rc = new HashMap();
RelationServiceMBean relationService = JMXUtil.getRelationService(server);
Map relatedMBeans = relationService.findAssociatedMBeans(objectName, relationshipID, null);
Iterator iter = relatedMBeans.keySet().iterator();
while (iter.hasNext()) {
ObjectName on = (ObjectName) iter.next();
Collection c = (Collection) relatedMBeans.get(on);
RouterTargetMBean rm = (RouterTargetMBean )MBeanProxyFactory.getProxy(RouterTargetMBean .class, server, on);
Router r = rm.getRouter();
Iterator i = c.iterator();
while(i.hasNext())
rc.put(i.next(), r);
}
return rc;
}
/**
* @see org.apache.geronimo.management.AbstractManagedObject#handleNotification(javax.management.Notification, java.lang.Object)
*/
public void handleNotification(Notification n, Object o) {
super.handleNotification(n, o);
if (n instanceof RelationNotification) {
RelationNotification rn = (RelationNotification) n;
if (!rn.getRelationTypeName().equals(relationshipID))
return;
try {
// Did our routes change??
Map map = calcRouteMap();
if( currentRoutingMap.equals(map) )
return;
log.info("Detected a change in the active subsystems. Restarting to reload subsystem routes.");
restart();
} catch (Exception e) {
e.printStackTrace();
}
}
}
public void restart() throws Exception {
doStop();
doStart();
}
/**
* @see org.apache.geronimo.remoting.router.AbstractRouterRouter#doStart()
*/
protected void doStart() throws Exception {
NotificationFilter filter = null;
server.addNotificationListener(JMXUtil.RELATION_SERVICE_NAME, objectName, filter, null);
currentRoutingMap = calcRouteMap();
super.doStart();
}
/**
* @see org.apache.geronimo.remoting.router.AbstractRouterRouter#doStop()
*/
protected void doStop() throws Exception {
super.doStop();
server.removeNotificationListener(JMXUtil.RELATION_SERVICE_NAME, objectName);
}
/**
* @see org.apache.geronimo.remoting.router.RouterTargetMBean#getRouter()
*/
public Router getRouter() {
return this;
}
}
1.1 incubator-geronimo/modules/core/src/java/org/apache/geronimo/remoting/router/SubsystemRouterMBean.java
Index: SubsystemRouterMBean.java
===================================================================
/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2003 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" and
* "Apache Geronimo" must not be used to endorse or promote products
* derived from this software without prior written permission. For
* written permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* "Apache Geronimo", nor may "Apache" appear in their name, without
* prior written permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
* ====================================================================
*/
package org.apache.geronimo.remoting.router;
/**
* @version $Revision: 1.1 $ $Date: 2003/08/29 19:16:54 $
*/
public interface SubsystemRouterMBean extends AbstractRouterRouterMBean, RouterTargetMBean {
public void restart() throws Exception;
}