Author: david.lloyd(a)jboss.com
Date: 2008-09-25 13:36:11 -0400 (Thu, 25 Sep 2008)
New Revision: 4577
Modified:
remoting3/trunk/core/src/main/java/org/jboss/remoting/core/ClientImpl.java
Log:
Externalizer for clients (experimental)
Modified: remoting3/trunk/core/src/main/java/org/jboss/remoting/core/ClientImpl.java
===================================================================
--- remoting3/trunk/core/src/main/java/org/jboss/remoting/core/ClientImpl.java 2008-09-23
21:56:54 UTC (rev 4576)
+++ remoting3/trunk/core/src/main/java/org/jboss/remoting/core/ClientImpl.java 2008-09-25
17:36:11 UTC (rev 4577)
@@ -30,8 +30,12 @@
import org.jboss.remoting.spi.remote.RemoteRequestContext;
import org.jboss.remoting.spi.remote.Handle;
import org.jboss.xnio.IoFuture;
+import org.jboss.marshalling.Externalizer;
+import org.jboss.marshalling.Creator;
import java.util.concurrent.Executor;
import java.io.IOException;
+import java.io.ObjectOutput;
+import java.io.ObjectInput;
/**
*
@@ -88,4 +92,26 @@
public String toString() {
return "client instance <" + Integer.toString(hashCode()) +
">";
}
+
+ static final class ExternalizerImpl implements Externalizer<ClientImpl<?,
?>> {
+
+ private final EndpointImpl endpoint;
+
+ ExternalizerImpl(final EndpointImpl endpoint) {
+ this.endpoint = endpoint;
+ }
+
+ public void writeExternal(final ClientImpl<?, ?> client, final ObjectOutput
output) throws IOException {
+ output.writeObject(client.handle.getResource());
+ }
+
+ public ClientImpl<?, ?> createExternal(final Class<ClientImpl<?,
?>> clientClass, final ObjectInput input, final Creator creator) throws IOException,
ClassNotFoundException {
+ final RequestHandler handler = (RequestHandler) input.readObject();
+ return new ClientImpl(handler.getHandle(), endpoint.getExecutor());
+ }
+
+ public void readExternal(final ClientImpl<?, ?> client, final ObjectInput
input) throws IOException, ClassNotFoundException {
+ // no op
+ }
+ }
}
Show replies by date