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 {