JBoss Remoting SVN: r4393 - in remoting3/trunk: core/src/main/java/org/jboss/cx/remoting/core and 1 other directories.
by jboss-remoting-commits@lists.jboss.org
Author: david.lloyd(a)jboss.com
Date: 2008-07-18 18:58:52 -0400 (Fri, 18 Jul 2008)
New Revision: 4393
Removed:
remoting3/trunk/api/src/main/java/org/jboss/cx/remoting/service/
remoting3/trunk/core/src/main/java/org/jboss/cx/remoting/core/RemoteClassLoader.java
remoting3/trunk/core/src/main/java/org/jboss/cx/remoting/core/service/ClassLoaderResourceListener.java
remoting3/trunk/core/src/main/java/org/jboss/cx/remoting/core/service/ServiceLocatorListener.java
Log:
Remove old service location system
Deleted: remoting3/trunk/core/src/main/java/org/jboss/cx/remoting/core/RemoteClassLoader.java
===================================================================
--- remoting3/trunk/core/src/main/java/org/jboss/cx/remoting/core/RemoteClassLoader.java 2008-07-18 22:31:44 UTC (rev 4392)
+++ remoting3/trunk/core/src/main/java/org/jboss/cx/remoting/core/RemoteClassLoader.java 2008-07-18 22:58:52 UTC (rev 4393)
@@ -1,72 +0,0 @@
-package org.jboss.cx.remoting.core;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.security.SecureClassLoader;
-import org.jboss.cx.remoting.Client;
-import org.jboss.cx.remoting.RemoteExecutionException;
-import org.jboss.cx.remoting.RemotingException;
-import org.jboss.cx.remoting.service.ClassLoaderResourceReply;
-import org.jboss.cx.remoting.service.ClassLoaderResourceRequest;
-import org.jboss.cx.remoting.service.RemoteResource;
-import org.jboss.cx.remoting.stream.ObjectSource;
-import org.jboss.xnio.IoUtils;
-
-/**
- *
- */
-public final class RemoteClassLoader extends SecureClassLoader {
- private static final org.jboss.xnio.log.Logger log = org.jboss.xnio.log.Logger.getLogger(RemoteClassLoader.class);
-
- private final Client<ClassLoaderResourceRequest, ClassLoaderResourceReply> loaderClient;
-
- public RemoteClassLoader(ClassLoader parent, final Client<ClassLoaderResourceRequest, ClassLoaderResourceReply> loaderClient) {
- super(parent);
- this.loaderClient = loaderClient;
- }
-
- protected Class<?> findClass(String name) throws ClassNotFoundException {
- try {
- final Class<?> firstClass = super.findClass(name);
- if (firstClass != null) {
- return firstClass;
- }
- } catch (ClassNotFoundException e) {
- // continue on...
- }
- try {
- final ClassLoaderResourceReply reply = loaderClient.invoke(new ClassLoaderResourceRequest(name + ".class"));
- final ObjectSource<RemoteResource> source = reply.getResources();
- try {
- if (! source.hasNext()) {
- throw new ClassNotFoundException("No resources matched");
- }
- final RemoteResource resource = source.next();
- final InputStream stream = resource.getInputStream();
- try {
- final int size = resource.getSize();
- final byte[] bytes = new byte[size];
- for (int t = 0; t < size; t += stream.read(bytes, t, size - t));
- return defineClass(name, bytes, 0, size);
- } finally {
- IoUtils.safeClose(stream);
- }
- } finally {
- IoUtils.safeClose(source);
- }
- } catch (RemotingException e) {
- throw new ClassNotFoundException("Cannot load class " + name + " due to an invocation failure", e);
- } catch (RemoteExecutionException e) {
- final Throwable cause = e.getCause();
- if (cause instanceof ClassNotFoundException) {
- throw (ClassNotFoundException)cause;
- }
- throw new ClassNotFoundException("Cannot load class " + name + " due to a remote invocation failure", cause);
- } catch (IOException e) {
- throw new ClassNotFoundException("Cannot load class " + name + " due to an I/O error", e);
- }
- }
-
- // todo - support arbitrary resources
- // todo - cache fetched resources locally for forwarding
-}
Deleted: remoting3/trunk/core/src/main/java/org/jboss/cx/remoting/core/service/ClassLoaderResourceListener.java
===================================================================
--- remoting3/trunk/core/src/main/java/org/jboss/cx/remoting/core/service/ClassLoaderResourceListener.java 2008-07-18 22:31:44 UTC (rev 4392)
+++ remoting3/trunk/core/src/main/java/org/jboss/cx/remoting/core/service/ClassLoaderResourceListener.java 2008-07-18 22:58:52 UTC (rev 4393)
@@ -1,67 +0,0 @@
-package org.jboss.cx.remoting.core.service;
-
-import java.io.IOException;
-import java.net.URL;
-import java.net.URLConnection;
-import java.util.Enumeration;
-import org.jboss.cx.remoting.AbstractRequestListener;
-import org.jboss.cx.remoting.IOExceptionCarrier;
-import org.jboss.cx.remoting.RemoteExecutionException;
-import org.jboss.cx.remoting.RequestContext;
-import org.jboss.cx.remoting.service.ClassLoaderResourceReply;
-import org.jboss.cx.remoting.service.ClassLoaderResourceRequest;
-import org.jboss.cx.remoting.service.RemoteResource;
-import org.jboss.cx.remoting.stream.ObjectSource;
-import org.jboss.cx.remoting.stream.ObjectSourceWrapper;
-import org.jboss.cx.remoting.stream.Streams;
-import org.jboss.cx.remoting.util.CollectionUtil;
-import org.jboss.cx.remoting.util.Translator;
-
-/**
- *
- */
-public final class ClassLoaderResourceListener extends AbstractRequestListener<ClassLoaderResourceRequest,ClassLoaderResourceReply> {
- private ClassLoader classLoader;
-
- public ClassLoader getClassLoader() {
- return classLoader;
- }
-
- public void setClassLoader(final ClassLoader classLoader) {
- this.classLoader = classLoader;
- }
-
- public void handleRequest(final RequestContext<ClassLoaderResourceReply> requestContext, final ClassLoaderResourceRequest request) throws RemoteExecutionException {
- try {
- final Enumeration<URL> urlResources = classLoader.getResources(request.getName());
- final Enumeration<RemoteResource> actualResources = CollectionUtil.translate(urlResources, new Translator<URL, RemoteResource>() {
- public RemoteResource translate(final URL input) {
- try {
- final RemoteResource resource = new RemoteResource();
- final URLConnection urlConnection = input.openConnection();
- final int size = urlConnection.getContentLength();
- resource.setInputStream(urlConnection.getInputStream());
- resource.setSize(size);
- return resource;
- } catch (IOException ex) {
- throw new IOExceptionCarrier(ex);
- }
- }
- });
- final ObjectSource<RemoteResource> resourceSequence = new ObjectSourceWrapper<RemoteResource>(Streams.getEnumerationObjectSource(actualResources)) {
- public RemoteResource next() throws IOException {
- try {
- return super.next();
- } catch (IOExceptionCarrier ex) {
- throw ex.getCause();
- }
- }
- };
- ClassLoaderResourceReply reply = new ClassLoaderResourceReply();
- reply.setResources(resourceSequence);
- requestContext.sendReply(reply);
- } catch (IOException e) {
- throw new RemoteExecutionException("Unable to get resources: " + e.getMessage(), e);
- }
- }
-}
Deleted: remoting3/trunk/core/src/main/java/org/jboss/cx/remoting/core/service/ServiceLocatorListener.java
===================================================================
--- remoting3/trunk/core/src/main/java/org/jboss/cx/remoting/core/service/ServiceLocatorListener.java 2008-07-18 22:31:44 UTC (rev 4392)
+++ remoting3/trunk/core/src/main/java/org/jboss/cx/remoting/core/service/ServiceLocatorListener.java 2008-07-18 22:58:52 UTC (rev 4393)
@@ -1,55 +0,0 @@
-package org.jboss.cx.remoting.core.service;
-
-import java.net.URI;
-import java.util.SortedMap;
-import java.util.concurrent.ConcurrentMap;
-import org.jboss.cx.remoting.AbstractRequestListener;
-import org.jboss.cx.remoting.Client;
-import org.jboss.cx.remoting.ClientSource;
-import org.jboss.cx.remoting.RemoteExecutionException;
-import org.jboss.cx.remoting.RequestContext;
-import org.jboss.cx.remoting.service.ServiceReply;
-import org.jboss.cx.remoting.service.ServiceRequest;
-import org.jboss.cx.remoting.util.CollectionUtil;
-import org.jboss.cx.remoting.util.ServiceURI;
-
-/**
- *
- */
-public final class ServiceLocatorListener<I, O> extends AbstractRequestListener<ServiceRequest<I, O>,ServiceReply<I, O>> {
-
- private interface Service {
- String getGroupName();
-
- String getType();
-
- // todo - add in whatever negotation to the request object (security?)
- <X, Y> Client<Void, ServiceReply<X, Y>> getServiceChannel();
- }
-
- private interface Peer {
- String getName();
-
- int getCost();
-
- <X, Y> Client<ServiceRequest<X, Y>, ServiceReply<X, Y>> getLocatorClient();
-
- SortedMap<String, Service> getServicesByGroupName();
-
- SortedMap<String, Service> getServicesByType();
- }
-
- private static <K, V> ConcurrentMap<K, V> syncMap() {
- return CollectionUtil.synchronizedMap(CollectionUtil.<K, V>hashMap());
- }
-
- private final ConcurrentMap<String, ConcurrentMap<String, ClientSource<?, ?>>> deployments = syncMap();
-
- public void handleRequest(final RequestContext<ServiceReply<I, O>> requestContext, final ServiceRequest<I, O> request) throws RemoteExecutionException {
- final URI uri = request.getUri();
- final ServiceURI serviceURI = new ServiceURI(uri);
- final String endpointName = serviceURI.getEndpointName();
- final String groupName = serviceURI.getGroupName();
- final String serviceType = serviceURI.getServiceType();
- }
-}
16 years, 5 months
JBoss Remoting SVN: r4392 - remoting3/trunk/testing-support/src/main/java/org/jboss/cx/remoting/test/support.
by jboss-remoting-commits@lists.jboss.org
Author: david.lloyd(a)jboss.com
Date: 2008-07-18 18:31:44 -0400 (Fri, 18 Jul 2008)
New Revision: 4392
Modified:
remoting3/trunk/testing-support/src/main/java/org/jboss/cx/remoting/test/support/LoggingSecurityManager.java
Log:
Better way to deal with this warning
Modified: remoting3/trunk/testing-support/src/main/java/org/jboss/cx/remoting/test/support/LoggingSecurityManager.java
===================================================================
--- remoting3/trunk/testing-support/src/main/java/org/jboss/cx/remoting/test/support/LoggingSecurityManager.java 2008-07-18 20:10:30 UTC (rev 4391)
+++ remoting3/trunk/testing-support/src/main/java/org/jboss/cx/remoting/test/support/LoggingSecurityManager.java 2008-07-18 22:31:44 UTC (rev 4392)
@@ -169,7 +169,7 @@
}
}
- @SuppressWarnings({"deprecation"})
+ @Deprecated
public void checkMulticast(final InetAddress maddr, final byte ttl) {
try {
super.checkMulticast(maddr, ttl);
16 years, 5 months
JBoss Remoting SVN: r4391 - remoting3/trunk/api/src/main/java/org/jboss/cx/remoting/spi.
by jboss-remoting-commits@lists.jboss.org
Author: david.lloyd(a)jboss.com
Date: 2008-07-18 16:10:30 -0400 (Fri, 18 Jul 2008)
New Revision: 4391
Modified:
remoting3/trunk/api/src/main/java/org/jboss/cx/remoting/spi/AbstractAutoCloseable.java
Log:
Improve trace logging of closable resources
Modified: remoting3/trunk/api/src/main/java/org/jboss/cx/remoting/spi/AbstractAutoCloseable.java
===================================================================
--- remoting3/trunk/api/src/main/java/org/jboss/cx/remoting/spi/AbstractAutoCloseable.java 2008-07-18 07:12:16 UTC (rev 4390)
+++ remoting3/trunk/api/src/main/java/org/jboss/cx/remoting/spi/AbstractAutoCloseable.java 2008-07-18 20:10:30 UTC (rev 4391)
@@ -55,7 +55,6 @@
protected void dec() throws RemotingException {
final int v = refcount.decrementAndGet();
- log.trace("Clearing reference to %s to %d", this, Integer.valueOf(v));
if (v == 0) {
// we dropped the refcount to zero
log.trace("Refcount of %s dropped to zero, closing", this);
@@ -67,6 +66,8 @@
} else if (v < 0) {
// was already closed; put the count back
refcount.incrementAndGet();
+ } else {
+ log.trace("Clearing reference to %s to %d", this, Integer.valueOf(v));
}
// otherwise, the resource remains open
}
16 years, 5 months
JBoss Remoting SVN: r4390 - remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/socket/socketfactory.
by jboss-remoting-commits@lists.jboss.org
Author: ron.sigal(a)jboss.com
Date: 2008-07-18 03:12:16 -0400 (Fri, 18 Jul 2008)
New Revision: 4390
Added:
remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/socket/socketfactory/SocketFactoryClassNameTestCase.java
Log:
JBREM-1014: New unit test.
Added: remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/socket/socketfactory/SocketFactoryClassNameTestCase.java
===================================================================
--- remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/socket/socketfactory/SocketFactoryClassNameTestCase.java (rev 0)
+++ remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/socket/socketfactory/SocketFactoryClassNameTestCase.java 2008-07-18 07:12:16 UTC (rev 4390)
@@ -0,0 +1,190 @@
+package org.jboss.test.remoting.transport.socket.socketfactory;
+
+import java.io.IOException;
+import java.net.InetAddress;
+import java.net.Socket;
+import java.net.UnknownHostException;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.management.MBeanServer;
+import javax.net.SocketFactory;
+
+import junit.framework.TestCase;
+
+import org.apache.log4j.ConsoleAppender;
+import org.apache.log4j.Level;
+import org.apache.log4j.Logger;
+import org.apache.log4j.PatternLayout;
+import org.jboss.logging.XLevel;
+import org.jboss.remoting.AbstractInvoker;
+import org.jboss.remoting.Client;
+import org.jboss.remoting.InvocationRequest;
+import org.jboss.remoting.InvokerLocator;
+import org.jboss.remoting.Remoting;
+import org.jboss.remoting.ServerInvocationHandler;
+import org.jboss.remoting.ServerInvoker;
+import org.jboss.remoting.callback.InvokerCallbackHandler;
+import org.jboss.remoting.transport.Connector;
+import org.jboss.remoting.transport.PortUtil;
+
+
+/**
+ *
+ * Unit test for JBREM-1014.
+ *
+ * @author <a href="ron.sigal(a)jboss.com">Ron Sigal</a>
+ * @version $Revision: 1.1 $
+ * <p>
+ * Copyright Jul 18, 2008
+ * </p>
+ */
+public class SocketFactoryClassNameTestCase extends TestCase
+{
+ private static Logger log = Logger.getLogger(SocketFactoryClassNameTestCase.class);
+
+ private static boolean firstTime = true;
+
+ protected String host;
+ protected int port;
+ protected String locatorURI;
+ protected InvokerLocator serverLocator;
+ protected Connector connector;
+ protected TestInvocationHandler invocationHandler;
+
+
+ public void setUp() throws Exception
+ {
+ if (firstTime)
+ {
+ firstTime = false;
+ Logger.getLogger("org.jboss.remoting").setLevel(XLevel.INFO);
+ Logger.getLogger("org.jboss.test.remoting").setLevel(Level.INFO);
+ String pattern = "[%d{ABSOLUTE}] [%t] %5p (%F:%L) - %m%n";
+ PatternLayout layout = new PatternLayout(pattern);
+ ConsoleAppender consoleAppender = new ConsoleAppender(layout);
+ Logger.getRootLogger().addAppender(consoleAppender);
+ }
+ }
+
+
+ public void tearDown()
+ {
+ }
+
+
+ public void testSocketFactoryClassName() throws Throwable
+ {
+ log.info("entering " + getName());
+
+ // Start server.
+ setupServer();
+
+ // Create client.
+ InvokerLocator clientLocator = new InvokerLocator(locatorURI);
+ HashMap clientConfig = new HashMap();
+ clientConfig.put(InvokerLocator.FORCE_REMOTE, "true");
+ clientConfig.put(Remoting.SOCKET_FACTORY_CLASS_NAME, TestSocketFactory.class.getName());
+ addExtraClientConfig(clientConfig);
+ Client client = new Client(clientLocator, clientConfig);
+ client.connect();
+ log.info("client is connected");
+
+ // Test connections.
+ assertEquals("abc", client.invoke("abc"));
+ log.info("connection is good");
+
+ // Verify client invoker is using configured SocketFactory.
+ AbstractInvoker invoker = (AbstractInvoker) client.getInvoker();
+ SocketFactory socketFactory = invoker.getSocketFactory();
+ log.info("SocketFactory: " + socketFactory);
+ assertTrue(socketFactory instanceof TestSocketFactory);
+
+ client.disconnect();
+ shutdownServer();
+ log.info(getName() + " PASSES");
+ }
+
+
+ protected String getTransport()
+ {
+ return "socket";
+ }
+
+
+ protected void addExtraClientConfig(Map config) {}
+ protected void addExtraServerConfig(Map config) {}
+
+
+ protected void setupServer() throws Exception
+ {
+ host = InetAddress.getLocalHost().getHostAddress();
+ port = PortUtil.findFreePort(host);
+ locatorURI = getTransport() + "://" + host + ":" + port;
+ serverLocator = new InvokerLocator(locatorURI);
+ log.info("Starting remoting server with locator uri of: " + locatorURI);
+ HashMap config = new HashMap();
+ config.put(InvokerLocator.FORCE_REMOTE, "true");
+ addExtraServerConfig(config);
+ connector = new Connector(serverLocator, config);
+ connector.create();
+ invocationHandler = new TestInvocationHandler();
+ connector.addInvocationHandler("test", invocationHandler);
+ connector.start();
+ }
+
+
+ protected void shutdownServer() throws Exception
+ {
+ if (connector != null)
+ connector.stop();
+ }
+
+
+ static class TestInvocationHandler implements ServerInvocationHandler
+ {
+ public void addListener(InvokerCallbackHandler callbackHandler) {}
+ public Object invoke(final InvocationRequest invocation) throws Throwable
+ {
+ return invocation.getParameter();
+ }
+ public void removeListener(InvokerCallbackHandler callbackHandler) {}
+ public void setMBeanServer(MBeanServer server) {}
+ public void setInvoker(ServerInvoker invoker) {}
+ }
+
+ public static class TestSocketFactory extends SocketFactory
+ {
+ private SocketFactory sf = SocketFactory.getDefault();
+
+ public TestSocketFactory()
+ {
+ }
+
+ public Socket createSocket() throws IOException, UnknownHostException
+ {
+ return sf.createSocket();
+ }
+
+ public Socket createSocket(String arg0, int arg1) throws IOException, UnknownHostException
+ {
+ return sf.createSocket(arg0, arg1);
+ }
+
+ public Socket createSocket(InetAddress arg0, int arg1) throws IOException
+ {
+ return sf.createSocket(arg0, arg1);
+ }
+
+ public Socket createSocket(String arg0, int arg1, InetAddress arg2, int arg3) throws IOException,
+ UnknownHostException
+ {
+ return sf.createSocket(arg0, arg1, arg2, arg3);
+ }
+
+ public Socket createSocket(InetAddress arg0, int arg1, InetAddress arg2, int arg3) throws IOException
+ {
+ return sf.createSocket(arg0, arg1, arg2, arg3);
+ }
+ }
+}
\ No newline at end of file
16 years, 5 months
JBoss Remoting SVN: r4389 - remoting2/branches/2.2/src/main/org/jboss/remoting.
by jboss-remoting-commits@lists.jboss.org
Author: ron.sigal(a)jboss.com
Date: 2008-07-18 03:09:15 -0400 (Fri, 18 Jul 2008)
New Revision: 4389
Modified:
remoting2/branches/2.2/src/main/org/jboss/remoting/AbstractInvoker.java
Log:
JBREM-1014: Uses new Remoting.SOCKET_FACTORY_CLASS_NAME parameter.
Modified: remoting2/branches/2.2/src/main/org/jboss/remoting/AbstractInvoker.java
===================================================================
--- remoting2/branches/2.2/src/main/org/jboss/remoting/AbstractInvoker.java 2008-07-18 07:08:26 UTC (rev 4388)
+++ remoting2/branches/2.2/src/main/org/jboss/remoting/AbstractInvoker.java 2008-07-18 07:09:15 UTC (rev 4389)
@@ -311,6 +311,11 @@
if(factory == null)
{
String socketFactoryString = (String)configuration.get(Remoting.SOCKET_FACTORY_NAME);
+ if (socketFactoryString == null)
+ {
+ socketFactoryString = (String)configuration.get(Remoting.SOCKET_FACTORY_CLASS_NAME);
+ }
+
if(socketFactoryString != null && socketFactoryString.length() > 0)
{
try
16 years, 5 months
JBoss Remoting SVN: r4388 - remoting2/branches/2.2/src/main/org/jboss/remoting.
by jboss-remoting-commits@lists.jboss.org
Author: ron.sigal(a)jboss.com
Date: 2008-07-18 03:08:26 -0400 (Fri, 18 Jul 2008)
New Revision: 4388
Modified:
remoting2/branches/2.2/src/main/org/jboss/remoting/Remoting.java
Log:
JBREM-1014: Added new SOCKET_FACTORY_CLASS_NAME parameter.
Modified: remoting2/branches/2.2/src/main/org/jboss/remoting/Remoting.java
===================================================================
--- remoting2/branches/2.2/src/main/org/jboss/remoting/Remoting.java 2008-07-18 07:07:35 UTC (rev 4387)
+++ remoting2/branches/2.2/src/main/org/jboss/remoting/Remoting.java 2008-07-18 07:08:26 UTC (rev 4388)
@@ -47,6 +47,12 @@
public static final String SOCKET_FACTORY_NAME = "socketFactory";
/**
+ * Key for the configuration map passed to a Client to indicate the classname of
+ * the socket factory to be used. This one is distinct from the bean property "socketFactory".
+ */
+ public static final String SOCKET_FACTORY_CLASS_NAME = "socketFactoryClassName";
+
+ /**
* Key for the configuration map passed to a Client or Connector to indicate
* a socket creation listener for sockets created by a SocketFactory.
*/
16 years, 5 months
JBoss Remoting SVN: r4387 - remoting2/branches/2.2/docs/guide/en.
by jboss-remoting-commits@lists.jboss.org
Author: ron.sigal(a)jboss.com
Date: 2008-07-18 03:07:35 -0400 (Fri, 18 Jul 2008)
New Revision: 4387
Modified:
remoting2/branches/2.2/docs/guide/en/chap5.xml
Log:
JBREM-1014: Described new Remoting.SOCKET_FACTORY_CLASS_NAME parameter.
Modified: remoting2/branches/2.2/docs/guide/en/chap5.xml
===================================================================
--- remoting2/branches/2.2/docs/guide/en/chap5.xml 2008-07-18 05:46:55 UTC (rev 4386)
+++ remoting2/branches/2.2/docs/guide/en/chap5.xml 2008-07-18 07:07:35 UTC (rev 4387)
@@ -4409,7 +4409,7 @@
<listitem>
<para>Put the class name of a <classname>SocketFactory</classname>
in a configuration map, using key
- <constant>Remoting.SOCKET_FACTORY_NAME</constant>, and pass the
+ <constant>Remoting.SOCKET_FACTORY_CLASS_NAME</constant>, and pass the
map to one of the <classname>Connector</classname> constructors.
The <classname>SocketFactory</classname> class must have a default
constructor.</para>
@@ -4609,7 +4609,7 @@
<listitem>
<para>Put the class name of a <classname>SocketFactory</classname>
in a configuration map, using key
- <constant>Remoting.SOCKET_FACTORY_NAME</constant>, and pass the
+ <constant>Remoting.SOCKET_FACTORY_CLASS_NAME</constant>, and pass the
map to one of the <classname>Client</classname> constructors. The
<classname>SocketFactory</classname> class must have a default
constructor, which will be used to create a
@@ -6081,8 +6081,8 @@
Client to indicate the socket factory to be used. Value must be instance
of javax.net.SocketFactory.</para>
- <para><emphasis role="bold">SOCKET_FACTORY_NAME</emphasis> (actual value
- is 'socketFactory') - key for the configuration map passed to a Client to
+ <para><emphasis role="bold">SOCKET_FACTORY_CLASS_NAME</emphasis> (actual value
+ is 'socketFactoryClassName') - key for the configuration map passed to a Client to
indicate the classname of the socket factory to be used. Value should be
fully qualified classname of class that is an instance of
javax.net.SocketFactory and has a void constructor. This property will not
16 years, 5 months
JBoss Remoting SVN: r4386 - remoting2/branches/2.2/docs/guide/en.
by jboss-remoting-commits@lists.jboss.org
Author: ron.sigal(a)jboss.com
Date: 2008-07-18 01:46:55 -0400 (Fri, 18 Jul 2008)
New Revision: 4386
Modified:
remoting2/branches/2.2/docs/guide/en/chap8.xml
Log:
JBREM-1010: Described injection of ConnectionListener.
Modified: remoting2/branches/2.2/docs/guide/en/chap8.xml
===================================================================
--- remoting2/branches/2.2/docs/guide/en/chap8.xml 2008-07-18 05:25:51 UTC (rev 4385)
+++ remoting2/branches/2.2/docs/guide/en/chap8.xml 2008-07-18 05:46:55 UTC (rev 4386)
@@ -90,16 +90,15 @@
<para>The second
criterion is that an implementation of the
<code>org.jboss.remoting.ConnectionListener</code> interface is added as a
- connection listener to the Connector, via the method</para>
+ connection listener to the Connector, either via the method</para>
<programlisting>public void addConnectionListener(ConnectionListener listener)</programlisting>
- <para> Once both criteria are met, the remoting server will turn on client
- leasing.</para>
-
- <para>Note that there is no way to register a
- <classname>ConnectionListener</classname> via xml based configuration for
- the <classname>Connector</classname>.</para>
+ <para>or though the use of the
+ <code>ServerInvoker.CONNECTION_LISTENER</code> parameter (actual value
+ "connectionListener") in the <classname>Connector</classname>'s
+ configuration map or XML configuration file. Once both criteria are met, the
+ remoting server will turn on client leasing.</para>
<para>The ConnectionListener will be notified of both client failures and
client disconnects via the handleConnectionException() method. If the client
16 years, 5 months
JBoss Remoting SVN: r4385 - remoting2/branches/2.2.
by jboss-remoting-commits@lists.jboss.org
Author: ron.sigal(a)jboss.com
Date: 2008-07-18 01:25:51 -0400 (Fri, 18 Jul 2008)
New Revision: 4385
Modified:
remoting2/branches/2.2/build.xml
Log:
JBREM-1011: Updated version to 2.2.2.SP9.
Modified: remoting2/branches/2.2/build.xml
===================================================================
--- remoting2/branches/2.2/build.xml 2008-07-18 05:23:36 UTC (rev 4384)
+++ remoting2/branches/2.2/build.xml 2008-07-18 05:25:51 UTC (rev 4385)
@@ -37,9 +37,9 @@
<!-- Module name(s) & version -->
<property name="module.name" value="remoting"/>
<property name="module.Name" value="JBoss Remoting"/>
- <property name="module.version" value="2.2.2.SP8"/>
+ <property name="module.version" value="2.2.2.SP9"/>
<!-- extension is for the file suffix to use for distribution build -->
- <property name="module.version.extension" value="2_2_2_SP8"/>
+ <property name="module.version.extension" value="2_2_2_SP9"/>
<property name="implementation.url" value="http://www.jboss.org/products/remoting"/>
<property name="root.dir" value="${basedir}"/>
16 years, 5 months
JBoss Remoting SVN: r4384 - remoting2/branches/2.2/src/tests/org/jboss/test/remoting/lease.
by jboss-remoting-commits@lists.jboss.org
Author: ron.sigal(a)jboss.com
Date: 2008-07-18 01:23:36 -0400 (Fri, 18 Jul 2008)
New Revision: 4384
Added:
remoting2/branches/2.2/src/tests/org/jboss/test/remoting/lease/InjectedConnectionListenerTestCase.java
Log:
JBREM-1010: New unit test.
Added: remoting2/branches/2.2/src/tests/org/jboss/test/remoting/lease/InjectedConnectionListenerTestCase.java
===================================================================
--- remoting2/branches/2.2/src/tests/org/jboss/test/remoting/lease/InjectedConnectionListenerTestCase.java (rev 0)
+++ remoting2/branches/2.2/src/tests/org/jboss/test/remoting/lease/InjectedConnectionListenerTestCase.java 2008-07-18 05:23:36 UTC (rev 4384)
@@ -0,0 +1,223 @@
+package org.jboss.test.remoting.lease;
+
+import java.io.ByteArrayInputStream;
+import java.net.InetAddress;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.management.MBeanServer;
+import javax.management.MBeanServerFactory;
+import javax.management.ObjectName;
+import javax.xml.parsers.DocumentBuilderFactory;
+
+import junit.framework.TestCase;
+
+import org.apache.log4j.ConsoleAppender;
+import org.apache.log4j.Level;
+import org.apache.log4j.Logger;
+import org.apache.log4j.PatternLayout;
+import org.jboss.logging.XLevel;
+import org.jboss.remoting.Client;
+import org.jboss.remoting.ConnectionListener;
+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.transport.Connector;
+import org.jboss.remoting.transport.PortUtil;
+import org.w3c.dom.Document;
+
+
+/**
+ *
+ * Unit test for JBREM-1010.
+ *
+ * @author <a href="ron.sigal(a)jboss.com">Ron Sigal</a>
+ * @version $Revision: 1.1 $
+ * <p>
+ * Copyright Jul 18, 2008
+ * </p>
+ */
+public class InjectedConnectionListenerTestCase extends TestCase
+{
+ private static Logger log = Logger.getLogger(InjectedConnectionListenerTestCase.class);
+
+ private static boolean firstTime = true;
+
+ protected String host;
+ protected int port;
+ protected String locatorURI;
+ protected Connector connector;
+ protected TestInvocationHandler invocationHandler;
+
+
+ public void setUp() throws Exception
+ {
+ if (firstTime)
+ {
+ firstTime = false;
+ Logger.getLogger("org.jboss.remoting").setLevel(XLevel.INFO);
+ Logger.getLogger("org.jboss.test.remoting").setLevel(Level.INFO);
+ String pattern = "[%d{ABSOLUTE}] [%t] %5p (%F:%L) - %m%n";
+ PatternLayout layout = new PatternLayout(pattern);
+ ConsoleAppender consoleAppender = new ConsoleAppender(layout);
+ Logger.getRootLogger().addAppender(consoleAppender);
+ }
+
+ TestConnectionListener.gotException = false;
+ }
+
+
+ public void tearDown()
+ {
+ }
+
+
+ public void testInjectionWithClassName() throws Throwable
+ {
+ log.info("entering " + getName());
+
+ // Start server.
+ MBeanServer mbeanServer = MBeanServerFactory.createMBeanServer();
+ setupServer(TestConnectionListener.class.getName(), mbeanServer);
+
+ // Create client.
+ InvokerLocator clientLocator = new InvokerLocator(locatorURI);
+ HashMap clientConfig = new HashMap();
+ clientConfig.put(InvokerLocator.FORCE_REMOTE, "true");
+ clientConfig.put(Client.ENABLE_LEASE, "true");
+ addExtraClientConfig(clientConfig);
+ Client client = new Client(clientLocator, clientConfig);
+ client.connect();
+ log.info("client is connected");
+
+ // Test connections.
+ assertEquals("abc", client.invoke("abc"));
+ log.info("connection is good");
+
+ // Verify ConnectionListener is notified.
+ log.info("client disconnecting");
+ client.disconnect();
+ log.info("client disconnected");
+ assertTrue(TestConnectionListener.gotException);
+
+ shutdownServer();
+ log.info(getName() + " PASSES");
+ }
+
+
+
+ public void testInjectionWithMBean() throws Throwable
+ {
+ log.info("entering " + getName());
+
+ // Start server.
+ String connectionListenerName = "jboss:type=connectionlistener";
+ ObjectName objName = new ObjectName(connectionListenerName);
+ MBeanServer mbeanServer = MBeanServerFactory.createMBeanServer();
+ TestConnectionListener listener = new TestConnectionListener();
+ mbeanServer.registerMBean(listener, objName);
+ setupServer(connectionListenerName, mbeanServer);
+
+ // Create client.
+ InvokerLocator clientLocator = new InvokerLocator(locatorURI);
+ HashMap clientConfig = new HashMap();
+ clientConfig.put(InvokerLocator.FORCE_REMOTE, "true");
+ clientConfig.put(Client.ENABLE_LEASE, "true");
+ addExtraClientConfig(clientConfig);
+ Client client = new Client(clientLocator, clientConfig);
+ client.connect();
+ log.info("client is connected");
+
+ // Test connections.
+ assertEquals("abc", client.invoke("abc"));
+ log.info("connection is good");
+
+ // Verify ConnectionListener is notified.
+ log.info("client disconnecting");
+ client.disconnect();
+ log.info("client disconnected");
+ assertTrue(TestConnectionListener.gotException);
+
+ shutdownServer();
+ log.info(getName() + " PASSES");
+ }
+
+
+ protected String getTransport()
+ {
+ return "socket";
+ }
+
+
+ protected void addExtraClientConfig(Map config) {}
+ protected void addExtraServerConfig(Map config) {}
+
+
+ protected void setupServer(String listener, MBeanServer mbeanServer) throws Exception
+ {
+ HashMap config = new HashMap();
+ config.put(InvokerLocator.FORCE_REMOTE, "true");
+ addExtraServerConfig(config);
+ Connector connector = new Connector(config);
+ mbeanServer.registerMBean(connector, new ObjectName("test:type=connector"));
+
+ host = InetAddress.getLocalHost().getHostAddress();
+ port = PortUtil.findFreePort(host);
+ StringBuffer buf = new StringBuffer();
+ buf.append("<?xml version=\"1.0\"?>\n");
+ buf.append("<config>");
+ buf.append(" <invoker transport=\"" + getTransport() + "\">");
+ buf.append(" <attribute name=\"serverBindAddress\">" + host + "</attribute>");
+ buf.append(" <attribute name=\"serverBindPort\">" + port + "</attribute>");
+ buf.append(" <attribute name=\"" + ServerInvoker.CONNECTION_LISTENER + "\">" + listener + "</attribute>");
+ buf.append(" <attribute name=\"" + ServerInvoker.CLIENT_LEASE_PERIOD + "\">5000</attribute>");
+ buf.append(" </invoker>");
+ buf.append("</config>");
+ ByteArrayInputStream bais = new ByteArrayInputStream(buf.toString().getBytes());
+ Document xml = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(bais);
+ connector.setConfiguration(xml.getDocumentElement());
+ connector.create();
+ connector.addInvocationHandler("test", new TestInvocationHandler());
+ connector.start();
+ locatorURI = connector.getInvokerLocator();
+ log.info("Started remoting server with locator uri of: " + locatorURI);
+ }
+
+
+ protected void shutdownServer() throws Exception
+ {
+ if (connector != null)
+ connector.stop();
+ }
+
+
+ static class TestInvocationHandler implements ServerInvocationHandler
+ {
+ public void addListener(InvokerCallbackHandler callbackHandler) {}
+ public Object invoke(final InvocationRequest invocation) throws Throwable
+ {
+ return invocation.getParameter();
+ }
+ public void removeListener(InvokerCallbackHandler callbackHandler) {}
+ public void setMBeanServer(MBeanServer server) {}
+ public void setInvoker(ServerInvoker invoker) {}
+ }
+
+
+ public interface TestConnectionListenerMBean extends ConnectionListener
+ {
+ }
+
+ public static class TestConnectionListener implements TestConnectionListenerMBean
+ {
+ public static boolean gotException;
+
+ public void handleConnectionException(Throwable throwable, Client client)
+ {
+ gotException = true;
+ log.info("TestConnectionListener got exception");
+ }
+ }
+}
\ No newline at end of file
16 years, 5 months