JBoss Remoting SVN: r5511 - remoting2/branches/2.x/src/main/org/jboss/remoting.
by jboss-remoting-commits@lists.jboss.org
Author: ron.sigal(a)jboss.com
Date: 2009-09-16 21:37:16 -0400 (Wed, 16 Sep 2009)
New Revision: 5511
Modified:
remoting2/branches/2.x/src/main/org/jboss/remoting/Version.java
Log:
JBREM-1135: Commented out print in static section.
Modified: remoting2/branches/2.x/src/main/org/jboss/remoting/Version.java
===================================================================
--- remoting2/branches/2.x/src/main/org/jboss/remoting/Version.java 2009-09-17 00:55:35 UTC (rev 5510)
+++ remoting2/branches/2.x/src/main/org/jboss/remoting/Version.java 2009-09-17 01:37:16 UTC (rev 5511)
@@ -53,6 +53,7 @@
// have a static block to load the user defined version to use
static
{
+// System.out.println("Remoting version: " + VERSION);
boolean precompatibleFlag = false;
String precompatible = getSystemProperty(PRE_2_0_COMPATIBLE);
15 years, 2 months
JBoss Remoting SVN: r5510 - in remoting2/branches/2.x/src/tests/org/jboss/test/remoting/transport/bisocket: socketexception and 1 other directory.
by jboss-remoting-commits@lists.jboss.org
Author: ron.sigal(a)jboss.com
Date: 2009-09-16 20:55:35 -0400 (Wed, 16 Sep 2009)
New Revision: 5510
Added:
remoting2/branches/2.x/src/tests/org/jboss/test/remoting/transport/bisocket/socketexception/
remoting2/branches/2.x/src/tests/org/jboss/test/remoting/transport/bisocket/socketexception/BisocketSocketCreationExceptionTestCase.java
Log:
JBREM-1152: Adding unit test even though no code changes were made on this branch.
Added: remoting2/branches/2.x/src/tests/org/jboss/test/remoting/transport/bisocket/socketexception/BisocketSocketCreationExceptionTestCase.java
===================================================================
--- remoting2/branches/2.x/src/tests/org/jboss/test/remoting/transport/bisocket/socketexception/BisocketSocketCreationExceptionTestCase.java (rev 0)
+++ remoting2/branches/2.x/src/tests/org/jboss/test/remoting/transport/bisocket/socketexception/BisocketSocketCreationExceptionTestCase.java 2009-09-17 00:55:35 UTC (rev 5510)
@@ -0,0 +1,235 @@
+/*
+* 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.test.remoting.transport.bisocket.socketexception;
+
+import java.io.IOException;
+import java.lang.reflect.Field;
+import java.net.InetAddress;
+import java.net.ServerSocket;
+import java.net.Socket;
+import java.net.SocketException;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Set;
+
+import javax.net.ServerSocketFactory;
+
+import org.apache.log4j.Logger;
+import org.jboss.remoting.Client;
+import org.jboss.remoting.InvokerLocator;
+import org.jboss.remoting.callback.Callback;
+import org.jboss.remoting.callback.HandleCallbackException;
+import org.jboss.remoting.callback.InvokerCallbackHandler;
+import org.jboss.remoting.transport.Connector;
+import org.jboss.remoting.transport.bisocket.Bisocket;
+import org.jboss.remoting.transport.socket.LRUPool;
+import org.jboss.remoting.transport.socket.ServerThread;
+import org.jboss.remoting.transport.socket.SocketServerInvoker;
+import org.jboss.test.remoting.transport.socket.socketexception.SocketCreationExceptionTestCase;
+
+/**
+ * Unit tests for JBREM-1152.
+ *
+ * @author <a href="ron.sigal(a)jboss.com">Ron Sigal</a>
+ * @version $Rev$
+ * <p>
+ * Copyright Sep 9, 2009
+ * </p>
+ */
+public class BisocketSocketCreationExceptionTestCase extends SocketCreationExceptionTestCase
+{
+ private static Logger log = Logger.getLogger(BisocketSocketCreationExceptionTestCase.class);
+
+
+ public void testCallbackException() throws Throwable
+ {
+ log.info("entering " + getName());
+
+ // Start server.
+ setupServer(new TestServerSocketFactory(2, new SocketException(getName())));
+
+ // Create client.
+ InvokerLocator clientLocator = new InvokerLocator(locatorURI);
+ HashMap clientConfig = new HashMap();
+ clientConfig.put(InvokerLocator.FORCE_REMOTE, "true");
+ addExtraClientConfig(clientConfig);
+ Client client = new Client(clientLocator, clientConfig);
+ client.connect();
+ log.info("client is connected");
+
+ // Test connection.
+ assertEquals("abc", client.invoke("abc"));
+ log.info("connection is good");
+
+ TestCallbackHandler callbackHandler = new TestCallbackHandler();
+ Map metadata = new HashMap();
+ metadata.put(Bisocket.IS_CALLBACK_SERVER, "true");
+ client.addListener(callbackHandler, metadata);
+
+ // Get client side ServerThread pool.
+ Set callbackConnectors = client.getCallbackConnectors(callbackHandler);
+ Connector callbackConnector = (Connector) callbackConnectors.iterator().next();
+ SocketServerInvoker serverInvoker = (SocketServerInvoker) callbackConnector.getServerInvoker();
+ Field field = SocketServerInvoker.class.getDeclaredField("clientpool");
+ field.setAccessible(true);
+ LRUPool clientpool = (LRUPool) field.get(serverInvoker);
+
+ // Verify MicroSocketClientInvoker retries invocation after failure to get a connection.
+ client.invoke(SEND_CALLBACK);
+ assertEquals(1, callbackHandler.received);
+ Set serverThreads = clientpool.getContents();
+ Iterator it = serverThreads.iterator();
+ while (it.hasNext())
+ {
+ ServerThread st = (ServerThread) it.next();
+ st.shutdown();
+ }
+ client.invoke(SEND_CALLBACK);
+ assertEquals(2, callbackHandler.received);
+ serverThreads = clientpool.getContents();
+ it = serverThreads.iterator();
+ while (it.hasNext())
+ {
+ ServerThread st = (ServerThread) it.next();
+ st.shutdown();
+ }
+ client.invoke(SEND_CALLBACK);
+ assertEquals(3, callbackHandler.received);
+
+ client.removeListener(callbackHandler);
+ client.disconnect();
+ shutdownServer();
+ log.info(getName() + " PASSES");
+ }
+
+
+ protected String getTransport()
+ {
+ return "bisocket";
+ }
+
+
+ static class TestCallbackHandler implements InvokerCallbackHandler
+ {
+ public int received;
+
+ public void handleCallback(Callback callback) throws HandleCallbackException
+ {
+ log.info("received callback");
+ received++;
+ }
+ }
+
+ static public class TestServerSocketFactory extends ServerSocketFactory
+ {
+ int initialSuccesses;
+ IOException exception;
+
+ public TestServerSocketFactory()
+ {
+ this.initialSuccesses = -1;
+ this.exception = new IOException();
+ }
+ public TestServerSocketFactory(int initialSuccesses, IOException exception)
+ {
+ this.initialSuccesses = initialSuccesses;
+ this.exception = exception;
+ }
+ public ServerSocket createServerSocket() throws IOException
+ {
+ ServerSocket ss = new TestServerSocket(initialSuccesses, exception);
+ log.info(this + " returning: " + ss);
+ return ss;
+ }
+ public ServerSocket createServerSocket(int port) throws IOException
+ {
+ ServerSocket ss = new TestServerSocket(port, initialSuccesses, exception);
+ log.info(this + " returning: " + ss);
+ return ss;
+ }
+
+ public ServerSocket createServerSocket(int port, int backlog) throws IOException
+ {
+ ServerSocket ss = new TestServerSocket(port, backlog, initialSuccesses, exception);
+ log.info(this + " returning: " + ss);
+ return ss;
+ }
+
+ public ServerSocket createServerSocket(int port, int backlog, InetAddress ifAddress) throws IOException
+ {
+ ServerSocket ss = new TestServerSocket(port, backlog, ifAddress, initialSuccesses, exception);
+ log.info(this + " returning: " + ss);
+ return ss;
+ }
+ }
+
+
+ static class TestServerSocket extends ServerSocket
+ {
+ int initialSuccesses;
+ IOException exception;
+ int counter;
+
+ public TestServerSocket(int initialSuccesses, IOException exception) throws IOException
+ {
+ super();
+ this.initialSuccesses = initialSuccesses;
+ this.exception = exception;
+ }
+ public TestServerSocket(int port, int initialSuccesses, IOException exception) throws IOException
+ {
+ super(port);
+ this.initialSuccesses = initialSuccesses;
+ this.exception = exception;
+ }
+ public TestServerSocket(int port, int backlog, int initialSuccesses, IOException exception) throws IOException
+ {
+ super(port, backlog);
+ this.initialSuccesses = initialSuccesses;
+ this.exception = exception;
+ }
+ public TestServerSocket(int port, int backlog, InetAddress bindAddr, int initialSuccesses, IOException exception) throws IOException
+ {
+ super(port, backlog, bindAddr);
+ this.initialSuccesses = initialSuccesses;
+ this.exception = exception;
+ }
+ public Socket accept() throws IOException
+ {
+ ++counter;
+ Socket s = super.accept();
+ log.info(this + " counter: " + counter);
+ if (counter > initialSuccesses && counter <= initialSuccesses + 2)
+ {
+ throw exception;
+ }
+ log.info(this + " returning: " + s);
+ return s;
+ }
+ public String toString()
+ {
+ return "TestServerSocket[" + getLocalPort() + "]";
+ }
+ }
+
+}
\ No newline at end of file
15 years, 2 months
JBoss Remoting SVN: r5509 - remoting2/branches/2.x/src/tests/org/jboss/test/remoting/transport/socket/socketexception.
by jboss-remoting-commits@lists.jboss.org
Author: ron.sigal(a)jboss.com
Date: 2009-09-16 20:55:10 -0400 (Wed, 16 Sep 2009)
New Revision: 5509
Added:
remoting2/branches/2.x/src/tests/org/jboss/test/remoting/transport/socket/socketexception/SocketCreationExceptionTestCase.java
Log:
JBREM-1152: Adding unit test even though no code changes were made on this branch.
Added: remoting2/branches/2.x/src/tests/org/jboss/test/remoting/transport/socket/socketexception/SocketCreationExceptionTestCase.java
===================================================================
--- remoting2/branches/2.x/src/tests/org/jboss/test/remoting/transport/socket/socketexception/SocketCreationExceptionTestCase.java (rev 0)
+++ remoting2/branches/2.x/src/tests/org/jboss/test/remoting/transport/socket/socketexception/SocketCreationExceptionTestCase.java 2009-09-17 00:55:10 UTC (rev 5509)
@@ -0,0 +1,299 @@
+/*
+* 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.test.remoting.transport.socket.socketexception;
+
+import java.io.IOException;
+import java.net.InetAddress;
+import java.net.Socket;
+import java.net.SocketException;
+import java.net.UnknownHostException;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.management.MBeanServer;
+import javax.net.ServerSocketFactory;
+import javax.net.SocketFactory;
+
+import junit.framework.TestCase;
+
+import org.apache.log4j.ConsoleAppender;
+import org.apache.log4j.Level;
+import org.apache.log4j.Logger;
+import org.apache.log4j.PatternLayout;
+import org.jboss.remoting.Client;
+import org.jboss.remoting.InvocationRequest;
+import org.jboss.remoting.InvokerLocator;
+import org.jboss.remoting.Remoting;
+import org.jboss.remoting.ServerInvocationHandler;
+import org.jboss.remoting.ServerInvoker;
+import org.jboss.remoting.callback.Callback;
+import org.jboss.remoting.callback.HandleCallbackException;
+import org.jboss.remoting.callback.InvokerCallbackHandler;
+import org.jboss.remoting.transport.Connector;
+import org.jboss.remoting.transport.PortUtil;
+
+/**
+ * Unit tests for JBREM-1152.
+ *
+ * @author <a href="ron.sigal(a)jboss.com">Ron Sigal</a>
+ * @version $Rev$
+ * <p>
+ * Copyright Sep 9, 2009
+ * </p>
+ */
+public class SocketCreationExceptionTestCase extends TestCase
+{
+ protected static String SEND_CALLBACK = "sendCallback";
+ private static Logger log = Logger.getLogger(SocketCreationExceptionTestCase.class);
+ private static boolean firstTime = true;
+
+ protected String host;
+ protected int port;
+ protected String locatorURI;
+ protected InvokerLocator serverLocator;
+ protected Connector connector;
+ protected TestInvocationHandler invocationHandler;
+
+
+ public void setUp() throws Exception
+ {
+ if (firstTime)
+ {
+ firstTime = false;
+ Logger.getLogger("org.jboss.remoting").setLevel(Level.TRACE);
+ Logger.getLogger("org.jboss.test.remoting").setLevel(Level.INFO);
+ String pattern = "[%d{ABSOLUTE}] [%t] %5p (%F:%L) - %m%n";
+ PatternLayout layout = new PatternLayout(pattern);
+ ConsoleAppender consoleAppender = new ConsoleAppender(layout);
+ Logger.getRootLogger().addAppender(consoleAppender);
+ }
+ }
+
+
+ public void tearDown()
+ {
+ }
+
+
+ public void testInvocationWithSocketException() throws Throwable
+ {
+ log.info("entering " + getName());
+
+ // Start server.
+ setupServer(null);
+
+ // Create client.
+ InvokerLocator clientLocator = new InvokerLocator(locatorURI);
+ HashMap clientConfig = new HashMap();
+ clientConfig.put(InvokerLocator.FORCE_REMOTE, "true");
+ clientConfig.put(Remoting.CUSTOM_SOCKET_FACTORY, new TestSocketFactory(new SocketException(getName()), 2));
+ addExtraClientConfig(clientConfig);
+ Client client = new Client(clientLocator, clientConfig);
+ client.connect();
+ log.info("client is connected");
+
+ // Test connection.
+ assertEquals("abc", client.invoke("abc"));
+ log.info("connection is good");
+
+ client.disconnect();
+ shutdownServer();
+ log.info(getName() + " PASSES");
+ }
+
+
+ public void testInvocationWithIOException() throws Throwable
+ {
+ log.info("entering " + getName());
+
+ // Start server.
+ setupServer(null);
+
+ // Create client.
+ InvokerLocator clientLocator = new InvokerLocator(locatorURI);
+ HashMap clientConfig = new HashMap();
+ clientConfig.put(InvokerLocator.FORCE_REMOTE, "true");
+ clientConfig.put(Remoting.CUSTOM_SOCKET_FACTORY, new TestSocketFactory(new IOException("Connection reset"), 2));
+ clientConfig.put("generalizeSocketException", "true");
+ addExtraClientConfig(clientConfig);
+ Client client = new Client(clientLocator, clientConfig);
+ client.connect();
+ log.info("client is connected");
+
+ // Test connection.
+ assertEquals("abc", client.invoke("abc"));
+ log.info("connection is good");
+
+ client.disconnect();
+ shutdownServer();
+ log.info(getName() + " PASSES");
+ }
+
+
+ protected String getTransport()
+ {
+ return "socket";
+ }
+
+
+ protected void addExtraClientConfig(Map config) {}
+ protected void addExtraServerConfig(Map config) {}
+
+
+ protected void setupServer(ServerSocketFactory ssf) throws Exception
+ {
+ host = InetAddress.getLocalHost().getHostAddress();
+ port = PortUtil.findFreePort(host);
+ locatorURI = getTransport() + "://" + host + ":" + port;
+ String metadata = System.getProperty("remoting.metadata");
+ if (metadata != null)
+ {
+ locatorURI += "&" + metadata;
+ }
+ serverLocator = new InvokerLocator(locatorURI);
+ log.info("Starting remoting server with locator uri of: " + locatorURI);
+ HashMap config = new HashMap();
+ config.put(InvokerLocator.FORCE_REMOTE, "true");
+ config.put("timeout", "5000");
+ if (ssf != null)
+ {
+ config.put(Remoting.CUSTOM_SERVER_SOCKET_FACTORY, ssf);
+ }
+ addExtraServerConfig(config);
+ connector = new Connector(serverLocator, config);
+ connector.create();
+ invocationHandler = new TestInvocationHandler();
+ connector.addInvocationHandler("test", invocationHandler);
+ connector.start();
+ }
+
+
+ protected void shutdownServer() throws Exception
+ {
+ if (connector != null)
+ connector.stop();
+ }
+
+
+ static class TestInvocationHandler implements ServerInvocationHandler
+ {
+ InvokerCallbackHandler callbackHandler;
+
+ public void addListener(InvokerCallbackHandler callbackHandler)
+ {
+ this.callbackHandler = callbackHandler;
+ }
+ public Object invoke(final InvocationRequest invocation) throws Throwable
+ {
+ Object parameter = invocation.getParameter();
+ if (SEND_CALLBACK.equals(parameter))
+ {
+ try
+ {
+ callbackHandler.handleCallback(new Callback("callback"));
+ }
+ catch (HandleCallbackException e)
+ {
+ log.error("unable to send callback", e);
+ }
+ }
+ return parameter;
+ }
+ public void removeListener(InvokerCallbackHandler callbackHandler) {}
+ public void setMBeanServer(MBeanServer server) {}
+ public void setInvoker(ServerInvoker invoker) {}
+ }
+
+
+ public static class TestSocketFactory extends SocketFactory
+ {
+ int counter;
+ int limit;
+ IOException exception;
+
+ public TestSocketFactory()
+ {
+ }
+ public TestSocketFactory(IOException exception, int limit)
+ {
+ this.exception = exception;
+ this.limit = limit;
+ }
+ public Socket createSocket() throws IOException
+ {
+ counter++;
+ log.info("counter: " + counter);
+ if (counter <= limit)
+ {
+ log.info("throwing exception");
+ throw exception;
+ }
+ log.info("returning socket");
+ return new Socket();
+ }
+ public Socket createSocket(String arg0, int arg1) throws IOException, UnknownHostException
+ {
+ counter++;
+ log.info("counter: " + counter);
+ if (counter <= limit)
+ {
+ throw exception;
+ }
+ log.info("returning socket");
+ return new Socket(arg0, arg1);
+ }
+ public Socket createSocket(InetAddress arg0, int arg1) throws IOException
+ {
+ counter++;
+ log.info("counter: " + counter);
+ if (counter <= limit)
+ {
+ throw exception;
+ }
+ log.info("returning socket");
+ return new Socket(arg0, arg1);
+ }
+ public Socket createSocket(String arg0, int arg1, InetAddress arg2, int arg3) throws IOException, UnknownHostException
+ {
+ counter++;
+ log.info("counter: " + counter);
+ if (counter <= limit)
+ {
+ throw exception;
+ }
+ log.info("returning socket");
+ return new Socket(arg0, arg1, arg2, arg3);
+ }
+
+ public Socket createSocket(InetAddress arg0, int arg1, InetAddress arg2, int arg3) throws IOException
+ {
+ counter++;
+ log.info("counter: " + counter);
+ if (counter <= limit)
+ {
+ throw exception;
+ }
+ log.info("returning socket");
+ return new Socket(arg0, arg1, arg2, arg3);
+ }
+ }
+}
\ No newline at end of file
15 years, 2 months
JBoss Remoting SVN: r5508 - remoting3-multiplex/trunk/src/main/java/org/jboss/remoting3/multiplex.
by jboss-remoting-commits@lists.jboss.org
Author: david.lloyd(a)jboss.com
Date: 2009-09-16 17:31:51 -0400 (Wed, 16 Sep 2009)
New Revision: 5508
Added:
remoting3-multiplex/trunk/src/main/java/org/jboss/remoting3/multiplex/MarshallingProtocol.java
remoting3-multiplex/trunk/src/main/java/org/jboss/remoting3/multiplex/MultiplexConnectionHandlerFactory.java
remoting3-multiplex/trunk/src/main/java/org/jboss/remoting3/multiplex/MultiplexConnectionProviderFactory.java
remoting3-multiplex/trunk/src/main/java/org/jboss/remoting3/multiplex/MultiplexServerFactory.java
Removed:
remoting3-multiplex/trunk/src/main/java/org/jboss/remoting3/multiplex/AtomicArrayReferenceArray.java
Modified:
remoting3-multiplex/trunk/src/main/java/org/jboss/remoting3/multiplex/ConnectionConfiguration.java
remoting3-multiplex/trunk/src/main/java/org/jboss/remoting3/multiplex/EstablishedConnection.java
remoting3-multiplex/trunk/src/main/java/org/jboss/remoting3/multiplex/MultiplexConnectionProvider.java
remoting3-multiplex/trunk/src/main/java/org/jboss/remoting3/multiplex/MultiplexRequestHandler.java
remoting3-multiplex/trunk/src/main/java/org/jboss/remoting3/multiplex/PermitManager.java
Log:
Point commit
Deleted: remoting3-multiplex/trunk/src/main/java/org/jboss/remoting3/multiplex/AtomicArrayReferenceArray.java
===================================================================
--- remoting3-multiplex/trunk/src/main/java/org/jboss/remoting3/multiplex/AtomicArrayReferenceArray.java 2009-09-16 21:31:30 UTC (rev 5507)
+++ remoting3-multiplex/trunk/src/main/java/org/jboss/remoting3/multiplex/AtomicArrayReferenceArray.java 2009-09-16 21:31:51 UTC (rev 5508)
@@ -1,170 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2009, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file 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.multiplex;
-
-import java.lang.reflect.Array;
-import java.util.concurrent.atomic.AtomicReferenceArray;
-
-final class AtomicArrayReferenceArray<V> extends AtomicReferenceArray<V[]> {
-
- private final V[] emptyArray;
- private final Class<V> componentType;
-
- private static final long serialVersionUID = -4748109403436000080L;
-
- private AtomicArrayReferenceArray(Class<V> componentType, int length) {
- super(length);
- this.componentType = componentType;
- emptyArray = newInstance(componentType, 0);
- }
-
- public static <V> AtomicArrayReferenceArray<V> create(AtomicReferenceArray<V[]> array, Class<V> componentType) {
- return new AtomicArrayReferenceArray<V>(array, componentType);
- }
-
- @SuppressWarnings({ "unchecked" })
- private static <V> V[] copyOf(final Class<V> componentType, V[] old, int newLen) {
- final V[] target = newInstance(componentType, newLen);
- System.arraycopy(old, 0, target, 0, Math.min(old.length, newLen));
- return target;
- }
-
- public void add(int idx, V value) {
- for (;;) {
- final V[] oldVal = get(idx);
- final int oldLen = oldVal.length;
- final V[] newVal = copyOf(componentType, oldVal, oldLen + 1);
- newVal[oldLen] = value;
- if (compareAndSet(idx, oldVal, newVal)) {
- return;
- }
- }
- }
-
- public boolean addIfAbsent(int idx, V value, boolean identity) {
- for (;;) {
- final V[] oldVal = get(idx);
- final int oldLen = oldVal.length;
- if (identity || value == null) {
- for (int i = 0; i < oldLen; i++) {
- if (oldVal[i] == value) {
- return false;
- }
- }
- } else {
- for (int i = 0; i < oldLen; i++) {
- if (value.equals(oldVal[i])) {
- return false;
- }
- }
- }
- final V[] newVal = copyOf(componentType, oldVal, oldLen + 1);
- newVal[oldLen] = value;
- if (compareAndSet(idx, oldVal, newVal)) {
- return true;
- }
- }
- }
-
- public boolean remove(int idx, V value, boolean identity) {
- for (;;) {
- final V[] oldVal = get(idx);
- final int oldLen = oldVal.length;
- if (oldLen == 0) {
- return false;
- } else {
- int index = -1;
- if (identity || value == null) {
- for (int i = 0; i < oldLen; i++) {
- if (oldVal[i] == value) {
- index = i;
- break;
- }
- }
- } else {
- for (int i = 0; i < oldLen; i++) {
- if (value.equals(oldVal[i])) {
- index = i;
- break;
- }
- }
- }
- if (index == -1) {
- return false;
- }
- final V[] newVal = newInstance(componentType, oldLen - 1);
- System.arraycopy(oldVal, 0, newVal, 0, index);
- System.arraycopy(oldVal, index + 1, newVal, index, oldLen - index - 1);
- if (compareAndSet(idx, oldVal, newVal)) {
- return true;
- }
- }
- }
- }
-
- public int removeAll(int idx, V value, boolean identity) {
- for (;;) {
- final V[] oldVal = get(idx);
- final int oldLen = oldVal.length;
- if (oldLen == 0) {
- return 0;
- } else {
- final boolean[] removeSlots = new boolean[oldLen];
- int removeCount = 0;
- if (identity || value == null) {
- for (int i = 0; i < oldLen; i++) {
- if (oldVal[i] == value) {
- removeSlots[i] = true;
- removeCount++;
- }
- }
- } else {
- for (int i = 0; i < oldLen; i++) {
- if (value.equals(oldVal[i])) {
- removeSlots[i] = true;
- removeCount++;
- }
- }
- }
- if (removeCount == 0) {
- return 0;
- }
- final int newLen = oldLen - removeCount;
- final V[] newVal;
- if (newLen == 0) {
- newVal = emptyArray;
- } else {
- newVal = newInstance(componentType, newLen);
- for (int i = 0, j = 0; i < oldLen; i ++) {
- if (! removeSlots[i]) {
- newVal[j++] = oldVal[i];
- }
- }
- }
- if (compareAndSet(idx, oldVal, newVal)) {
- return removeCount;
- }
- }
- }
- }
-}
Modified: remoting3-multiplex/trunk/src/main/java/org/jboss/remoting3/multiplex/ConnectionConfiguration.java
===================================================================
--- remoting3-multiplex/trunk/src/main/java/org/jboss/remoting3/multiplex/ConnectionConfiguration.java 2009-09-16 21:31:30 UTC (rev 5507)
+++ remoting3-multiplex/trunk/src/main/java/org/jboss/remoting3/multiplex/ConnectionConfiguration.java 2009-09-16 21:31:51 UTC (rev 5508)
@@ -25,7 +25,7 @@
/**
* A configuration object for the multiplex protocol.
*/
-public final class ConnectionConfiguration implements Cloneable {
+final class ConnectionConfiguration implements Cloneable {
private int linkMetric = 100;
private int maximumReceiveSize = 0x200;
Modified: remoting3-multiplex/trunk/src/main/java/org/jboss/remoting3/multiplex/EstablishedConnection.java
===================================================================
--- remoting3-multiplex/trunk/src/main/java/org/jboss/remoting3/multiplex/EstablishedConnection.java 2009-09-16 21:31:30 UTC (rev 5507)
+++ remoting3-multiplex/trunk/src/main/java/org/jboss/remoting3/multiplex/EstablishedConnection.java 2009-09-16 21:31:51 UTC (rev 5508)
@@ -27,8 +27,13 @@
import java.util.concurrent.Executor;
import java.util.concurrent.atomic.AtomicReferenceArray;
import java.util.Iterator;
-import org.jboss.marshalling.Marshaller;
-import org.jboss.marshalling.Unmarshaller;
+import java.util.List;
+import org.jboss.marshalling.ClassTable;
+import org.jboss.marshalling.ObjectTable;
+import org.jboss.marshalling.ClassResolver;
+import org.jboss.marshalling.ObjectResolver;
+import org.jboss.marshalling.ClassExternalizerFactory;
+import org.jboss.marshalling.util.IntMap;
import org.jboss.remoting3.IndeterminateOutcomeException;
import org.jboss.remoting3.spi.AbstractHandleableCloseable;
import org.jboss.remoting3.spi.Cancellable;
@@ -41,7 +46,6 @@
import org.jboss.remoting3.spi.SpiUtils;
import org.jboss.xnio.BufferAllocator;
import org.jboss.xnio.Buffers;
-import org.jboss.xnio.Pool;
import org.jboss.xnio.IoFuture;
import org.jboss.xnio.IoUtils;
import org.jboss.xnio.channels.AllocatedMessageChannel;
@@ -54,12 +58,33 @@
private static final Logger log = Loggers.MAIN_LOGGER;
//--== Connection configuration items ==--
- private final Pool<Marshaller> marshallerPool;
- private final Pool<Unmarshaller> unmarshallerPool;
- private final int linkMetric;
private final Executor executor;
// buffer allocator for outbound message assembly
private final BufferAllocator<ByteBuffer> allocator;
+ // remotely available marshalling protocol index
+ private final IntMap<String> remoteMarshallingProtocols;
+ // locally available marshalling protocol index
+ private final List<MarshallingProtocol> localMarshallingProtocols;
+ // remotely available class table index
+ private final IntMap<String> remoteClassTables;
+ // locally available class table index
+ private final List<ClassTable> localClassTables;
+ // remotely available object table index
+ private final IntMap<String> remoteObjectTables;
+ // locally available object table index
+ private final List<ObjectTable> localObjectTables;
+ // Remotely available class resolvers
+ private final IntMap<String> remoteClassResolvers;
+ // locally available class resolvers
+ private final List<ClassResolver> localClassResolvers;
+ // remotely available object resolvers
+ private final IntMap<String> remoteObjectResolvers;
+ // locally available object resolvers
+ private final List<ObjectResolver> localObjectResolvers;
+ // remotely available externalizer factories
+ private final IntMap<String> remoteExternalizerFactories;
+ // locally available externalizer factories
+ private final List<ClassExternalizerFactory> localExternalizerFactories;
// running on remote node
private final AtomicReferenceArray<ReplyHandler> remoteRequests;
@@ -85,21 +110,19 @@
// the local connection handler
private final ConnectionHandler localConnectionHandler;
- private final int sendWindowSize;
+ private final int transmitWindowSize;
+ private final int receiveWindowSize;
+ private final int linkMetric;
+
private static final ThreadLocal<EstablishedConnection> currentConnection = new ThreadLocal<EstablishedConnection>();
- public EstablishedConnection(final AllocatedMessageChannel channel, final ConnectionConfiguration configuration, final ConnectionHandler localConnectionHandler) {
- super(configuration.getExecutor());
+ public EstablishedConnection(final AllocatedMessageChannel channel, final Executor executor, final ConnectionConfiguration configuration, final ConnectionHandler localConnectionHandler) {
+ super(executor);
this.channel = channel;
linkMetric = configuration.getLinkMetric();
- executor = configuration.getExecutor();
- if (executor == null) {
- throw new NullPointerException("executor is null");
- }
+ this.executor = executor;
allocator = Buffers.createHeapByteBufferAllocator(configuration.getMaximumTransmitSize());
- marshallerPool = configuration.getMarshallerPool();
- unmarshallerPool = configuration.getUnmarshallerPool();
final int maximumInboundRequests = configuration.getMaximumInboundRequests();
remoteRequests = new AtomicReferenceArray<ReplyHandler>(maximumInboundRequests);
requestPermits = new PermitManager(maximumInboundRequests);
@@ -111,7 +134,8 @@
final int maximumInboundClients = configuration.getMaximumInboundClients();
requestedClients = new AtomicReferenceArray<RequestHandler>(maximumInboundClients);
forwardedClientPermits = new PermitManager(maximumInboundClients);
- sendWindowSize = configuration.getTransmitWindowSize();
+ transmitWindowSize = configuration.getTransmitWindowSize();
+ receiveWindowSize = configuration.getReceiveWindowSize();
this.localConnectionHandler = localConnectionHandler;
}
@@ -151,14 +175,6 @@
return channel;
}
- Pool<Marshaller> getMarshallerPool() {
- return marshallerPool;
- }
-
- Pool<Unmarshaller> getUnmarshallerPool() {
- return unmarshallerPool;
- }
-
ConnectionHandler getLocalConnectionHandler() {
return localConnectionHandler;
}
@@ -210,10 +226,14 @@
return null;
}
- int getSendWindowSize() {
- return sendWindowSize;
+ int getTransmitWindowSize() {
+ return transmitWindowSize;
}
+ int getReceiveWindowSize() {
+ return receiveWindowSize;
+ }
+
private static <T> Iterable<T> clearing(final AtomicReferenceArray<T> array) {
return new Iterable<T>() {
Added: remoting3-multiplex/trunk/src/main/java/org/jboss/remoting3/multiplex/MarshallingProtocol.java
===================================================================
--- remoting3-multiplex/trunk/src/main/java/org/jboss/remoting3/multiplex/MarshallingProtocol.java (rev 0)
+++ remoting3-multiplex/trunk/src/main/java/org/jboss/remoting3/multiplex/MarshallingProtocol.java 2009-09-16 21:31:51 UTC (rev 5508)
@@ -0,0 +1,46 @@
+/*
+ * 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.multiplex;
+
+import org.jboss.marshalling.MarshallerFactory;
+
+/**
+ * A registered marshalling protocol, which consists of the combination of a factory and the version.
+ */
+final class MarshallingProtocol {
+ private final MarshallerFactory marshallerFactory;
+ private final int configuredVersion;
+
+ MarshallingProtocol(final MarshallerFactory marshallerFactory, final int configuredVersion) {
+ this.marshallerFactory = marshallerFactory;
+ this.configuredVersion = configuredVersion;
+ }
+
+ public MarshallerFactory getMarshallerFactory() {
+ return marshallerFactory;
+ }
+
+ public int getConfiguredVersion() {
+ return configuredVersion;
+ }
+}
Added: remoting3-multiplex/trunk/src/main/java/org/jboss/remoting3/multiplex/MultiplexConnectionHandlerFactory.java
===================================================================
--- remoting3-multiplex/trunk/src/main/java/org/jboss/remoting3/multiplex/MultiplexConnectionHandlerFactory.java (rev 0)
+++ remoting3-multiplex/trunk/src/main/java/org/jboss/remoting3/multiplex/MultiplexConnectionHandlerFactory.java 2009-09-16 21:31:51 UTC (rev 5508)
@@ -0,0 +1,33 @@
+/*
+ * 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.multiplex;
+
+import org.jboss.remoting3.spi.ConnectionHandlerFactory;
+import org.jboss.remoting3.spi.ConnectionHandler;
+
+final class MultiplexConnectionHandlerFactory implements ConnectionHandlerFactory {
+
+ public ConnectionHandler createInstance(final ConnectionHandler localConnectionHandler) {
+ return new MultiplexConnectionHandler(localConnectionHandler);
+ }
+}
Modified: remoting3-multiplex/trunk/src/main/java/org/jboss/remoting3/multiplex/MultiplexConnectionProvider.java
===================================================================
--- remoting3-multiplex/trunk/src/main/java/org/jboss/remoting3/multiplex/MultiplexConnectionProvider.java 2009-09-16 21:31:30 UTC (rev 5507)
+++ remoting3-multiplex/trunk/src/main/java/org/jboss/remoting3/multiplex/MultiplexConnectionProvider.java 2009-09-16 21:31:51 UTC (rev 5508)
@@ -27,21 +27,32 @@
import org.jboss.remoting3.spi.ConnectionHandlerFactory;
import org.jboss.remoting3.spi.Result;
import org.jboss.remoting3.spi.SpiUtils;
+import org.jboss.remoting3.spi.ConnectionProviderContext;
import org.jboss.remoting3.OptionMap;
-import org.jboss.xnio.TcpConnector;
import org.jboss.xnio.FutureConnection;
import org.jboss.xnio.IoFuture;
-import org.jboss.xnio.channels.TcpChannel;
+import org.jboss.xnio.IoHandlerFactory;
+import org.jboss.xnio.Connector;
+import org.jboss.xnio.channels.AllocatedMessageChannel;
import java.net.URI;
import java.net.InetSocketAddress;
import java.io.IOException;
-public final class MultiplexConnectionProvider implements ConnectionProvider {
+final class MultiplexConnectionProvider implements ConnectionProvider<MultiplexServerFactory> {
- private final TcpConnector tcpConnector;
+ private final Connector<InetSocketAddress, AllocatedMessageChannel> connector;
+ private final ConnectionProviderContext context;
+ private final IoHandlerFactory<AllocatedMessageChannel> handlerFactory;
+ private final MultiplexServerFactory providerInterface = new MultiplexServerFactory() {
+ public IoHandlerFactory<AllocatedMessageChannel> getHandlerFactory() {
+ return handlerFactory;
+ }
+ };
- public MultiplexConnectionProvider(final TcpConnector tcpConnector) {
- this.tcpConnector = tcpConnector;
+ public MultiplexConnectionProvider(final Connector<InetSocketAddress, AllocatedMessageChannel> connector, final ConnectionProviderContext context) {
+ this.connector = connector;
+ this.context = context;
+ handlerFactory = null;
}
public Cancellable connect(final URI uri, final OptionMap connectOptions, final Result<ConnectionHandlerFactory> result) throws IllegalArgumentException {
@@ -51,14 +62,14 @@
throw new IllegalArgumentException("A valid port number must be explicitly specified");
}
// TODO - change this to use async DNS via XNIO DNS
- final FutureConnection<InetSocketAddress,TcpChannel> connection = tcpConnector.connectTo(new InetSocketAddress(host, port), null);
- connection.addNotifier(new IoFuture.HandlingNotifier<TcpChannel, Result<ConnectionHandlerFactory>>() {
+ final FutureConnection<InetSocketAddress, AllocatedMessageChannel> connection = connector.connectTo(new InetSocketAddress(host, port), null);
+ connection.addNotifier(new IoFuture.HandlingNotifier<AllocatedMessageChannel, Result<ConnectionHandlerFactory>>() {
public void handleFailed(final IOException exception, final Result<ConnectionHandlerFactory> attachment) {
attachment.setException(exception);
}
- public void handleDone(final TcpChannel result, final Result<ConnectionHandlerFactory> attachment) {
- attachment.setResult(null);
+ public void handleDone(final AllocatedMessageChannel result, final Result<ConnectionHandlerFactory> attachment) {
+ attachment.setResult(new MultiplexConnectionHandlerFactory());
}
public void handleCancelled(final Result<ConnectionHandlerFactory> attachment) {
@@ -67,4 +78,23 @@
}, result);
return SpiUtils.cancellable(connection);
}
+
+ /**
+ * Get the server factory.
+ *
+ * @return the server factory
+ */
+ public MultiplexServerFactory getProviderInterface() {
+ return providerInterface;
+ }
+
+ /**
+ * Get the server handler for this connection provider.
+ *
+ * @return the server handler factory
+ */
+ public IoHandlerFactory<AllocatedMessageChannel> getHandlerFactory() {
+ // todo - should this be secured somehow?
+ return handlerFactory;
+ }
}
Added: remoting3-multiplex/trunk/src/main/java/org/jboss/remoting3/multiplex/MultiplexConnectionProviderFactory.java
===================================================================
--- remoting3-multiplex/trunk/src/main/java/org/jboss/remoting3/multiplex/MultiplexConnectionProviderFactory.java (rev 0)
+++ remoting3-multiplex/trunk/src/main/java/org/jboss/remoting3/multiplex/MultiplexConnectionProviderFactory.java 2009-09-16 21:31:51 UTC (rev 5508)
@@ -0,0 +1,42 @@
+/*
+ * 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.multiplex;
+
+import org.jboss.remoting3.spi.ConnectionProviderFactory;
+import org.jboss.remoting3.spi.ConnectionProvider;
+import org.jboss.remoting3.spi.ConnectionProviderContext;
+import org.jboss.xnio.Connector;
+import org.jboss.xnio.channels.AllocatedMessageChannel;
+import java.net.InetSocketAddress;
+
+public final class MultiplexConnectionProviderFactory implements ConnectionProviderFactory<MultiplexServerFactory> {
+ private final Connector<InetSocketAddress, AllocatedMessageChannel> connector;
+
+ public MultiplexConnectionProviderFactory(final Connector<InetSocketAddress, AllocatedMessageChannel> connector) {
+ this.connector = connector;
+ }
+
+ public ConnectionProvider<MultiplexServerFactory> createInstance(final ConnectionProviderContext context) {
+ return new MultiplexConnectionProvider(connector, context);
+ }
+}
Modified: remoting3-multiplex/trunk/src/main/java/org/jboss/remoting3/multiplex/MultiplexRequestHandler.java
===================================================================
--- remoting3-multiplex/trunk/src/main/java/org/jboss/remoting3/multiplex/MultiplexRequestHandler.java 2009-09-16 21:31:30 UTC (rev 5507)
+++ remoting3-multiplex/trunk/src/main/java/org/jboss/remoting3/multiplex/MultiplexRequestHandler.java 2009-09-16 21:31:51 UTC (rev 5508)
@@ -71,7 +71,7 @@
connection.setCurrent();
try {
final Marshaller marshaller = marshallerPool.allocate();
- final ByteOutput output = new SendingByteOutput(null, allocator, connection.getSendWindowSize());
+ final ByteOutput output = new SendingByteOutput(null, allocator, connection.getTransmitWindowSize());
boolean ok = false;
try {
marshaller.start(output);
Added: remoting3-multiplex/trunk/src/main/java/org/jboss/remoting3/multiplex/MultiplexServerFactory.java
===================================================================
--- remoting3-multiplex/trunk/src/main/java/org/jboss/remoting3/multiplex/MultiplexServerFactory.java (rev 0)
+++ remoting3-multiplex/trunk/src/main/java/org/jboss/remoting3/multiplex/MultiplexServerFactory.java 2009-09-16 21:31:51 UTC (rev 5508)
@@ -0,0 +1,40 @@
+/*
+ * 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.multiplex;
+
+import org.jboss.xnio.channels.AllocatedMessageChannel;
+import org.jboss.xnio.IoHandlerFactory;
+
+/**
+ * The server factory for a multiplex connection provider. Use this to create servers which connect to the
+ * corresponding endpoint.
+ */
+public interface MultiplexServerFactory {
+
+ /**
+ * Get the I/O handler factory for this server factory.
+ *
+ * @return the I/O handler factory
+ */
+ IoHandlerFactory<AllocatedMessageChannel> getHandlerFactory();
+}
Modified: remoting3-multiplex/trunk/src/main/java/org/jboss/remoting3/multiplex/PermitManager.java
===================================================================
--- remoting3-multiplex/trunk/src/main/java/org/jboss/remoting3/multiplex/PermitManager.java 2009-09-16 21:31:30 UTC (rev 5507)
+++ remoting3-multiplex/trunk/src/main/java/org/jboss/remoting3/multiplex/PermitManager.java 2009-09-16 21:31:51 UTC (rev 5508)
@@ -24,7 +24,7 @@
import java.util.concurrent.atomic.AtomicIntegerFieldUpdater;
-public final class PermitManager {
+final class PermitManager {
private final Object lock = new Object();
private final int maxPermits;
15 years, 2 months
JBoss Remoting SVN: r5507 - in remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3: spi and 1 other directory.
by jboss-remoting-commits@lists.jboss.org
Author: david.lloyd(a)jboss.com
Date: 2009-09-16 17:31:30 -0400 (Wed, 16 Sep 2009)
New Revision: 5507
Modified:
remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/EndpointImpl.java
remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/spi/ConnectionProvider.java
remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/spi/RequestHandlerConnector.java
Log:
Javadoc and API cleanup
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 2009-09-16 20:46:48 UTC (rev 5506)
+++ remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/EndpointImpl.java 2009-09-16 21:31:30 UTC (rev 5507)
@@ -380,7 +380,7 @@
}
public T getProviderInterface() {
- return provider.getUserData();
+ return provider.getProviderInterface();
}
};
context.addCloseHandler(new CloseHandler<ConnectionProviderContext>() {
Modified: remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/spi/ConnectionProvider.java
===================================================================
--- remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/spi/ConnectionProvider.java 2009-09-16 20:46:48 UTC (rev 5506)
+++ remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/spi/ConnectionProvider.java 2009-09-16 21:31:30 UTC (rev 5507)
@@ -50,5 +50,5 @@
*
* @return the user data
*/
- T getUserData();
+ T getProviderInterface();
}
Modified: remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/spi/RequestHandlerConnector.java
===================================================================
--- remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/spi/RequestHandlerConnector.java 2009-09-16 20:46:48 UTC (rev 5506)
+++ remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/spi/RequestHandlerConnector.java 2009-09-16 21:31:30 UTC (rev 5507)
@@ -23,7 +23,7 @@
package org.jboss.remoting3.spi;
/**
- *
+ * A holder for a request handler that is to be sent to a remote peer.
*/
public interface RequestHandlerConnector {
15 years, 2 months
JBoss Remoting SVN: r5506 - remoting3/trunk/samples/src/main/java/org/jboss/remoting3/samples/simple.
by jboss-remoting-commits@lists.jboss.org
Author: david.lloyd(a)jboss.com
Date: 2009-09-16 16:46:48 -0400 (Wed, 16 Sep 2009)
New Revision: 5506
Added:
remoting3/trunk/samples/src/main/java/org/jboss/remoting3/samples/simple/StringRot13ClientListener.java
Removed:
remoting3/trunk/samples/src/main/java/org/jboss/remoting3/samples/simple/LocalStreamExampleMain.java
remoting3/trunk/samples/src/main/java/org/jboss/remoting3/samples/simple/StreamingRot13RequestListener.java
Modified:
remoting3/trunk/samples/src/main/java/org/jboss/remoting3/samples/simple/MultiplexClientExample.java
remoting3/trunk/samples/src/main/java/org/jboss/remoting3/samples/simple/MultiplexServerExample.java
remoting3/trunk/samples/src/main/java/org/jboss/remoting3/samples/simple/StringRot13RequestListener.java
Log:
Fix samples
Deleted: remoting3/trunk/samples/src/main/java/org/jboss/remoting3/samples/simple/LocalStreamExampleMain.java
===================================================================
--- remoting3/trunk/samples/src/main/java/org/jboss/remoting3/samples/simple/LocalStreamExampleMain.java 2009-09-16 20:31:34 UTC (rev 5505)
+++ remoting3/trunk/samples/src/main/java/org/jboss/remoting3/samples/simple/LocalStreamExampleMain.java 2009-09-16 20:46:48 UTC (rev 5506)
@@ -1,51 +0,0 @@
-package org.jboss.remoting3.samples.simple;
-
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.Reader;
-import java.io.StringReader;
-import org.jboss.remoting3.Client;
-import org.jboss.remoting3.Endpoint;
-import org.jboss.remoting3.Remoting;
-import org.jboss.xnio.IoUtils;
-
-/**
- *
- */
-public final class LocalStreamExampleMain {
-
- private LocalStreamExampleMain() {
- }
-
- public static void main(String[] args) throws IOException {
- final StreamingRot13RequestListener listener = new StreamingRot13RequestListener();
- final Endpoint endpoint = Remoting.createEndpoint("simple");
- try {
- final Client<Reader,Reader> client = Remoting.createLocalClient(endpoint, listener, null, null);
- try {
- final String original = "The Secret Message\n";
- final StringReader originalReader = new StringReader(original);
- try {
- final Reader reader = client.send(originalReader).get();
- try {
- final BufferedReader bufferedReader = new BufferedReader(reader);
- try {
- final String secretLine = bufferedReader.readLine();
- System.out.printf("The secret message \"%s\" became \"%s\"!\n", original.trim(), secretLine);
- } finally {
- IoUtils.safeClose(bufferedReader);
- }
- } finally {
- IoUtils.safeClose(reader);
- }
- } finally {
- IoUtils.safeClose(originalReader);
- }
- } finally {
- IoUtils.safeClose(client);
- }
- } finally {
- IoUtils.safeClose(endpoint);
- }
- }
-}
Modified: remoting3/trunk/samples/src/main/java/org/jboss/remoting3/samples/simple/MultiplexClientExample.java
===================================================================
--- remoting3/trunk/samples/src/main/java/org/jboss/remoting3/samples/simple/MultiplexClientExample.java 2009-09-16 20:31:34 UTC (rev 5505)
+++ remoting3/trunk/samples/src/main/java/org/jboss/remoting3/samples/simple/MultiplexClientExample.java 2009-09-16 20:46:48 UTC (rev 5506)
@@ -24,24 +24,12 @@
import org.jboss.remoting3.Endpoint;
import org.jboss.remoting3.Remoting;
+import org.jboss.remoting3.OptionMap;
+import org.jboss.remoting3.Connection;
import org.jboss.remoting3.Client;
-import org.jboss.remoting3.multiplex.MultiplexProtocol;
-import org.jboss.remoting3.multiplex.MultiplexConfiguration;
-import org.jboss.remoting3.multiplex.MultiplexConnection;
import org.jboss.xnio.IoUtils;
-import org.jboss.xnio.Buffers;
-import org.jboss.xnio.Xnio;
-import org.jboss.xnio.ConfigurableFactory;
-import org.jboss.xnio.ChannelSource;
-import org.jboss.xnio.IoFuture;
-import org.jboss.xnio.channels.Channels;
-import org.jboss.xnio.channels.AllocatedMessageChannel;
-import org.jboss.river.RiverMarshallerFactory;
-import org.jboss.marshalling.MarshallingConfiguration;
import java.io.IOException;
-import java.io.BufferedReader;
-import java.io.InputStreamReader;
-import java.net.InetSocketAddress;
+import java.net.URI;
import java.util.logging.Logger;
import java.util.logging.Level;
@@ -64,54 +52,18 @@
try {
final Endpoint endpoint = Remoting.createEndpoint("example-client-endpoint");
try {
- // now create the client
- final NamedServiceRegistry serviceRegistry = new NamedServiceRegistry();
- final MultiplexConfiguration config = new MultiplexConfiguration();
- config.setNamedServiceRegistry(serviceRegistry);
- config.setAllocator(Buffers.createHeapByteBufferAllocator(1024));
- config.setMarshallerFactory(new RiverMarshallerFactory());
- config.setExecutor(IoUtils.directExecutor());
- config.setLinkMetric(100);
- config.setMarshallingConfiguration(new MarshallingConfiguration());
- final Xnio xnio = Xnio.create();
+ final Connection connection = endpoint.connect(URI.create(args[0]), OptionMap.EMPTY).get();
try {
- final ConfigurableFactory<CloseableTcpConnector> tcpConnectorFactory = xnio.createTcpConnector();
- final CloseableTcpConnector closeableTcpConnector = tcpConnectorFactory.create();
+ final Client<String,String> client = connection.openClient("samples.rot13", "*", String.class, String.class).get();
try {
- final ChannelSource<AllocatedMessageChannel> channelSource = Channels.convertStreamToAllocatedMessage(closeableTcpConnector.createChannelSource(new InetSocketAddress("localhost", 10000)), 1024, 1024);
- final IoFuture<MultiplexConnection> futureConnection = MultiplexProtocol.connect(config, channelSource);
- final MultiplexConnection connection = futureConnection.get();
- try {
- final Handle<RequestHandlerSource> handle = connection.openRemoteService(QualifiedName.parse("/jboss/example/string-rot-13"));
- try {
- final ClientSource<String, String> clientSource = endpoint.createClientSource(handle.getResource(), String.class, String.class);
- try {
- final Client<String, String> client = clientSource.createClient();
- try {
- System.out.println("Enter text, send EOF to terminate");
- final BufferedReader inputReader = new BufferedReader(new InputStreamReader(System.in));
- String line;
- while ((line = inputReader.readLine()) != null) {
- System.out.println("Response: " + client.invoke(line));
- }
- System.out.println("Done!");
- } finally {
- IoUtils.safeClose(client);
- }
- } finally {
- IoUtils.safeClose(clientSource);
- }
- } finally {
- IoUtils.safeClose(handle);
- }
- } finally {
- IoUtils.safeClose(connection);
- }
+ 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(closeableTcpConnector);
+ IoUtils.safeClose(client);
}
} finally {
- IoUtils.safeClose(xnio);
+ IoUtils.safeClose(connection);
}
} finally {
IoUtils.safeClose(endpoint);
Modified: remoting3/trunk/samples/src/main/java/org/jboss/remoting3/samples/simple/MultiplexServerExample.java
===================================================================
--- remoting3/trunk/samples/src/main/java/org/jboss/remoting3/samples/simple/MultiplexServerExample.java 2009-09-16 20:31:34 UTC (rev 5505)
+++ remoting3/trunk/samples/src/main/java/org/jboss/remoting3/samples/simple/MultiplexServerExample.java 2009-09-16 20:46:48 UTC (rev 5506)
@@ -25,23 +25,16 @@
import org.jboss.remoting3.Remoting;
import org.jboss.remoting3.Endpoint;
import org.jboss.remoting3.LocalServiceConfiguration;
-import org.jboss.remoting3.multiplex.MultiplexProtocol;
-import org.jboss.remoting3.multiplex.MultiplexConfiguration;
+import org.jboss.remoting3.SimpleCloseable;
+import org.jboss.remoting3.spi.ConnectionProviderRegistration;
+import org.jboss.remoting3.multiplex.MultiplexConnectionProviderFactory;
+import org.jboss.remoting3.multiplex.MultiplexServerFactory;
import org.jboss.xnio.IoUtils;
-import org.jboss.xnio.Buffers;
-import org.jboss.xnio.IoHandlerFactory;
-import org.jboss.xnio.Xnio;
-import org.jboss.xnio.ConfigurableFactory;
import org.jboss.xnio.CloseableExecutor;
-import org.jboss.xnio.channels.AllocatedMessageChannel;
+import org.jboss.xnio.Xnio;
+import org.jboss.xnio.TcpServer;
import org.jboss.xnio.channels.Channels;
-import org.jboss.xnio.channels.StreamChannel;
-import org.jboss.river.RiverMarshallerFactory;
-import org.jboss.marshalling.MarshallingConfiguration;
-import org.jboss.marshalling.reflect.SunReflectiveCreator;
import java.io.IOException;
-import java.io.Closeable;
-import java.net.InetSocketAddress;
import java.util.logging.Logger;
import java.util.logging.Level;
@@ -60,57 +53,41 @@
private MultiplexServerExample() {
}
- public static void main(String[] args) {
+ public static void main(String[] args) throws InterruptedException, IOException {
final CloseableExecutor executor = Remoting.createExecutor(10);
try {
- final Endpoint endpoint = Remoting.createEndpoint(executor, "example-endpoint");
+ Xnio xnio = Xnio.create();
try {
- final StringRot13RequestListener listener = new StringRot13RequestListener();
- final LocalServiceConfiguration<String, String> config = new LocalServiceConfiguration<String, String>(listener, String.class, String.class);
- config.setGroupName("main");
- config.setServiceType("jboss.example.streaming-rot-13");
- final Handle<RequestHandlerSource> handle = endpoint.registerService(config);
+ final Endpoint endpoint = Remoting.createEndpoint(executor, "example-endpoint");
try {
- // now create the server...
- final NamedServiceRegistry serviceRegistry = new NamedServiceRegistry();
- final Handle<RequestHandlerSource> connHandle = serviceRegistry.registerService(QualifiedName.parse("/jboss/example/string-rot-13"), handle.getResource());
+ final LocalServiceConfiguration<String, String> config = LocalServiceConfiguration.create(new StringRot13ClientListener(), String.class, String.class);
+ config.setGroupName("main");
+ config.setServiceType("simple.rot13");
+ final SimpleCloseable handle = endpoint.registerService(config);
try {
- final MultiplexConfiguration multiplexConfig = new MultiplexConfiguration();
- multiplexConfig.setNamedServiceRegistry(serviceRegistry);
- multiplexConfig.setAllocator(Buffers.createHeapByteBufferAllocator(1024));
- multiplexConfig.setLinkMetric(100);
- multiplexConfig.setMarshallerFactory(new RiverMarshallerFactory());
- multiplexConfig.setExecutor(executor);
- final MarshallingConfiguration marshallingConfig = new MarshallingConfiguration();
- marshallingConfig.setCreator(new SunReflectiveCreator());
- multiplexConfig.setMarshallingConfiguration(marshallingConfig);
- final IoHandlerFactory<AllocatedMessageChannel> handlerFactory = MultiplexProtocol.createServer(multiplexConfig);
- final IoHandlerFactory<StreamChannel> streamHandlerFactory = Channels.convertStreamToAllocatedMessage(handlerFactory, 1024, 1024);
- // finally, bind it
- final Xnio xnio = Xnio.create();
+ // now create the server...
+ final MultiplexConnectionProviderFactory multiplexConnectionProviderFactory = new MultiplexConnectionProviderFactory(xnio.createTcpConnector().create());
+ final ConnectionProviderRegistration<MultiplexServerFactory> cpHandle = endpoint.addConnectionProvider("multiplex", multiplexConnectionProviderFactory);
try {
- final ConfigurableFactory<? extends Closeable> tcpServerFactory = xnio.createTcpServer(streamHandlerFactory, new InetSocketAddress(10000));
- final Closeable server = tcpServerFactory.create();
+ final TcpServer tcpServer = xnio.createTcpServer(Channels.convertStreamToAllocatedMessage(cpHandle.getProviderInterface().getHandlerFactory(), 0x1000, 0x1000)).create();
try {
- System.out.println("Press enter to terminate.");
- while (System.in.read() != '\n');
+ // now just wait for 15 seconds, and then shut it all down
+ Thread.sleep(15000L);
} finally {
- IoUtils.safeClose(server);
+ IoUtils.safeClose(tcpServer);
}
} finally {
- IoUtils.safeClose(xnio);
+ IoUtils.safeClose(cpHandle);
}
} finally {
- IoUtils.safeClose(connHandle);
+ IoUtils.safeClose(handle);
}
} finally {
- IoUtils.safeClose(handle);
+ IoUtils.safeClose(endpoint);
}
} finally {
- IoUtils.safeClose(endpoint);
+ IoUtils.safeClose(xnio);
}
- } catch (IOException e) {
- e.printStackTrace();
} finally {
IoUtils.safeClose(executor);
}
Deleted: remoting3/trunk/samples/src/main/java/org/jboss/remoting3/samples/simple/StreamingRot13RequestListener.java
===================================================================
--- remoting3/trunk/samples/src/main/java/org/jboss/remoting3/samples/simple/StreamingRot13RequestListener.java 2009-09-16 20:31:34 UTC (rev 5505)
+++ remoting3/trunk/samples/src/main/java/org/jboss/remoting3/samples/simple/StreamingRot13RequestListener.java 2009-09-16 20:46:48 UTC (rev 5506)
@@ -1,55 +0,0 @@
-package org.jboss.remoting3.samples.simple;
-
-import java.io.IOException;
-import java.io.Reader;
-import org.jboss.remoting3.RemoteExecutionException;
-import org.jboss.remoting3.RequestContext;
-
-/**
- *
- */
-public final class StreamingRot13RequestListener extends AbstractRequestListener<Reader, Reader> {
-
- public void handleRequest(final RequestContext<Reader> readerRequestContext, final Reader request) throws RemoteExecutionException {
- try {
- readerRequestContext.sendReply(new Reader() {
-
- public int read() throws IOException {
- final int i = request.read();
- if (i > 0) {
- return rot13((char) i);
- } else {
- return i;
- }
- }
-
- public int read(final char cbuf[], final int off, final int len) throws IOException {
- for (int i = 0; i < len; i++) {
- final int c = read();
- if (c == -1) {
- return i;
- }
- cbuf[off + i] = (char) c;
- }
- return len;
- }
-
- public void close() throws IOException {
- request.close();
- }
- });
- } catch (IOException e) {
- throw new RemoteExecutionException("Failed to send reply", e);
- }
- }
-
- private char rot13(final char i) {
- if (i >= 'A' && i <= 'M' || i >= 'a' && i <= 'm') {
- return (char) (i + 13);
- } else if (i >= 'N' && i <= 'Z' || i >= 'n' && i <= 'z') {
- return (char) (i - 13);
- } else {
- return i;
- }
- }
-}
Added: remoting3/trunk/samples/src/main/java/org/jboss/remoting3/samples/simple/StringRot13ClientListener.java
===================================================================
--- remoting3/trunk/samples/src/main/java/org/jboss/remoting3/samples/simple/StringRot13ClientListener.java (rev 0)
+++ remoting3/trunk/samples/src/main/java/org/jboss/remoting3/samples/simple/StringRot13ClientListener.java 2009-09-16 20:46:48 UTC (rev 5506)
@@ -0,0 +1,34 @@
+/*
+ * 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 org.jboss.remoting3.ClientListener;
+import org.jboss.remoting3.RequestListener;
+import org.jboss.remoting3.ClientContext;
+
+public final class StringRot13ClientListener implements ClientListener<String, String> {
+
+ public RequestListener<String, String> handleClientOpen(final ClientContext clientContext) {
+ return new StringRot13RequestListener();
+ }
+}
Modified: remoting3/trunk/samples/src/main/java/org/jboss/remoting3/samples/simple/StringRot13RequestListener.java
===================================================================
--- remoting3/trunk/samples/src/main/java/org/jboss/remoting3/samples/simple/StringRot13RequestListener.java 2009-09-16 20:31:34 UTC (rev 5505)
+++ remoting3/trunk/samples/src/main/java/org/jboss/remoting3/samples/simple/StringRot13RequestListener.java 2009-09-16 20:46:48 UTC (rev 5506)
@@ -3,12 +3,13 @@
import java.io.IOException;
import org.jboss.remoting3.RemoteExecutionException;
import org.jboss.remoting3.RequestContext;
+import org.jboss.remoting3.RequestListener;
import org.jboss.xnio.log.Logger;
/**
*
*/
-public final class StringRot13RequestListener extends AbstractRequestListener<String, String> {
+public final class StringRot13RequestListener implements RequestListener<String, String> {
private static final Logger log = Logger.getLogger("jboss.example.string-rot-13");
@@ -27,6 +28,9 @@
}
}
+ public void handleClose() {
+ }
+
private char rot13(final char i) {
if (i >= 'A' && i <= 'M' || i >= 'a' && i <= 'm') {
return (char) (i + 13);
15 years, 2 months
JBoss Remoting SVN: r5505 - in remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3: spi and 1 other directory.
by jboss-remoting-commits@lists.jboss.org
Author: david.lloyd(a)jboss.com
Date: 2009-09-16 16:31:34 -0400 (Wed, 16 Sep 2009)
New Revision: 5505
Added:
remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/spi/AbstractConnectionProviderRegistration.java
Modified:
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/spi/ConnectionProviderRegistration.java
Log:
Make it possible for network servers to connect in to Remoting with the new API (part 2)
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 2009-09-16 20:20:26 UTC (rev 5504)
+++ remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/Endpoint.java 2009-09-16 20:31:34 UTC (rev 5505)
@@ -5,6 +5,7 @@
import java.util.Set;
import org.jboss.remoting3.spi.ConnectionProviderFactory;
import org.jboss.remoting3.spi.RequestHandler;
+import org.jboss.remoting3.spi.ConnectionProviderRegistration;
import org.jboss.xnio.IoFuture;
/**
@@ -92,7 +93,7 @@
* @param providerFactory the provider factory
* @return a handle which may be used to remove the registration
*/
- SimpleCloseable addConnectionProvider(String uriScheme, ConnectionProviderFactory providerFactory);
+ <T> ConnectionProviderRegistration<T> addConnectionProvider(String uriScheme, ConnectionProviderFactory<T> providerFactory);
/**
* Flags which can be passed in to listener registration methods.
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 2009-09-16 20:20:26 UTC (rev 5504)
+++ remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/EndpointImpl.java 2009-09-16 20:31:34 UTC (rev 5505)
@@ -50,6 +50,8 @@
import org.jboss.remoting3.spi.RequestHandler;
import org.jboss.remoting3.spi.RequestHandlerConnector;
import org.jboss.remoting3.spi.Result;
+import org.jboss.remoting3.spi.ConnectionProviderRegistration;
+import org.jboss.remoting3.spi.AbstractConnectionProviderRegistration;
import org.jboss.xnio.IoFuture;
import org.jboss.xnio.IoUtils;
import org.jboss.xnio.WeakCloseable;
@@ -98,7 +100,7 @@
private final Set<Registration<ServiceRegistrationListener>> serviceListenerRegistrations = hashSet();
private final Map<String, ServiceRegistration> registeredLocalServices = hashMap();
- private final ConcurrentMap<String, ConnectionProvider> connectionProviders = concurrentHashMap();
+ private final ConcurrentMap<String, ConnectionProvider<?>> connectionProviders = concurrentHashMap();
private static final EndpointPermission CREATE_ENDPOINT_PERM = new EndpointPermission("createEndpoint");
private static final EndpointPermission CREATE_REQUEST_HANDLER_PERM = new EndpointPermission("createRequestHandler");
@@ -343,7 +345,7 @@
sm.checkPermission(CONNECT_PERM);
}
final String scheme = destination.getScheme();
- final ConnectionProvider connectionProvider = connectionProviders.get(scheme);
+ final ConnectionProvider<?> connectionProvider = connectionProviders.get(scheme);
if (connectionProvider == null) {
throw new UnknownURISchemeException("No connection provider for URI scheme \"" + scheme + "\" is installed");
}
@@ -356,13 +358,13 @@
return futureResult;
}
- public SimpleCloseable addConnectionProvider(final String uriScheme, final ConnectionProviderFactory providerFactory) {
+ public <T> ConnectionProviderRegistration<T> addConnectionProvider(final String uriScheme, final ConnectionProviderFactory<T> providerFactory) {
final SecurityManager sm = System.getSecurityManager();
if (sm != null) {
sm.checkPermission(ADD_CONNECTION_PROVIDER_PERM);
}
final ConnectionProviderContextImpl context = new ConnectionProviderContextImpl(executor, loopbackConnectionHandler);
- final ConnectionProvider provider = providerFactory.createInstance(context);
+ final ConnectionProvider<T> provider = providerFactory.createInstance(context);
if (connectionProviders.putIfAbsent(uriScheme, provider) != null) {
IoUtils.safeClose(context);
throw new IllegalArgumentException("URI scheme '" + uriScheme + "' is already registered to a provider");
@@ -372,10 +374,14 @@
connectionProviders.remove(uriScheme, provider);
}
});
- final AbstractSimpleCloseable handle = new AbstractSimpleCloseable(executor) {
+ final AbstractConnectionProviderRegistration<T> handle = new AbstractConnectionProviderRegistration<T>(executor) {
protected void closeAction() throws IOException {
context.close();
}
+
+ public T getProviderInterface() {
+ return provider.getUserData();
+ }
};
context.addCloseHandler(new CloseHandler<ConnectionProviderContext>() {
public void handleClose(final ConnectionProviderContext closed) {
Added: remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/spi/AbstractConnectionProviderRegistration.java
===================================================================
--- remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/spi/AbstractConnectionProviderRegistration.java (rev 0)
+++ remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/spi/AbstractConnectionProviderRegistration.java 2009-09-16 20:31:34 UTC (rev 5505)
@@ -0,0 +1,42 @@
+/*
+ * 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.spi;
+
+import java.util.concurrent.Executor;
+
+/**
+ * An abstract implementation of {@code ConnectionProviderRegistration}.
+ *
+ * @param <T> the provider interface type
+ */
+public abstract class AbstractConnectionProviderRegistration<T> extends AbstractHandleableCloseable<ConnectionProviderRegistration<T>> implements ConnectionProviderRegistration<T> {
+
+ /**
+ * Basic constructor.
+ *
+ * @param executor the executor used to execute the close notification handlers
+ */
+ protected AbstractConnectionProviderRegistration(final Executor executor) {
+ super(executor);
+ }
+}
Modified: remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/spi/ConnectionProviderRegistration.java
===================================================================
--- remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/spi/ConnectionProviderRegistration.java 2009-09-16 20:20:26 UTC (rev 5504)
+++ remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/spi/ConnectionProviderRegistration.java 2009-09-16 20:31:34 UTC (rev 5505)
@@ -25,7 +25,9 @@
import org.jboss.remoting3.HandleableCloseable;
/**
+ * A handle representing the registration of a connection provider.
*
+ * @param <T> the provider interface type
*/
public interface ConnectionProviderRegistration<T> extends HandleableCloseable<ConnectionProviderRegistration<T>> {
15 years, 2 months
JBoss Remoting SVN: r5504 - remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/spi.
by jboss-remoting-commits@lists.jboss.org
Author: david.lloyd(a)jboss.com
Date: 2009-09-16 16:20:26 -0400 (Wed, 16 Sep 2009)
New Revision: 5504
Added:
remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/spi/ConnectionProviderRegistration.java
Modified:
remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/spi/ConnectionProvider.java
remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/spi/ConnectionProviderFactory.java
Log:
Make it possible for network servers to connect in to Remoting with the new API
Modified: remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/spi/ConnectionProvider.java
===================================================================
--- remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/spi/ConnectionProvider.java 2009-09-16 20:19:59 UTC (rev 5503)
+++ remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/spi/ConnectionProvider.java 2009-09-16 20:20:26 UTC (rev 5504)
@@ -31,7 +31,7 @@
*
* @remoting.implement
*/
-public interface ConnectionProvider {
+public interface ConnectionProvider<T> {
/**
* Open an outbound connection to the given URI. This method is expected to be non-blocking, with the result
@@ -44,4 +44,11 @@
* @throws IllegalArgumentException if the URI is not valid
*/
Cancellable connect(URI uri, OptionMap connectOptions, Result<ConnectionHandlerFactory> result) throws IllegalArgumentException;
+
+ /**
+ * Get the user data associated with this connection provider.
+ *
+ * @return the user data
+ */
+ T getUserData();
}
Modified: remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/spi/ConnectionProviderFactory.java
===================================================================
--- remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/spi/ConnectionProviderFactory.java 2009-09-16 20:19:59 UTC (rev 5503)
+++ remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/spi/ConnectionProviderFactory.java 2009-09-16 20:20:26 UTC (rev 5504)
@@ -27,7 +27,7 @@
* endpoint will call the {@code createInstance()} method with its provider context when instances of this interface
* are registered on that endpoint.
*/
-public interface ConnectionProviderFactory {
+public interface ConnectionProviderFactory<T> {
/**
* Create a provider instance for an endpoint.
@@ -35,5 +35,5 @@
* @param context the provider context
* @return the provider
*/
- ConnectionProvider createInstance(ConnectionProviderContext context);
+ ConnectionProvider<T> createInstance(ConnectionProviderContext context);
}
Added: remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/spi/ConnectionProviderRegistration.java
===================================================================
--- remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/spi/ConnectionProviderRegistration.java (rev 0)
+++ remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/spi/ConnectionProviderRegistration.java 2009-09-16 20:20:26 UTC (rev 5504)
@@ -0,0 +1,38 @@
+/*
+ * 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.spi;
+
+import org.jboss.remoting3.HandleableCloseable;
+
+/**
+ *
+ */
+public interface ConnectionProviderRegistration<T> extends HandleableCloseable<ConnectionProviderRegistration<T>> {
+
+ /**
+ * Get the created provider interface associated with this registration.
+ *
+ * @return the connection provider interface
+ */
+ T getProviderInterface();
+}
15 years, 2 months
JBoss Remoting SVN: r5503 - remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3.
by jboss-remoting-commits@lists.jboss.org
Author: david.lloyd(a)jboss.com
Date: 2009-09-16 16:19:59 -0400 (Wed, 16 Sep 2009)
New Revision: 5503
Modified:
remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/LocalServiceConfiguration.java
Log:
Add a factory method
Modified: remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/LocalServiceConfiguration.java
===================================================================
--- remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/LocalServiceConfiguration.java 2009-09-16 18:51:55 UTC (rev 5502)
+++ remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/LocalServiceConfiguration.java 2009-09-16 20:19:59 UTC (rev 5503)
@@ -26,6 +26,9 @@
* A configuration for a service to be deployed into the endpoint.
*
* @apiviz.exclude
+ *
+ * @param <I> the request type
+ * @param <O> the reply type
*/
public final class LocalServiceConfiguration<I, O> {
private final ClientListener<I, O> clientListener;
@@ -49,6 +52,20 @@
}
/**
+ * Create a new instance.
+ *
+ * @param clientListener the client listener
+ * @param requestClass the request class
+ * @param replyClass the reply class
+ * @param <I> the request type
+ * @param <O> the reply type
+ * @return a new configuration instance
+ */
+ public static <I, O> LocalServiceConfiguration<I, O> create(final ClientListener<I, O> clientListener, final Class<I> requestClass, final Class<O> replyClass) {
+ return new LocalServiceConfiguration<I,O>(clientListener, requestClass, replyClass);
+ }
+
+ /**
* Get the request listener for this service.
*
* @return the request listener
15 years, 2 months
JBoss Remoting SVN: r5502 - remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3.
by jboss-remoting-commits@lists.jboss.org
Author: david.lloyd(a)jboss.com
Date: 2009-09-16 14:51:55 -0400 (Wed, 16 Sep 2009)
New Revision: 5502
Modified:
remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/OptionMap.java
Log:
javadoc
Modified: remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/OptionMap.java
===================================================================
--- remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/OptionMap.java 2009-09-16 17:44:19 UTC (rev 5501)
+++ remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/OptionMap.java 2009-09-16 18:51:55 UTC (rev 5502)
@@ -97,10 +97,13 @@
}
/**
- * A builder for immutable option maps.
+ * A builder for immutable option maps. Create an instance with the {@link OptionMap#builder()} method.
*/
public static final class Builder {
+ private Builder() {
+ }
+
private static class OVPair<T> {
Option<T> option;
T value;
15 years, 2 months