JBoss Remoting SVN: r5845 - in remoting3/trunk: jboss-remoting/src/main/java/org/jboss/remoting3/spi and 2 other directories.
by jboss-remoting-commits@lists.jboss.org
Author: david.lloyd(a)jboss.com
Date: 2010-04-09 09:04:25 -0400 (Fri, 09 Apr 2010)
New Revision: 5845
Added:
remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/RemotingContext.java
remoting3/trunk/samples/src/main/java/org/jboss/remoting3/samples/simple/LocalBasicExampleMain.java
Removed:
remoting3/trunk/samples/src/main/java/org/jboss/remoting3/samples/simple/LocalBasicExample2Main.java
remoting3/trunk/samples/src/main/java/org/jboss/remoting3/samples/simple/LocalBasicExampleMain.java
Modified:
remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/Client.java
remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/ClientConnectorImpl.java
remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/ClientImpl.java
remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/ConnectionImpl.java
remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/Endpoint.java
remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/EndpointImpl.java
remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/LocalConnectionHandler.java
remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/LocalRemoteReplyHandler.java
remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/LocalRemoteRequestHandler.java
remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/LocalRequestHandlerConnector.java
remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/spi/ConnectionHandlerContext.java
remoting3/trunk/jboss-remoting/src/test/java/org/jboss/remoting3/test/EndpointTestCase.java
Log:
Eliminate redundant local connection API; add getConnection() to Client; add RemotingContext
Modified: remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/Client.java
===================================================================
--- remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/Client.java 2010-04-08 02:40:34 UTC (rev 5844)
+++ remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/Client.java 2010-04-09 13:04:25 UTC (rev 5845)
@@ -166,4 +166,11 @@
* @see #send(Object) send(I)
*/
<T extends O> IoFuture<? extends T> sendTyped(TypedRequest<? extends I, T> request) throws IOException;
+
+ /**
+ * Get the connection of this client.
+ *
+ * @return the connection
+ */
+ Connection getConnection();
}
Modified: remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/ClientConnectorImpl.java
===================================================================
--- remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/ClientConnectorImpl.java 2010-04-08 02:40:34 UTC (rev 5844)
+++ remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/ClientConnectorImpl.java 2010-04-09 13:04:25 UTC (rev 5845)
@@ -57,7 +57,7 @@
final FutureResult<Client<I, O>> futureResult = new FutureResult<Client<I, O>>();
requestHandlerConnector.createRequestHandler(new TranslatingResult<RemoteRequestHandler, Client<I, O>>(futureResult) {
protected Client<I, O> translate(final RemoteRequestHandler input) throws IOException {
- return endpoint.createClient(input, requestClass, replyClass, classloader);
+ return endpoint.createClient(input, requestClass, replyClass, classloader, RemotingContext.requireCurrent().getConnection());
}
});
return futureResult.getIoFuture();
Modified: remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/ClientImpl.java
===================================================================
--- remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/ClientImpl.java 2010-04-08 02:40:34 UTC (rev 5844)
+++ remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/ClientImpl.java 2010-04-09 13:04:25 UTC (rev 5845)
@@ -45,18 +45,20 @@
private final Class<I> requestClass;
private final Class<O> replyClass;
private final ClassLoader clientClassLoader;
+ private final Connection connection;
private final Attachments attachments = new AttachmentsImpl();
- private ClientImpl(final RemoteRequestHandler handler, final Executor executor, final Class<I> requestClass, final Class<O> replyClass, final ClassLoader clientClassLoader) {
+ private ClientImpl(final RemoteRequestHandler handler, final Executor executor, final Class<I> requestClass, final Class<O> replyClass, final ClassLoader clientClassLoader, final Connection connection) {
super(executor);
this.handler = handler;
this.requestClass = requestClass;
this.replyClass = replyClass;
this.clientClassLoader = clientClassLoader;
+ this.connection = connection;
}
- static <I, O> ClientImpl<I, O> create(final RemoteRequestHandler handler, final Executor executor, final Class<I> requestClass, final Class<O> replyClass, final ClassLoader clientClassLoader) {
- final ClientImpl<I, O> ci = new ClientImpl<I, O>(handler, executor, requestClass, replyClass, clientClassLoader);
+ static <I, O> ClientImpl<I, O> create(final RemoteRequestHandler handler, final Executor executor, final Class<I> requestClass, final Class<O> replyClass, final ClassLoader clientClassLoader, final Connection connection) {
+ final ClientImpl<I, O> ci = new ClientImpl<I, O>(handler, executor, requestClass, replyClass, clientClassLoader, connection);
handler.addCloseHandler(SpiUtils.closingCloseHandler(ci));
return ci;
}
@@ -157,6 +159,10 @@
return futureReply;
}
+ public Connection getConnection() {
+ return connection;
+ }
+
/*
* Since type is erased, it's possible that the wrong type was passed.
*/
Modified: remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/ConnectionImpl.java
===================================================================
--- remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/ConnectionImpl.java 2010-04-08 02:40:34 UTC (rev 5844)
+++ remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/ConnectionImpl.java 2010-04-09 13:04:25 UTC (rev 5845)
@@ -102,7 +102,7 @@
return "Connection to " + name;
}
- private static class ClientWrapper<I, O> extends TranslatingResult<RemoteRequestHandler, Client<I, O>> {
+ private class ClientWrapper<I, O> extends TranslatingResult<RemoteRequestHandler, Client<I, O>> {
private final Class<I> requestClass;
private final Class<O> replyClass;
@@ -118,7 +118,7 @@
}
protected Client<I, O> translate(final RemoteRequestHandler input) throws IOException {
- return endpoint.createClient(input, requestClass, replyClass, classLoader);
+ return endpoint.createClient(input, requestClass, replyClass, classLoader, ConnectionImpl.this);
}
}
}
Modified: remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/Endpoint.java
===================================================================
--- remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/Endpoint.java 2010-04-08 02:40:34 UTC (rev 5844)
+++ remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/Endpoint.java 2010-04-09 13:04:25 UTC (rev 5845)
@@ -177,31 +177,6 @@
Registration addServiceRegistrationListener(ServiceRegistrationListener listener, Set<ListenerFlag> flags);
/**
- * Create a local client for a client listener.
- *
- * @param clientListener the client listener
- * @param requestClass the request class
- * @param replyClass the reply class
- * @param clientClassLoader the class loader to use for replies
- * @param optionMap the options
- * @return a new client
- * @throws IOException if an error occurs
- */
- <I, O> Client<I, O> createLocalClient(ClientListener<I, O> clientListener, Class<I> requestClass, Class<O> replyClass, ClassLoader clientClassLoader, OptionMap optionMap) throws IOException;
-
- /**
- * Create a local client for a client listener.
- *
- * @param clientListener
- * @param requestClass the request class
- * @param replyClass the reply class
- * @param optionMap the options
- * @return a new client
- * @throws IOException if an error occurs
- */
- <I, O> Client<I, O> createLocalClient(ClientListener<I, O> clientListener, Class<I> requestClass, Class<O> replyClass, OptionMap optionMap) throws IOException;
-
- /**
* Open a connection with a peer. Returns a future connection which may be used to cancel the connection attempt.
* This method does not block; use the return value to wait for a result if you wish to block.
* <p/>
Modified: remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/EndpointImpl.java
===================================================================
--- remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/EndpointImpl.java 2010-04-08 02:40:34 UTC (rev 5844)
+++ remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/EndpointImpl.java 2010-04-09 13:04:25 UTC (rev 5845)
@@ -424,7 +424,7 @@
log.error(t, "Service listener threw an exception");
}
- <I, O> Client<I, O> createClient(final RemoteRequestHandler requestHandler, final Class<I> requestType, final Class<O> replyType, final ClassLoader clientClassLoader) throws IOException {
+ <I, O> Client<I, O> createClient(final RemoteRequestHandler requestHandler, final Class<I> requestType, final Class<O> replyType, final ClassLoader clientClassLoader, final Connection connection) throws IOException {
SecurityManager sm = System.getSecurityManager();
if (sm != null) {
sm.checkPermission(CREATE_CLIENT_PERM);
@@ -439,7 +439,7 @@
throw new IllegalArgumentException("replyType is null");
}
checkOpen();
- final ClientImpl<I, O> client = ClientImpl.create(requestHandler, executor, requestType, replyType, clientClassLoader);
+ final ClientImpl<I, O> client = ClientImpl.create(requestHandler, executor, requestType, replyType, clientClassLoader, connection);
final WeakCloseable lrhCloseable = new WeakCloseable(client);
// this registration closes the client when the endpoint is closed
final Key key = addCloseHandler(SpiUtils.closingCloseHandler(lrhCloseable));
@@ -527,18 +527,6 @@
return registration;
}
- public <I, O> Client<I, O> createLocalClient(final ClientListener<I, O> clientListener, final Class<I> requestClass, final Class<O> replyClass, final OptionMap optionMap) throws IOException {
- return createLocalClient(clientListener, requestClass, replyClass, Thread.currentThread().getContextClassLoader(), optionMap);
- }
-
- public <I, O> Client<I, O> createLocalClient(final ClientListener<I, O> clientListener, final Class<I> requestClass, final Class<O> replyClass, final ClassLoader clientClassLoader, final OptionMap optionMap) throws IOException {
- final ClientContextImpl context = new ClientContextImpl(executor, null);
- final RequestListener<I, O> requestListener = clientListener.handleClientOpen(context, optionMap);
- final LocalRequestHandler localRequestHandler = createLocalRequestHandler(requestListener, context, requestClass, replyClass);
- final LocalRemoteRequestHandler remoteRequestHandler = new LocalRemoteRequestHandler(localRequestHandler, clientClassLoader, optionMap, this.optionMap, executor);
- return ClientImpl.create(remoteRequestHandler, executor, requestClass, replyClass, clientClassLoader);
- }
-
public IoFuture<? extends Connection> connect(final URI destination) throws IOException {
final Pair<String, String> userRealm = getUserAndRealm(destination);
final String uriUserName = userRealm.getA();
@@ -776,6 +764,14 @@
public void remoteClosed() {
IoUtils.safeClose(connection);
}
+
+ public void beginContext() {
+ RemotingContext.setCurrent(new RemotingContext(EndpointImpl.this, connection));
+ }
+
+ public void endContext() {
+ RemotingContext.clearCurrent();
+ }
}
private final class ConnectionProviderContextImpl implements ConnectionProviderContext {
Modified: remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/LocalConnectionHandler.java
===================================================================
--- remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/LocalConnectionHandler.java 2010-04-08 02:40:34 UTC (rev 5844)
+++ remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/LocalConnectionHandler.java 2010-04-09 13:04:25 UTC (rev 5845)
@@ -46,16 +46,16 @@
public Cancellable open(final String serviceType, final String instanceName, final Result<RemoteRequestHandler> result, final ClassLoader classLoader, final OptionMap optionMap) {
final LocalRequestHandler handler = connectionHandlerContext.openService(serviceType, instanceName, optionMap);
if (handler == null) {
- result.setException(new ServiceNotFoundException(ServiceURI.create(serviceType, instanceName, null)));
+ result.setException(new ServiceNotFoundException(ServiceURI.create(serviceType, instanceName, connectionHandlerContext.getConnectionProviderContext().getEndpoint().getName())));
} else {
- final LocalRemoteRequestHandler requestHandler = new LocalRemoteRequestHandler(handler, classLoader, optionMap, connectionOptionMap, connectionHandlerContext.getConnectionProviderContext().getExecutor());
+ final LocalRemoteRequestHandler requestHandler = new LocalRemoteRequestHandler(handler, classLoader, optionMap, connectionOptionMap, connectionHandlerContext.getConnectionProviderContext().getExecutor(), connectionHandlerContext);
result.setResult(requestHandler);
}
return IoUtils.nullCancellable();
}
public RequestHandlerConnector createConnector(final LocalRequestHandler localHandler) {
- return new LocalRequestHandlerConnector(localHandler, connectionHandlerContext.getConnectionProviderContext().getExecutor());
+ return new LocalRequestHandlerConnector(connectionHandlerContext, localHandler, connectionHandlerContext.getConnectionProviderContext().getExecutor());
}
public void close() throws IOException {
Modified: remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/LocalRemoteReplyHandler.java
===================================================================
--- remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/LocalRemoteReplyHandler.java 2010-04-08 02:40:34 UTC (rev 5844)
+++ remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/LocalRemoteReplyHandler.java 2010-04-09 13:04:25 UTC (rev 5845)
@@ -24,22 +24,30 @@
import java.io.IOException;
import org.jboss.marshalling.cloner.ObjectCloner;
+import org.jboss.remoting3.spi.ConnectionHandlerContext;
import org.jboss.remoting3.spi.LocalReplyHandler;
import org.jboss.remoting3.spi.RemoteReplyHandler;
class LocalRemoteReplyHandler implements RemoteReplyHandler {
+ private final ConnectionHandlerContext context;
private final LocalReplyHandler replyHandler;
private final ObjectCloner replyCloner;
- public LocalRemoteReplyHandler(final LocalReplyHandler replyHandler, final ObjectCloner replyCloner) {
+ public LocalRemoteReplyHandler(final ConnectionHandlerContext context, final LocalReplyHandler replyHandler, final ObjectCloner replyCloner) {
+ this.context = context;
this.replyHandler = replyHandler;
this.replyCloner = replyCloner;
}
public void handleReply(final Object reply) throws IOException {
try {
- replyHandler.handleReply(replyCloner.clone(reply));
+ context.beginContext();
+ try {
+ replyHandler.handleReply(replyCloner.clone(reply));
+ } finally {
+ context.endContext();
+ }
} catch (ClassNotFoundException e) {
final ReplyException re = new ReplyException("Cannot clone reply", e);
replyHandler.handleException(re);
@@ -49,7 +57,12 @@
public void handleException(final IOException exception) throws IOException {
try {
- replyHandler.handleException((IOException) replyCloner.clone(exception));
+ context.beginContext();
+ try {
+ replyHandler.handleException((IOException) replyCloner.clone(exception));
+ } finally {
+ context.endContext();
+ }
} catch (ClassNotFoundException e) {
final ReplyException re = new ReplyException("Cannot clone reply", e);
replyHandler.handleException(re);
Modified: remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/LocalRemoteRequestHandler.java
===================================================================
--- remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/LocalRemoteRequestHandler.java 2010-04-08 02:40:34 UTC (rev 5844)
+++ remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/LocalRemoteRequestHandler.java 2010-04-09 13:04:25 UTC (rev 5845)
@@ -43,6 +43,7 @@
import org.jboss.marshalling.cloner.ObjectClonerFactory;
import org.jboss.marshalling.cloner.ObjectCloners;
import org.jboss.remoting3.spi.AbstractHandleableCloseable;
+import org.jboss.remoting3.spi.ConnectionHandlerContext;
import org.jboss.remoting3.spi.LocalReplyHandler;
import org.jboss.remoting3.spi.LocalRequestHandler;
import org.jboss.remoting3.spi.RemoteRequestHandler;
@@ -56,10 +57,12 @@
class LocalRemoteRequestHandler extends AbstractHandleableCloseable<RemoteRequestHandler> implements RemoteRequestHandler {
private final LocalRequestHandler handler;
+ private final ConnectionHandlerContext handlerContext;
private final ClonerPairSource clonerPairSource;
- public LocalRemoteRequestHandler(final LocalRequestHandler handler, final ClassLoader replyClassLoader, final OptionMap optionMap, final OptionMap defaultOptionMap, final Executor executor) {
+ public LocalRemoteRequestHandler(final LocalRequestHandler handler, final ClassLoader replyClassLoader, final OptionMap optionMap, final OptionMap defaultOptionMap, final Executor executor, final ConnectionHandlerContext handlerContext) {
super(executor);
+ this.handlerContext = handlerContext;
final boolean callByValue = optionMap.get(RemotingOptions.CALL_BY_VALUE, defaultOptionMap.get(RemotingOptions.CALL_BY_VALUE, false));
final ClonerPairSource clonerPairSource;
if (callByValue) {
@@ -85,7 +88,12 @@
final ObjectCloner replyCloner = pair.getB();
final Object clonedRequest;
try {
- clonedRequest = requestCloner.clone(request);
+ handlerContext.beginContext();
+ try {
+ clonedRequest = requestCloner.clone(request);
+ } finally {
+ handlerContext.endContext();
+ }
} catch (IOException e) {
replyHandler.handleException(e);
return IoUtils.nullCancellable();
@@ -95,7 +103,7 @@
replyHandler.handleException(ioe);
return IoUtils.nullCancellable();
}
- return handler.receiveRequest(clonedRequest, new LocalRemoteReplyHandler(replyHandler, replyCloner));
+ return handler.receiveRequest(clonedRequest, new LocalRemoteReplyHandler(INIT_ME, replyHandler, replyCloner));
}
private static class LocalCloneTable implements CloneTable {
Modified: remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/LocalRequestHandlerConnector.java
===================================================================
--- remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/LocalRequestHandlerConnector.java 2010-04-08 02:40:34 UTC (rev 5844)
+++ remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/LocalRequestHandlerConnector.java 2010-04-09 13:04:25 UTC (rev 5845)
@@ -23,6 +23,7 @@
package org.jboss.remoting3;
import java.util.concurrent.Executor;
+import org.jboss.remoting3.spi.ConnectionHandlerContext;
import org.jboss.remoting3.spi.LocalRequestHandler;
import org.jboss.remoting3.spi.RemoteRequestHandler;
import org.jboss.remoting3.spi.RequestHandlerConnector;
@@ -34,16 +35,18 @@
final class LocalRequestHandlerConnector implements RequestHandlerConnector {
+ private final ConnectionHandlerContext context;
private final LocalRequestHandler localHandler;
private final Executor executor;
- LocalRequestHandlerConnector(final LocalRequestHandler localHandler, final Executor executor) {
+ LocalRequestHandlerConnector(final ConnectionHandlerContext context, final LocalRequestHandler localHandler, final Executor executor) {
+ this.context = context;
this.localHandler = localHandler;
this.executor = executor;
}
public Cancellable createRequestHandler(final Result<RemoteRequestHandler> result) throws SecurityException {
- final LocalRemoteRequestHandler handler = new LocalRemoteRequestHandler(localHandler, null, OptionMap.EMPTY, OptionMap.EMPTY, executor);
+ final LocalRemoteRequestHandler handler = new LocalRemoteRequestHandler(localHandler, null, OptionMap.EMPTY, OptionMap.EMPTY, executor, context);
localHandler.addCloseHandler(SpiUtils.closingCloseHandler(handler));
result.setResult(handler);
return IoUtils.nullCancellable();
Added: remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/RemotingContext.java
===================================================================
--- remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/RemotingContext.java (rev 0)
+++ remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/RemotingContext.java 2010-04-09 13:04:25 UTC (rev 5845)
@@ -0,0 +1,71 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, 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.remoting3;
+
+/**
+ * The Remoting context.
+ *
+ * @author <a href="mailto:david.lloyd@redhat.com">David M. Lloyd</a>
+ */
+public final class RemotingContext {
+ private static final ThreadLocal<RemotingContext> current = new ThreadLocal<RemotingContext>();
+
+ private final Endpoint endpoint;
+ private final Connection connection;
+
+ RemotingContext(final Endpoint endpoint, final Connection connection) {
+ this.endpoint = endpoint;
+ this.connection = connection;
+ }
+
+ public static RemotingContext getCurrent() {
+ return current.get();
+ }
+
+ public static RemotingContext requireCurrent() {
+ final RemotingContext context = getCurrent();
+ if (context == null) {
+ throw new IllegalStateException("No current Remoting context");
+ }
+ return context;
+ }
+
+ static void setCurrent(RemotingContext context) {
+ if (current.get() != null) {
+ throw new IllegalStateException("Remoting context already set");
+ }
+ current.set(context);
+ }
+
+ static void clearCurrent() {
+ current.set(null);
+ }
+
+ public Endpoint getEndpoint() {
+ return endpoint;
+ }
+
+ public Connection getConnection() {
+ return connection;
+ }
+}
Modified: remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/spi/ConnectionHandlerContext.java
===================================================================
--- remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/spi/ConnectionHandlerContext.java 2010-04-08 02:40:34 UTC (rev 5844)
+++ remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/spi/ConnectionHandlerContext.java 2010-04-09 13:04:25 UTC (rev 5845)
@@ -58,4 +58,14 @@
* @remoting.nonblocking
*/
void remoteClosed();
+
+ /**
+ * Indicate that an unmarshalling operation is just about to begin.
+ */
+ void beginContext();
+
+ /**
+ * Indicate that an unmarshalling operation is finished.
+ */
+ void endContext();
}
Modified: remoting3/trunk/jboss-remoting/src/test/java/org/jboss/remoting3/test/EndpointTestCase.java
===================================================================
--- remoting3/trunk/jboss-remoting/src/test/java/org/jboss/remoting3/test/EndpointTestCase.java 2010-04-08 02:40:34 UTC (rev 5844)
+++ remoting3/trunk/jboss-remoting/src/test/java/org/jboss/remoting3/test/EndpointTestCase.java 2010-04-09 13:04:25 UTC (rev 5845)
@@ -22,25 +22,15 @@
package org.jboss.remoting3.test;
-import java.io.IOException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
-import org.jboss.remoting3.Client;
-import org.jboss.remoting3.ClientContext;
-import org.jboss.remoting3.ClientListener;
-import org.jboss.remoting3.CloseHandler;
import org.jboss.remoting3.Endpoint;
-import org.jboss.remoting3.RemoteExecutionException;
import org.jboss.remoting3.Remoting;
-import org.jboss.remoting3.RequestContext;
-import org.jboss.remoting3.RequestListener;
-import org.jboss.xnio.IoUtils;
import org.jboss.xnio.OptionMap;
import org.jboss.xnio.log.Logger;
import org.testng.annotations.Test;
-import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertTrue;
/**
@@ -75,80 +65,4 @@
exit();
}
}
-
- public void testLocalClientInvoke() throws Throwable {
- enter();
- try {
- final Endpoint endpoint = Remoting.getConfiguredEndpoint();
- try {
- final Object requestObj = new Object();
- final Object replyObj = new Object();
- final Client<Object, Object> localClient = endpoint.createLocalClient(new ClientListener<Object, Object>() {
- public RequestListener<Object, Object> handleClientOpen(final ClientContext clientContext, final OptionMap optionMap) {
- return new RequestListener<Object, Object>() {
- public void handleRequest(final RequestContext<Object> objectRequestContext, final Object request) throws RemoteExecutionException {
- try {
- objectRequestContext.sendReply(replyObj);
- } catch (IOException e) {
- throw new RemoteExecutionException(e);
- }
- }
- };
- }
- }, Object.class, Object.class, Thread.currentThread().getContextClassLoader(), OptionMap.EMPTY);
- localClient.addCloseHandler(new CloseHandler<Client<Object, Object>>() {
- public void handleClose(final Client<Object, Object> closed) {
- log.info("Listener closed");
- }
- });
- try {
- assertEquals(replyObj, localClient.invoke(requestObj));
- } finally {
- IoUtils.safeClose(localClient);
- }
- } finally {
- IoUtils.safeClose(endpoint);
- }
- } finally {
- exit();
- }
- }
-
- public void testLocalClientSend() throws Throwable {
- enter();
- try {
- final Endpoint endpoint = Remoting.getConfiguredEndpoint();
- try {
- final Object requestObj = new Object();
- final Object replyObj = new Object();
- final Client<Object, Object> localClient = endpoint.createLocalClient(new ClientListener<Object, Object>() {
- public RequestListener<Object, Object> handleClientOpen(final ClientContext clientContext, final OptionMap optionMap) {
- return new RequestListener<Object, Object>() {
- public void handleRequest(final RequestContext<Object> objectRequestContext, final Object request) throws RemoteExecutionException {
- try {
- objectRequestContext.sendReply(replyObj);
- } catch (IOException e) {
- throw new RemoteExecutionException(e);
- }
- }
- };
- }
- }, Object.class, Object.class, Thread.currentThread().getContextClassLoader(), OptionMap.EMPTY);
- localClient.addCloseHandler(new CloseHandler<Client<Object, Object>>() {
- public void handleClose(final Client<Object, Object> closed) {
- log.info("Listener closed");
- }
- });
- try {
- assertEquals(replyObj, localClient.send(requestObj).get());
- } finally {
- IoUtils.safeClose(localClient);
- }
- } finally {
- IoUtils.safeClose(endpoint);
- }
- } finally {
- exit();
- }
- }
}
Deleted: remoting3/trunk/samples/src/main/java/org/jboss/remoting3/samples/simple/LocalBasicExample2Main.java
===================================================================
--- remoting3/trunk/samples/src/main/java/org/jboss/remoting3/samples/simple/LocalBasicExample2Main.java 2010-04-08 02:40:34 UTC (rev 5844)
+++ remoting3/trunk/samples/src/main/java/org/jboss/remoting3/samples/simple/LocalBasicExample2Main.java 2010-04-09 13:04:25 UTC (rev 5845)
@@ -1,69 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2009, 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.remoting3.samples.simple;
-
-import java.net.URI;
-import org.jboss.remoting3.Client;
-import org.jboss.remoting3.Endpoint;
-import org.jboss.remoting3.Remoting;
-import org.jboss.remoting3.Connection;
-import org.jboss.remoting3.Registration;
-import org.jboss.xnio.IoUtils;
-import org.jboss.xnio.OptionMap;
-
-/**
- *
- */
-public final class LocalBasicExample2Main {
-
- private LocalBasicExample2Main() {
- }
-
- public static void main(String[] args) throws Exception {
- final Endpoint endpoint = Remoting.getConfiguredEndpoint();
- try {
- final Registration handle = endpoint.serviceBuilder().setServiceType("simple.rot13").setInstanceName("main")
- .setRequestType(String.class).setReplyType(String.class).setClientListener(new StringRot13ClientListener())
- .register();
- try {
- final Connection connection = endpoint.connect(new URI("local:///"), OptionMap.EMPTY).get();
- try {
- final Client<String, String> client = connection.openClient("simple.rot13", "*", String.class, String.class).get();
- try {
- final String original = "The Secret Message";
- final String result = client.invoke(original);
- System.out.printf("The secret message \"%s\" became \"%s\"!\n", original.trim(), result.trim());
- } finally {
- IoUtils.safeClose(client);
- }
- } finally {
- IoUtils.safeClose(connection);
- }
- } finally {
- IoUtils.safeClose(handle);
- }
- } finally {
- IoUtils.safeClose(endpoint);
- }
- }
-}
\ No newline at end of file
Deleted: remoting3/trunk/samples/src/main/java/org/jboss/remoting3/samples/simple/LocalBasicExampleMain.java
===================================================================
--- remoting3/trunk/samples/src/main/java/org/jboss/remoting3/samples/simple/LocalBasicExampleMain.java 2010-04-08 02:40:34 UTC (rev 5844)
+++ remoting3/trunk/samples/src/main/java/org/jboss/remoting3/samples/simple/LocalBasicExampleMain.java 2010-04-09 13:04:25 UTC (rev 5845)
@@ -1,34 +0,0 @@
-package org.jboss.remoting3.samples.simple;
-
-import java.io.IOException;
-import org.jboss.remoting3.Client;
-import org.jboss.remoting3.Endpoint;
-import org.jboss.remoting3.Remoting;
-import org.jboss.xnio.IoUtils;
-import org.jboss.xnio.OptionMap;
-
-/**
- *
- */
-public final class LocalBasicExampleMain {
-
- private LocalBasicExampleMain() {
- }
-
- public static void main(String[] args) throws IOException {
- final StringRot13ClientListener listener = new StringRot13ClientListener();
- final Endpoint endpoint = Remoting.getConfiguredEndpoint();
- try {
- final Client<String,String> client = endpoint.createLocalClient(listener, String.class, String.class, Thread.currentThread().getContextClassLoader(), OptionMap.EMPTY);
- try {
- final String original = "The Secret Message\n";
- final String result = client.invoke(original);
- System.out.printf("The secret message \"%s\" became \"%s\"!\n", original.trim(), result.trim());
- } finally {
- IoUtils.safeClose(client);
- }
- } finally {
- IoUtils.safeClose(endpoint);
- }
- }
-}
\ No newline at end of file
Copied: remoting3/trunk/samples/src/main/java/org/jboss/remoting3/samples/simple/LocalBasicExampleMain.java (from rev 5839, remoting3/trunk/samples/src/main/java/org/jboss/remoting3/samples/simple/LocalBasicExample2Main.java)
===================================================================
--- remoting3/trunk/samples/src/main/java/org/jboss/remoting3/samples/simple/LocalBasicExampleMain.java (rev 0)
+++ remoting3/trunk/samples/src/main/java/org/jboss/remoting3/samples/simple/LocalBasicExampleMain.java 2010-04-09 13:04:25 UTC (rev 5845)
@@ -0,0 +1,69 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, 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.remoting3.samples.simple;
+
+import java.net.URI;
+import org.jboss.remoting3.Client;
+import org.jboss.remoting3.Endpoint;
+import org.jboss.remoting3.Remoting;
+import org.jboss.remoting3.Connection;
+import org.jboss.remoting3.Registration;
+import org.jboss.xnio.IoUtils;
+import org.jboss.xnio.OptionMap;
+
+/**
+ *
+ */
+public final class LocalBasicExampleMain {
+
+ private LocalBasicExampleMain() {
+ }
+
+ public static void main(String[] args) throws Exception {
+ final Endpoint endpoint = Remoting.getConfiguredEndpoint();
+ try {
+ final Registration handle = endpoint.serviceBuilder().setServiceType("simple.rot13").setInstanceName("main")
+ .setRequestType(String.class).setReplyType(String.class).setClientListener(new StringRot13ClientListener())
+ .register();
+ try {
+ final Connection connection = endpoint.connect(new URI("local:///"), OptionMap.EMPTY).get();
+ try {
+ final Client<String, String> client = connection.openClient("simple.rot13", "*", String.class, String.class).get();
+ try {
+ final String original = "The Secret Message";
+ final String result = client.invoke(original);
+ System.out.printf("The secret message \"%s\" became \"%s\"!\n", original.trim(), result.trim());
+ } finally {
+ IoUtils.safeClose(client);
+ }
+ } finally {
+ IoUtils.safeClose(connection);
+ }
+ } finally {
+ IoUtils.safeClose(handle);
+ }
+ } finally {
+ IoUtils.safeClose(endpoint);
+ }
+ }
+}
\ No newline at end of file