From: Tom E. <te...@us...> - 2004-12-20 18:56:43
|
User: telrod Date: 04/12/20 10:56:36 Modified: src/main/org/jboss/remoting ConnectionFailedException.java InvokerRegistry.java Log: JBREM-17: Updated to allow for better configuration of detectors, added throwing of CannotConnectExceptions within transports, and updated tests cases. Revision Changes Path 1.5 +6 -1 jboss-remoting/src/main/org/jboss/remoting/ConnectionFailedException.java Index: ConnectionFailedException.java =================================================================== RCS file: /cvsroot/jboss/jboss-remoting/src/main/org/jboss/remoting/ConnectionFailedException.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- ConnectionFailedException.java 22 May 2003 04:48:44 -0000 1.4 +++ ConnectionFailedException.java 20 Dec 2004 18:56:36 -0000 1.5 @@ -13,7 +13,7 @@ * fails. * * @author <a href="mailto:jh...@vo...">Jeff Haynie</a> - * @version $Revision: 1.4 $ + * @version $Revision: 1.5 $ */ public class ConnectionFailedException extends RuntimeException { @@ -25,4 +25,9 @@ { super(msg); } + + public ConnectionFailedException(String msg, Exception ex) + { + super(msg, ex); + } } 1.16 +34 -26 jboss-remoting/src/main/org/jboss/remoting/InvokerRegistry.java Index: InvokerRegistry.java =================================================================== RCS file: /cvsroot/jboss/jboss-remoting/src/main/org/jboss/remoting/InvokerRegistry.java,v retrieving revision 1.15 retrieving revision 1.16 diff -u -r1.15 -r1.16 --- InvokerRegistry.java 13 Dec 2004 20:19:48 -0000 1.15 +++ InvokerRegistry.java 20 Dec 2004 18:56:36 -0000 1.16 @@ -29,7 +29,7 @@ * * @author <a href="mailto:jh...@vo...">Jeff Haynie</a> * @author <a href="mailto:te...@e2...">Tom Elrod</a> - * @version $Revision: 1.15 $ + * @version $Revision: 1.16 $ */ public class InvokerRegistry { @@ -73,10 +73,10 @@ public static synchronized InvokerLocator getSuitableServerLocatorForRemote(InvokerLocator remote) { Iterator iter = registeredLocators.iterator(); - while (iter.hasNext()) + while(iter.hasNext()) { InvokerLocator l = (InvokerLocator) iter.next(); - if (l.getProtocol().equals(remote.getProtocol())) + if(l.getProtocol().equals(remote.getProtocol())) { // we found a valid transport match return l; @@ -92,7 +92,7 @@ */ public static final String[] getRegisteredInvokerTransports() { - synchronized (clientLock) + synchronized(clientLock) { Set set = clientInvokers.keySet(); String transports[] = new String[set.size()]; @@ -107,9 +107,9 @@ */ public static final ClientInvoker[] getClientInvokers() { - synchronized (clientLock) + synchronized(clientLock) { - if (clientLocators.isEmpty()) + if(clientLocators.isEmpty()) { return new ClientInvoker[0]; } @@ -125,9 +125,9 @@ */ public static final ServerInvoker[] getServerInvokers() { - synchronized (serverLock) + synchronized(serverLock) { - if (serverLocators.isEmpty()) + if(serverLocators.isEmpty()) { return new ServerInvoker[0]; } @@ -174,7 +174,7 @@ */ public static boolean isClientInvokerRegistered(InvokerLocator locator) { - synchronized (clientLock) + synchronized(clientLock) { return clientLocators.containsKey(locator); } @@ -189,15 +189,23 @@ */ public static void destroyClientInvoker(InvokerLocator locator) { - synchronized (clientLock) + ClientInvoker invoker = null; + + synchronized(clientLock) { - ClientInvoker invoker = (ClientInvoker) clientLocators.remove(locator); - if (invoker != null) + invoker = (ClientInvoker) clientLocators.remove(locator); + } + + if(invoker != null) + { + if(log.isDebugEnabled()) { - invoker.disconnect(); - invoker = null; + log.debug("destroying client for locator: " + locator + ", invoker:" + invoker + ", remaining list:" + clientLocators); } + invoker.disconnect(); + invoker = null; } + } /** @@ -211,14 +219,14 @@ public static ClientInvoker createClientInvoker(InvokerLocator locator) throws Exception { - if (locator == null) + if(locator == null) { throw new NullPointerException("locator cannot be null"); } - synchronized (clientLock) + synchronized(clientLock) { ClientInvoker invoker = (ClientInvoker) clientLocators.get(locator); - if (invoker != null) + if(invoker != null) { return invoker; } @@ -227,7 +235,7 @@ Map parameters = locator.getParameters(); if(parameters != null) { - String value = (String)parameters.get(InvokerLocator.BYVALUE); + String value = (String) parameters.get(InvokerLocator.BYVALUE); if(value != null && Boolean.valueOf(value).booleanValue()) { isPassByValue = true; @@ -237,7 +245,7 @@ // Check to see if server invoker is local // If in server locators map, then created locally by this class ServerInvoker svrInvoker = (ServerInvoker) serverLocators.get(locator); - if (svrInvoker != null && !isPassByValue) + if(svrInvoker != null && !isPassByValue) { LocalClientInvoker localInvoker = new LocalClientInvoker(locator); // have to set reference to local server invoker so client in invoke directly @@ -249,12 +257,12 @@ else //not local { String protocol = locator.getProtocol(); - if (protocol == null) + if(protocol == null) { throw new NullPointerException("protocol cannot be null for the locator"); } Class cl = (Class) clientInvokers.get(protocol); - if (cl == null) + if(cl == null) { throw new RuntimeException("Couldn't find valid client invoker class for transport '" + protocol + "'"); } @@ -275,7 +283,7 @@ */ public static boolean isServerInvokerRegistered(InvokerLocator locator) { - synchronized (serverLock) + synchronized(serverLock) { return serverLocators.containsKey(locator); } @@ -293,15 +301,15 @@ throws Exception { ServerInvoker invoker = null; - synchronized (serverLock) + synchronized(serverLock) { invoker = (ServerInvoker) serverLocators.get(locator); - if (invoker != null) + if(invoker != null) { return invoker; } Class cl = (Class) serverInvokers.get(locator.getProtocol()); - if (cl == null) + if(cl == null) { throw new RuntimeException("Couldn't find valid server invoker class for transport '" + locator.getProtocol() + "'"); } @@ -314,7 +322,7 @@ { return invoker; } - catch (Exception ex) + catch(Exception ex) { serverLocators.remove(locator); registeredLocators.remove(locator); |