JBoss Remoting SVN: r5126 - remoting2/branches/2.2.2-SP11_JBREM-1112/src/main/org/jboss/remoting.
by jboss-remoting-commits@lists.jboss.org
Author: ron.sigal(a)jboss.com
Date: 2009-05-04 21:46:25 -0400 (Mon, 04 May 2009)
New Revision: 5126
Modified:
remoting2/branches/2.2.2-SP11_JBREM-1112/src/main/org/jboss/remoting/ConnectionValidator.java
Log:
JBREM-1112 (and others to be named): Doesn't need to call notifyListeners() if stopLeaseOnFailure is true.
Modified: remoting2/branches/2.2.2-SP11_JBREM-1112/src/main/org/jboss/remoting/ConnectionValidator.java
===================================================================
--- remoting2/branches/2.2.2-SP11_JBREM-1112/src/main/org/jboss/remoting/ConnectionValidator.java 2009-05-05 01:42:48 UTC (rev 5125)
+++ remoting2/branches/2.2.2-SP11_JBREM-1112/src/main/org/jboss/remoting/ConnectionValidator.java 2009-05-05 01:46:25 UTC (rev 5126)
@@ -468,6 +468,44 @@
// Package protected ----------------------------------------------------------------------------
+ void notifyListeners(Throwable thr)
+ {
+ final Throwable t = thr;
+ synchronized (lock)
+ {
+ if (stopped)
+ {
+ return;
+ }
+ stopped = true;
+ log.debug(this + " is stopped. No more listeners will be accepted.");
+
+ Iterator itr = listeners.keySet().iterator();
+ while (itr.hasNext())
+ {
+ final ConnectionListener listener = (ConnectionListener) itr.next();
+ Set clients = (Set) listeners.get(listener);
+ Iterator itr2 = clients.iterator();
+ while (itr2.hasNext())
+ {
+ final Client client = (Client) itr2.next();
+ new Thread()
+ {
+ public void run()
+ {
+ log.debug(ConnectionValidator.this + " calling " + listener + ".handleConnectionException() for " + client);
+ listener.handleConnectionException(t, client);
+ }
+ }.start();
+ }
+ }
+
+ listeners.clear();
+ }
+
+ stop();
+ }
+
// Protected ------------------------------------------------------------------------------------
// Private --------------------------------------------------------------------------------------
@@ -626,7 +664,7 @@
try
{
- TimerUtil.schedule(this, pingPeriod);
+ TimerUtil.schedule(this, pingPeriod);
}
catch (Exception e)
{
@@ -727,43 +765,43 @@
return result;
}
- private void notifyListeners(Throwable thr)
- {
- final Throwable t = thr;
- synchronized (lock)
- {
- if (stopped)
- {
- return;
- }
- stopped = true;
- log.debug(this + " is stopped. No more listeners will be accepted.");
-
- Iterator itr = listeners.keySet().iterator();
- while (itr.hasNext())
- {
- final ConnectionListener listener = (ConnectionListener) itr.next();
- Set clients = (Set) listeners.get(listener);
- Iterator itr2 = clients.iterator();
- while (itr2.hasNext())
- {
- final Client client = (Client) itr2.next();
- new Thread()
- {
- public void run()
- {
- log.debug(ConnectionValidator.this + " calling " + listener + ".handleConnectionException() for " + client);
- listener.handleConnectionException(t, client);
- }
- }.start();
- }
- }
-
- listeners.clear();
- }
-
- stop();
- }
+// void notifyListeners(Throwable thr)
+// {
+// final Throwable t = thr;
+// synchronized (lock)
+// {
+// if (stopped)
+// {
+// return;
+// }
+// stopped = true;
+// log.debug(this + " is stopped. No more listeners will be accepted.");
+//
+// Iterator itr = listeners.keySet().iterator();
+// while (itr.hasNext())
+// {
+// final ConnectionListener listener = (ConnectionListener) itr.next();
+// Set clients = (Set) listeners.get(listener);
+// Iterator itr2 = clients.iterator();
+// while (itr2.hasNext())
+// {
+// final Client client = (Client) itr2.next();
+// new Thread()
+// {
+// public void run()
+// {
+// log.debug(ConnectionValidator.this + " calling " + listener + ".handleConnectionException() for " + client);
+// listener.handleConnectionException(t, client);
+// }
+// }.start();
+// }
+// }
+//
+// listeners.clear();
+// }
+//
+// stop();
+// }
// Inner classes --------------------------------------------------------------------------------
@@ -808,23 +846,31 @@
//
// if (invoker != null)
// {
- if (leasePinger == null)
+// if (leasePinger == null)
+// {
+// leasePinger = sharedInvoker.getLeasePinger();
+// }
+ if (leasePinger != null)
{
- leasePinger = sharedInvoker.getLeasePinger();
+ log.debug(ConnectionValidator.this + " shutting down lease pinger: " + leasePinger);
+ int disconnectTimeout = (failureDisconnectTimeout == -1) ? client.getDisconnectTimeout() : failureDisconnectTimeout;
+ // MicroRemoteClientInvoker.terminateLease() will call LeasePinger.stopPing(), which will call
+ // Client.disconnectAndNotify() for all Clients with registered ConnectionListeners, and
+ // Client.disconnectAndNotify() will call ConnectionValidator.notifyListeners().
+ sharedInvoker.terminateLease(null, disconnectTimeout, leasePinger);
}
- log.debug(ConnectionValidator.this + " shutting down lease pinger: " + leasePinger);
- int disconnectTimeout = (failureDisconnectTimeout == -1) ? client.getDisconnectTimeout() : failureDisconnectTimeout;
- sharedInvoker.terminateLease(null, disconnectTimeout);
-// }
-// else
-// {
+ else
+ {
// log.debug(ConnectionValidator.this + " unable to shut down lease pinger: " + leasePinger + ". Client must have shut down");
-// }
+ log.debug(ConnectionValidator.this + " unable to shut down null lease pinger. Client must have shut down");
+ }
cancel();
}
-
- notifyListeners(new Exception("Could not connect to server!"));
+ else
+ {
+ notifyListeners(new Exception("Could not connect to server!"));
+ }
}
}
}
15 years, 6 months
JBoss Remoting SVN: r5125 - remoting2/branches/2.2.2-SP11_JBREM-1112/src/main/org/jboss/remoting.
by jboss-remoting-commits@lists.jboss.org
Author: ron.sigal(a)jboss.com
Date: 2009-05-04 21:42:48 -0400 (Mon, 04 May 2009)
New Revision: 5125
Modified:
remoting2/branches/2.2.2-SP11_JBREM-1112/src/main/org/jboss/remoting/Client.java
Log:
JBREM-1112 (and others to be named): (1) Added new version of connect(); (2) added disconnectAndNotify(); (3) changed synchronization.
Modified: remoting2/branches/2.2.2-SP11_JBREM-1112/src/main/org/jboss/remoting/Client.java
===================================================================
--- remoting2/branches/2.2.2-SP11_JBREM-1112/src/main/org/jboss/remoting/Client.java 2009-05-02 00:37:05 UTC (rev 5124)
+++ remoting2/branches/2.2.2-SP11_JBREM-1112/src/main/org/jboss/remoting/Client.java 2009-05-05 01:42:48 UTC (rev 5125)
@@ -157,6 +157,9 @@
private static Map connectionValidators = new HashMap();
private static Object connectionValidatorLock = new Object();
+ static final String CLIENT = "client";
+ static final String CONNECTION_LISTENER = "connectionListener";
+
private static final Logger log = Logger.getLogger(Client.class);
private static final long serialVersionUID = 5679279425009837934L;
@@ -375,12 +378,12 @@
*
* @see org.jboss.remoting.ConnectionValidator
*/
- public void addConnectionListener(ConnectionListener listener, Map metadata)
+ public synchronized void addConnectionListener(ConnectionListener listener, Map metadata)
{
if (invoker == null)
{
throw new RuntimeException("Can not add connection listener to remoting client " +
- "until client has been connected.");
+ "while client is not connected.");
}
else
{
@@ -391,8 +394,8 @@
}
}
- synchronized (connectionValidatorLock)
- {
+// synchronized (connectionValidatorLock)
+// {
if (connectionValidator == null)
{
Map map = new HashMap(configuration);
@@ -415,6 +418,7 @@
}
else
{
+ log.debug(this + ": unable to reuse existing ConnectionValidator in static map: " + connectionValidator);
connectionValidator = new ConnectionValidator(this, metadata);
connectionValidators.put(connectionValidatorKey, new WeakReference(connectionValidator));
connectionValidator.addConnectionListener(this, listener);
@@ -430,6 +434,7 @@
}
else
{
+ log.debug(this + ": unable to reuse ConnectionValidator from local reference: " + connectionValidator);
connectionValidator = new ConnectionValidator(this, metadata);
connectionValidators.put(connectionValidatorKey, new WeakReference(connectionValidator));
connectionValidator.addConnectionListener(this, listener);
@@ -438,17 +443,17 @@
}
connectionListeners.add(listener);
- }
+// }
}
/**
* Removes specified connection listener. Will return true if it has already been registered,
* false otherwise.
*/
- public boolean removeConnectionListener(ConnectionListener listener)
+ public synchronized boolean removeConnectionListener(ConnectionListener listener)
{
boolean isRemoved = false;
- synchronized (connectionValidatorLock)
+// synchronized (connectionValidatorLock)
{
if (connectionValidator == null)
{
@@ -515,6 +520,39 @@
*/
public void connect() throws Exception
{
+ connect(null, null);
+ }
+
+ /**
+ * Will cause the underlying transport to make connection to the target server. This is
+ * important for any stateful transports, like socket or multiplex. This is also when a client
+ * lease with the server is started. If listener is not null, it will be registered to
+ * receive a callback if the connection fails.
+ */
+ public void connect(ConnectionListener listener) throws Exception
+ {
+ connect(listener, null);
+ }
+
+ /**
+ * Will cause the underlying transport to make connection to the target server. This is
+ * important for any stateful transports, like socket or multiplex. This is also when a client
+ * lease with the server is started. If listener is not null, it will be registered to
+ * receive a callback if the connection fails.
+ * <p>
+ *
+ * If this version of connect() is used, and leasing is enabled, the concept of "connection
+ * identity" is enforced. That is, the ConnectionValidator used by this Client will be
+ * tied to the LeasePinger currently used by the MicroRemoteClientInvoker created or reused
+ * in this method, and that LeasePinger will be tied to this Client and its ConnectionValidator.
+ * If the ConnectionValidator used by any of the Clients associated with the MicroRemoteClientInvoker
+ * used by this Client detects a broken connection, it will shut down that LeasePinger.
+ * Moreover, each ConnectionValidator associated with that LeasePinger will notify its
+ * ConnectionListeners of the broken connection. At that point, the LeasePinger will be
+ * destroyed, and all of the associated Clients will be disconnected.
+ */
+ public void connect(ConnectionListener listener, Map metadata) throws Exception
+ {
if (isConnected())
return;
@@ -533,7 +571,7 @@
invoker = InvokerRegistry.createClientInvoker(locator, configuration);
}
- connect(invoker);
+ connect(invoker, listener, metadata);
connected = true;
}
@@ -544,14 +582,14 @@
* remoting client. Otherwise resource will not be cleaned up and if the target server requires
* a lease, it will be maintained in the background.
*/
- public void disconnect()
+ public synchronized void disconnect()
{
if (invoker != null)
{
// this is a noop if no lease is active
invoker.terminateLease(sessionId, disconnectTimeout);
- synchronized (connectionValidatorLock)
+// synchronized (connectionValidatorLock)
{
if (connectionValidator != null)
{
@@ -1600,18 +1638,30 @@
// Package protected ----------------------------------------------------------------------------
+ synchronized void disconnectAndNotify()
+ {
+// synchronized (connectionValidatorLock)
+ {
+ disconnect();
+ if (connectionValidator != null)
+ {
+ connectionValidator.notifyListeners(new Exception("Could not connect to server!"));
+ }
+ }
+ }
+
// Protected ------------------------------------------------------------------------------------
// Private --------------------------------------------------------------------------------------
- private void connect(ClientInvoker invoker)
+ private void connect(ClientInvoker invoker, ConnectionListener listener, Map metadata)
{
if (invoker != null)
{
invoker.connect();
try
{
- setupClientLease(invoker);
+ setupClientLease(invoker, listener, metadata);
}
catch (Throwable throwable)
{
@@ -1629,7 +1679,7 @@
}
}
- private void setupClientLease(ClientInvoker invoker) throws Throwable
+ private void setupClientLease(ClientInvoker invoker, ConnectionListener listener, Map metadata) throws Throwable
{
long leasePeriod = -1;
boolean enableLease = false;
@@ -1712,8 +1762,19 @@
if (enableLease)
{
- invoker.establishLease(sessionId, configuration, leasePeriod);
+ Map temp = new HashMap(configuration);
+ if (metadata != null)
+ {
+ temp.putAll(metadata);
+ }
+ temp.put(CLIENT, this);
+ temp.put(CONNECTION_LISTENER, listener);
+ invoker.establishLease(sessionId, temp, leasePeriod);
}
+ else if (listener != null)
+ {
+ addConnectionListener(listener, configuration);
+ }
}
private Object invoke(Object param, Map metadata, InvokerLocator callbackServerLocator)
15 years, 6 months
JBoss Remoting SVN: r5124 - remoting2/branches/2.x/src/main/org/jboss/remoting/transport/socket.
by jboss-remoting-commits@lists.jboss.org
Author: ron.sigal(a)jboss.com
Date: 2009-05-01 20:37:05 -0400 (Fri, 01 May 2009)
New Revision: 5124
Modified:
remoting2/branches/2.x/src/main/org/jboss/remoting/transport/socket/TimedOutputStream.java
Log:
JBREM-1120: Changed Logger declaration, Timer() constructor to support Java 1.4
Modified: remoting2/branches/2.x/src/main/org/jboss/remoting/transport/socket/TimedOutputStream.java
===================================================================
--- remoting2/branches/2.x/src/main/org/jboss/remoting/transport/socket/TimedOutputStream.java 2009-05-01 20:51:40 UTC (rev 5123)
+++ remoting2/branches/2.x/src/main/org/jboss/remoting/transport/socket/TimedOutputStream.java 2009-05-02 00:37:05 UTC (rev 5124)
@@ -5,11 +5,11 @@
import java.util.Timer;
import java.util.TimerTask;
-import org.apache.log4j.Logger;
+import org.jboss.logging.Logger;
public class TimedOutputStream extends OutputStream
{
- static private Timer timer = new Timer("TimedOutputStreamTimer", true);
+ static private Timer timer = new Timer(true);
static private Logger log = Logger.getLogger(TimedOutputStream.class);
private OutputStream os;
@@ -42,7 +42,7 @@
}
catch (IllegalStateException e)
{
- timer = new Timer("TimedOutputStreamTimer", true);
+ timer = new Timer(true);
timer.schedule(new OutputTimerTask(this), outputTimeout);
if (log.isTraceEnabled()) log.trace("scheduled OutputTimerTask: " + outputTimeout);
}
@@ -77,7 +77,8 @@
}
catch (IllegalStateException e)
{
- timer = new Timer("TimedOutputStreamTimer", true);
+// timer = new Timer("TimedOutputStreamTimer", true);
+ timer = new Timer(true);
timer.schedule(new OutputTimerTask(this), outputTimeout);
if (log.isTraceEnabled()) log.trace("scheduled OutputTimerTask: " + outputTimeout);
}
15 years, 6 months
JBoss Remoting SVN: r5123 - remoting2/branches/2.2/src/tests/org/jboss/test/remoting/socketfactory.
by jboss-remoting-commits@lists.jboss.org
Author: ron.sigal(a)jboss.com
Date: 2009-05-01 16:51:40 -0400 (Fri, 01 May 2009)
New Revision: 5123
Added:
remoting2/branches/2.2/src/tests/org/jboss/test/remoting/socketfactory/UseAllSocketFactoryParamsTestCase.java
Log:
JBREM-1121: New unit tests.
Added: remoting2/branches/2.2/src/tests/org/jboss/test/remoting/socketfactory/UseAllSocketFactoryParamsTestCase.java
===================================================================
--- remoting2/branches/2.2/src/tests/org/jboss/test/remoting/socketfactory/UseAllSocketFactoryParamsTestCase.java (rev 0)
+++ remoting2/branches/2.2/src/tests/org/jboss/test/remoting/socketfactory/UseAllSocketFactoryParamsTestCase.java 2009-05-01 20:51:40 UTC (rev 5123)
@@ -0,0 +1,320 @@
+/*
+* 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.socketfactory;
+
+import java.io.IOException;
+import java.net.InetAddress;
+import java.net.Socket;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.management.MBeanServer;
+
+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.InvokerCallbackHandler;
+import org.jboss.remoting.socketfactory.SocketCreationListener;
+import org.jboss.remoting.transport.Connector;
+import org.jboss.remoting.transport.PortUtil;
+
+
+/**
+ * Unit tests for JBREM-1121.
+ *
+ * @author <a href="ron.sigal(a)jboss.com">Ron Sigal</a>
+ * @version $Rev$
+ * <p>
+ * Copyright Apr 21, 2009
+ * </p>
+ */
+public class UseAllSocketFactoryParamsTestCase extends TestCase
+{
+ private static Logger log = Logger.getLogger(UseAllSocketFactoryParamsTestCase.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.INFO);
+ 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);
+ }
+
+ TestSocketCreationListener.called = false;
+ }
+
+
+ public void tearDown()
+ {
+ }
+
+
+ public void testDefault() throws Throwable
+ {
+ log.info("entering " + getName());
+
+ // Start server.
+ setupServer(false, null);
+
+ // Create client.
+ InvokerLocator clientLocator = new InvokerLocator(locatorURI);
+ HashMap clientConfig = new HashMap();
+ clientConfig.put(InvokerLocator.FORCE_REMOTE, "true");
+ addExtraClientConfig(clientConfig);
+ log.info("clientConfig: " + clientConfig);
+ Client client = new Client(clientLocator, clientConfig);
+ client.connect();
+ log.info("client is connected");
+
+ // Test connections.
+ assertEquals("abc", client.invoke("abc"));
+ log.info("connection is good");
+
+ // Verify that TestSocketCreationListener was called.
+ assertFalse(TestSocketCreationListener.called);
+
+ client.disconnect();
+ shutdownServer();
+ log.info(getName() + " PASSES");
+ }
+
+
+ public void testUseAllSocketFactoryParamsFalseInLocator() throws Throwable
+ {
+ log.info("entering " + getName());
+
+ // Start server.
+ setupServer(true, "false");
+
+ // Create client.
+ InvokerLocator clientLocator = new InvokerLocator(locatorURI);
+ HashMap clientConfig = new HashMap();
+ clientConfig.put(InvokerLocator.FORCE_REMOTE, "true");
+ addExtraClientConfig(clientConfig);
+ log.info("clientConfig: " + clientConfig);
+ Client client = new Client(clientLocator, clientConfig);
+ client.connect();
+ log.info("client is connected");
+
+ // Test connections.
+ assertEquals("abc", client.invoke("abc"));
+ log.info("connection is good");
+
+ // Verify that TestSocketCreationListener was called.
+ assertFalse(TestSocketCreationListener.called);
+
+ client.disconnect();
+ shutdownServer();
+ log.info(getName() + " PASSES");
+ }
+
+
+ public void testUseAllSocketFactoryParamsFalseInConfig() throws Throwable
+ {
+ log.info("entering " + getName());
+
+ // Start server.
+ setupServer(false, null);
+
+ // Create client.
+ InvokerLocator clientLocator = new InvokerLocator(locatorURI);
+ HashMap clientConfig = new HashMap();
+ clientConfig.put(InvokerLocator.FORCE_REMOTE, "true");
+ clientConfig.put(Remoting.USE_ALL_SOCKET_FACTORY_PARAMS, "false");
+ addExtraClientConfig(clientConfig);
+ log.info("clientConfig: " + clientConfig);
+ Client client = new Client(clientLocator, clientConfig);
+ client.connect();
+ log.info("client is connected");
+
+ // Test connections.
+ assertEquals("abc", client.invoke("abc"));
+ log.info("connection is good");
+
+ // Verify that TestSocketCreationListener was called.
+ assertFalse(TestSocketCreationListener.called);
+
+ client.disconnect();
+ shutdownServer();
+ log.info(getName() + " PASSES");
+ }
+
+
+ public void testUseAllSocketFactoryParamsTrueInLocator() throws Throwable
+ {
+ log.info("entering " + getName());
+
+ // Start server.
+ setupServer(true, "true");
+
+ // Create client.
+ InvokerLocator clientLocator = new InvokerLocator(locatorURI);
+ HashMap clientConfig = new HashMap();
+ clientConfig.put(InvokerLocator.FORCE_REMOTE, "true");
+ addExtraClientConfig(clientConfig);
+ log.info("clientConfig: " + clientConfig);
+ Client client = new Client(clientLocator, clientConfig);
+ client.connect();
+ log.info("client is connected");
+
+ // Test connections.
+ assertEquals("abc", client.invoke("abc"));
+ log.info("connection is good");
+
+ // Verify that TestSocketCreationListener was called.
+ assertTrue(TestSocketCreationListener.called);
+
+ client.disconnect();
+ shutdownServer();
+ log.info(getName() + " PASSES");
+ }
+
+
+ public void testUseAllSocketFactoryParamsTrueInConfig() throws Throwable
+ {
+ log.info("entering " + getName());
+
+ // Start server.
+ setupServer(false, null);
+
+ // Create client.
+ InvokerLocator clientLocator = new InvokerLocator(locatorURI);
+ HashMap clientConfig = new HashMap();
+ clientConfig.put(InvokerLocator.FORCE_REMOTE, "true");
+ clientConfig.put(Remoting.USE_ALL_SOCKET_FACTORY_PARAMS, "true");
+ addExtraClientConfig(clientConfig);
+ log.info("clientConfig: " + clientConfig);
+ Client client = new Client(clientLocator, clientConfig);
+ client.connect();
+ log.info("client is connected");
+
+ // Test connections.
+ assertEquals("abc", client.invoke("abc"));
+ log.info("connection is good");
+
+ // Verify that TestSocketCreationListener was called.
+ assertTrue(TestSocketCreationListener.called);
+
+ 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(boolean setUseAllParams, String useAllParams) throws Exception
+ {
+ host = InetAddress.getLocalHost().getHostAddress();
+ port = PortUtil.findFreePort(host);
+ locatorURI = getTransport() + "://" + host + ":" + port;
+ locatorURI += "/?" + Remoting.SOCKET_CREATION_CLIENT_LISTENER + "=" + TestSocketCreationListener.class.getName();
+ String metadata = System.getProperty("remoting.metadata");
+ if (metadata != null)
+ {
+ locatorURI += "&" + metadata;
+ }
+ if (setUseAllParams)
+ {
+ locatorURI += "&" + Remoting.USE_ALL_SOCKET_FACTORY_PARAMS + "=" + useAllParams;
+ }
+ serverLocator = new InvokerLocator(locatorURI);
+ log.info("Starting remoting server with locator uri of: " + locatorURI);
+ HashMap config = new HashMap();
+ config.put(InvokerLocator.FORCE_REMOTE, "true");
+ 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
+ {
+ public void addListener(InvokerCallbackHandler callbackHandler) {}
+ public Object invoke(final InvocationRequest invocation) throws Throwable
+ {
+ return invocation.getParameter();
+ }
+ public void removeListener(InvokerCallbackHandler callbackHandler) {}
+ public void setMBeanServer(MBeanServer server) {}
+ public void setInvoker(ServerInvoker invoker) {}
+ }
+
+
+ public static class TestSocketCreationListener implements SocketCreationListener
+ {
+ static public boolean called;
+
+ public TestSocketCreationListener()
+ {
+ log.info("TestSocketCreationListener created");
+ }
+
+ public void socketCreated(Socket socket, Object source) throws IOException
+ {
+ called = true;
+ log.info("TestSocketCreationListener called");
+ }
+ }
+}
\ No newline at end of file
15 years, 6 months
JBoss Remoting SVN: r5122 - remoting2/branches/2.2/src/tests/org/jboss/test/remoting/socketfactory.
by jboss-remoting-commits@lists.jboss.org
Author: ron.sigal(a)jboss.com
Date: 2009-05-01 16:51:03 -0400 (Fri, 01 May 2009)
New Revision: 5122
Modified:
remoting2/branches/2.2/src/tests/org/jboss/test/remoting/socketfactory/SocketFactoryClassNameTestRoot.java
Log:
JBREM-1121: Added variation of existing test methods with "useAllSocketFactoryParams=true" in InvokerLocator.
Modified: remoting2/branches/2.2/src/tests/org/jboss/test/remoting/socketfactory/SocketFactoryClassNameTestRoot.java
===================================================================
--- remoting2/branches/2.2/src/tests/org/jboss/test/remoting/socketfactory/SocketFactoryClassNameTestRoot.java 2009-05-01 20:41:26 UTC (rev 5121)
+++ remoting2/branches/2.2/src/tests/org/jboss/test/remoting/socketfactory/SocketFactoryClassNameTestRoot.java 2009-05-01 20:51:03 UTC (rev 5122)
@@ -77,11 +77,11 @@
log.info("entering " + getName());
// Start server.
- setupServer();
+ setupServer(false);
// Create client.
String clientLocatorURI = locatorURI;
- clientLocatorURI += "/?" + Remoting.SOCKET_FACTORY_CLASS_NAME + "=" + getSocketFactoryClass().getName();
+ clientLocatorURI += "&" + Remoting.SOCKET_FACTORY_CLASS_NAME + "=" + getSocketFactoryClass().getName();
InvokerLocator clientLocator = new InvokerLocator(clientLocatorURI);
HashMap clientConfig = new HashMap();
clientConfig.put(InvokerLocator.FORCE_REMOTE, "true");
@@ -111,7 +111,7 @@
log.info("entering " + getName());
// Start server.
- setupServer();
+ setupServer(false);
// Create client.
InvokerLocator clientLocator = new InvokerLocator(locatorURI);
@@ -139,6 +139,73 @@
}
+ public void testSocketFactoryClassNameInLocatorWithUseAllParams() throws Throwable
+ {
+ log.info("entering " + getName());
+
+ // Start server.
+ setupServer(true);
+
+ // Create client.
+ String clientLocatorURI = locatorURI;
+ clientLocatorURI += "&" + Remoting.SOCKET_FACTORY_CLASS_NAME + "=" + getSocketFactoryClass().getName();
+ InvokerLocator clientLocator = new InvokerLocator(clientLocatorURI);
+ 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 to " + clientLocatorURI);
+
+ // Test connections.
+ assertEquals("abc", client.invoke("abc"));
+ log.info("connection is good");
+
+ // Verify client invoker is using configured SocketFactory.
+ AbstractInvoker invoker = (AbstractInvoker) client.getInvoker();
+ SocketFactory socketFactory = invoker.getSocketFactory();
+ log.info("SocketFactory: " + socketFactory);
+ assertTrue(getSocketFactoryClass().isInstance(socketFactory));
+
+ client.disconnect();
+ shutdownServer();
+ log.info(getName() + " PASSES");
+ }
+
+
+ public void testSocketFactoryClassNameInConfigMapWithUseAllParams() throws Throwable
+ {
+ log.info("entering " + getName());
+
+ // Start server.
+ setupServer(true);
+
+ // Create client.
+ InvokerLocator clientLocator = new InvokerLocator(locatorURI);
+ HashMap clientConfig = new HashMap();
+ clientConfig.put(InvokerLocator.FORCE_REMOTE, "true");
+ clientConfig.put(Remoting.SOCKET_FACTORY_CLASS_NAME, getSocketFactoryClass().getName());
+ addExtraClientConfig(clientConfig);
+ Client client = new Client(clientLocator, clientConfig);
+ client.connect();
+ log.info("client is connected");
+
+ // Test connections.
+ assertEquals("abc", client.invoke("abc"));
+ log.info("connection is good");
+
+ // Verify client invoker is using configured SocketFactory.
+ AbstractInvoker invoker = (AbstractInvoker) client.getInvoker();
+ SocketFactory socketFactory = invoker.getSocketFactory();
+ log.info("SocketFactory: " + socketFactory);
+ assertTrue(getSocketFactoryClass().isInstance(socketFactory));
+
+ client.disconnect();
+ shutdownServer();
+ log.info(getName() + " PASSES");
+ }
+
+
protected abstract String getTransport();
@@ -152,11 +219,20 @@
protected void addExtraServerConfig(Map config) {}
- protected void setupServer() throws Exception
+ protected void setupServer(boolean useAllParams) throws Exception
{
host = InetAddress.getLocalHost().getHostAddress();
port = PortUtil.findFreePort(host);
- locatorURI = getTransport() + "://" + host + ":" + port;
+ locatorURI = getTransport() + "://" + host + ":" + port + "/?x=x";
+ String metadata = System.getProperty("remoting.metadata");
+ if (metadata != null)
+ {
+ locatorURI += "&" + metadata;
+ }
+ if (useAllParams)
+ {
+ locatorURI += "&" + Remoting.USE_ALL_SOCKET_FACTORY_PARAMS + "=true";
+ }
serverLocator = new InvokerLocator(locatorURI);
log.info("Starting remoting server with locator uri of: " + locatorURI);
HashMap config = new HashMap();
15 years, 6 months
JBoss Remoting SVN: r5121 - remoting2/branches/2.2/src/main/org/jboss/remoting.
by jboss-remoting-commits@lists.jboss.org
Author: ron.sigal(a)jboss.com
Date: 2009-05-01 16:41:26 -0400 (Fri, 01 May 2009)
New Revision: 5121
Modified:
remoting2/branches/2.2/src/main/org/jboss/remoting/AbstractInvoker.java
Log:
JBREM-1121: Added getConfiguration().
Modified: remoting2/branches/2.2/src/main/org/jboss/remoting/AbstractInvoker.java
===================================================================
--- remoting2/branches/2.2/src/main/org/jboss/remoting/AbstractInvoker.java 2009-05-01 20:40:33 UTC (rev 5120)
+++ remoting2/branches/2.2/src/main/org/jboss/remoting/AbstractInvoker.java 2009-05-01 20:41:26 UTC (rev 5121)
@@ -352,6 +352,10 @@
return wrapSocketFactory(factory, configuration);
}
+ protected Map getConfiguration()
+ {
+ return configuration;
+ }
static public SocketFactory wrapSocketFactory(SocketFactory socketFactory, Map config)
{
15 years, 6 months
JBoss Remoting SVN: r5120 - remoting2/branches/2.2/src/main/org/jboss/remoting.
by jboss-remoting-commits@lists.jboss.org
Author: ron.sigal(a)jboss.com
Date: 2009-05-01 16:40:33 -0400 (Fri, 01 May 2009)
New Revision: 5120
Modified:
remoting2/branches/2.2/src/main/org/jboss/remoting/RemoteClientInvoker.java
Log:
JBREM-1121: Added optional behavior for getting SocketFactory parameters from InvokerLocator.
Modified: remoting2/branches/2.2/src/main/org/jboss/remoting/RemoteClientInvoker.java
===================================================================
--- remoting2/branches/2.2/src/main/org/jboss/remoting/RemoteClientInvoker.java 2009-05-01 20:35:45 UTC (rev 5119)
+++ remoting2/branches/2.2/src/main/org/jboss/remoting/RemoteClientInvoker.java 2009-05-01 20:40:33 UTC (rev 5120)
@@ -25,6 +25,8 @@
import java.util.Map;
+import org.jboss.logging.Logger;
+
/**
* This class extends the MicroRemoteClientInvoker and adds extra
* functionality that can not be included in a J2ME envrionment, such as
@@ -35,6 +37,8 @@
*/
public abstract class RemoteClientInvoker extends MicroRemoteClientInvoker
{
+ private static Logger log = Logger.getLogger(RemoteClientInvoker.class);
+
public RemoteClientInvoker(InvokerLocator locator)
{
super(locator);
@@ -52,6 +56,35 @@
configuration.put(Remoting.SOCKET_FACTORY_CLASS_NAME, socketFactoryClassName);
}
}
- socketFactory = createSocketFactory(configuration);
+ if (useAllParams(getConfiguration()))
+ {
+ // getConfiguration() returns combination of InvokerLocator and configuration parameters.
+ socketFactory = createSocketFactory(getConfiguration());
+ }
+ else
+ {
+ socketFactory = createSocketFactory(configuration);
+ }
}
+
+ protected boolean useAllParams(Map configuration)
+ {
+ boolean result = false;
+ if (configuration != null)
+ {
+ Object o = configuration.get(Remoting.USE_ALL_SOCKET_FACTORY_PARAMS);
+ if (o != null)
+ {
+ if (o instanceof String)
+ {
+ result = Boolean.valueOf((String) o).booleanValue();
+ }
+ else
+ {
+ log.warn("Value of " + Remoting.USE_ALL_SOCKET_FACTORY_PARAMS + " must be a String: " + o);
+ }
+ }
+ }
+ return result;
+ }
}
15 years, 6 months
JBoss Remoting SVN: r5119 - remoting2/branches/2.2/src/main/org/jboss/remoting.
by jboss-remoting-commits@lists.jboss.org
Author: ron.sigal(a)jboss.com
Date: 2009-05-01 16:35:45 -0400 (Fri, 01 May 2009)
New Revision: 5119
Modified:
remoting2/branches/2.2/src/main/org/jboss/remoting/Remoting.java
Log:
JBREM-1121: Added USE_ALL_SOCKET_FACTORY_PARAMS constant.
Modified: remoting2/branches/2.2/src/main/org/jboss/remoting/Remoting.java
===================================================================
--- remoting2/branches/2.2/src/main/org/jboss/remoting/Remoting.java 2009-05-01 20:24:51 UTC (rev 5118)
+++ remoting2/branches/2.2/src/main/org/jboss/remoting/Remoting.java 2009-05-01 20:35:45 UTC (rev 5119)
@@ -76,4 +76,10 @@
* org.jboss.remoting.ServerInvoker.InvalidStateException to an org.jboss.remoting.CannotConnectException.
*/
public static final String CHANGE_INVALID_STATE_TO_CANNOT_CONNECT = "changeInvalidStateToCannotConnect";
+
+ /**
+ * A flag indicating that RemoteClientInvoker should use parameters in the InvokerLocator as
+ * well as the configuration map when creating a SocketFactory.
+ */
+ public static final String USE_ALL_SOCKET_FACTORY_PARAMS = "useAllSocketFactoryParams";
}
15 years, 6 months
JBoss Remoting SVN: r5118 - remoting2/branches/2.2/docs/guide/en.
by jboss-remoting-commits@lists.jboss.org
Author: ron.sigal(a)jboss.com
Date: 2009-05-01 16:24:51 -0400 (Fri, 01 May 2009)
New Revision: 5118
Modified:
remoting2/branches/2.2/docs/guide/en/chap5.xml
Log:
JBREM-1119: Added discussion of ServerInvokerCallbackHandler.shutdown().
Modified: remoting2/branches/2.2/docs/guide/en/chap5.xml
===================================================================
--- remoting2/branches/2.2/docs/guide/en/chap5.xml 2009-05-01 20:10:55 UTC (rev 5117)
+++ remoting2/branches/2.2/docs/guide/en/chap5.xml 2009-05-01 20:24:51 UTC (rev 5118)
@@ -3171,6 +3171,16 @@
generated callback to some or all of them.
</para>
+ <para>
+ <emphasis role="bold">Note.</emphasis> As of release 2.2.2.SP12,,
+ <classname>ServerInvokerCallbackHandler</classname>
+ has a new method, <methodname>shutdown()</methodname>, which can be used by, for example, the
+ <classname>ServerInvocationHandler</classname> with which it is registered, or by an
+ <classname>org.jboss.remoting.ConnectionListener</classname> upon being informed of a
+ connection failure, to clean up the <classname>ServerInvokerCallbackHandler</classname>
+ and references thereto.
+ </para>
+
<para>
The client side of a callback connection is identified in one of two
ways, according to whether there is a callback
15 years, 6 months
JBoss Remoting SVN: r5117 - remoting2/branches/2.2/src/tests/org/jboss/test/remoting/callback/leak.
by jboss-remoting-commits@lists.jboss.org
Author: ron.sigal(a)jboss.com
Date: 2009-05-01 16:10:55 -0400 (Fri, 01 May 2009)
New Revision: 5117
Modified:
remoting2/branches/2.2/src/tests/org/jboss/test/remoting/callback/leak/ServerInvokerCallbackHandlerLeakTestCase.java
Log:
JBREM-1119: Changed JIRA reference in javadoc.
Modified: remoting2/branches/2.2/src/tests/org/jboss/test/remoting/callback/leak/ServerInvokerCallbackHandlerLeakTestCase.java
===================================================================
--- remoting2/branches/2.2/src/tests/org/jboss/test/remoting/callback/leak/ServerInvokerCallbackHandlerLeakTestCase.java 2009-05-01 19:59:09 UTC (rev 5116)
+++ remoting2/branches/2.2/src/tests/org/jboss/test/remoting/callback/leak/ServerInvokerCallbackHandlerLeakTestCase.java 2009-05-01 20:10:55 UTC (rev 5117)
@@ -57,7 +57,7 @@
/**
- * Unit tests for JBREM-1113.
+ * Unit tests for JBREM-1119.
*
* @author <a href="ron.sigal(a)jboss.com">Ron Sigal</a>
* @version $Rev$
15 years, 6 months