[jboss-cvs] JBossAS SVN: r57277 - in branches/JBoss_4_0_2_CP: cluster/src/main/org/jboss/invocation/pooled/server common/src/main/org/jboss/net/sockets server/src/main/org/jboss/invocation/pooled/interfaces server/src/main/org/jboss/invocation/pooled/server tools/etc/buildmagic

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Fri Sep 29 00:06:34 EDT 2006


Author: ryan.campbell at jboss.com
Date: 2006-09-29 00:06:33 -0400 (Fri, 29 Sep 2006)
New Revision: 57277

Modified:
   branches/JBoss_4_0_2_CP/cluster/src/main/org/jboss/invocation/pooled/server/PooledInvokerHA.java
   branches/JBoss_4_0_2_CP/common/src/main/org/jboss/net/sockets/DefaultSocketFactory.java
   branches/JBoss_4_0_2_CP/server/src/main/org/jboss/invocation/pooled/interfaces/PooledInvokerProxy.java
   branches/JBoss_4_0_2_CP/server/src/main/org/jboss/invocation/pooled/interfaces/ServerAddress.java
   branches/JBoss_4_0_2_CP/server/src/main/org/jboss/invocation/pooled/server/PooledInvoker.java
   branches/JBoss_4_0_2_CP/tools/etc/buildmagic/buildmagic.ent
   branches/JBoss_4_0_2_CP/tools/etc/buildmagic/version-info.xml
Log:
ASPATCH-46: JBAS-2234: PooledInvokerHA not dealing with 0.0.0.0 addresses correctly

Modified: branches/JBoss_4_0_2_CP/cluster/src/main/org/jboss/invocation/pooled/server/PooledInvokerHA.java
===================================================================
--- branches/JBoss_4_0_2_CP/cluster/src/main/org/jboss/invocation/pooled/server/PooledInvokerHA.java	2006-09-29 03:45:30 UTC (rev 57276)
+++ branches/JBoss_4_0_2_CP/cluster/src/main/org/jboss/invocation/pooled/server/PooledInvokerHA.java	2006-09-29 04:06:33 UTC (rev 57277)
@@ -1,11 +1,10 @@
-/***************************************
+/*
+ * JBoss, Home of Professional Open Source
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
  *                                     *
- *  JBoss: The OpenSource J2EE WebOS   *
- *                                     *
- *  Distributable under LGPL license.  *
- *  See terms of license at gnu.org.   *
- *                                     *
- ***************************************/
+ */
 
 package org.jboss.invocation.pooled.server;
 
@@ -46,6 +45,7 @@
  * 
  *
  * @author    <a href="mailto:bill at jboss.org">Bill Burke</a>
+ * @version $Revision$
  *
  * @jmx:mbean extends="org.jboss.system.ServiceMBean"
  */
@@ -62,7 +62,8 @@
 
    public java.io.Serializable getStub() 
    {
-      ServerAddress sa = new ServerAddress(clientConnectAddress, clientConnectPort, enableTcpNoDelay, timeout); 
+      ServerAddress sa = new ServerAddress(clientConnectAddress,
+         clientConnectPort, enableTcpNoDelay, timeout, clientSocketFactory); 
       return new PooledInvokerProxy(sa, clientMaxPoolSize);
    }
 
@@ -178,4 +179,4 @@
       }      
    }
 }
-// vim:expandtab:tabstop=3:shiftwidth=3
+// vim:expandtab:tabstop=3:shiftwidth=3
\ No newline at end of file

Modified: branches/JBoss_4_0_2_CP/common/src/main/org/jboss/net/sockets/DefaultSocketFactory.java
===================================================================
--- branches/JBoss_4_0_2_CP/common/src/main/org/jboss/net/sockets/DefaultSocketFactory.java	2006-09-29 03:45:30 UTC (rev 57276)
+++ branches/JBoss_4_0_2_CP/common/src/main/org/jboss/net/sockets/DefaultSocketFactory.java	2006-09-29 04:06:33 UTC (rev 57277)
@@ -1,9 +1,9 @@
 /*
-* JBoss, the OpenSource J2EE webOS
-*
-* Distributable under LGPL license.
-* See terms of license at gnu.org.
-*/
+ * JBoss, Home of Professional Open Source
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
 package org.jboss.net.sockets;
 
 import java.io.IOException;
@@ -12,21 +12,15 @@
 import java.net.ServerSocket;
 import java.net.UnknownHostException;
 import java.rmi.server.RMIServerSocketFactory;
+import javax.net.ServerSocketFactory;
 
-import java.io.IOException;
-import java.io.Serializable;
-import java.net.InetAddress;
-import java.net.ServerSocket;
-import java.net.UnknownHostException;
-import java.rmi.server.RMIServerSocketFactory;
-
 /** An implementation of RMIServerSocketFactory that supports backlog and
  * bind address settings
  *
  * @author Scott.Stark at jboss.org
  * @version $Revision$
  */
-public class DefaultSocketFactory
+public class DefaultSocketFactory extends ServerSocketFactory
    implements RMIServerSocketFactory, Serializable
 {
    static final long serialVersionUID = -7626239955727142958L;
@@ -83,6 +77,31 @@
      */
     public ServerSocket createServerSocket(int port) throws IOException
     {
+      return createServerSocket(port, backlog, bindAddress);
+   }
+
+   /**
+    * @param port - the port to listen to
+    * @param backlog - how many connections are queued
+    * @return A ServerSocket
+    * @throws IOException
+    */ 
+   public ServerSocket createServerSocket(int port, int backlog)
+      throws IOException
+   {
+      return createServerSocket(port, backlog, null);
+   }
+
+   /**
+    * @param port - the port to listen to
+    * @param backlog - how many connections are queued
+    * @param inetAddress - the network interface address to use
+    * @return
+    * @throws IOException
+    */ 
+   public ServerSocket createServerSocket(int port, int backlog,
+      InetAddress inetAddress) throws IOException
+   {
         ServerSocket activeSocket = new ServerSocket(port, backlog, bindAddress);
         return activeSocket;
     }
@@ -95,4 +114,4 @@
     {
         return getClass().getName().hashCode();
     }
-}
+}
\ No newline at end of file

Modified: branches/JBoss_4_0_2_CP/server/src/main/org/jboss/invocation/pooled/interfaces/PooledInvokerProxy.java
===================================================================
--- branches/JBoss_4_0_2_CP/server/src/main/org/jboss/invocation/pooled/interfaces/PooledInvokerProxy.java	2006-09-29 03:45:30 UTC (rev 57276)
+++ branches/JBoss_4_0_2_CP/server/src/main/org/jboss/invocation/pooled/interfaces/PooledInvokerProxy.java	2006-09-29 04:06:33 UTC (rev 57277)
@@ -1,5 +1,5 @@
 /*
- * JBoss, the OpenSource J2EE webOS
+ * JBoss, Home of Professional Open Source
  *
  * Distributable under LGPL license.
  * See terms of license at gnu.org.
@@ -7,31 +7,34 @@
 
 package org.jboss.invocation.pooled.interfaces;
 
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+
+import org.jboss.invocation.Invocation;
+import org.jboss.invocation.Invoker;
+import org.jboss.tm.TransactionPropagationContextFactory;
+import org.jboss.logging.Logger;
+
+import javax.transaction.SystemException;
+import javax.transaction.TransactionRolledbackException;
+import java.io.BufferedInputStream;
+import java.io.BufferedOutputStream;
+import java.io.Externalizable;
 import java.io.IOException;
-import java.io.Externalizable;
 import java.io.ObjectInput;
 import java.io.ObjectOutput;
-import java.io.BufferedOutputStream;
-import java.io.BufferedInputStream;
-import java.io.ObjectInputStream;
-import java.io.ObjectOutputStream;
+import java.io.EOFException;
+import java.io.OptionalDataException;
 import java.net.Socket;
+import java.rmi.ConnectException;
 import java.rmi.MarshalledObject;
 import java.rmi.NoSuchObjectException;
 import java.rmi.ServerException;
-import java.rmi.ConnectException;
 import java.util.HashMap;
 import java.util.Iterator;
 import java.util.LinkedList;
 
-import javax.transaction.TransactionRolledbackException;
-import javax.transaction.SystemException;
 
-import org.jboss.invocation.Invocation;
-import org.jboss.invocation.Invoker;
-import org.jboss.tm.TransactionPropagationContextFactory;
-
-
 /**
  * Client socket connections are pooled to avoid the overhead of
  * making a connection.  RMI seems to do a new connection with each
@@ -44,13 +47,16 @@
    implements Invoker, Externalizable
 {
    // Attributes ----------------------------------------------------
+   private static final Logger log = Logger.getLogger(PooledInvokerProxy.class);
    /** The serialVersionUID @since 1.1.4.3 */
    private static final long serialVersionUID = -1456509931095566410L;
+   /** The current wire format we write */
+   private static final int WIRE_VERSION = 1;
 
    /**
     * Factory for transaction propagation contexts.
     *
-    * @todo marcf remove all transaction spill from here
+    * todo: marcf remove all transaction spill from here
     * 
     * When set to a non-null value, it is used to get transaction
     * propagation contexts for remote method invocations.
@@ -93,7 +99,12 @@
     * instances of proxies attached to a specific invoker
     */
    protected LinkedList pool = null;
+   /** */
    protected int maxPoolSize;
+   /** The */
+   protected int retryCount = 1;
+   /** The logging trace flag */
+   private transient boolean trace;
 
    protected static class ClientSocket
    {
@@ -126,6 +137,7 @@
    public PooledInvokerProxy()
    {
       super();
+      trace = log.isTraceEnabled();
    }
 
    
@@ -135,8 +147,13 @@
     */
    public PooledInvokerProxy(ServerAddress sa, int maxPoolSize)
    {
+      this(sa, maxPoolSize, MAX_RETRIES);
+   }
+   public PooledInvokerProxy(ServerAddress sa, int maxPoolSize, int retryCount)
+   {
       this.address = sa;
       this.maxPoolSize = maxPoolSize;
+      this.retryCount = retryCount;
    }
 
    /**
@@ -144,6 +161,9 @@
     */
    public static void clearPool(ServerAddress sa)
    {
+      boolean trace = log.isTraceEnabled();
+      if( trace )
+         log.trace("clearPool, sa: "+sa);
       try
       {
          LinkedList thepool = (LinkedList)connectionPools.get(sa);
@@ -156,6 +176,8 @@
                ClientSocket socket = (ClientSocket)thepool.removeFirst();
                try
                {
+                  if( trace )
+                     log.trace("Closing, ClientSocket: "+socket.socket);
                   socket.socket.close();
                   socket.socket = null;
                }
@@ -216,7 +238,7 @@
       // have nothing to do with backlog or number of threads
       // waiting in accept() on the server.
       // 
-      for (int i = 0; i < MAX_RETRIES; i++)
+      for (int i = 0; i < retryCount; i++)
       {
          synchronized(pool)
          {
@@ -233,12 +255,23 @@
          
          try
          {
-            socket = new Socket(address.address, address.port);
+            if( trace)
+               log.trace("Connecting to addr: "+address.address+", port: "+address.port);
+            /*
+            if( address.clientSocketFactory != null )
+               socket = address.clientSocketFactory.createSocket(address.address, address.port);
+            else
+            */
+               socket = new Socket(address.address, address.port);
+            if( trace )
+               log.trace("Connected: "+socket);
             break;
          }
-         catch (Exception ex)
+         catch (ConnectException ex)
          {
-            if (i + 1 < MAX_RETRIES)
+            if( trace )
+               log.trace("Connect failed", ex);
+            if (i + 1 < retryCount)
             {
                Thread.sleep(1);
                continue;
@@ -288,7 +321,7 @@
    /**
     * ???
     *
-    * @todo MOVE TO TRANSACTION
+    * todo: MOVE TO TRANSACTION
     *  
     * @return the transaction propagation context of the transaction
     *         associated with the current thread.
@@ -401,27 +434,68 @@
          throw ex;
       }  
    }
-   
+
    /**
-    * Externalize this instance and handle obtaining the remoteInvoker stub
-    */
+    * Write out the serializable data
+    * @serialData address ServerAddress
+    * @serialData maxPoolSize int 
+    * @serialData WIRE_VERSION int version
+    * @serialData retryCount int
+    * @param out
+    * @throws IOException
+    */ 
    public void writeExternal(final ObjectOutput out)
       throws IOException
-   { 
+   {
+      // The legacy wire format is address, maxPoolSize
       out.writeObject(address);
       out.writeInt(maxPoolSize);
+      // Write out the current version format and its data
+      out.writeInt(WIRE_VERSION);
+      out.writeInt(retryCount);
    }
  
-   /**
-    * Un-externalize this instance.
-    *
-    */
    public void readExternal(final ObjectInput in)
       throws IOException, ClassNotFoundException
    {
+      trace = log.isTraceEnabled();
       address = (ServerAddress)in.readObject();
       maxPoolSize = in.readInt();
+      int version = 0;
+      try
+      {
+         version = in.readInt();
+      }
+      catch(EOFException e)
+      {
+         // No version written and there is no more data
+      }
+      catch(OptionalDataException e)
+      {
+         // No version written and there is data from other objects
+      }
+
+      switch( version )
+      {
+         case 0:
+            // This has no retryCount, default it to the hard-coded value
+            retryCount = MAX_RETRIES;
+            break;
+         case 1:
+            readVersion1(in);
+            break;
+         default:
+            /* Assume a newer version that only adds defaultable values.
+            The alternative would be to thrown an exception
+            */
+            break;
+      }
       initPool();
    }
-}
 
+   private void readVersion1(final ObjectInput in)
+      throws IOException
+   {
+      retryCount = in.readInt();
+   }
+}
\ No newline at end of file

Modified: branches/JBoss_4_0_2_CP/server/src/main/org/jboss/invocation/pooled/interfaces/ServerAddress.java
===================================================================
--- branches/JBoss_4_0_2_CP/server/src/main/org/jboss/invocation/pooled/interfaces/ServerAddress.java	2006-09-29 03:45:30 UTC (rev 57276)
+++ branches/JBoss_4_0_2_CP/server/src/main/org/jboss/invocation/pooled/interfaces/ServerAddress.java	2006-09-29 04:06:33 UTC (rev 57277)
@@ -1,14 +1,13 @@
-/***************************************
- *                                     *
- *  JBoss: The OpenSource J2EE WebOS   *
- *                                     *
- *  Distributable under LGPL license.  *
- *  See terms of license at gnu.org.   *
- *                                     *
- ***************************************/
+/*
+ * JBoss, Home of Professional Open Source
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
 package org.jboss.invocation.pooled.interfaces;
 
 import java.io.Serializable;
+import javax.net.SocketFactory;
 
 /**
  * This class encapsulates all the required information for a client to 
@@ -17,7 +16,8 @@
  * It also attempts to provide a fast hash() function since this object
  * is used as a key in a hashmap mainted by the ConnectionManager. 
  *
- * @author <a href="mailto:hiram.chirino at jboss.org">Hiram Chirino</a>
+ * @author Bill Burke
+ * @author Scott.Stark at jboss.org
  * @version $Revision$
  */
 public class ServerAddress implements Serializable
@@ -26,24 +26,32 @@
    private static final long serialVersionUID = -7206359745950445445L;
 
    /**
-    * Address of host ot connect to
+    * Address of host to connect to
+    * @serial
     */
    public String address;
 
    /**
     * Port the service is listening on
+    * @serial
     */
    public int port;
 
    /**
     * If the TcpNoDelay option should be used on the socket.
+    * @serial
     */
    public boolean enableTcpNoDelay = false;
 
    /**
     * Timeout of setSoTimeout
+    * @serial
     */
    public int timeout = 60000;
+   /** An option socket factory for connecting to the server
+    * @serial
+    */
+   //public SocketFactory clientSocketFactory;
 
    /**
     * This object is used as a key in a hashmap,
@@ -51,13 +59,24 @@
     */
    private transient int hashCode;
 
-   public ServerAddress(String address, int port, boolean enableTcpNoDelay, int timeout)
+   /**
+    * The server address/port representation.
+    * 
+    * @param address - hostname/ip of the server
+    * @param port - the invoker port
+    * @param enableTcpNoDelay - the Socket.setTcpNoDelay flag
+    * @param timeout - the Socket.setSoTimeout value
+    * @param clientSocketFactory - optional SocketFactory
+    */ 
+   public ServerAddress(String address, int port, boolean enableTcpNoDelay,
+      int timeout, SocketFactory clientSocketFactory)
    {
       this.address = address;
       this.port = port;
       this.enableTcpNoDelay = enableTcpNoDelay;
       this.hashCode = address.hashCode() + port;
       this.timeout = timeout;
+      //this.clientSocketFactory = clientSocketFactory;
    }
 
    public String toString()
@@ -91,4 +110,4 @@
       return hashCode;
    }
 
-}
+}
\ No newline at end of file

Modified: branches/JBoss_4_0_2_CP/server/src/main/org/jboss/invocation/pooled/server/PooledInvoker.java
===================================================================
--- branches/JBoss_4_0_2_CP/server/src/main/org/jboss/invocation/pooled/server/PooledInvoker.java	2006-09-29 03:45:30 UTC (rev 57276)
+++ branches/JBoss_4_0_2_CP/server/src/main/org/jboss/invocation/pooled/server/PooledInvoker.java	2006-09-29 04:06:33 UTC (rev 57277)
@@ -1,26 +1,27 @@
-/***************************************
- *                                     *
- *  JBoss: The OpenSource J2EE WebOS   *
- *                                     *
- *  Distributable under LGPL license.  *
- *  See terms of license at gnu.org.   *
- *                                     *
- ***************************************/
+/*
+ * JBoss, Home of Professional Open Source
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
 
 package org.jboss.invocation.pooled.server;
 
 import java.net.InetAddress;
 import java.net.ServerSocket;
 import java.net.Socket;
+import java.net.UnknownHostException;
 import java.util.LinkedList;
 import java.security.PrivilegedExceptionAction;
 import java.security.AccessController;
 import java.security.PrivilegedActionException;
-import java.io.IOException;
+import java.lang.reflect.Method;
 import javax.management.ObjectName;
 import javax.naming.InitialContext;
 import javax.transaction.Transaction;
 import javax.transaction.TransactionManager;
+import javax.net.SocketFactory;
+import javax.net.ServerSocketFactory;
 
 import org.jboss.invocation.Invocation;
 import org.jboss.invocation.pooled.interfaces.PooledInvokerProxy;
@@ -30,9 +31,12 @@
 import org.jboss.proxy.TransactionInterceptor;
 import org.jboss.system.Registry;
 import org.jboss.system.ServiceMBeanSupport;
+import org.jboss.system.server.ServerConfigUtil;
 import org.jboss.tm.TransactionPropagationContextFactory;
 import org.jboss.tm.TransactionPropagationContextImporter;
 import org.jboss.tm.TransactionPropagationContextUtil;
+import org.jboss.security.SecurityDomain;
+import org.jboss.net.sockets.DefaultSocketFactory;
 
 /**
  * This invoker pools Threads and client connections to one server socket.
@@ -49,7 +53,9 @@
  * So we have connection pooling on the server and client side, and thread pooling
  * on the server side.  Pool, is an LRU pool, so resources should be cleaned up.
  * 
- * @author  <a href="mailto:bill at jboss.org">Bill Burke</a>
+ *
+ * @author <a href="mailto:bill at jboss.org">Bill Burke</a>
+ * @author Scott.Stark at jboss.org
  * @version $Revision$
  *
  * @jmx:mbean extends="org.jboss.system.ServiceMBean"
@@ -87,11 +93,30 @@
     * The port a client will use to connect to the sever.
     */
    protected int clientConnectPort = 0;
+   /**
+    * The number of retry attempts on 
+    */ 
+   protected int clientRetryCount = 1;
 
    protected int backlog = 200;
 
+   /** The class name of the optional custom client socket factory */
+   protected String clientSocketFactoryName;
+
+   /** The class name of the optional custom server socket factory */
+   protected String serverSocketFactoryName;
+
+   /** An optional custom client socket factory */
+   protected SocketFactory clientSocketFactory;
+
+   /** An optional custom server socket factory */
+   protected ServerSocketFactory serverSocketFactory;
+   /** The server socket for */
    protected ServerSocket serverSocket = null;
 
+   /** The name of the security domain to use with server sockets that support SSL */
+   protected String sslDomain;
+
    protected int timeout = 60000; // 60 seconds.
 
    protected int maxPoolSize = 300;
@@ -166,8 +191,12 @@
          (clientConnectAddress == null || clientConnectAddress.length() == 0)
             ? InetAddress.getLocalHost().getHostName()
             : clientConnectAddress;
+      /* We need to check the address against "0.0.0.0" as this is not a valid
+      address although some jdks will default to the host, while others fail
+      with java.net.BindException: Cannot assign requested address: connect
+      */
+      clientConnectAddress = ServerConfigUtil.fixRemoteAddress(clientConnectAddress);
 
-
       clientpool = new LRUPool(2, maxPoolSize);
       clientpool.create();
       threadpool = new LinkedList();
@@ -181,8 +210,9 @@
        serverBindPort = serverSocket.getLocalPort();
       clientConnectPort = (clientConnectPort == 0) ? serverSocket.getLocalPort() : clientConnectPort;
 
-      ServerAddress sa = new ServerAddress(clientConnectAddress, clientConnectPort, enableTcpNoDelay, timeout); 
-      optimizedInvokerProxy = new PooledInvokerProxy(sa, clientMaxPoolSize);
+      ServerAddress sa = new ServerAddress(clientConnectAddress, clientConnectPort,
+         enableTcpNoDelay, timeout, clientSocketFactory);
+      optimizedInvokerProxy = new PooledInvokerProxy(sa, clientMaxPoolSize, clientRetryCount);
 
       ///////////////////////////////////////////////////////////      
       // Register the service with the rest of the JBoss Kernel
@@ -386,7 +416,7 @@
    /**
     * Setter for property maxPoolSize.
     *
-    * @param maxPoolSize New value of property serverBindPort.
+    * @param maxPoolSize New value of property maxPoolSize.
     * @jmx:managed-attribute
     */
    public void setMaxPoolSize(int maxPoolSize)
@@ -440,7 +470,7 @@
 
    /**
     *
-    * @return Value of property serverBindPort.
+    * @return Value of property CurrentClientPoolSize.
     * @jmx:managed-attribute
     */
    public int getCurrentClientPoolSize()
@@ -450,7 +480,7 @@
 
    /**
     *
-    * @return Value of property serverBindPort.
+    * @return Value of property CurrentThreadPoolSize.
     * @jmx:managed-attribute
     */
    public int getCurrentThreadPoolSize()
@@ -515,6 +545,22 @@
    /**
     * @jmx:managed-attribute
     */
+   public int getClientRetryCount()
+   {
+      return clientRetryCount;
+   }
+
+   /**
+    * @jmx:managed-attribute
+    */
+   public void setClientRetryCount(int clientRetryCount)
+   {
+      this.clientRetryCount = clientRetryCount;
+   }
+
+   /**
+    * @jmx:managed-attribute
+    */
    public int getBacklog()
    {
       return backlog;
@@ -560,8 +606,102 @@
       this.serverBindAddress = serverBindAddress;
    }
 
+   /**
+    * @jmx:managed-attribute
+    */
+   public String getClientSocketFactoryName()
+   {
+      return clientSocketFactoryName;
+   }
+
+   /**
+    * @jmx:managed-attribute
+    */
+   public void setClientSocketFactoryName(String clientSocketFactoryName)
+   {
+      this.clientSocketFactoryName = clientSocketFactoryName;
+   }
+
+   /**
+    * @jmx:managed-attribute
+    */
+   public String getServerSocketFactoryName()
+   {
+      return serverSocketFactoryName;
+   }
+
+   /**
+    * @jmx:managed-attribute
+    */
+   public void setServerSocketFactoryName(String serverSocketFactoryName)
+   {
+      this.serverSocketFactoryName = serverSocketFactoryName;
+   }
+
+   /**
+    * @jmx:managed-attribute
+    */
+   public SocketFactory getClientSocketFactory()
+   {
+      return clientSocketFactory;
+   }
+
+   /**
+    * @jmx:managed-attribute
+    */
+   public void setClientSocketFactory(SocketFactory clientSocketFactory)
+   {
+      this.clientSocketFactory = clientSocketFactory;
+   }
+
+   /**
+    * @jmx:managed-attribute
+    */
+   public ServerSocket getServerSocket()
+   {
+      return serverSocket;
+   }
+
+   /**
+    * @jmx:managed-attribute
+    */
+   public void setServerSocket(ServerSocket serverSocket)
+   {
+      this.serverSocket = serverSocket;
+   }
+
+   /**
+    * @jmx:managed-attribute
+    */
+   public String getSslDomain()
+   {
+      return sslDomain;
+   }
+
+   /**
+    * @jmx:managed-attribute
+    */
+   public void setSslDomain(String sslDomain)
+   {
+      this.sslDomain = sslDomain;
+   }
+
+   /**
+    * @jmx:managed-attribute
+    */
+   public ServerSocketFactory getServerSocketFactory()
+   {
+      return serverSocketFactory;
+   }
+
+   /**
+    * @jmx:managed-attribute
+    */
+   public void setServerSocketFactory(ServerSocketFactory serverSocketFactory)
+   {
+      this.serverSocketFactory = serverSocketFactory;
+   }
    
-   
    /**
     * mbean get-set pair for field transactionManagerService
     * Get the value of transactionManagerService
@@ -594,6 +734,101 @@
       return optimizedInvokerProxy;
    }
 
+   /** Load and instantiate the clientSocketFactory, serverSocketFactory using
+    the TCL and set the bind address and SSL domain if the serverSocketFactory
+    supports it.
+   */
+   protected void loadCustomSocketFactories()
+   {
+      ClassLoader loader = Thread.currentThread().getContextClassLoader();
+
+      try
+      {
+         if( clientSocketFactoryName != null )
+         {
+            Class csfClass = loader.loadClass(clientSocketFactoryName);
+            clientSocketFactory = (SocketFactory) csfClass.newInstance();
+         }
+      }
+      catch (Exception e)
+      {
+         log.error("Failed to load client socket factory", e);
+         clientSocketFactory = null;
+      }
+
+      try
+      {
+         if( serverSocketFactoryName != null )
+         {
+            Class ssfClass = loader.loadClass(serverSocketFactoryName);
+            serverSocketFactory = (ServerSocketFactory) ssfClass.newInstance();
+            if( serverBindAddress != null )
+            {
+               // See if the server socket supports setBindAddress(String)
+               try
+               {
+                  Class[] parameterTypes = {String.class};
+                  Method m = ssfClass.getMethod("setBindAddress", parameterTypes);
+                  Object[] args = {serverBindAddress};
+                  m.invoke(serverSocketFactory, args);
+               }
+               catch (NoSuchMethodException e)
+               {
+                  log.warn("Socket factory does not support setBindAddress(String)");
+                  // Go with default address
+               }
+               catch (Exception e)
+               {
+                  log.warn("Failed to setBindAddress="+serverBindAddress+" on socket factory", e);
+                  // Go with default address
+               }
+            }
+            /* See if the server socket supports setSecurityDomain(SecurityDomain)
+            if an sslDomain was specified
+            */
+            if( sslDomain != null )
+            {
+               try
+               {
+                  InitialContext ctx = new InitialContext();
+                  SecurityDomain domain = (SecurityDomain) ctx.lookup(sslDomain);
+                  Class[] parameterTypes = {SecurityDomain.class};
+                  Method m = ssfClass.getMethod("setSecurityDomain", parameterTypes);
+                  Object[] args = {domain};
+                  m.invoke(serverSocketFactory, args);
+               }
+               catch(NoSuchMethodException e)
+               {
+                  log.error("Socket factory does not support setSecurityDomain(SecurityDomain)");
+               }
+               catch(Exception e)
+               {
+                  log.error("Failed to setSecurityDomain="+sslDomain+" on socket factory", e);
+               }
+            }
+         }
+         // If a bind address was specified create a DefaultSocketFactory
+         else if( serverBindAddress != null )
+         {
+            DefaultSocketFactory defaultFactory = new DefaultSocketFactory(backlog);
+            serverSocketFactory = defaultFactory;
+            try
+            {
+               defaultFactory.setBindAddress(serverBindAddress);
+            }
+            catch (UnknownHostException e)
+            {
+               log.error("Failed to setBindAddress="+serverBindAddress+" on socket factory", e);
+            }
+         }
+      }
+      catch (Exception e)
+      {
+         log.error("operation failed", e);
+         serverSocketFactory = null;
+      }
+   }
+
    /** Perform the MBeanServer.invoke op in a PrivilegedExceptionAction if
     * running with a security manager.
     */ 
@@ -648,4 +883,4 @@
       }
    }
 }
-// vim:expandtab:tabstop=3:shiftwidth=3
+// vim:expandtab:tabstop=3:shiftwidth=3
\ No newline at end of file

Modified: branches/JBoss_4_0_2_CP/tools/etc/buildmagic/buildmagic.ent
===================================================================
--- branches/JBoss_4_0_2_CP/tools/etc/buildmagic/buildmagic.ent	2006-09-29 03:45:30 UTC (rev 57276)
+++ branches/JBoss_4_0_2_CP/tools/etc/buildmagic/buildmagic.ent	2006-09-29 04:06:33 UTC (rev 57277)
@@ -102,7 +102,7 @@
   <property name="version.tag" value=""/>
   <property name="version.name" value="Zion"/>
   <!-- This must be set to the CVS tag for any release -->
-  <property name="version.cvstag" value="JBoss_4_0_2"/>
+  <property name="version.cvstag" value="JBoss_4_0_2_JBAS-2234"/>
 
   <!-- Manifest version info -->
   <property name="specification.title" value="JBoss"/>

Modified: branches/JBoss_4_0_2_CP/tools/etc/buildmagic/version-info.xml
===================================================================
--- branches/JBoss_4_0_2_CP/tools/etc/buildmagic/version-info.xml	2006-09-29 03:45:30 UTC (rev 57276)
+++ branches/JBoss_4_0_2_CP/tools/etc/buildmagic/version-info.xml	2006-09-29 04:06:33 UTC (rev 57277)
@@ -20,7 +20,7 @@
     <property name="version.tag" value=""/>
     <property name="version.name" value="Zion"/>
     <!-- This must be set to the CVS tag for any release -->
-    <property name="version.cvstag" value="JBoss_4_0_2"/>
+    <property name="version.cvstag" value="JBoss_4_0_2_JBAS-2234"/>
 
     <!-- Manifest version info -->
     <property name="specification.title" value="JBoss"/>




More information about the jboss-cvs-commits mailing list