User: starksm
Date: 01/07/19 13:13:07
Modified: src/main/org/jboss/ejb/plugins/jrmp/server Tag: Branch_2_4
JRMPContainerInvoker.java
Added: src/main/org/jboss/ejb/plugins/jrmp/server Tag: Branch_2_4
DefaultSocketFactory.java
Log:
Add support for binding the JRMP/RMI objects on a specific address
Integrate the jnp changes to support binding the name service on a specific address
Revision Changes Path
No revision
No revision
1.37.4.1 +62 -18
jboss/src/main/org/jboss/ejb/plugins/jrmp/server/JRMPContainerInvoker.java
Index: JRMPContainerInvoker.java
===================================================================
RCS file:
/cvsroot/jboss/jboss/src/main/org/jboss/ejb/plugins/jrmp/server/JRMPContainerInvoker.java,v
retrieving revision 1.37
retrieving revision 1.37.4.1
diff -u -r1.37 -r1.37.4.1
--- JRMPContainerInvoker.java 2001/05/02 03:04:15 1.37
+++ JRMPContainerInvoker.java 2001/07/19 20:13:07 1.37.4.1
@@ -12,6 +12,7 @@
import java.io.IOException;
import java.lang.reflect.Method;
import java.lang.reflect.Constructor;
+import java.net.UnknownHostException;
import java.rmi.ServerException;
import java.rmi.RemoteException;
import java.rmi.MarshalledObject;
@@ -69,14 +70,13 @@
import org.w3c.dom.Element;
/**
- * <description>
*
- * @see <related>
- * @author Rickard �berg ([EMAIL PROTECTED])
- * @author <a href="mailto:[EMAIL PROTECTED]">Sebastien
Alborini</a>
- * @author <a href="mailto:[EMAIL PROTECTED]">Marc Fleury</a>
- * @author <a href="mailto:[EMAIL PROTECTED]">Juha Lindfors</a>
- * @version $Revision: 1.37 $
+ * @author Rickard �berg ([EMAIL PROTECTED])
+ * @author <a href="mailto:[EMAIL PROTECTED]">Sebastien Alborini</a>
+ * @author <a href="mailto:[EMAIL PROTECTED]">Marc Fleury</a>
+ * @author <a href="mailto:[EMAIL PROTECTED]">Juha Lindfors</a>
+ * @author <a href="mailto:[EMAIL PROTECTED]">Scott Stark</a>
+ * @version $Revision: 1.37.4.1 $
*/
public class JRMPContainerInvoker
extends RemoteServer
@@ -97,6 +97,8 @@
protected String clientSocketFactoryName;
/** The class name of the optional custom server socket factory */
protected String serverSocketFactoryName;
+ /** The address to bind the rmi port on */
+ protected String serverAddress;
protected boolean jdk122 = false;
protected Container container;
protected String jndiName;
@@ -176,7 +178,8 @@
// Hash it
homeMethodInvokerMap.put(new
Long(RemoteMethodInvocation.calculateHash(getEJBObjectMethod)),getEJBObjectMethod);
- } catch (Exception e)
+ }
+ catch (Exception e)
{
Logger.exception(e);
}
@@ -254,7 +257,7 @@
}
public void start()
- throws Exception
+ throws Exception
{
try
{
@@ -354,7 +357,7 @@
* Invoke a Home interface method.
*/
public MarshalledObject invokeHome(MarshalledObject mimo)
- throws Exception
+ throws Exception
{
ClassLoader oldCl = Thread.currentThread().getContextClassLoader();
Thread.currentThread().setContextClassLoader(container.getClassLoader());
@@ -376,7 +379,7 @@
* Invoke a Remote interface method.
*/
public MarshalledObject invoke(MarshalledObject mimo)
- throws Exception
+ throws Exception
{
ClassLoader oldCl = Thread.currentThread().getContextClassLoader();
Thread.currentThread().setContextClassLoader(container.getClassLoader());
@@ -401,7 +404,7 @@
*/
public Object invokeHome(Method m, Object[] args, Transaction tx,
Principal identity, Object credential)
- throws Exception
+ throws Exception
{
// Check if this call really can be optimized
if
(!m.getDeclaringClass().isAssignableFrom(((ContainerInvokerContainer)container).getHomeClass()))
@@ -445,7 +448,7 @@
*/
public Object invoke(Object id, Method m, Object[] args, Transaction tx,
Principal identity, Object credential )
- throws Exception
+ throws Exception
{
// Check if this call really can be optimized
// If parent of callers classloader is != parent of our classloader -> not
optimizable!
@@ -478,7 +481,8 @@
try
{
return container.invoke(new MethodInvocation(id, m, args, tx, identity,
credential));
- } finally
+ }
+ finally
{
Thread.currentThread().setContextClassLoader(oldCl);
}
@@ -518,10 +522,12 @@
String port = MetaData.getElementContent(portElement);
rmiPort = Integer.parseInt(port);
}
- } catch(NumberFormatException e)
+ }
+ catch(NumberFormatException e)
{
rmiPort = ANONYMOUS_PORT;
- } catch(DeploymentException e)
+ }
+ catch(DeploymentException e)
{
rmiPort = ANONYMOUS_PORT;
}
@@ -554,11 +560,15 @@
Logger.error(e);
serverSocketFactoryName = null;
}
+ Element addrElement = MetaData.getOptionalChild(element,
"RMIServerSocketAddr");
+ if( addrElement != null )
+ this.serverAddress = MetaData.getElementContent(addrElement);
loadCustomSocketFactories(loader);
Logger.debug("Container Invoker RMI Port='"+(rmiPort == ANONYMOUS_PORT ?
"Anonymous" : Integer.toString(rmiPort))+"'");
Logger.debug("Container Invoker Client
SocketFactory='"+(clientSocketFactory == null ? "Default" :
clientSocketFactory.toString())+"'");
Logger.debug("Container Invoker Server
SocketFactory='"+(serverSocketFactory == null ? "Default" :
serverSocketFactory.toString())+"'");
+ Logger.debug("Container Invoker Server SocketAddr='"+(serverAddress == null
? "Default" : serverAddress)+"'");
Logger.debug("Container Invoker Optimize='"+optimize+"'");
}
@@ -567,7 +577,7 @@
// Protected -----------------------------------------------------
protected void rebind(Context ctx, String name, Object val)
- throws NamingException
+ throws NamingException
{
// Bind val to name in ctx, and make sure that all intermediate contexts exist
@@ -610,7 +620,42 @@
{
Class ssfClass = loader.loadClass(serverSocketFactoryName);
serverSocketFactory = (RMIServerSocketFactory)
ssfClass.newInstance();
+ if( serverAddress != null )
+ {
+ // See if the server socket supports setBindAddress(String)
+ try
+ {
+ Class[] parameterTypes = {String.class};
+ Method m = ssfClass.getMethod("setBindAddress",
parameterTypes);
+ Object[] args = {serverAddress};
+ m.invoke(serverSocketFactory, args);
+ }
+ catch(NoSuchMethodException e)
+ {
+ Logger.error("Socket factory does not support
setBindAddress(String)");
+ // Go with default address
+ }
+ catch(Exception e)
+ {
+ Logger.error("Failed to setBindAddress="+serverAddress+" on
socket factory");
+ // Go with default address
+ }
+ }
}
+ // If a bind address was specified create a DefaultSocketFactory
+ else if( serverAddress != null )
+ {
+ DefaultSocketFactory defaultFactory = new DefaultSocketFactory();
+ serverSocketFactory = defaultFactory;
+ try
+ {
+ defaultFactory.setBindAddress(serverAddress);
+ }
+ catch(UnknownHostException e)
+ {
+ Logger.error("Failed to setBindAddress="+serverAddress+" on
socket factory, "+e.getMessage());
+ }
+ }
}
catch(Exception e)
{
@@ -621,4 +666,3 @@
// Inner classes -------------------------------------------------
}
-
No revision
No revision
1.1.2.1 +55 -0
jboss/src/main/org/jboss/ejb/plugins/jrmp/server/Attic/DefaultSocketFactory.java
_______________________________________________
Jboss-development mailing list
[EMAIL PROTECTED]
http://lists.sourceforge.net/lists/listinfo/jboss-development