JBoss Remoting SVN: r4423 - remoting3/trunk.
by jboss-remoting-commits@lists.jboss.org
Author: david.lloyd(a)jboss.com
Date: 2008-07-21 14:38:27 -0400 (Mon, 21 Jul 2008)
New Revision: 4423
Modified:
remoting3/trunk/build.xml
Log:
Add basic protocol to clean targets
Modified: remoting3/trunk/build.xml
===================================================================
--- remoting3/trunk/build.xml 2008-07-21 18:37:22 UTC (rev 4422)
+++ remoting3/trunk/build.xml 2008-07-21 18:38:27 UTC (rev 4423)
@@ -1308,7 +1308,7 @@
<target name="all-core" description="Build all core targets" depends="api,compat,core,mc-deployers,protocol.basic,samples,standalone,testing-support,tools,util"/>
- <target name="clean-core" description="Clean all core targets" depends="api.clean,compat.clean,core.clean,mc-deployers.clean,samples.clean,standalone.clean,testing-support.clean,tools.clean,util.clean"/>
+ <target name="clean-core" description="Clean all core targets" depends="api.clean,compat.clean,core.clean,mc-deployers.clean,protocol.basic.clean,samples.clean,standalone.clean,testing-support.clean,tools.clean,util.clean"/>
<!-- http -->
16 years, 5 months
JBoss Remoting SVN: r4422 - in remoting3/trunk: testing-support/src/main/resources and 1 other directory.
by jboss-remoting-commits@lists.jboss.org
Author: david.lloyd(a)jboss.com
Date: 2008-07-21 14:37:22 -0400 (Mon, 21 Jul 2008)
New Revision: 4422
Modified:
remoting3/trunk/build.properties
remoting3/trunk/build.xml
remoting3/trunk/testing-support/src/main/resources/testing.policy
Log:
Add basic protocol stuff to main build; upgrade XNIO to 1.1.0 alpha
Modified: remoting3/trunk/build.properties
===================================================================
--- remoting3/trunk/build.properties 2008-07-21 18:36:32 UTC (rev 4421)
+++ remoting3/trunk/build.properties 2008-07-21 18:37:22 UTC (rev 4422)
@@ -173,10 +173,19 @@
lib.trove.local=${local.repository}/${lib.trove.path}
lib.trove.remote=${remote.repository}/${lib.trove.path}
-lib.xnio-api.version=1.0.0.CR3
-lib.xnio-api.name=xnio-api-${lib.xnio-api.version}.jar
+lib.xnio.version=1.1.0.Alpha2008072101
+
+lib.xnio-api.name=xnio-api-${lib.xnio.version}.jar
lib.xnio-api.license=lgpl
-lib.xnio-api.dir=maven2/org/jboss/xnio/xnio-api/${lib.xnio-api.version}/
+lib.xnio-api.dir=maven2/org/jboss/xnio/xnio-api/${lib.xnio.version}
lib.xnio-api.path=${lib.xnio-api.dir}/${lib.xnio-api.name}
lib.xnio-api.local=${local.repository}/${lib.xnio-api.path}
lib.xnio-api.remote=${remote.repository}/${lib.xnio-api.path}
+
+lib.xnio-standalone.name=xnio-standalone-${lib.xnio.version}.jar
+lib.xnio-standalone.license=lgpl
+lib.xnio-standalone.dir=maven2/org/jboss/xnio/xnio-standalone/${lib.xnio.version}
+lib.xnio-standalone.path=${lib.xnio-standalone.dir}/${lib.xnio-standalone.name}
+lib.xnio-standalone.local=${local.repository}/${lib.xnio-standalone.path}
+lib.xnio-standalone.remote=${remote.repository}/${lib.xnio-standalone.path}
+
Modified: remoting3/trunk/build.xml
===================================================================
--- remoting3/trunk/build.xml 2008-07-21 18:36:32 UTC (rev 4421)
+++ remoting3/trunk/build.xml 2008-07-21 18:37:22 UTC (rev 4422)
@@ -185,7 +185,7 @@
<get src="${remote.license.dir}/${lib.sun-httpserver.license}.txt" dest="${lib.sun-httpserver.local}.license.txt" usetimestamp="true" ignoreerrors="false"/>
</target>
- <!-- External library: XNIO -->
+ <!-- External library: XNIO api -->
<target name="lib.xnio-api-check">
<available property="lib.xnio-api.exists" file="${lib.xnio-api.local}"/>
@@ -197,6 +197,18 @@
<get src="${remote.license.dir}/${lib.xnio-api.license}.txt" dest="${lib.xnio-api.local}.license.txt" usetimestamp="true" ignoreerrors="false"/>
</target>
+ <!-- External library: XNIO standalone -->
+
+ <target name="lib.xnio-standalone-check">
+ <available property="lib.xnio-standalone.exists" file="${lib.xnio-standalone.local}"/>
+ </target>
+
+ <target name="lib.xnio-standalone" depends="lib.xnio-standalone-check" unless="lib.xnio-standalone.exists">
+ <mkdir dir="${local.repository}/${lib.xnio-standalone.dir}"/>
+ <get src="${lib.xnio-standalone.remote}" dest="${lib.xnio-standalone.local}" usetimestamp="true" ignoreerrors="false"/>
+ <get src="${remote.license.dir}/${lib.xnio-standalone.license}.txt" dest="${lib.xnio-standalone.local}.license.txt" usetimestamp="true" ignoreerrors="false"/>
+ </target>
+
<!-- ============================================== -->
<!-- MODULES - Keep in alpha order by target name -->
<!-- ============================================== -->
@@ -704,6 +716,127 @@
</path>
</target>
+ <!-- protocol.basic module -->
+
+ <target name="protocol.basic.compile.depcheck">
+ <mkdir dir="protocol/basic/target/main"/>
+ <uptodate property="protocol/basic.compile.uptodate" targetfile="protocol/basic/target/main/.lastcompile">
+ <srcfiles dir="protocol/basic/src/main/java">
+ <include name="**/"/>
+ <include name="**/*.java"/>
+ <exclude name="**/.*"/>
+ </srcfiles>
+ </uptodate>
+ </target>
+
+ <target name="protocol.basic.compile" depends="protocol.basic.compile.depcheck" unless="protocol.basic.compile.uptodate">
+ <mkdir dir="protocol/basic/target/main/classes"/>
+ <javac
+ source="${javac.source}"
+ target="${javac.target}"
+ srcdir="protocol/basic/src/main/java"
+ destdir="protocol/basic/target/main/classes"
+ debug="true">
+ <compilerarg value="-Xlint:unchecked"/>
+ <classpath>
+ <path refid="api.classpath"/>
+ <!-- TODO: marshallers should be moved to their own module -->
+ <path refid="core.classpath"/>
+ <path refid="util.classpath"/>
+ <pathelement location="${lib.xnio-api.local}"/>
+ </classpath>
+ </javac>
+ <touch file="protocol/basic/target/main/.lastcompile" verbose="false"/>
+ </target>
+
+ <target name="protocol.basic.test.compile.depcheck">
+ <mkdir dir="protocol/basic/target/test"/>
+ <uptodate property="protocol.basic.compile.uptodate" targetfile="protocol/basic/target/test/.lastcompile">
+ <srcfiles dir="protocol/basic/src/test/java">
+ <include name="**/"/>
+ <include name="**/*.java"/>
+ <exclude name="**/.*"/>
+ </srcfiles>
+ </uptodate>
+ </target>
+
+ <target name="protocol.basic.test.compile" depends="lib.junit,protocol.basic.compile,protocol.basic.test.compile.depcheck" unless="protocol.basic.test.compile.uptodate">
+ <mkdir dir="protocol/basic/target/test/classes"/>
+ <javac
+ source="${javac.source}"
+ target="${javac.target}"
+ srcdir="protocol/basic/src/test/java"
+ destdir="protocol/basic/target/test/classes"
+ debug="true">
+ <compilerarg value="-Xlint:unchecked"/>
+ <classpath>
+ <path refid="api.classpath"/>
+ <path refid="core.classpath"/>
+ <path refid="protocol.basic.classpath"/>
+ <path refid="util.classpath"/>
+ <path refid="testing-support.classpath"/>
+ <pathelement location="${lib.junit.local}"/>
+ <pathelement location="${lib.xnio-standalone.local}"/>
+ </classpath>
+ </javac>
+ <touch file="protocol/basic/target/test/.lastcompile" verbose="false"/>
+ </target>
+
+ <target name="protocol.basic.test.pseudotarget">
+ <echo message="============================================="/>
+ <echo message="${message}"/>
+ <echo message="============================================="/>
+ <mkdir dir="protocol/basic/target/test-results"/>
+ <junit printsummary="true" fork="yes" includeantruntime="true">
+ <sysproperty key="build.home" value="${basedir}"/>
+ <sysproperty key="ant.library.dir" value="${ant.home}/lib"/>
+ <sysproperty key="lib.junit.local" value="${lib.junit.local}"/>
+ <sysproperty key="lib.xnio-standalone.local" value="${lib.xnio-standalone.local}"/>
+ <jvmarg line="${test.jvmargs}"/>
+ <formatter type="plain" extension="${extension}"/>
+ <classpath>
+ <path refid="api.classpath"/>
+ <path refid="core.classpath"/>
+ <path refid="protocol.basic.classpath"/>
+ <path refid="testing-support.classpath"/>
+ <path refid="util.classpath"/>
+ <pathelement location="protocol/basic/target/test/classes"/>
+ <pathelement location="${lib.junit.local}"/>
+ <pathelement location="${lib.xnio-standalone.local}"/>
+ </classpath>
+ <batchtest fork="yes" todir="protocol/basic/target/test-results"
+ haltonfailure="no">
+ <fileset dir="protocol/basic/target/test/classes">
+ <include name="**/*TestCase.class"/>
+ </fileset>
+ </batchtest>
+ </junit>
+ </target>
+
+ <target name="protocol.basic.test" depends="lib.xnio-standalone,api,core,protocol.basic,testing-support,util,protocol.basic.test.compile">
+ <antcall inheritall="true" inheritrefs="true" target="protocol.basic.test.pseudotarget">
+ <param name="extension" value=".txt"/>
+ <param name="message" value="Running with no security manager"/>
+ <param name="test.jvmargs" value="-Ddummy=dummy"/>
+ </antcall>
+ <antcall inheritall="true" inheritrefs="true" target="protocol.basic.test.pseudotarget">
+ <param name="extension" value="-security.txt"/>
+ <param name="message" value="Running with security manager"/>
+ <param name="test.jvmargs" value="-Djava.security.manager=org.jboss.cx.remoting.test.support.LoggingSecurityManager -Djava.security.policy=${basedir}/testing-support/src/main/resources/testing.policy -Dsecurity.debug=policy"/>
+ </antcall>
+ </target>
+
+ <target name="protocol.basic.clean">
+ <delete dir="protocol.basic/target"/>
+ </target>
+
+ <target name="protocol.basic" description="Build the protocol.basic module" depends="lib.xnio-api,api,core,util,protocol.basic.compile">
+ <path id="protocol.basic.classpath">
+ <pathelement location="protocol/basic/target/main/classes"/>
+ </path>
+ </target>
+
+
<!-- samples module -->
<target name="samples.compile.depcheck">
@@ -1173,7 +1306,7 @@
<!-- core -->
- <target name="all-core" description="Build all core targets" depends="api,compat,core,mc-deployers,samples,standalone,testing-support,tools,util"/>
+ <target name="all-core" description="Build all core targets" depends="api,compat,core,mc-deployers,protocol.basic,samples,standalone,testing-support,tools,util"/>
<target name="clean-core" description="Clean all core targets" depends="api.clean,compat.clean,core.clean,mc-deployers.clean,samples.clean,standalone.clean,testing-support.clean,tools.clean,util.clean"/>
@@ -1197,6 +1330,6 @@
<target name="clean" description="Clean out all build files" depends="clean-core,clean-http"/>
- <target name="test" description="Run all tests" depends="api.test,core.test"/>
+ <target name="test" description="Run all tests" depends="api.test,core.test,protocol.basic.test"/>
</project>
Modified: remoting3/trunk/testing-support/src/main/resources/testing.policy
===================================================================
--- remoting3/trunk/testing-support/src/main/resources/testing.policy 2008-07-21 18:36:32 UTC (rev 4421)
+++ remoting3/trunk/testing-support/src/main/resources/testing.policy 2008-07-21 18:37:22 UTC (rev 4422)
@@ -11,6 +11,24 @@
permission java.lang.RuntimePermission "modifyThread"; // for executor control
};
+grant codeBase "file:${build.home}/protocol/basic/target/test/classes/-"
+{
+ permission java.lang.RuntimePermission "modifyThread"; // for executor control
+ permission java.net.SocketPermission "*:*", "accept, connect, resolve";
+};
+
+grant codeBase "file:${build.home}/protocol/basic/target/main/classes/-"
+{
+ permission java.net.SocketPermission "*:*", "accept, connect, resolve";
+};
+
+// TODO: this is for the marshallers, which ought to be in their own module/module set
+
+grant codeBase "file:${build.home}/core/target/main/classes/-"
+{
+ permission java.io.SerializablePermission "enableSubstitution";
+};
+
// Support classes
grant codeBase "file:${build.home}/testing-support/target/main/classes/-"
@@ -37,3 +55,8 @@
{
permission java.security.AllPermission;
};
+
+grant codeBase "file:${lib.xnio-standalone.local}"
+{
+ permission java.security.AllPermission;
+};
16 years, 5 months
JBoss Remoting SVN: r4421 - remoting3/trunk/protocol/basic/src/main/java/org/jboss/cx/remoting/protocol/basic.
by jboss-remoting-commits@lists.jboss.org
Author: david.lloyd(a)jboss.com
Date: 2008-07-21 14:36:32 -0400 (Mon, 21 Jul 2008)
New Revision: 4421
Modified:
remoting3/trunk/protocol/basic/src/main/java/org/jboss/cx/remoting/protocol/basic/BasicHandler.java
Log:
Run handlers in separate thread to prevent a deadlock
Modified: remoting3/trunk/protocol/basic/src/main/java/org/jboss/cx/remoting/protocol/basic/BasicHandler.java
===================================================================
--- remoting3/trunk/protocol/basic/src/main/java/org/jboss/cx/remoting/protocol/basic/BasicHandler.java 2008-07-21 18:36:10 UTC (rev 4420)
+++ remoting3/trunk/protocol/basic/src/main/java/org/jboss/cx/remoting/protocol/basic/BasicHandler.java 2008-07-21 18:36:32 UTC (rev 4421)
@@ -679,14 +679,22 @@
registerWriter(channel, new SimpleWriteHandler(allocator, bufferList));
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
- SpiUtils.safeHandleCancellation(handler);
+ executor.execute(new Runnable() {
+ public void run() {
+ SpiUtils.safeHandleCancellation(handler);
+ }
+ });
return SpiUtils.getBlankRemoteRequestContext();
}
log.trace("Sent request %s", request);
return new RemoteRequestContextImpl(id, allocator, channel);
- } catch (Throwable t) {
+ } catch (final Throwable t) {
log.trace(t, "receiveRequest failed with an exception");
- SpiUtils.safeHandleException(handler, "Failed to build request", t);
+ executor.execute(new Runnable() {
+ public void run() {
+ SpiUtils.safeHandleException(handler, "Failed to build request", t);
+ }
+ });
return SpiUtils.getBlankRemoteRequestContext();
}
}
16 years, 5 months
JBoss Remoting SVN: r4420 - remoting3/trunk/core/src/main/java/org/jboss/cx/remoting/core/marshal.
by jboss-remoting-commits@lists.jboss.org
Author: david.lloyd(a)jboss.com
Date: 2008-07-21 14:36:10 -0400 (Mon, 21 Jul 2008)
New Revision: 4420
Modified:
remoting3/trunk/core/src/main/java/org/jboss/cx/remoting/core/marshal/JavaSerializationMarhsaller.java
remoting3/trunk/core/src/main/java/org/jboss/cx/remoting/core/marshal/JavaSerializationUnmarshaller.java
Log:
Make object replacement be a privileged action
Modified: remoting3/trunk/core/src/main/java/org/jboss/cx/remoting/core/marshal/JavaSerializationMarhsaller.java
===================================================================
--- remoting3/trunk/core/src/main/java/org/jboss/cx/remoting/core/marshal/JavaSerializationMarhsaller.java 2008-07-21 18:31:12 UTC (rev 4419)
+++ remoting3/trunk/core/src/main/java/org/jboss/cx/remoting/core/marshal/JavaSerializationMarhsaller.java 2008-07-21 18:36:10 UTC (rev 4420)
@@ -4,6 +4,8 @@
import java.io.OutputStream;
import java.io.ObjectOutputStream;
import java.util.concurrent.Executor;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
import org.jboss.cx.remoting.spi.marshal.ObjectResolver;
import org.jboss.cx.remoting.spi.marshal.IdentityResolver;
import org.jboss.xnio.log.Logger;
@@ -28,7 +30,12 @@
private OurObjectOutputStream(final OutputStream outputStream, final ObjectResolver resolver) throws IOException {
super(outputStream);
- enableReplaceObject(true);
+ AccessController.doPrivileged(new PrivilegedAction<Void>() {
+ public Void run() {
+ enableReplaceObject(true);
+ return null;
+ }
+ });
this.resolver = resolver;
}
Modified: remoting3/trunk/core/src/main/java/org/jboss/cx/remoting/core/marshal/JavaSerializationUnmarshaller.java
===================================================================
--- remoting3/trunk/core/src/main/java/org/jboss/cx/remoting/core/marshal/JavaSerializationUnmarshaller.java 2008-07-21 18:31:12 UTC (rev 4419)
+++ remoting3/trunk/core/src/main/java/org/jboss/cx/remoting/core/marshal/JavaSerializationUnmarshaller.java 2008-07-21 18:36:10 UTC (rev 4420)
@@ -30,6 +30,8 @@
import java.util.Map;
import java.util.HashMap;
import java.lang.reflect.Proxy;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
import org.jboss.cx.remoting.spi.marshal.ObjectResolver;
/**
@@ -54,6 +56,12 @@
private OurObjectInputStream(final InputStream inputStream, final ObjectResolver resolver, final ClassLoader classLoader) throws IOException {
super(inputStream);
+ AccessController.doPrivileged(new PrivilegedAction<Void>() {
+ public Void run() {
+ enableResolveObject(true);
+ return null;
+ }
+ });
this.classLoader = classLoader;
this.resolver = resolver;
}
16 years, 5 months
JBoss Remoting SVN: r4419 - 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-21 14:31:12 -0400 (Mon, 21 Jul 2008)
New Revision: 4419
Modified:
remoting3/trunk/testing-support/src/main/java/org/jboss/cx/remoting/test/support/LoggingSecurityManager.java
Log:
Use logging for logging security manager to make the output more readable
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-21 16:52:29 UTC (rev 4418)
+++ remoting3/trunk/testing-support/src/main/java/org/jboss/cx/remoting/test/support/LoggingSecurityManager.java 2008-07-21 18:31:12 UTC (rev 4419)
@@ -3,17 +3,20 @@
import java.security.Permission;
import java.io.FileDescriptor;
import java.net.InetAddress;
+import org.jboss.xnio.log.Logger;
/**
*
*/
public final class LoggingSecurityManager extends SecurityManager {
+ private static final Logger log = Logger.getLogger("ACCESS_EXCEPTION");
+
public LoggingSecurityManager() {
}
private static <T extends Throwable> T logged(T se) {
- se.printStackTrace(System.err);
+ log.error(se, "Access violation!");
return se;
}
16 years, 5 months
JBoss Remoting SVN: r4418 - in remoting3/trunk: api/src/main/java/org/jboss/cx/remoting/spi and 7 other directories.
by jboss-remoting-commits@lists.jboss.org
Author: david.lloyd(a)jboss.com
Date: 2008-07-21 12:52:29 -0400 (Mon, 21 Jul 2008)
New Revision: 4418
Added:
remoting3/trunk/api/src/main/java/org/jboss/cx/remoting/spi/remote/RequestHandler.java
remoting3/trunk/api/src/main/java/org/jboss/cx/remoting/spi/remote/RequestHandlerSource.java
remoting3/trunk/core/src/main/java/org/jboss/cx/remoting/core/LocalRequestHandler.java
remoting3/trunk/core/src/main/java/org/jboss/cx/remoting/core/LocalRequestHandlerSource.java
Removed:
remoting3/trunk/api/src/main/java/org/jboss/cx/remoting/spi/remote/RemoteClientEndpoint.java
remoting3/trunk/api/src/main/java/org/jboss/cx/remoting/spi/remote/RemoteServiceEndpoint.java
remoting3/trunk/core/src/main/java/org/jboss/cx/remoting/core/RemoteClientEndpointLocalImpl.java
remoting3/trunk/core/src/main/java/org/jboss/cx/remoting/core/RemoteServiceEndpointLocalImpl.java
Modified:
remoting3/trunk/api/src/main/java/org/jboss/cx/remoting/Endpoint.java
remoting3/trunk/api/src/main/java/org/jboss/cx/remoting/spi/SpiUtils.java
remoting3/trunk/api/src/main/java/org/jboss/cx/remoting/spi/wrapper/EndpointWrapper.java
remoting3/trunk/core/src/main/java/org/jboss/cx/remoting/core/ClientImpl.java
remoting3/trunk/core/src/main/java/org/jboss/cx/remoting/core/ClientSourceImpl.java
remoting3/trunk/core/src/main/java/org/jboss/cx/remoting/core/EndpointImpl.java
remoting3/trunk/core/src/test/java/org/jboss/cx/remoting/core/EndpointTestCase.java
remoting3/trunk/protocol/basic/src/main/java/org/jboss/cx/remoting/protocol/basic/BasicHandler.java
remoting3/trunk/protocol/basic/src/main/java/org/jboss/cx/remoting/protocol/basic/BasicProtocol.java
remoting3/trunk/protocol/basic/src/main/java/org/jboss/cx/remoting/protocol/basic/Connection.java
remoting3/trunk/protocol/basic/src/main/java/org/jboss/cx/remoting/protocol/basic/ServiceRegistry.java
remoting3/trunk/protocol/basic/src/main/java/org/jboss/cx/remoting/protocol/basic/ServiceRegistryImpl.java
remoting3/trunk/protocol/basic/src/test/java/org/jboss/cx/remoting/protocol/basic/ConnectionTestCase.java
remoting3/trunk/standalone/src/main/java/org/jboss/cx/remoting/Remoting.java
Log:
RemoteClientEndpint -> RequestHandler; RemoteServiceEndpoint -> RequestHandlerSource
Modified: remoting3/trunk/api/src/main/java/org/jboss/cx/remoting/Endpoint.java
===================================================================
--- remoting3/trunk/api/src/main/java/org/jboss/cx/remoting/Endpoint.java 2008-07-21 16:29:04 UTC (rev 4417)
+++ remoting3/trunk/api/src/main/java/org/jboss/cx/remoting/Endpoint.java 2008-07-21 16:52:29 UTC (rev 4418)
@@ -1,8 +1,8 @@
package org.jboss.cx.remoting;
import java.util.concurrent.ConcurrentMap;
-import org.jboss.cx.remoting.spi.remote.RemoteClientEndpoint;
-import org.jboss.cx.remoting.spi.remote.RemoteServiceEndpoint;
+import org.jboss.cx.remoting.spi.remote.RequestHandler;
+import org.jboss.cx.remoting.spi.remote.RequestHandlerSource;
import org.jboss.cx.remoting.spi.remote.Handle;
/**
@@ -27,7 +27,7 @@
String getName();
/**
- * Create a client endpoint that can be used to receive incoming requests on this endpoint. The client may be passed to a
+ * Create a request handler that can be used to receive incoming requests on this endpoint. The client may be passed to a
* remote endpoint as part of a request or a reply, or it may be used locally.
*
* You must have the TODO permission to invoke this method.
@@ -38,12 +38,12 @@
* @return a handle for the client
* @throws RemotingException if an error occurs
*/
- <I, O> Handle<RemoteClientEndpoint> createClientEndpoint(RequestListener<I, O> requestListener) throws RemotingException;
+ <I, O> Handle<RequestHandler> createRequestHandler(RequestListener<I, O> requestListener) throws RemotingException;
/**
- * Create a client source that can be used to acquire clients associated with a request listener on this endpoint.
- * The client source may be passed to a remote endpoint as part of a request or a reply, or it may be used locally.
- * The objects that are produced by this method may be used to mass-produce {@code Client} instances.
+ * Create a request handler source that can be used to acquire clients associated with a request listener on this endpoint.
+ * The request handler source may be passed to a remote endpoint as part of a request or a reply, or it may be used locally.
+ * The objects that are produced by this method may be used to mass-produce {@code RequestHandler} instances.
*
* You must have the TODO permission to invoke this method.
*
@@ -53,27 +53,27 @@
* @return a handle for the client source
* @throws RemotingException if an error occurs
*/
- <I, O> Handle<RemoteServiceEndpoint> createServiceEndpoint(RequestListener<I, O> requestListener) throws RemotingException;
+ <I, O> Handle<RequestHandlerSource> createRequestHandlerSource(RequestListener<I, O> requestListener) throws RemotingException;
/**
- * Create a client from a remote client endpoint.
+ * Create a client that uses the given request handler to handle its requests.
*
* @param <I> the request type
* @param <O> the reply type
- * @param endpoint the remote client endpoint
+ * @param handler the request handler
* @return the client
* @throws RemotingException if an error occurs
*/
- <I, O> Client<I, O> createClient(RemoteClientEndpoint endpoint) throws RemotingException;
+ <I, O> Client<I, O> createClient(RequestHandler handler) throws RemotingException;
/**
- * Create a client source from a remote service endpoint.
+ * Create a client source that uses the given request handler source to generate clients.
*
* @param <I> the request type
* @param <O> the reply type
- * @param endpoint the remote service endpoint
+ * @param handlerSource the request handler source
* @return the client source
* @throws RemotingException if an error occurs
*/
- <I, O> ClientSource<I, O> createClientSource(RemoteServiceEndpoint endpoint) throws RemotingException;
+ <I, O> ClientSource<I, O> createClientSource(RequestHandlerSource handlerSource) throws RemotingException;
}
Modified: remoting3/trunk/api/src/main/java/org/jboss/cx/remoting/spi/SpiUtils.java
===================================================================
--- remoting3/trunk/api/src/main/java/org/jboss/cx/remoting/spi/SpiUtils.java 2008-07-21 16:29:04 UTC (rev 4417)
+++ remoting3/trunk/api/src/main/java/org/jboss/cx/remoting/spi/SpiUtils.java 2008-07-21 16:52:29 UTC (rev 4418)
@@ -24,8 +24,6 @@
import org.jboss.cx.remoting.spi.remote.ReplyHandler;
import org.jboss.cx.remoting.spi.remote.RemoteRequestContext;
-import org.jboss.cx.remoting.spi.remote.RemoteClientEndpoint;
-import org.jboss.cx.remoting.spi.remote.RemoteServiceEndpoint;
import org.jboss.cx.remoting.RequestCancelHandler;
import org.jboss.cx.remoting.RequestContext;
import org.jboss.cx.remoting.CloseHandler;
Deleted: remoting3/trunk/api/src/main/java/org/jboss/cx/remoting/spi/remote/RemoteClientEndpoint.java
===================================================================
--- remoting3/trunk/api/src/main/java/org/jboss/cx/remoting/spi/remote/RemoteClientEndpoint.java 2008-07-21 16:29:04 UTC (rev 4417)
+++ remoting3/trunk/api/src/main/java/org/jboss/cx/remoting/spi/remote/RemoteClientEndpoint.java 2008-07-21 16:52:29 UTC (rev 4418)
@@ -1,80 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2008, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-package org.jboss.cx.remoting.spi.remote;
-
-import org.jboss.cx.remoting.Closeable;
-import org.jboss.cx.remoting.RemotingException;
-import org.jboss.cx.remoting.CloseHandler;
-
-/**
- * A remote client endpoint, which can be passed to remote endpoints. Remote systems can then use the client endpoint
- * to make invocations, or they may pass the client endpoint on to other remote systems.
- */
-public interface RemoteClientEndpoint extends Closeable<RemoteClientEndpoint> {
-
- /**
- * Receive a one-way request from a remote system. This method is intended to be called by protocol handlers. No
- * reply will be sent back to the client.
- *
- * @param request the request
- */
- void receiveRequest(Object request);
-
- /**
- * Receive a request from a remote system. This method is intended to be called by protocol handlers. If the
- * request cannot be accepted for some reason, the
- * {@link ReplyHandler#handleException(String, Throwable)}
- * method is called immediately.
- *
- * @param request the request
- * @param replyHandler a handler for the reply
- * @return a context which may be used to cancel the request
- */
- RemoteRequestContext receiveRequest(Object request, ReplyHandler replyHandler);
-
- /**
- * Get a handle to this client endpoint. The client endpoint will not auto-close as long as there is at least
- * one open handle or local client instance. If a handle is "leaked", it will be closed
- * automatically if/when the garbage collector invokes its {@link Object#finalize()} method, with a log message
- * warning of the leak.
- *
- * @return the handle
- * @throws RemotingException if a handle could not be acquired
- */
- Handle<RemoteClientEndpoint> getHandle() throws RemotingException;
-
- /**
- * Close this client endpoint. The outcome of any outstanding requests is not defined, though implementations
- * should make an effort to cancel any outstanding requests.
- *
- * @throws RemotingException if the client endpoint could not be closed
- */
- void close() throws RemotingException;
-
- /**
- * Add a handler that is called when the client endpoint is closed.
- *
- * @param handler the handler to be called
- */
- void addCloseHandler(final CloseHandler<? super RemoteClientEndpoint> handler);
-}
Deleted: remoting3/trunk/api/src/main/java/org/jboss/cx/remoting/spi/remote/RemoteServiceEndpoint.java
===================================================================
--- remoting3/trunk/api/src/main/java/org/jboss/cx/remoting/spi/remote/RemoteServiceEndpoint.java 2008-07-21 16:29:04 UTC (rev 4417)
+++ remoting3/trunk/api/src/main/java/org/jboss/cx/remoting/spi/remote/RemoteServiceEndpoint.java 2008-07-21 16:52:29 UTC (rev 4418)
@@ -1,67 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2008, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-package org.jboss.cx.remoting.spi.remote;
-
-import org.jboss.cx.remoting.Closeable;
-import org.jboss.cx.remoting.RemotingException;
-import org.jboss.cx.remoting.CloseHandler;
-
-/**
- * A remote service endpoint, which can be passed to remote endpoints. Remote systems can then use the service endpoint
- * to acquire client endpoints, or they may pass it on to other systems. Acquiring a client endpoint using this method
- * has the advantage that a round trip to the remote side is not necessary; the local side can spawn a client endpoint
- * and simply notify the remote side of the change.
- */
-public interface RemoteServiceEndpoint extends Closeable<RemoteServiceEndpoint> {
-
- /**
- * Create a client endpoint for the service corresponding to this service endpoint.
- *
- * @return a client endpoint
- * @throws RemotingException if a client could not be opened
- */
- Handle<RemoteClientEndpoint> createClientEndpoint() throws RemotingException;
-
- /**
- * Get a handle to this service endpoint. The service endpoint will not auto-close as long as there is at least
- * one open handle,remote client endpoint, or client source. If a handle is "leaked", it will be closed
- * automatically if/when the garbage collector invokes its {@link Object#finalize()} method, with a log message
- * warning of the leak.
- *
- * @return the handle
- * @throws RemotingException if a handle could not be acquired
- */
- Handle<RemoteServiceEndpoint> getHandle() throws RemotingException;
-
- /**
- * Close this service endpoint immediately.
- */
- void close() throws RemotingException;
-
- /**
- * Add a handler that is called when the service endpoint is closed.
- *
- * @param handler the handler to be called
- */
- void addCloseHandler(final CloseHandler<? super RemoteServiceEndpoint> handler);
-}
Copied: remoting3/trunk/api/src/main/java/org/jboss/cx/remoting/spi/remote/RequestHandler.java (from rev 4398, remoting3/trunk/api/src/main/java/org/jboss/cx/remoting/spi/remote/RemoteClientEndpoint.java)
===================================================================
--- remoting3/trunk/api/src/main/java/org/jboss/cx/remoting/spi/remote/RequestHandler.java (rev 0)
+++ remoting3/trunk/api/src/main/java/org/jboss/cx/remoting/spi/remote/RequestHandler.java 2008-07-21 16:52:29 UTC (rev 4418)
@@ -0,0 +1,80 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.cx.remoting.spi.remote;
+
+import org.jboss.cx.remoting.Closeable;
+import org.jboss.cx.remoting.RemotingException;
+import org.jboss.cx.remoting.CloseHandler;
+
+/**
+ * A request handler, which can be passed to remote endpoints. Remote systems can then use the handler
+ * to make invocations, or they may forward a handler on to other remote systems.
+ */
+public interface RequestHandler extends Closeable<RequestHandler> {
+
+ /**
+ * Receive a one-way request from a remote system. This method is intended to be called by protocol handlers. No
+ * reply will be sent back to the client.
+ *
+ * @param request the request
+ */
+ void receiveRequest(Object request);
+
+ /**
+ * Receive a request from a remote system. This method is intended to be called by protocol handlers. If the
+ * request cannot be accepted for some reason, the
+ * {@link ReplyHandler#handleException(String, Throwable)}
+ * method is called immediately.
+ *
+ * @param request the request
+ * @param replyHandler a handler for the reply
+ * @return a context which may be used to cancel the request
+ */
+ RemoteRequestContext receiveRequest(Object request, ReplyHandler replyHandler);
+
+ /**
+ * Get a handle to this request handler. The request handler will not auto-close as long as there is at least
+ * one open handle. If a handle is "leaked", it will be closed
+ * automatically if/when the garbage collector invokes its {@link Object#finalize()} method, with a log message
+ * warning of the leak.
+ *
+ * @return the handle
+ * @throws RemotingException if a handle could not be acquired
+ */
+ Handle<RequestHandler> getHandle() throws RemotingException;
+
+ /**
+ * Close this request handler. The outcome of any outstanding requests is not defined, though implementations
+ * should make an effort to cancel any outstanding requests.
+ *
+ * @throws RemotingException if the client endpoint could not be closed
+ */
+ void close() throws RemotingException;
+
+ /**
+ * Add a handler that is called when the request handler is closed.
+ *
+ * @param handler the handler to be called
+ */
+ void addCloseHandler(final CloseHandler<? super RequestHandler> handler);
+}
Copied: remoting3/trunk/api/src/main/java/org/jboss/cx/remoting/spi/remote/RequestHandlerSource.java (from rev 4398, remoting3/trunk/api/src/main/java/org/jboss/cx/remoting/spi/remote/RemoteServiceEndpoint.java)
===================================================================
--- remoting3/trunk/api/src/main/java/org/jboss/cx/remoting/spi/remote/RequestHandlerSource.java (rev 0)
+++ remoting3/trunk/api/src/main/java/org/jboss/cx/remoting/spi/remote/RequestHandlerSource.java 2008-07-21 16:52:29 UTC (rev 4418)
@@ -0,0 +1,67 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.cx.remoting.spi.remote;
+
+import org.jboss.cx.remoting.Closeable;
+import org.jboss.cx.remoting.RemotingException;
+import org.jboss.cx.remoting.CloseHandler;
+
+/**
+ * A request handler source, which can be passed to remote endpoints. Remote systems can then use the handler source
+ * to acquire request handlers, or they may pass it on to other systems. Acquiring a request handler using this method
+ * has the advantage that a round trip to the remote side is not necessary; the local side can spawn a request handler
+ * and simply notify the remote side of the change.
+ */
+public interface RequestHandlerSource extends Closeable<RequestHandlerSource> {
+
+ /**
+ * Create a request handler for the service corresponding to this request handler source.
+ *
+ * @return a request handler
+ * @throws RemotingException if a client could not be opened
+ */
+ Handle<RequestHandler> createRequestHandler() throws RemotingException;
+
+ /**
+ * Get a handle to this request handler source. The request handler source will not auto-close as long as there is at least
+ * one open handle, or request handler. If a handle is "leaked", it will be closed
+ * automatically if/when the garbage collector invokes its {@link Object#finalize()} method, with a log message
+ * warning of the leak.
+ *
+ * @return the handle
+ * @throws RemotingException if a handle could not be acquired
+ */
+ Handle<RequestHandlerSource> getHandle() throws RemotingException;
+
+ /**
+ * Close this request handler source immediately.
+ */
+ void close() throws RemotingException;
+
+ /**
+ * Add a handler that is called when the request handler source is closed.
+ *
+ * @param handler the handler to be called
+ */
+ void addCloseHandler(final CloseHandler<? super RequestHandlerSource> handler);
+}
Modified: remoting3/trunk/api/src/main/java/org/jboss/cx/remoting/spi/wrapper/EndpointWrapper.java
===================================================================
--- remoting3/trunk/api/src/main/java/org/jboss/cx/remoting/spi/wrapper/EndpointWrapper.java 2008-07-21 16:29:04 UTC (rev 4417)
+++ remoting3/trunk/api/src/main/java/org/jboss/cx/remoting/spi/wrapper/EndpointWrapper.java 2008-07-21 16:52:29 UTC (rev 4418)
@@ -6,8 +6,8 @@
import org.jboss.cx.remoting.RequestListener;
import org.jboss.cx.remoting.Client;
import org.jboss.cx.remoting.ClientSource;
-import org.jboss.cx.remoting.spi.remote.RemoteClientEndpoint;
-import org.jboss.cx.remoting.spi.remote.RemoteServiceEndpoint;
+import org.jboss.cx.remoting.spi.remote.RequestHandler;
+import org.jboss.cx.remoting.spi.remote.RequestHandlerSource;
import org.jboss.cx.remoting.spi.remote.Handle;
/**
@@ -42,28 +42,28 @@
/**
* {@inheritDoc} This implementation calls the same method on the delegate object.
*/
- public <I, O> Handle<RemoteClientEndpoint> createClientEndpoint(final RequestListener<I, O> requestListener) throws RemotingException {
- return delegate.createClientEndpoint(requestListener);
+ public <I, O> Handle<RequestHandler> createRequestHandler(final RequestListener<I, O> requestListener) throws RemotingException {
+ return delegate.createRequestHandler(requestListener);
}
/**
* {@inheritDoc} This implementation calls the same method on the delegate object.
*/
- public <I, O> Handle<RemoteServiceEndpoint> createServiceEndpoint(final RequestListener<I, O> requestListener) throws RemotingException {
- return delegate.createServiceEndpoint(requestListener);
+ public <I, O> Handle<RequestHandlerSource> createRequestHandlerSource(final RequestListener<I, O> requestListener) throws RemotingException {
+ return delegate.createRequestHandlerSource(requestListener);
}
/**
* {@inheritDoc} This implementation calls the same method on the delegate object.
*/
- public <I, O> Client<I, O> createClient(final RemoteClientEndpoint endpoint) throws RemotingException {
- return delegate.createClient(endpoint);
+ public <I, O> Client<I, O> createClient(final RequestHandler handler) throws RemotingException {
+ return delegate.createClient(handler);
}
/**
* {@inheritDoc} This implementation calls the same method on the delegate object.
*/
- public <I, O> ClientSource<I, O> createClientSource(final RemoteServiceEndpoint endpoint) throws RemotingException {
- return delegate.createClientSource(endpoint);
+ public <I, O> ClientSource<I, O> createClientSource(final RequestHandlerSource handlerSource) throws RemotingException {
+ return delegate.createClientSource(handlerSource);
}
}
Modified: remoting3/trunk/core/src/main/java/org/jboss/cx/remoting/core/ClientImpl.java
===================================================================
--- remoting3/trunk/core/src/main/java/org/jboss/cx/remoting/core/ClientImpl.java 2008-07-21 16:29:04 UTC (rev 4417)
+++ remoting3/trunk/core/src/main/java/org/jboss/cx/remoting/core/ClientImpl.java 2008-07-21 16:52:29 UTC (rev 4418)
@@ -28,7 +28,7 @@
import org.jboss.cx.remoting.FutureReply;
import org.jboss.cx.remoting.RequestCompletionHandler;
import org.jboss.cx.remoting.core.util.QueueExecutor;
-import org.jboss.cx.remoting.spi.remote.RemoteClientEndpoint;
+import org.jboss.cx.remoting.spi.remote.RequestHandler;
import org.jboss.cx.remoting.spi.remote.ReplyHandler;
import org.jboss.cx.remoting.spi.remote.RemoteRequestContext;
import org.jboss.cx.remoting.spi.remote.Handle;
@@ -39,9 +39,9 @@
*/
public final class ClientImpl<I, O> extends AbstractContextImpl<Client<I, O>> implements Client<I, O> {
- private final Handle<RemoteClientEndpoint> handle;
+ private final Handle<RequestHandler> handle;
- ClientImpl(final Handle<RemoteClientEndpoint> handle, final Executor executor) {
+ ClientImpl(final Handle<RequestHandler> handle, final Executor executor) {
super(executor);
this.handle = handle;
}
Modified: remoting3/trunk/core/src/main/java/org/jboss/cx/remoting/core/ClientSourceImpl.java
===================================================================
--- remoting3/trunk/core/src/main/java/org/jboss/cx/remoting/core/ClientSourceImpl.java 2008-07-21 16:29:04 UTC (rev 4417)
+++ remoting3/trunk/core/src/main/java/org/jboss/cx/remoting/core/ClientSourceImpl.java 2008-07-21 16:52:29 UTC (rev 4418)
@@ -26,8 +26,8 @@
import org.jboss.cx.remoting.Client;
import org.jboss.cx.remoting.RemotingException;
import org.jboss.cx.remoting.Endpoint;
-import org.jboss.cx.remoting.spi.remote.RemoteClientEndpoint;
-import org.jboss.cx.remoting.spi.remote.RemoteServiceEndpoint;
+import org.jboss.cx.remoting.spi.remote.RequestHandler;
+import org.jboss.cx.remoting.spi.remote.RequestHandlerSource;
import org.jboss.cx.remoting.spi.remote.Handle;
import org.jboss.cx.remoting.spi.AbstractCloseable;
import org.jboss.xnio.IoUtils;
@@ -37,10 +37,10 @@
*/
public final class ClientSourceImpl<I, O> extends AbstractCloseable<ClientSource<I, O>> implements ClientSource<I, O> {
- private final Handle<RemoteServiceEndpoint> handle;
+ private final Handle<RequestHandlerSource> handle;
private final Endpoint endpoint;
- ClientSourceImpl(final Handle<RemoteServiceEndpoint> handle, final EndpointImpl endpoint) {
+ ClientSourceImpl(final Handle<RequestHandlerSource> handle, final EndpointImpl endpoint) {
super(endpoint.getExecutor());
this.handle = handle;
this.endpoint = endpoint;
@@ -54,7 +54,7 @@
if (! isOpen()) {
throw new RemotingException("Client source is not open");
}
- final Handle<RemoteClientEndpoint> clientHandle = handle.getResource().createClientEndpoint();
+ final Handle<RequestHandler> clientHandle = handle.getResource().createRequestHandler();
try {
return endpoint.createClient(clientHandle.getResource());
} finally {
Modified: remoting3/trunk/core/src/main/java/org/jboss/cx/remoting/core/EndpointImpl.java
===================================================================
--- remoting3/trunk/core/src/main/java/org/jboss/cx/remoting/core/EndpointImpl.java 2008-07-21 16:29:04 UTC (rev 4417)
+++ remoting3/trunk/core/src/main/java/org/jboss/cx/remoting/core/EndpointImpl.java 2008-07-21 16:52:29 UTC (rev 4418)
@@ -14,8 +14,8 @@
import org.jboss.cx.remoting.Client;
import org.jboss.cx.remoting.ClientSource;
import org.jboss.cx.remoting.core.util.OrderedExecutorFactory;
-import org.jboss.cx.remoting.spi.remote.RemoteClientEndpoint;
-import org.jboss.cx.remoting.spi.remote.RemoteServiceEndpoint;
+import org.jboss.cx.remoting.spi.remote.RequestHandler;
+import org.jboss.cx.remoting.spi.remote.RequestHandlerSource;
import org.jboss.cx.remoting.spi.remote.Handle;
import org.jboss.cx.remoting.util.CollectionUtil;
import org.jboss.cx.remoting.util.NamingThreadFactory;
@@ -121,23 +121,23 @@
return endpointMap;
}
- public <I, O> Handle<RemoteClientEndpoint> createClientEndpoint(final RequestListener<I, O> requestListener) throws RemotingException {
- final RemoteClientEndpointLocalImpl<I, O> clientEndpoint = new RemoteClientEndpointLocalImpl<I, O>(executor, requestListener);
- clientEndpoint.addCloseHandler(remover);
- clientEndpoint.open();
- return clientEndpoint.getHandle();
+ public <I, O> Handle<RequestHandler> createRequestHandler(final RequestListener<I, O> requestListener) throws RemotingException {
+ final LocalRequestHandler<I, O> localRequestHandler = new LocalRequestHandler<I, O>(executor, requestListener);
+ localRequestHandler.addCloseHandler(remover);
+ localRequestHandler.open();
+ return localRequestHandler.getHandle();
}
- public <I, O> Handle<RemoteServiceEndpoint> createServiceEndpoint(final RequestListener<I, O> requestListener) throws RemotingException {
- final RemoteServiceEndpointLocalImpl<I, O> serviceEndpoint = new RemoteServiceEndpointLocalImpl<I, O>(executor, requestListener);
- serviceEndpoint.addCloseHandler(remover);
- serviceEndpoint.open();
- return serviceEndpoint.getHandle();
+ public <I, O> Handle<RequestHandlerSource> createRequestHandlerSource(final RequestListener<I, O> requestListener) throws RemotingException {
+ final LocalRequestHandlerSource<I, O> localRequestHandlerSource = new LocalRequestHandlerSource<I, O>(executor, requestListener);
+ localRequestHandlerSource.addCloseHandler(remover);
+ localRequestHandlerSource.open();
+ return localRequestHandlerSource.getHandle();
}
- public <I, O> Client<I, O> createClient(final RemoteClientEndpoint endpoint) throws RemotingException {
+ public <I, O> Client<I, O> createClient(final RequestHandler endpoint) throws RemotingException {
boolean ok = false;
- final Handle<RemoteClientEndpoint> handle = endpoint.getHandle();
+ final Handle<RequestHandler> handle = endpoint.getHandle();
try {
final ClientImpl<I, O> client = new ClientImpl<I, O>(handle, executor);
client.addCloseHandler(new CloseHandler<Client<I, O>>() {
@@ -154,13 +154,13 @@
}
}
- public <I, O> ClientSource<I, O> createClientSource(final RemoteServiceEndpoint remoteServiceEndpoint) throws RemotingException {
+ public <I, O> ClientSource<I, O> createClientSource(final RequestHandlerSource requestHandlerSource) throws RemotingException {
boolean ok = false;
- final Handle<RemoteServiceEndpoint> handle = remoteServiceEndpoint.getHandle();
+ final Handle<RequestHandlerSource> handle = requestHandlerSource.getHandle();
try {
- final ClientSourceImpl<I, O> client = new ClientSourceImpl<I, O>(handle, this);
+ final ClientSourceImpl<I, O> clientSource = new ClientSourceImpl<I, O>(handle, this);
ok = true;
- return client;
+ return clientSource;
} finally {
if (! ok) {
IoUtils.safeClose(handle);
Copied: remoting3/trunk/core/src/main/java/org/jboss/cx/remoting/core/LocalRequestHandler.java (from rev 4401, remoting3/trunk/core/src/main/java/org/jboss/cx/remoting/core/RemoteClientEndpointLocalImpl.java)
===================================================================
--- remoting3/trunk/core/src/main/java/org/jboss/cx/remoting/core/LocalRequestHandler.java (rev 0)
+++ remoting3/trunk/core/src/main/java/org/jboss/cx/remoting/core/LocalRequestHandler.java 2008-07-21 16:52:29 UTC (rev 4418)
@@ -0,0 +1,118 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.cx.remoting.core;
+
+import org.jboss.cx.remoting.spi.remote.RequestHandler;
+import org.jboss.cx.remoting.spi.remote.RemoteRequestContext;
+import org.jboss.cx.remoting.spi.remote.ReplyHandler;
+import org.jboss.cx.remoting.spi.SpiUtils;
+import org.jboss.cx.remoting.spi.AbstractAutoCloseable;
+import org.jboss.cx.remoting.RemotingException;
+import org.jboss.cx.remoting.RequestListener;
+import org.jboss.cx.remoting.RemoteExecutionException;
+import org.jboss.cx.remoting.CloseHandler;
+import org.jboss.xnio.log.Logger;
+import java.util.concurrent.Executor;
+
+/**
+ *
+ */
+public final class LocalRequestHandler<I, O> extends AbstractAutoCloseable<RequestHandler> implements RequestHandler {
+
+ private final RequestListener<I, O> requestListener;
+ private final Executor executor;
+ private final ClientContextImpl clientContext;
+
+ private static final Logger log = Logger.getLogger(LocalRequestHandler.class);
+
+ private LocalRequestHandler(final Executor executor, final RequestListener<I, O> requestListener, final ClientContextImpl clientContext) {
+ super(executor);
+ this.executor = executor;
+ this.requestListener = requestListener;
+ this.clientContext = clientContext;
+ }
+
+ LocalRequestHandler(final Executor executor, final LocalRequestHandlerSource<I, O> service, final RequestListener<I, O> requestListener) {
+ this(executor, requestListener, new ClientContextImpl(service.getServiceContext()));
+ }
+
+ LocalRequestHandler(final Executor executor, final RequestListener<I, O> requestListener) {
+ this(executor, requestListener, new ClientContextImpl(executor));
+ }
+
+ public void receiveRequest(final Object request) {
+ final RequestContextImpl<O> context = new RequestContextImpl<O>(clientContext);
+ executor.execute(new Runnable() {
+ @SuppressWarnings({ "unchecked" })
+ public void run() {
+ try {
+ requestListener.handleRequest(context, (I) request);
+ } catch (Throwable t) {
+ log.error(t, "Unexpected exception in request listener");
+ }
+ }
+ });
+ }
+
+ public RemoteRequestContext receiveRequest(final Object request, final ReplyHandler replyHandler) {
+ final RequestContextImpl<O> context = new RequestContextImpl<O>(replyHandler, clientContext);
+ executor.execute(new Runnable() {
+ @SuppressWarnings({ "unchecked" })
+ public void run() {
+ try {
+ requestListener.handleRequest(context, (I) request);
+ } catch (RemoteExecutionException e) {
+ SpiUtils.safeHandleException(replyHandler, e.getMessage(), e.getCause());
+ } catch (Throwable t) {
+ SpiUtils.safeHandleException(replyHandler, "Unexpected exception in request listener", t);
+ }
+ }
+ });
+ return new RemoteRequestContext() {
+ public void cancel(final boolean mayInterrupt) {
+ context.cancel(mayInterrupt);
+ }
+ };
+ }
+
+ void open() throws RemotingException {
+ try {
+ requestListener.handleClientOpen(clientContext);
+ addCloseHandler(new CloseHandler<RequestHandler>() {
+ public void handleClose(final RequestHandler closed) {
+ try {
+ requestListener.handleClientClose(clientContext);
+ } catch (Throwable t) {
+ log.error(t, "Unexpected exception in request listener client close handler method");
+ }
+ }
+ });
+ } catch (Throwable t) {
+ throw new RemotingException("Failed to open client context", t);
+ }
+ }
+
+ public String toString() {
+ return "local request handler <" + Integer.toString(hashCode(), 16) + "> (request listener = " + String.valueOf(requestListener) + ")";
+ }
+}
Copied: remoting3/trunk/core/src/main/java/org/jboss/cx/remoting/core/LocalRequestHandlerSource.java (from rev 4401, remoting3/trunk/core/src/main/java/org/jboss/cx/remoting/core/RemoteServiceEndpointLocalImpl.java)
===================================================================
--- remoting3/trunk/core/src/main/java/org/jboss/cx/remoting/core/LocalRequestHandlerSource.java (rev 0)
+++ remoting3/trunk/core/src/main/java/org/jboss/cx/remoting/core/LocalRequestHandlerSource.java 2008-07-21 16:52:29 UTC (rev 4418)
@@ -0,0 +1,87 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.cx.remoting.core;
+
+import org.jboss.cx.remoting.spi.remote.RequestHandlerSource;
+import org.jboss.cx.remoting.spi.remote.RequestHandler;
+import org.jboss.cx.remoting.spi.remote.Handle;
+import org.jboss.cx.remoting.spi.AbstractAutoCloseable;
+import org.jboss.cx.remoting.RequestListener;
+import org.jboss.cx.remoting.RemotingException;
+import org.jboss.cx.remoting.CloseHandler;
+import org.jboss.xnio.log.Logger;
+import java.util.concurrent.Executor;
+
+/**
+ *
+ */
+public final class LocalRequestHandlerSource<I, O> extends AbstractAutoCloseable<RequestHandlerSource> implements RequestHandlerSource {
+
+ private final RequestListener<I, O> requestListener;
+ private final ServiceContextImpl serviceContext;
+ private final Executor executor;
+
+ private static final Logger log = Logger.getLogger(LocalRequestHandlerSource.class);
+
+ LocalRequestHandlerSource(final Executor executor, final RequestListener<I, O> requestListener) {
+ super(executor);
+ this.requestListener = requestListener;
+ this.executor = executor;
+ serviceContext = new ServiceContextImpl(executor);
+ }
+
+ public Handle<RequestHandler> createRequestHandler() throws RemotingException {
+ if (isOpen()) {
+ final LocalRequestHandler<I, O> localRequestHandler = new LocalRequestHandler<I, O>(executor, this, requestListener);
+ localRequestHandler.open();
+ return localRequestHandler.getHandle();
+ } else {
+ throw new RemotingException("LocalRequestHandlerSource is closed");
+ }
+ }
+
+ void open() throws RemotingException {
+ try {
+ requestListener.handleServiceOpen(serviceContext);
+ addCloseHandler(new CloseHandler<RequestHandlerSource>() {
+ public void handleClose(final RequestHandlerSource closed) {
+ try {
+ requestListener.handleServiceClose(serviceContext);
+ } catch (Throwable t) {
+ log.error(t, "Unexpected exception in request listener client close handler method");
+ }
+ }
+ });
+ } catch (Throwable t) {
+ throw new RemotingException("Failed to open client context", t);
+ }
+ }
+
+ ServiceContextImpl getServiceContext() {
+ return serviceContext;
+ }
+
+ public String toString() {
+ return "local request handler source <" + Integer.toString(hashCode(), 16) + "> (request listener = " + String.valueOf(requestListener) + ")";
+ }
+}
Deleted: remoting3/trunk/core/src/main/java/org/jboss/cx/remoting/core/RemoteClientEndpointLocalImpl.java
===================================================================
--- remoting3/trunk/core/src/main/java/org/jboss/cx/remoting/core/RemoteClientEndpointLocalImpl.java 2008-07-21 16:29:04 UTC (rev 4417)
+++ remoting3/trunk/core/src/main/java/org/jboss/cx/remoting/core/RemoteClientEndpointLocalImpl.java 2008-07-21 16:52:29 UTC (rev 4418)
@@ -1,118 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2008, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-package org.jboss.cx.remoting.core;
-
-import org.jboss.cx.remoting.spi.remote.RemoteClientEndpoint;
-import org.jboss.cx.remoting.spi.remote.RemoteRequestContext;
-import org.jboss.cx.remoting.spi.remote.ReplyHandler;
-import org.jboss.cx.remoting.spi.SpiUtils;
-import org.jboss.cx.remoting.spi.AbstractAutoCloseable;
-import org.jboss.cx.remoting.RemotingException;
-import org.jboss.cx.remoting.RequestListener;
-import org.jboss.cx.remoting.RemoteExecutionException;
-import org.jboss.cx.remoting.CloseHandler;
-import org.jboss.xnio.log.Logger;
-import java.util.concurrent.Executor;
-
-/**
- *
- */
-public final class RemoteClientEndpointLocalImpl<I, O> extends AbstractAutoCloseable<RemoteClientEndpoint> implements RemoteClientEndpoint {
-
- private final RequestListener<I, O> requestListener;
- private final Executor executor;
- private final ClientContextImpl clientContext;
-
- private static final Logger log = Logger.getLogger(RemoteClientEndpointLocalImpl.class);
-
- private RemoteClientEndpointLocalImpl(final Executor executor, final RequestListener<I, O> requestListener, final ClientContextImpl clientContext) {
- super(executor);
- this.executor = executor;
- this.requestListener = requestListener;
- this.clientContext = clientContext;
- }
-
- RemoteClientEndpointLocalImpl(final Executor executor, final RemoteServiceEndpointLocalImpl<I, O> service, final RequestListener<I, O> requestListener) {
- this(executor, requestListener, new ClientContextImpl(service.getServiceContext()));
- }
-
- RemoteClientEndpointLocalImpl(final Executor executor, final RequestListener<I, O> requestListener) {
- this(executor, requestListener, new ClientContextImpl(executor));
- }
-
- public void receiveRequest(final Object request) {
- final RequestContextImpl<O> context = new RequestContextImpl<O>(clientContext);
- executor.execute(new Runnable() {
- @SuppressWarnings({ "unchecked" })
- public void run() {
- try {
- requestListener.handleRequest(context, (I) request);
- } catch (Throwable t) {
- log.error(t, "Unexpected exception in request listener");
- }
- }
- });
- }
-
- public RemoteRequestContext receiveRequest(final Object request, final ReplyHandler replyHandler) {
- final RequestContextImpl<O> context = new RequestContextImpl<O>(replyHandler, clientContext);
- executor.execute(new Runnable() {
- @SuppressWarnings({ "unchecked" })
- public void run() {
- try {
- requestListener.handleRequest(context, (I) request);
- } catch (RemoteExecutionException e) {
- SpiUtils.safeHandleException(replyHandler, e.getMessage(), e.getCause());
- } catch (Throwable t) {
- SpiUtils.safeHandleException(replyHandler, "Unexpected exception in request listener", t);
- }
- }
- });
- return new RemoteRequestContext() {
- public void cancel(final boolean mayInterrupt) {
- context.cancel(mayInterrupt);
- }
- };
- }
-
- void open() throws RemotingException {
- try {
- requestListener.handleClientOpen(clientContext);
- addCloseHandler(new CloseHandler<RemoteClientEndpoint>() {
- public void handleClose(final RemoteClientEndpoint closed) {
- try {
- requestListener.handleClientClose(clientContext);
- } catch (Throwable t) {
- log.error(t, "Unexpected exception in request listener client close handler method");
- }
- }
- });
- } catch (Throwable t) {
- throw new RemotingException("Failed to open client context", t);
- }
- }
-
- public String toString() {
- return "local client endpoint <" + Integer.toString(hashCode(), 16) + "> (request listener = " + String.valueOf(requestListener) + ")";
- }
-}
Deleted: remoting3/trunk/core/src/main/java/org/jboss/cx/remoting/core/RemoteServiceEndpointLocalImpl.java
===================================================================
--- remoting3/trunk/core/src/main/java/org/jboss/cx/remoting/core/RemoteServiceEndpointLocalImpl.java 2008-07-21 16:29:04 UTC (rev 4417)
+++ remoting3/trunk/core/src/main/java/org/jboss/cx/remoting/core/RemoteServiceEndpointLocalImpl.java 2008-07-21 16:52:29 UTC (rev 4418)
@@ -1,87 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2008, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-package org.jboss.cx.remoting.core;
-
-import org.jboss.cx.remoting.spi.remote.RemoteServiceEndpoint;
-import org.jboss.cx.remoting.spi.remote.RemoteClientEndpoint;
-import org.jboss.cx.remoting.spi.remote.Handle;
-import org.jboss.cx.remoting.spi.AbstractAutoCloseable;
-import org.jboss.cx.remoting.RequestListener;
-import org.jboss.cx.remoting.RemotingException;
-import org.jboss.cx.remoting.CloseHandler;
-import org.jboss.xnio.log.Logger;
-import java.util.concurrent.Executor;
-
-/**
- *
- */
-public final class RemoteServiceEndpointLocalImpl<I, O> extends AbstractAutoCloseable<RemoteServiceEndpoint> implements RemoteServiceEndpoint {
-
- private final RequestListener<I, O> requestListener;
- private final ServiceContextImpl serviceContext;
- private final Executor executor;
-
- private static final Logger log = Logger.getLogger(RemoteServiceEndpointLocalImpl.class);
-
- RemoteServiceEndpointLocalImpl(final Executor executor, final RequestListener<I, O> requestListener) {
- super(executor);
- this.requestListener = requestListener;
- this.executor = executor;
- serviceContext = new ServiceContextImpl(executor);
- }
-
- public Handle<RemoteClientEndpoint> createClientEndpoint() throws RemotingException {
- if (isOpen()) {
- final RemoteClientEndpointLocalImpl<I, O> clientEndpoint = new RemoteClientEndpointLocalImpl<I, O>(executor, this, requestListener);
- clientEndpoint.open();
- return clientEndpoint.getHandle();
- } else {
- throw new RemotingException("RemotingServiceEndpoint is closed");
- }
- }
-
- void open() throws RemotingException {
- try {
- requestListener.handleServiceOpen(serviceContext);
- addCloseHandler(new CloseHandler<RemoteServiceEndpoint>() {
- public void handleClose(final RemoteServiceEndpoint closed) {
- try {
- requestListener.handleServiceClose(serviceContext);
- } catch (Throwable t) {
- log.error(t, "Unexpected exception in request listener client close handler method");
- }
- }
- });
- } catch (Throwable t) {
- throw new RemotingException("Failed to open client context", t);
- }
- }
-
- ServiceContextImpl getServiceContext() {
- return serviceContext;
- }
-
- public String toString() {
- return "local service endpoint <" + Integer.toString(hashCode(), 16) + "> (request listener = " + String.valueOf(requestListener) + ")";
- }
-}
Modified: remoting3/trunk/core/src/test/java/org/jboss/cx/remoting/core/EndpointTestCase.java
===================================================================
--- remoting3/trunk/core/src/test/java/org/jboss/cx/remoting/core/EndpointTestCase.java 2008-07-21 16:29:04 UTC (rev 4417)
+++ remoting3/trunk/core/src/test/java/org/jboss/cx/remoting/core/EndpointTestCase.java 2008-07-21 16:52:29 UTC (rev 4418)
@@ -34,7 +34,7 @@
import org.jboss.cx.remoting.Client;
import org.jboss.cx.remoting.RemotingException;
import org.jboss.cx.remoting.test.support.LoggingHelper;
-import org.jboss.cx.remoting.spi.remote.RemoteClientEndpoint;
+import org.jboss.cx.remoting.spi.remote.RequestHandler;
import org.jboss.cx.remoting.spi.remote.Handle;
import org.jboss.xnio.IoUtils;
@@ -79,7 +79,7 @@
endpoint.setExecutor(executorService);
endpoint.start();
try {
- final Handle<RemoteClientEndpoint> handle = endpoint.createClientEndpoint(new AbstractRequestListener<Object, Object>() {
+ final Handle<RequestHandler> handle = endpoint.createRequestHandler(new AbstractRequestListener<Object, Object>() {
public void handleRequest(final RequestContext<Object> context, final Object request) throws RemoteExecutionException {
assertEquals(request, requestObj);
try {
@@ -93,14 +93,14 @@
}
}
});
- final RemoteClientEndpoint clientEndpoint = handle.getResource();
+ final RequestHandler requestHandler = handle.getResource();
try {
- clientEndpoint.addCloseHandler(new CloseHandler<RemoteClientEndpoint>() {
- public void handleClose(final RemoteClientEndpoint closed) {
+ requestHandler.addCloseHandler(new CloseHandler<RequestHandler>() {
+ public void handleClose(final RequestHandler closed) {
clientEndpointClosed.set(true);
}
});
- final Client<Object,Object> client = endpoint.createClient(clientEndpoint);
+ final Client<Object,Object> client = endpoint.createClient(requestHandler);
try {
client.addCloseHandler(new CloseHandler<Client<Object, Object>>() {
public void handleClose(final Client<Object, Object> closed) {
@@ -113,7 +113,7 @@
IoUtils.safeClose(client);
}
} finally {
- IoUtils.safeClose(clientEndpoint);
+ IoUtils.safeClose(requestHandler);
}
} finally {
safeStop(endpoint);
@@ -138,7 +138,7 @@
endpoint.setExecutor(executorService);
endpoint.start();
try {
- final Handle<RemoteClientEndpoint> handle = endpoint.createClientEndpoint(new AbstractRequestListener<Object, Object>() {
+ final Handle<RequestHandler> handle = endpoint.createRequestHandler(new AbstractRequestListener<Object, Object>() {
public void handleRequest(final RequestContext<Object> context, final Object request) throws RemoteExecutionException {
assertEquals(request, requestObj);
try {
@@ -152,14 +152,14 @@
}
}
});
- final RemoteClientEndpoint clientEndpoint = handle.getResource();
+ final RequestHandler requestHandler = handle.getResource();
try {
- clientEndpoint.addCloseHandler(new CloseHandler<RemoteClientEndpoint>() {
- public void handleClose(final RemoteClientEndpoint closed) {
+ requestHandler.addCloseHandler(new CloseHandler<RequestHandler>() {
+ public void handleClose(final RequestHandler closed) {
clientEndpointClosed.set(true);
}
});
- final Client<Object,Object> client = endpoint.createClient(clientEndpoint);
+ final Client<Object,Object> client = endpoint.createClient(requestHandler);
try {
client.addCloseHandler(new CloseHandler<Client<Object, Object>>() {
public void handleClose(final Client<Object, Object> closed) {
@@ -172,7 +172,7 @@
IoUtils.safeClose(client);
}
} finally {
- IoUtils.safeClose(clientEndpoint);
+ IoUtils.safeClose(requestHandler);
}
} finally {
safeStop(endpoint);
Modified: remoting3/trunk/protocol/basic/src/main/java/org/jboss/cx/remoting/protocol/basic/BasicHandler.java
===================================================================
--- remoting3/trunk/protocol/basic/src/main/java/org/jboss/cx/remoting/protocol/basic/BasicHandler.java 2008-07-21 16:29:04 UTC (rev 4417)
+++ remoting3/trunk/protocol/basic/src/main/java/org/jboss/cx/remoting/protocol/basic/BasicHandler.java 2008-07-21 16:52:29 UTC (rev 4418)
@@ -28,8 +28,8 @@
import org.jboss.xnio.IoUtils;
import org.jboss.xnio.log.Logger;
import static org.jboss.xnio.Buffers.*;
-import org.jboss.cx.remoting.spi.remote.RemoteClientEndpoint;
-import org.jboss.cx.remoting.spi.remote.RemoteServiceEndpoint;
+import org.jboss.cx.remoting.spi.remote.RequestHandler;
+import org.jboss.cx.remoting.spi.remote.RequestHandlerSource;
import org.jboss.cx.remoting.spi.remote.ReplyHandler;
import org.jboss.cx.remoting.spi.remote.RemoteRequestContext;
import org.jboss.cx.remoting.spi.remote.Handle;
@@ -74,11 +74,11 @@
private static final int LOCAL_VERSION = 1;
// clients whose requests get forwarded to the remote side
- private final ConcurrentMap<Integer, RemoteClientEndpoint> remoteClients = concurrentMap();
+ private final ConcurrentMap<Integer, RequestHandler> remoteClients = concurrentMap();
// running on remote node
private final ConcurrentMap<Integer, ReplyHandler> outstandingRequests = concurrentMap();
// forwarded to remote side (handled on this side)
- private final ConcurrentMap<Integer, Handle<RemoteClientEndpoint>> forwardedClients = concurrentMap();
+ private final ConcurrentMap<Integer, Handle<RequestHandler>> forwardedClients = concurrentMap();
private final ServiceRegistry registry;
@@ -101,7 +101,7 @@
this.allocator = allocator;
this.executor = executor;
this.registry = registry;
- final RemoteClientEndpointImpl endpoint = new RemoteClientEndpointImpl(0, allocator);
+ final RequestHandlerImpl endpoint = new RequestHandlerImpl(0, allocator);
remoteClients.put(Integer.valueOf(0), endpoint);
this.marshallerFactory = marshallerFactory;
// todo
@@ -189,7 +189,7 @@
}
case REQUEST_ONEWAY: {
final int clientId = buffer.getInt();
- final Handle<RemoteClientEndpoint> handle = getForwardedClient(clientId);
+ final Handle<RequestHandler> handle = getForwardedClient(clientId);
if (handle == null) {
log.trace("Request on invalid client ID %d", Integer.valueOf(clientId));
return;
@@ -206,13 +206,13 @@
log.trace("Class not found in one-way request for client ID %d", Integer.valueOf(clientId));
break;
}
- final RemoteClientEndpoint clientEndpoint = handle.getResource();
- clientEndpoint.receiveRequest(payload);
+ final RequestHandler requestHandler = handle.getResource();
+ requestHandler.receiveRequest(payload);
break;
}
case REQUEST: {
final int clientId = buffer.getInt();
- final Handle<RemoteClientEndpoint> handle = getForwardedClient(clientId);
+ final Handle<RequestHandler> handle = getForwardedClient(clientId);
if (handle == null) {
log.trace("Request on invalid client ID %d", Integer.valueOf(clientId));
break;
@@ -231,8 +231,8 @@
log.trace("Class not found in request ID %d for client ID %d", Integer.valueOf(requestId), Integer.valueOf(clientId));
break;
}
- final RemoteClientEndpoint clientEndpoint = handle.getResource();
- clientEndpoint.receiveRequest(payload, (ReplyHandler) new ReplyHandlerImpl(channel, requestId, allocator));
+ final RequestHandler requestHandler = handle.getResource();
+ requestHandler.receiveRequest(payload, (ReplyHandler) new ReplyHandlerImpl(channel, requestId, allocator));
break;
}
case REPLY: {
@@ -293,7 +293,7 @@
}
case CLIENT_CLOSE: {
final int clientId = buffer.getInt();
- final Handle<RemoteClientEndpoint> handle = takeForwardedClient(clientId);
+ final Handle<RequestHandler> handle = takeForwardedClient(clientId);
if (handle == null) {
log.warn("Got client close message for unknown client %d", Integer.valueOf(clientId));
break;
@@ -304,14 +304,14 @@
case CLIENT_OPEN: {
final int serviceId = buffer.getInt();
final int clientId = buffer.getInt();
- final Handle<RemoteServiceEndpoint> handle = registry.lookup(serviceId);
+ final Handle<RequestHandlerSource> handle = registry.lookup(serviceId);
if (handle == null) {
log.warn("Received client open message for unknown service %d", Integer.valueOf(serviceId));
break;
}
try {
- final RemoteServiceEndpoint serviceEndpoint = handle.getResource();
- final Handle<RemoteClientEndpoint> clientHandle = serviceEndpoint.createClientEndpoint();
+ final RequestHandlerSource requestHandlerSource = handle.getResource();
+ final Handle<RequestHandler> clientHandle = requestHandlerSource.createRequestHandler();
// todo check for duplicate
// todo validate the client ID
log.trace("Opening client %d from service %d", Integer.valueOf(clientId), Integer.valueOf(serviceId));
@@ -370,12 +370,12 @@
public void handleClosed(final AllocatedMessageChannel channel) {
}
- RemoteClientEndpoint getRemoteClient(final int i) {
+ RequestHandler getRemoteClient(final int i) {
return remoteClients.get(Integer.valueOf(i));
}
- RemoteServiceEndpoint getRemoteService(final int id) {
- return new RemoteServiceEndpointImpl(allocator, id);
+ RequestHandlerSource getRemoteService(final int id) {
+ return new RequestHandlerSourceImpl(allocator, id);
}
private final class ReplyHandlerImpl implements ReplyHandler {
@@ -473,11 +473,11 @@
int id;
do {
id = remoteClientIdSeq.getAndIncrement() << 1 | (server ? 1 : 0);
- } while (remoteClients.putIfAbsent(Integer.valueOf(id), new RemoteClientEndpointImpl(id, allocator)) != null);
+ } while (remoteClients.putIfAbsent(Integer.valueOf(id), new RequestHandlerImpl(id, allocator)) != null);
return id;
}
- public void openClientForForwardedService(int id, RemoteClientEndpoint clientEndpoint) {
+ public void openClientForForwardedService(int id, RequestHandler clientEndpoint) {
try {
forwardedClients.put(Integer.valueOf(id), clientEndpoint.getHandle());
} catch (RemotingException e) {
@@ -486,11 +486,11 @@
}
}
- public Handle<RemoteClientEndpoint> getForwardedClient(int id) {
+ public Handle<RequestHandler> getForwardedClient(int id) {
return forwardedClients.get(Integer.valueOf(id));
}
- private Handle<RemoteClientEndpoint> takeForwardedClient(final int id) {
+ private Handle<RequestHandler> takeForwardedClient(final int id) {
return forwardedClients.remove(Integer.valueOf(id));
}
@@ -604,20 +604,20 @@
// client endpoint
- private final class RemoteClientEndpointImpl extends AbstractAutoCloseable<RemoteClientEndpoint> implements RemoteClientEndpoint {
+ private final class RequestHandlerImpl extends AbstractAutoCloseable<RequestHandler> implements RequestHandler {
private final int identifier;
private final BufferAllocator<ByteBuffer> allocator;
- public RemoteClientEndpointImpl(final int identifier, final BufferAllocator<ByteBuffer> allocator) {
+ public RequestHandlerImpl(final int identifier, final BufferAllocator<ByteBuffer> allocator) {
super(executor);
if (allocator == null) {
throw new NullPointerException("allocator is null");
}
this.identifier = identifier;
this.allocator = allocator;
- addCloseHandler(new CloseHandler<RemoteClientEndpoint>() {
- public void handleClose(final RemoteClientEndpoint closed) {
+ addCloseHandler(new CloseHandler<RequestHandler>() {
+ public void handleClose(final RequestHandler closed) {
ByteBuffer buffer = allocator.allocate();
buffer.put((byte) MessageType.CLIENT_CLOSE);
buffer.putInt(identifier);
@@ -692,7 +692,7 @@
}
public String toString() {
- return "forwarded client endpoint <" + Integer.toString(hashCode(), 16) + "> (id = " + identifier + ")";
+ return "forwarding request handler <" + Integer.toString(hashCode(), 16) + "> (id = " + identifier + ")";
}
}
@@ -725,17 +725,17 @@
}
}
- public final class RemoteServiceEndpointImpl extends AbstractAutoCloseable<RemoteServiceEndpoint> implements RemoteServiceEndpoint {
+ public final class RequestHandlerSourceImpl extends AbstractAutoCloseable<RequestHandlerSource> implements RequestHandlerSource {
private final BufferAllocator<ByteBuffer> allocator;
private final int identifier;
- protected RemoteServiceEndpointImpl(final BufferAllocator<ByteBuffer> allocator, final int identifier) {
+ protected RequestHandlerSourceImpl(final BufferAllocator<ByteBuffer> allocator, final int identifier) {
super(executor);
this.allocator = allocator;
this.identifier = identifier;
- addCloseHandler(new CloseHandler<RemoteServiceEndpoint>() {
- public void handleClose(final RemoteServiceEndpoint closed) {
+ addCloseHandler(new CloseHandler<RequestHandlerSource>() {
+ public void handleClose(final RequestHandlerSource closed) {
ByteBuffer buffer = allocator.allocate();
buffer.put((byte) MessageType.SERVICE_CLOSE);
buffer.putInt(identifier);
@@ -749,7 +749,7 @@
});
}
- public Handle<RemoteClientEndpoint> createClientEndpoint() throws RemotingException {
+ public Handle<RequestHandler> createRequestHandler() throws RemotingException {
final int clientId = openClientFromService();
final ByteBuffer buffer = allocator.allocate();
buffer.put((byte) MessageType.CLIENT_OPEN);
@@ -762,7 +762,7 @@
try {
registerWriter(channel, new SimpleWriteHandler(allocator, buffer));
try {
- return new RemoteClientEndpointImpl(clientId, allocator).getHandle();
+ return new RequestHandlerImpl(clientId, allocator).getHandle();
} finally {
if (intr) {
Thread.currentThread().interrupt();
@@ -775,7 +775,7 @@
}
public String toString() {
- return "forwarded service endpoint <" + Integer.toString(hashCode(), 16) + "> (id = " + identifier + ")";
+ return "forwarding request handler source <" + Integer.toString(hashCode(), 16) + "> (id = " + identifier + ")";
}
}
}
Modified: remoting3/trunk/protocol/basic/src/main/java/org/jboss/cx/remoting/protocol/basic/BasicProtocol.java
===================================================================
--- remoting3/trunk/protocol/basic/src/main/java/org/jboss/cx/remoting/protocol/basic/BasicProtocol.java 2008-07-21 16:29:04 UTC (rev 4417)
+++ remoting3/trunk/protocol/basic/src/main/java/org/jboss/cx/remoting/protocol/basic/BasicProtocol.java 2008-07-21 16:52:29 UTC (rev 4418)
@@ -23,7 +23,7 @@
package org.jboss.cx.remoting.protocol.basic;
import org.jboss.cx.remoting.RemotingException;
-import org.jboss.cx.remoting.spi.remote.RemoteServiceEndpoint;
+import org.jboss.cx.remoting.spi.remote.RequestHandlerSource;
import org.jboss.cx.remoting.spi.remote.Handle;
import org.jboss.cx.remoting.core.marshal.JavaSerializationMarshallerFactory;
import org.jboss.xnio.IoHandlerFactory;
@@ -79,7 +79,7 @@
return new AbstractConvertingIoFuture<Connection, AllocatedMessageChannel>(futureChannel) {
protected Connection convert(final AllocatedMessageChannel channel) throws RemotingException {
return new AbstractConnection(executor) {
- public Handle<RemoteServiceEndpoint> getServiceForId(final int id) throws RemotingException {
+ public Handle<RequestHandlerSource> getServiceForId(final int id) throws RemotingException {
return basicHandler.getRemoteService(id).getHandle();
}
};
Modified: remoting3/trunk/protocol/basic/src/main/java/org/jboss/cx/remoting/protocol/basic/Connection.java
===================================================================
--- remoting3/trunk/protocol/basic/src/main/java/org/jboss/cx/remoting/protocol/basic/Connection.java 2008-07-21 16:29:04 UTC (rev 4417)
+++ remoting3/trunk/protocol/basic/src/main/java/org/jboss/cx/remoting/protocol/basic/Connection.java 2008-07-21 16:52:29 UTC (rev 4418)
@@ -22,7 +22,7 @@
package org.jboss.cx.remoting.protocol.basic;
-import org.jboss.cx.remoting.spi.remote.RemoteServiceEndpoint;
+import org.jboss.cx.remoting.spi.remote.RequestHandlerSource;
import org.jboss.cx.remoting.spi.remote.Handle;
import org.jboss.cx.remoting.Closeable;
import org.jboss.cx.remoting.RemotingException;
@@ -31,5 +31,5 @@
*
*/
public interface Connection extends Closeable<Connection> {
- Handle<RemoteServiceEndpoint> getServiceForId(int id) throws RemotingException;
+ Handle<RequestHandlerSource> getServiceForId(int id) throws RemotingException;
}
Modified: remoting3/trunk/protocol/basic/src/main/java/org/jboss/cx/remoting/protocol/basic/ServiceRegistry.java
===================================================================
--- remoting3/trunk/protocol/basic/src/main/java/org/jboss/cx/remoting/protocol/basic/ServiceRegistry.java 2008-07-21 16:29:04 UTC (rev 4417)
+++ remoting3/trunk/protocol/basic/src/main/java/org/jboss/cx/remoting/protocol/basic/ServiceRegistry.java 2008-07-21 16:52:29 UTC (rev 4418)
@@ -22,7 +22,7 @@
package org.jboss.cx.remoting.protocol.basic;
-import org.jboss.cx.remoting.spi.remote.RemoteServiceEndpoint;
+import org.jboss.cx.remoting.spi.remote.RequestHandlerSource;
import org.jboss.cx.remoting.spi.remote.Handle;
import org.jboss.cx.remoting.RemotingException;
@@ -30,13 +30,13 @@
*
*/
public interface ServiceRegistry {
- int bind(RemoteServiceEndpoint remoteServiceEndpoint) throws RemotingException;
+ int bind(RequestHandlerSource requestHandlerSource) throws RemotingException;
- void bind(RemoteServiceEndpoint remoteServiceEndpoint, int id) throws RemotingException;
+ void bind(RequestHandlerSource requestHandlerSource, int id) throws RemotingException;
void unbind(int id) throws RemotingException;
void clear();
- Handle<RemoteServiceEndpoint> lookup(int id) throws RemotingException;
+ Handle<RequestHandlerSource> lookup(int id) throws RemotingException;
}
Modified: remoting3/trunk/protocol/basic/src/main/java/org/jboss/cx/remoting/protocol/basic/ServiceRegistryImpl.java
===================================================================
--- remoting3/trunk/protocol/basic/src/main/java/org/jboss/cx/remoting/protocol/basic/ServiceRegistryImpl.java 2008-07-21 16:29:04 UTC (rev 4417)
+++ remoting3/trunk/protocol/basic/src/main/java/org/jboss/cx/remoting/protocol/basic/ServiceRegistryImpl.java 2008-07-21 16:52:29 UTC (rev 4418)
@@ -22,7 +22,7 @@
package org.jboss.cx.remoting.protocol.basic;
-import org.jboss.cx.remoting.spi.remote.RemoteServiceEndpoint;
+import org.jboss.cx.remoting.spi.remote.RequestHandlerSource;
import org.jboss.cx.remoting.spi.remote.Handle;
import org.jboss.cx.remoting.RemotingException;
import org.jboss.cx.remoting.util.CollectionUtil;
@@ -38,7 +38,7 @@
private static final int START = 32768;
- private final ConcurrentMap<Integer, Handle<RemoteServiceEndpoint>> map = CollectionUtil.concurrentMap();
+ private final ConcurrentMap<Integer, Handle<RequestHandlerSource>> map = CollectionUtil.concurrentMap();
private final AtomicInteger dynamicSequence = new AtomicInteger(START);
private final ServiceRegistry parent;
@@ -50,8 +50,8 @@
parent = null;
}
- public int bind(final RemoteServiceEndpoint remoteServiceEndpoint) throws RemotingException {
- final Handle<RemoteServiceEndpoint> handle = remoteServiceEndpoint.getHandle();
+ public int bind(final RequestHandlerSource requestHandlerSource) throws RemotingException {
+ final Handle<RequestHandlerSource> handle = requestHandlerSource.getHandle();
boolean ok = false;
try {
for (;;) {
@@ -72,8 +72,8 @@
}
}
- public void bind(final RemoteServiceEndpoint remoteServiceEndpoint, final int id) throws RemotingException {
- final Handle<RemoteServiceEndpoint> handle = remoteServiceEndpoint.getHandle();
+ public void bind(final RequestHandlerSource requestHandlerSource, final int id) throws RemotingException {
+ final Handle<RequestHandlerSource> handle = requestHandlerSource.getHandle();
boolean ok = false;
try {
if (map.putIfAbsent(Integer.valueOf(id), handle) != null) {
@@ -92,15 +92,15 @@
}
public void clear() {
- Iterator<Handle<RemoteServiceEndpoint>> it = map.values().iterator();
+ Iterator<Handle<RequestHandlerSource>> it = map.values().iterator();
while (it.hasNext()) {
IoUtils.safeClose(it.next());
it.remove();
}
}
- public Handle<RemoteServiceEndpoint> lookup(final int id) throws RemotingException {
- final Handle<RemoteServiceEndpoint> handle = map.get(Integer.valueOf(id));
+ public Handle<RequestHandlerSource> lookup(final int id) throws RemotingException {
+ final Handle<RequestHandlerSource> handle = map.get(Integer.valueOf(id));
return handle != null || parent == null ? handle.getResource().getHandle() : parent.lookup(id);
}
Modified: remoting3/trunk/protocol/basic/src/test/java/org/jboss/cx/remoting/protocol/basic/ConnectionTestCase.java
===================================================================
--- remoting3/trunk/protocol/basic/src/test/java/org/jboss/cx/remoting/protocol/basic/ConnectionTestCase.java 2008-07-21 16:29:04 UTC (rev 4417)
+++ remoting3/trunk/protocol/basic/src/test/java/org/jboss/cx/remoting/protocol/basic/ConnectionTestCase.java 2008-07-21 16:52:29 UTC (rev 4418)
@@ -40,7 +40,7 @@
import org.jboss.cx.remoting.RemotingException;
import org.jboss.cx.remoting.FutureReply;
import org.jboss.cx.remoting.AbstractRequestListener;
-import org.jboss.cx.remoting.spi.remote.RemoteServiceEndpoint;
+import org.jboss.cx.remoting.spi.remote.RequestHandlerSource;
import org.jboss.cx.remoting.spi.remote.Handle;
import org.jboss.xnio.BufferAllocator;
import org.jboss.xnio.IoUtils;
@@ -85,7 +85,7 @@
try {
final ServiceRegistry serviceRegistry = new ServiceRegistryImpl();
try {
- final Handle<RemoteServiceEndpoint> serviceEndpointHandle = endpoint.createServiceEndpoint(new AbstractRequestListener<Object, Object>() {
+ final Handle<RequestHandlerSource> requestHandlerSourceHandle = endpoint.createRequestHandlerSource(new AbstractRequestListener<Object, Object>() {
public void handleRequest(final RequestContext<Object> context, final Object request) throws RemoteExecutionException {
try {
context.sendReply(REPLY);
@@ -95,7 +95,7 @@
}
});
try {
- serviceRegistry.bind(serviceEndpointHandle.getResource(), 13);
+ serviceRegistry.bind(requestHandlerSourceHandle.getResource(), 13);
final IoHandlerFactory<AllocatedMessageChannel> handlerFactory = BasicProtocol.createServer(closeableExecutor, allocator, serviceRegistry);
final IoHandlerFactory<StreamChannel> newHandlerFactory = Channels.convertStreamToAllocatedMessage(handlerFactory, 32768, 32768);
final Closeable tcpServerCloseable = xnio.createTcpServer(newHandlerFactory, new InetSocketAddress(12345)).create();
@@ -107,7 +107,7 @@
final IoFuture<Connection> futureCloseable = BasicProtocol.connect(closeableExecutor, channelSource, allocator, serviceRegistry);
final Connection connection = futureCloseable.get();
try {
- final Handle<RemoteServiceEndpoint> handleThirteen = connection.getServiceForId(13);
+ final Handle<RequestHandlerSource> handleThirteen = connection.getServiceForId(13);
try {
final ClientSource<Object,Object> clientSource = endpoint.createClientSource(handleThirteen.getResource());
try {
@@ -121,7 +121,7 @@
connection.close();
connector.close();
tcpServerCloseable.close();
- serviceEndpointHandle.close();
+ requestHandlerSourceHandle.close();
serviceRegistry.clear();
endpoint.stop();
xnio.close();
@@ -145,7 +145,7 @@
IoUtils.safeClose(tcpServerCloseable);
}
} finally {
- IoUtils.safeClose(serviceEndpointHandle);
+ IoUtils.safeClose(requestHandlerSourceHandle);
}
} finally {
serviceRegistry.clear();
Modified: remoting3/trunk/standalone/src/main/java/org/jboss/cx/remoting/Remoting.java
===================================================================
--- remoting3/trunk/standalone/src/main/java/org/jboss/cx/remoting/Remoting.java 2008-07-21 16:29:04 UTC (rev 4417)
+++ remoting3/trunk/standalone/src/main/java/org/jboss/cx/remoting/Remoting.java 2008-07-21 16:52:29 UTC (rev 4418)
@@ -2,8 +2,8 @@
import java.io.IOException;
import org.jboss.cx.remoting.core.EndpointImpl;
-import org.jboss.cx.remoting.spi.remote.RemoteClientEndpoint;
-import org.jboss.cx.remoting.spi.remote.RemoteServiceEndpoint;
+import org.jboss.cx.remoting.spi.remote.RequestHandler;
+import org.jboss.cx.remoting.spi.remote.RequestHandlerSource;
import org.jboss.cx.remoting.spi.remote.Handle;
import org.jboss.xnio.IoUtils;
@@ -33,7 +33,7 @@
}
public static <I, O> Client<I, O> createLocalClient(Endpoint endpoint, RequestListener<I, O> requestListener) throws RemotingException {
- final Handle<RemoteClientEndpoint> handle = endpoint.createClientEndpoint(requestListener);
+ final Handle<RequestHandler> handle = endpoint.createRequestHandler(requestListener);
try {
return endpoint.createClient(handle.getResource());
} finally {
@@ -42,7 +42,7 @@
}
public static <I, O> ClientSource<I, O> createLocalClientSource(Endpoint endpoint, RequestListener<I, O> requestListener) throws RemotingException {
- final Handle<RemoteServiceEndpoint> handle = endpoint.createServiceEndpoint(requestListener);
+ final Handle<RequestHandlerSource> handle = endpoint.createRequestHandlerSource(requestListener);
try {
return endpoint.createClientSource(handle.getResource());
} finally {
16 years, 5 months
JBoss Remoting SVN: r4417 - in remoting3/trunk: util/src/main/java/org/jboss/cx/remoting/util and 1 other directory.
by jboss-remoting-commits@lists.jboss.org
Author: david.lloyd(a)jboss.com
Date: 2008-07-21 12:29:04 -0400 (Mon, 21 Jul 2008)
New Revision: 4417
Modified:
remoting3/trunk/protocol/basic/src/main/java/org/jboss/cx/remoting/protocol/basic/BasicHandler.java
remoting3/trunk/protocol/basic/src/main/java/org/jboss/cx/remoting/protocol/basic/MessageType.java
remoting3/trunk/util/src/main/java/org/jboss/cx/remoting/util/CollectionUtil.java
Log:
Add a VERSION message for protocol forward compatibility
Modified: remoting3/trunk/protocol/basic/src/main/java/org/jboss/cx/remoting/protocol/basic/BasicHandler.java
===================================================================
--- remoting3/trunk/protocol/basic/src/main/java/org/jboss/cx/remoting/protocol/basic/BasicHandler.java 2008-07-21 14:10:27 UTC (rev 4416)
+++ remoting3/trunk/protocol/basic/src/main/java/org/jboss/cx/remoting/protocol/basic/BasicHandler.java 2008-07-21 16:29:04 UTC (rev 4417)
@@ -50,6 +50,7 @@
import static org.jboss.cx.remoting.protocol.basic.MessageType.SERVICE_CLOSE;
import static org.jboss.cx.remoting.protocol.basic.MessageType.REQUEST_FAILED;
import static org.jboss.cx.remoting.protocol.basic.MessageType.CANCEL_ACK;
+import static org.jboss.cx.remoting.protocol.basic.MessageType.VERSION;
import org.jboss.cx.remoting.RemotingException;
import org.jboss.cx.remoting.CloseHandler;
import java.util.concurrent.ConcurrentMap;
@@ -59,6 +60,7 @@
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.List;
import java.util.ArrayList;
+import java.util.Collections;
import java.nio.ByteBuffer;
import java.nio.BufferUnderflowException;
import java.io.IOException;
@@ -69,6 +71,7 @@
public final class BasicHandler implements IoHandler<AllocatedMessageChannel> {
private static final Logger log = Logger.getLogger(BasicHandler.class);
+ private static final int LOCAL_VERSION = 1;
// clients whose requests get forwarded to the remote side
private final ConcurrentMap<Integer, RemoteClientEndpoint> remoteClients = concurrentMap();
@@ -84,10 +87,14 @@
private final AtomicBoolean isnew = new AtomicBoolean(true);
private volatile AllocatedMessageChannel channel;
+ private volatile int remoteVersion;
private final Executor executor;
private final MarshallerFactory<ByteBuffer> marshallerFactory;
private final ObjectResolver resolver;
private final ClassLoader classLoader;
+ private List<String> localMarshallerList = Collections.singletonList("java-serialization");
+ private volatile String marshallerType;
+ private final AtomicBoolean initialized = new AtomicBoolean(false);
public BasicHandler(final boolean server, final BufferAllocator<ByteBuffer> allocator, final Executor executor, final MarshallerFactory<ByteBuffer> marshallerFactory, final ServiceRegistry registry) {
this.server = server;
@@ -119,6 +126,19 @@
if (isnew.getAndSet(false)) {
this.channel = channel;
}
+ final ByteBuffer buffer = allocator.allocate();
+ buffer.put((byte) VERSION);
+ buffer.putInt(LOCAL_VERSION);
+ writeUTFZ(buffer, CollectionUtil.join(",", localMarshallerList));
+ buffer.flip();
+ try {
+ registerWriter(channel, new SimpleWriteHandler(allocator, buffer));
+ } catch (InterruptedException e) {
+ log.error("Interrupted while sending intial version message");
+ IoUtils.safeClose(channel);
+ Thread.currentThread().interrupt();
+ return;
+ }
channel.resumeReads();
}
@@ -136,8 +156,37 @@
return;
}
int msgType = buffer.get() & 0xff;
+ if (initialized.getAndSet(true) != (msgType != 0)) {
+ log.error("Expected a version message; closing connection");
+ IoUtils.safeClose(channel);
+ return;
+ }
log.trace("Received message %s, type %d", buffer, Integer.valueOf(msgType));
switch (msgType) {
+ case VERSION: {
+ // participants always choose the lowest version number
+ // since we only support one version (0), we don't do anything with the value
+ buffer.getInt();
+ // Select the client's most preferred marshaling method that the server supports
+ final String marshallerList = readUTFZ(buffer);
+ final Iterable<String> remoteMarshallerList = CollectionUtil.split(",", marshallerList);
+ final Iterable<String> clientList = server ? remoteMarshallerList : localMarshallerList;
+ final Iterable<String> serverList = server ? localMarshallerList : remoteMarshallerList;
+ for (final String clientSuggestion : clientList) {
+ for (final String serverSuggestion : serverList) {
+ if (clientSuggestion.equals(serverSuggestion)) {
+ marshallerType = clientSuggestion;
+ log.trace("Chose marshaller type '%s'", marshallerType);
+ }
+ }
+ }
+ if (marshallerType == null) {
+ log.error("Could not agree on a marshaller type; closing connection");
+ IoUtils.safeClose(channel);
+ return;
+ }
+ break;
+ }
case REQUEST_ONEWAY: {
final int clientId = buffer.getInt();
final Handle<RemoteClientEndpoint> handle = getForwardedClient(clientId);
@@ -286,6 +335,11 @@
return;
} catch (BufferUnderflowException e) {
log.error(e, "Malformed packet");
+// } catch (InterruptedException e) {
+// log.error(e, "Read thread interrupted, closing channel");
+// IoUtils.safeClose(channel);
+// Thread.currentThread().interrupt();
+// return;
} catch (Throwable t) {
log.error(t, "Handler failed");
}
@@ -456,6 +510,98 @@
}
}
+ private int writeUTFZ(ByteBuffer buffer, CharSequence s) {
+ final int len = s.length();
+ for (int i = 0; i < len; i++) {
+ char c = s.charAt(i);
+ if (1 <= c && c < 0x80) {
+ if (buffer.hasRemaining()) {
+ buffer.put((byte) c);
+ } else {
+ return i;
+ }
+ } else if (c < 0x0800) {
+ if (buffer.remaining() >= 2) {
+ buffer.put((byte) (0xc0 | (c >> 6)));
+ buffer.put((byte) (0x80 | (c & 0x3f)));
+ } else {
+ return i;
+ }
+ } else {
+ if (buffer.remaining() >= 3) {
+ buffer.put((byte) (0xe0 | (c >> 12)));
+ buffer.put((byte) (0x80 | ((c >> 6) & 0x3f)));
+ buffer.put((byte) (0x80 | (c & 0x3f)));
+ } else {
+ return i;
+ }
+ }
+ }
+ if (buffer.hasRemaining()) {
+ buffer.put((byte) 0);
+ return -1;
+ } else {
+ return len;
+ }
+ }
+
+ // Reader utils
+
+ private String readUTFZ(ByteBuffer buffer) {
+ StringBuilder builder = new StringBuilder();
+ int state = 0, a = 0;
+ while (buffer.hasRemaining()) {
+ final int v = buffer.get() & 0xff;
+ switch (state) {
+ case 0: {
+ if (v == 0) {
+ return builder.toString();
+ } else if (v < 128) {
+ builder.append((char) v);
+ } else if (192 <= v && v < 224) {
+ a = v << 6;
+ state = 1;
+ } else if (224 <= v && v < 232) {
+ a = v << 12;
+ state = 2;
+ } else {
+ builder.append('?');
+ }
+ break;
+ }
+ case 1: {
+ if (v == 0) {
+ builder.append('?');
+ return builder.toString();
+ } else if (128 <= v && v < 192) {
+ a |= v & 0x3f;
+ builder.append((char) a);
+ } else {
+ builder.append('?');
+ }
+ state = 0;
+ break;
+ }
+ case 2: {
+ if (v == 0) {
+ builder.append('?');
+ return builder.toString();
+ } else if (128 <= v && v < 192) {
+ a |= (v & 0x3f) << 6;
+ state = 1;
+ } else {
+ builder.append('?');
+ state = 0;
+ }
+ break;
+ }
+ default:
+ throw new IllegalStateException("wrong state");
+ }
+ }
+ return builder.toString();
+ }
+
// client endpoint
private final class RemoteClientEndpointImpl extends AbstractAutoCloseable<RemoteClientEndpoint> implements RemoteClientEndpoint {
Modified: remoting3/trunk/protocol/basic/src/main/java/org/jboss/cx/remoting/protocol/basic/MessageType.java
===================================================================
--- remoting3/trunk/protocol/basic/src/main/java/org/jboss/cx/remoting/protocol/basic/MessageType.java 2008-07-21 14:10:27 UTC (rev 4416)
+++ remoting3/trunk/protocol/basic/src/main/java/org/jboss/cx/remoting/protocol/basic/MessageType.java 2008-07-21 16:29:04 UTC (rev 4417)
@@ -26,18 +26,18 @@
*
*/
public final class MessageType {
- //
- public static final int REQUEST_ONEWAY = 0;
- public static final int REQUEST = 1;
- public static final int REPLY = 2;
- public static final int CANCEL_REQUEST = 3;
- public static final int CANCEL_ACK = 4;
- public static final int REQUEST_FAILED = 5;
+ public static final int VERSION = 0;
+ public static final int REQUEST_ONEWAY = 1;
+ public static final int REQUEST = 2;
+ public static final int REPLY = 3;
+ public static final int CANCEL_REQUEST = 4;
+ public static final int CANCEL_ACK = 5;
+ public static final int REQUEST_FAILED = 6;
// Remote side called .close() on a forwarded RemoteClientEndpoint
- public static final int CLIENT_CLOSE = 6;
+ public static final int CLIENT_CLOSE = 7;
// Remote side called .close() on a forwarded RemoteClientEndpoint
- public static final int CLIENT_OPEN = 7;
- public static final int SERVICE_CLOSE = 8;
+ public static final int CLIENT_OPEN = 8;
+ public static final int SERVICE_CLOSE = 9;
private MessageType() {
}
Modified: remoting3/trunk/util/src/main/java/org/jboss/cx/remoting/util/CollectionUtil.java
===================================================================
--- remoting3/trunk/util/src/main/java/org/jboss/cx/remoting/util/CollectionUtil.java 2008-07-21 14:10:27 UTC (rev 4416)
+++ remoting3/trunk/util/src/main/java/org/jboss/cx/remoting/util/CollectionUtil.java 2008-07-21 16:29:04 UTC (rev 4417)
@@ -395,6 +395,26 @@
};
}
+ /**
+ * Join a series of character sequences using a delimiter.
+ *
+ * @param delimiter the delimiter
+ * @param strings the strings
+ * @return a joined string
+ */
+ public static String join(final CharSequence delimiter, final Iterable<? extends CharSequence> strings) {
+ StringBuilder builder = new StringBuilder();
+ Iterator<? extends CharSequence> it = strings.iterator();
+ while (it.hasNext()) {
+ CharSequence s = it.next();
+ builder.append(s);
+ if (it.hasNext()) {
+ builder.append(delimiter);
+ }
+ }
+ return builder.toString();
+ }
+
@SuppressWarnings({ "unchecked" })
private static <T> T[] unroll(final Iterator<? extends T> iterator, final Class<T> type, final int c) {
if (iterator.hasNext()) {
16 years, 5 months
JBoss Remoting SVN: r4416 - remoting3/trunk/protocol/basic/src/test/java/org/jboss/cx/remoting/protocol/basic.
by jboss-remoting-commits@lists.jboss.org
Author: david.lloyd(a)jboss.com
Date: 2008-07-21 10:10:27 -0400 (Mon, 21 Jul 2008)
New Revision: 4416
Modified:
remoting3/trunk/protocol/basic/src/test/java/org/jboss/cx/remoting/protocol/basic/ConnectionTestCase.java
Log:
Organize for readability
Modified: remoting3/trunk/protocol/basic/src/test/java/org/jboss/cx/remoting/protocol/basic/ConnectionTestCase.java
===================================================================
--- remoting3/trunk/protocol/basic/src/test/java/org/jboss/cx/remoting/protocol/basic/ConnectionTestCase.java 2008-07-21 13:16:30 UTC (rev 4415)
+++ remoting3/trunk/protocol/basic/src/test/java/org/jboss/cx/remoting/protocol/basic/ConnectionTestCase.java 2008-07-21 14:10:27 UTC (rev 4416)
@@ -26,7 +26,6 @@
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
-import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
import java.net.InetSocketAddress;
@@ -47,7 +46,6 @@
import org.jboss.xnio.IoUtils;
import org.jboss.xnio.Xnio;
import org.jboss.xnio.IoHandlerFactory;
-import org.jboss.xnio.ConfigurableFactory;
import org.jboss.xnio.IoFuture;
import org.jboss.xnio.TcpClient;
import org.jboss.xnio.ChannelSource;
@@ -100,11 +98,9 @@
serviceRegistry.bind(serviceEndpointHandle.getResource(), 13);
final IoHandlerFactory<AllocatedMessageChannel> handlerFactory = BasicProtocol.createServer(closeableExecutor, allocator, serviceRegistry);
final IoHandlerFactory<StreamChannel> newHandlerFactory = Channels.convertStreamToAllocatedMessage(handlerFactory, 32768, 32768);
- final ConfigurableFactory<Closeable> tcpServerFactory = xnio.createTcpServer(newHandlerFactory, new InetSocketAddress(12345));
- final Closeable tcpServerCloseable = tcpServerFactory.create();
+ final Closeable tcpServerCloseable = xnio.createTcpServer(newHandlerFactory, new InetSocketAddress(12345)).create();
try {
- final ConfigurableFactory<CloseableTcpConnector> connectorFactory = xnio.createTcpConnector();
- final CloseableTcpConnector connector = connectorFactory.create();
+ final CloseableTcpConnector connector = xnio.createTcpConnector().create();
try {
final TcpClient tcpClient = connector.createChannelSource(new InetSocketAddress("localhost", 12345));
final ChannelSource<AllocatedMessageChannel> channelSource = Channels.convertStreamToAllocatedMessage(tcpClient, 32768, 32768);
@@ -113,8 +109,7 @@
try {
final Handle<RemoteServiceEndpoint> handleThirteen = connection.getServiceForId(13);
try {
- final RemoteServiceEndpoint serviceThirteen = handleThirteen.getResource();
- final ClientSource<Object,Object> clientSource = endpoint.createClientSource(serviceThirteen);
+ final ClientSource<Object,Object> clientSource = endpoint.createClientSource(handleThirteen.getResource());
try {
final Client<Object,Object> client = clientSource.createClient();
try {
16 years, 5 months
JBoss Remoting SVN: r4415 - remoting3/trunk/protocol/basic/src/test/java/org/jboss/cx/remoting/protocol/basic.
by jboss-remoting-commits@lists.jboss.org
Author: david.lloyd(a)jboss.com
Date: 2008-07-21 09:16:30 -0400 (Mon, 21 Jul 2008)
New Revision: 4415
Modified:
remoting3/trunk/protocol/basic/src/test/java/org/jboss/cx/remoting/protocol/basic/ConnectionTestCase.java
Log:
Make successful close part of the test
Modified: remoting3/trunk/protocol/basic/src/test/java/org/jboss/cx/remoting/protocol/basic/ConnectionTestCase.java
===================================================================
--- remoting3/trunk/protocol/basic/src/test/java/org/jboss/cx/remoting/protocol/basic/ConnectionTestCase.java 2008-07-21 13:01:14 UTC (rev 4414)
+++ remoting3/trunk/protocol/basic/src/test/java/org/jboss/cx/remoting/protocol/basic/ConnectionTestCase.java 2008-07-21 13:16:30 UTC (rev 4415)
@@ -120,6 +120,17 @@
try {
final FutureReply<Object> future = client.send(REQUEST);
assertEquals(REPLY, future.get(500L, TimeUnit.MILLISECONDS));
+ client.close();
+ clientSource.close();
+ handleThirteen.close();
+ connection.close();
+ connector.close();
+ tcpServerCloseable.close();
+ serviceEndpointHandle.close();
+ serviceRegistry.clear();
+ endpoint.stop();
+ xnio.close();
+ closeableExecutor.close();
} finally {
IoUtils.safeClose(client);
}
16 years, 5 months
JBoss Remoting SVN: r4414 - remoting3/trunk/protocol/basic/src/test/java/org/jboss/cx/remoting/protocol/basic.
by jboss-remoting-commits@lists.jboss.org
Author: david.lloyd(a)jboss.com
Date: 2008-07-21 09:01:14 -0400 (Mon, 21 Jul 2008)
New Revision: 4414
Modified:
remoting3/trunk/protocol/basic/src/test/java/org/jboss/cx/remoting/protocol/basic/ConnectionTestCase.java
Log:
Use new XNIO methods for clean shutdown of executor, channel source
Modified: remoting3/trunk/protocol/basic/src/test/java/org/jboss/cx/remoting/protocol/basic/ConnectionTestCase.java
===================================================================
--- remoting3/trunk/protocol/basic/src/test/java/org/jboss/cx/remoting/protocol/basic/ConnectionTestCase.java 2008-07-20 21:10:21 UTC (rev 4413)
+++ remoting3/trunk/protocol/basic/src/test/java/org/jboss/cx/remoting/protocol/basic/ConnectionTestCase.java 2008-07-21 13:01:14 UTC (rev 4414)
@@ -49,9 +49,10 @@
import org.jboss.xnio.IoHandlerFactory;
import org.jboss.xnio.ConfigurableFactory;
import org.jboss.xnio.IoFuture;
-import org.jboss.xnio.TcpConnector;
import org.jboss.xnio.TcpClient;
import org.jboss.xnio.ChannelSource;
+import org.jboss.xnio.CloseableTcpConnector;
+import org.jboss.xnio.CloseableExecutor;
import org.jboss.xnio.channels.AllocatedMessageChannel;
import org.jboss.xnio.channels.Channels;
import org.jboss.xnio.channels.StreamChannel;
@@ -68,7 +69,7 @@
final String REQUEST = "request";
final String REPLY = "reply";
final List<Throwable> problems = Collections.synchronizedList(new LinkedList<Throwable>());
- final ExecutorService executorService = Executors.newCachedThreadPool();
+ final CloseableExecutor closeableExecutor = IoUtils.closeableExecutor(Executors.newCachedThreadPool(), 500L, TimeUnit.MILLISECONDS);
try {
final BufferAllocator<ByteBuffer> allocator = new BufferAllocator<ByteBuffer>() {
public ByteBuffer allocate() {
@@ -81,7 +82,7 @@
final Xnio xnio = Xnio.createNio();
try {
final EndpointImpl endpoint = new EndpointImpl();
- endpoint.setExecutor(executorService);
+ endpoint.setExecutor(closeableExecutor);
endpoint.start();
try {
final ServiceRegistry serviceRegistry = new ServiceRegistryImpl();
@@ -97,17 +98,17 @@
});
try {
serviceRegistry.bind(serviceEndpointHandle.getResource(), 13);
- final IoHandlerFactory<AllocatedMessageChannel> handlerFactory = BasicProtocol.createServer(executorService, allocator, serviceRegistry);
+ final IoHandlerFactory<AllocatedMessageChannel> handlerFactory = BasicProtocol.createServer(closeableExecutor, allocator, serviceRegistry);
final IoHandlerFactory<StreamChannel> newHandlerFactory = Channels.convertStreamToAllocatedMessage(handlerFactory, 32768, 32768);
final ConfigurableFactory<Closeable> tcpServerFactory = xnio.createTcpServer(newHandlerFactory, new InetSocketAddress(12345));
final Closeable tcpServerCloseable = tcpServerFactory.create();
try {
- final ConfigurableFactory<TcpConnector> connectorFactory = xnio.createTcpConnector();
- final TcpConnector connector = connectorFactory.create();
+ final ConfigurableFactory<CloseableTcpConnector> connectorFactory = xnio.createTcpConnector();
+ final CloseableTcpConnector connector = connectorFactory.create();
try {
final TcpClient tcpClient = connector.createChannelSource(new InetSocketAddress("localhost", 12345));
final ChannelSource<AllocatedMessageChannel> channelSource = Channels.convertStreamToAllocatedMessage(tcpClient, 32768, 32768);
- final IoFuture<Connection> futureCloseable = BasicProtocol.connect(executorService, channelSource, allocator, serviceRegistry);
+ final IoFuture<Connection> futureCloseable = BasicProtocol.connect(closeableExecutor, channelSource, allocator, serviceRegistry);
final Connection connection = futureCloseable.get();
try {
final Handle<RemoteServiceEndpoint> handleThirteen = connection.getServiceForId(13);
@@ -132,7 +133,7 @@
IoUtils.safeClose(connection);
}
} finally {
- // todo close connector
+ IoUtils.safeClose(connector);
}
} finally {
IoUtils.safeClose(tcpServerCloseable);
@@ -150,7 +151,7 @@
IoUtils.safeClose(xnio);
}
} finally {
- executorService.shutdownNow();
+ IoUtils.safeClose(closeableExecutor);
}
for (Throwable t : problems) {
throw t;
16 years, 5 months