Author: ron.sigal(a)jboss.com
Date: 2008-09-08 02:19:23 -0400 (Mon, 08 Sep 2008)
New Revision: 4552
Modified:
remoting2/branches/2.x/src/tests/org/jboss/test/remoting/detection/jndi/CleanDetectionTestServer.java
remoting2/branches/2.x/src/tests/org/jboss/test/remoting/detection/jndi/JNDIDetector2TestCase.java
remoting2/branches/2.x/src/tests/org/jboss/test/remoting/detection/jndi/JNDIDetectorTest1.java
remoting2/branches/2.x/src/tests/org/jboss/test/remoting/detection/jndi/JNDIDetectorTestCase.java
remoting2/branches/2.x/src/tests/org/jboss/test/remoting/detection/jndi/RestartTestServer.java
remoting2/branches/2.x/src/tests/org/jboss/test/remoting/detection/jndi/deadlock/Server.java
remoting2/branches/2.x/src/tests/org/jboss/test/remoting/detection/jndi/deadlock3/Server.java
remoting2/branches/2.x/src/tests/org/jboss/test/remoting/detection/jndi/startup/JNDIDetectorServer.java
Log:
JBREM-1033: Creates NamingBeanImpl reflectively to enable use of older jnpserver.jar.
Modified:
remoting2/branches/2.x/src/tests/org/jboss/test/remoting/detection/jndi/CleanDetectionTestServer.java
===================================================================
---
remoting2/branches/2.x/src/tests/org/jboss/test/remoting/detection/jndi/CleanDetectionTestServer.java 2008-09-08
06:18:18 UTC (rev 4551)
+++
remoting2/branches/2.x/src/tests/org/jboss/test/remoting/detection/jndi/CleanDetectionTestServer.java 2008-09-08
06:19:23 UTC (rev 4552)
@@ -30,11 +30,11 @@
import org.jboss.remoting.callback.InvokerCallbackHandler;
import org.jboss.remoting.detection.AbstractDetector;
import org.jboss.remoting.detection.jndi.JNDIDetector;
+import org.jboss.remoting.samples.detection.jndi.SimpleJNDIServer;
import org.jboss.remoting.transport.Connector;
import org.jboss.remoting.transport.PortUtil;
import org.jboss.remoting.util.SecurityUtility;
import org.jnp.server.Main;
-import org.jnp.server.NamingBeanImpl;
import javax.management.MBeanServer;
import javax.management.MBeanServerFactory;
@@ -43,6 +43,7 @@
import java.io.InputStream;
import java.io.OutputStream;
import java.lang.reflect.Field;
+import java.lang.reflect.Method;
import java.net.InetAddress;
import java.net.ServerSocket;
import java.net.Socket;
@@ -127,17 +128,32 @@
protected void setupJNDI() throws Exception
{
- SecurityUtility.setSystemProperty("java.naming.factory.initial",
"org.jnp.interfaces.NamingContextFactory");
- NamingBeanImpl namingBean = new NamingBeanImpl();
- namingBean.start();
-
+ Object namingBean = null;
+ Class namingBeanClass = null;
+ try
+ {
+ namingBeanClass = Class.forName("org.jnp.server.NamingBeanImpl");
+ namingBean = namingBeanClass.newInstance();
+ Method startMethod = namingBeanClass.getMethod("start", new Class[]
{});
+ SecurityUtility.setSystemProperty("java.naming.factory.initial",
"org.jnp.interfaces.NamingContextFactory");
+ startMethod.invoke(namingBean, new Object[] {});
+ }
+ catch (Exception e)
+ {
+ SimpleJNDIServer.println("Cannot find NamingBeanImpl: must be running jdk
1.4");
+ }
+
String host = InetAddress.getLocalHost().getHostAddress();
jserver = new Main();
jserver.setPort(detectorPort);
jserver.setBindAddress(host);
jserver.setRmiPort(31000);
- jserver.setNamingInfo(namingBean);
+ if (namingBean != null)
+ {
+ Method setNamingInfoMethod =
jserver.getClass().getMethod("setNamingInfo", new Class[] {namingBeanClass});
+ setNamingInfoMethod.invoke(jserver, new Object[] {namingBean});
+ }
jserver.start();
System.out.println("Started JNDI server on " + host + ":" +
port);
}
Modified:
remoting2/branches/2.x/src/tests/org/jboss/test/remoting/detection/jndi/JNDIDetector2TestCase.java
===================================================================
---
remoting2/branches/2.x/src/tests/org/jboss/test/remoting/detection/jndi/JNDIDetector2TestCase.java 2008-09-08
06:18:18 UTC (rev 4551)
+++
remoting2/branches/2.x/src/tests/org/jboss/test/remoting/detection/jndi/JNDIDetector2TestCase.java 2008-09-08
06:19:23 UTC (rev 4552)
@@ -1,11 +1,12 @@
package org.jboss.test.remoting.detection.jndi;
import org.jboss.jrunit.harness.TestDriver;
+import org.jboss.remoting.samples.detection.jndi.SimpleJNDIServer;
import org.jboss.remoting.util.SecurityUtility;
import org.jnp.server.Main;
-import org.jnp.server.NamingBeanImpl;
import org.apache.log4j.Level;
+import java.lang.reflect.Method;
import java.net.InetAddress;
/**
@@ -28,14 +29,29 @@
{
try
{
- SecurityUtility.setSystemProperty("java.naming.factory.initial",
"org.jnp.interfaces.NamingContextFactory");
- NamingBeanImpl namingBean = new NamingBeanImpl();
- namingBean.start();
+ Object namingBean = null;
+ Class namingBeanClass = null;
+ try
+ {
+ namingBeanClass = Class.forName("org.jnp.server.NamingBeanImpl");
+ namingBean = namingBeanClass.newInstance();
+ Method startMethod = namingBeanClass.getMethod("start", new Class[]
{});
+ SecurityUtility.setSystemProperty("java.naming.factory.initial",
"org.jnp.interfaces.NamingContextFactory");
+ startMethod.invoke(namingBean, new Object[] {});
+ }
+ catch (Exception e)
+ {
+ SimpleJNDIServer.println("Cannot find NamingBeanImpl: must be running
jdk 1.4");
+ }
String host = InetAddress.getLocalHost().getHostAddress();
Main jserver = new Main();
- jserver.setNamingInfo(namingBean);
+ if (namingBean != null)
+ {
+ Method setNamingInfoMethod =
jserver.getClass().getMethod("setNamingInfo", new Class[] {namingBeanClass});
+ setNamingInfoMethod.invoke(jserver, new Object[] {namingBean});
+ }
int port = 2410;
jserver.setPort(port);
jserver.setBindAddress(host);
Modified:
remoting2/branches/2.x/src/tests/org/jboss/test/remoting/detection/jndi/JNDIDetectorTest1.java
===================================================================
---
remoting2/branches/2.x/src/tests/org/jboss/test/remoting/detection/jndi/JNDIDetectorTest1.java 2008-09-08
06:18:18 UTC (rev 4551)
+++
remoting2/branches/2.x/src/tests/org/jboss/test/remoting/detection/jndi/JNDIDetectorTest1.java 2008-09-08
06:19:23 UTC (rev 4552)
@@ -22,6 +22,7 @@
package org.jboss.test.remoting.detection.jndi;
+import java.lang.reflect.Method;
import java.net.InetAddress;
import javax.management.MBeanServer;
import javax.management.MBeanServerFactory;
@@ -32,12 +33,12 @@
import org.jboss.remoting.detection.jndi.JNDIDetector;
import org.jboss.remoting.network.NetworkInstance;
import org.jboss.remoting.network.NetworkRegistry;
+import org.jboss.remoting.samples.detection.jndi.SimpleJNDIServer;
import org.jboss.remoting.transport.Connector;
import org.jboss.remoting.util.SecurityUtility;
import org.jboss.test.remoting.TestUtil;
import org.jboss.test.remoting.transport.mock.MockServerInvocationHandler;
import org.jnp.server.Main;
-import org.jnp.server.NamingBeanImpl;
import junit.framework.TestCase;
@@ -168,15 +169,30 @@
try
{
// start JNDI server
- SecurityUtility.setSystemProperty("java.naming.factory.initial",
"org.jnp.interfaces.NamingContextFactory");
- NamingBeanImpl namingBean = new NamingBeanImpl();
- namingBean.start();
+ Object namingBean = null;
+ Class namingBeanClass = null;
+ try
+ {
+ namingBeanClass = Class.forName("org.jnp.server.NamingBeanImpl");
+ namingBean = namingBeanClass.newInstance();
+ Method startMethod = namingBeanClass.getMethod("start", new Class[]
{});
+ SecurityUtility.setSystemProperty("java.naming.factory.initial",
"org.jnp.interfaces.NamingContextFactory");
+ startMethod.invoke(namingBean, new Object[] {});
+ }
+ catch (Exception e)
+ {
+ SimpleJNDIServer.println("Cannot find NamingBeanImpl: must be running
jdk 1.4");
+ }
int port = 1099;
//String host = "localhost";
String host = InetAddress.getLocalHost().getHostName();
Main JNDIServer = new Main();
- JNDIServer.setNamingInfo(namingBean);
+ if (namingBean != null)
+ {
+ Method setNamingInfoMethod =
JNDIServer.getClass().getMethod("setNamingInfo", new Class[]
{namingBeanClass});
+ setNamingInfoMethod.invoke(JNDIServer, new Object[] {namingBean});
+ }
JNDIServer.setPort(port);
JNDIServer.setBindAddress(host);
JNDIServer.start();
Modified:
remoting2/branches/2.x/src/tests/org/jboss/test/remoting/detection/jndi/JNDIDetectorTestCase.java
===================================================================
---
remoting2/branches/2.x/src/tests/org/jboss/test/remoting/detection/jndi/JNDIDetectorTestCase.java 2008-09-08
06:18:18 UTC (rev 4551)
+++
remoting2/branches/2.x/src/tests/org/jboss/test/remoting/detection/jndi/JNDIDetectorTestCase.java 2008-09-08
06:19:23 UTC (rev 4552)
@@ -22,12 +22,13 @@
package org.jboss.test.remoting.detection.jndi;
+import java.lang.reflect.Method;
import java.net.InetAddress;
import org.apache.log4j.Level;
import org.jboss.jrunit.harness.TestDriver;
+import org.jboss.remoting.samples.detection.jndi.SimpleJNDIServer;
import org.jboss.remoting.util.SecurityUtility;
import org.jnp.server.Main;
-import org.jnp.server.NamingBeanImpl;
/**
* This should be used as the main test case for JNDI detector.
@@ -50,15 +51,30 @@
try
{
// start JNDI server
- SecurityUtility.setSystemProperty("java.naming.factory.initial",
"org.jnp.interfaces.NamingContextFactory");
- NamingBeanImpl namingBean = new NamingBeanImpl();
- namingBean.start();
+ Object namingBean = null;
+ Class namingBeanClass = null;
+ try
+ {
+ namingBeanClass = Class.forName("org.jnp.server.NamingBeanImpl");
+ namingBean = namingBeanClass.newInstance();
+ Method startMethod = namingBeanClass.getMethod("start", new Class[]
{});
+ SecurityUtility.setSystemProperty("java.naming.factory.initial",
"org.jnp.interfaces.NamingContextFactory");
+ startMethod.invoke(namingBean, new Object[] {});
+ }
+ catch (Exception e)
+ {
+ SimpleJNDIServer.println("Cannot find NamingBeanImpl: must be running
jdk 1.4");
+ }
int port = 1099;
//String host = "localhost";
String host = InetAddress.getLocalHost().getHostName();
Main JNDIServer = new Main();
- JNDIServer.setNamingInfo(namingBean);
+ if (namingBean != null)
+ {
+ Method setNamingInfoMethod =
JNDIServer.getClass().getMethod("setNamingInfo", new Class[]
{namingBeanClass});
+ setNamingInfoMethod.invoke(JNDIServer, new Object[] {namingBean});
+ }
JNDIServer.setPort(port);
JNDIServer.setBindAddress(host);
JNDIServer.start();
Modified:
remoting2/branches/2.x/src/tests/org/jboss/test/remoting/detection/jndi/RestartTestServer.java
===================================================================
---
remoting2/branches/2.x/src/tests/org/jboss/test/remoting/detection/jndi/RestartTestServer.java 2008-09-08
06:18:18 UTC (rev 4551)
+++
remoting2/branches/2.x/src/tests/org/jboss/test/remoting/detection/jndi/RestartTestServer.java 2008-09-08
06:19:23 UTC (rev 4552)
@@ -29,10 +29,10 @@
import org.jboss.remoting.ServerInvoker;
import org.jboss.remoting.callback.InvokerCallbackHandler;
import org.jboss.remoting.detection.jndi.JNDIDetector;
+import org.jboss.remoting.samples.detection.jndi.SimpleJNDIServer;
import org.jboss.remoting.transport.Connector;
import org.jboss.remoting.util.SecurityUtility;
import org.jnp.server.Main;
-import org.jnp.server.NamingBeanImpl;
import javax.management.MBeanServer;
import javax.management.MBeanServerFactory;
@@ -40,6 +40,7 @@
import java.io.InputStream;
import java.io.OutputStream;
+import java.lang.reflect.Method;
import java.net.InetAddress;
import java.net.ServerSocket;
import java.net.Socket;
@@ -124,14 +125,29 @@
protected void setupJNDI() throws Exception
{
- SecurityUtility.setSystemProperty("java.naming.factory.initial",
"org.jnp.interfaces.NamingContextFactory");
- NamingBeanImpl namingBean = new NamingBeanImpl();
- namingBean.start();
+ Object namingBean = null;
+ Class namingBeanClass = null;
+ try
+ {
+ namingBeanClass = Class.forName("org.jnp.server.NamingBeanImpl");
+ namingBean = namingBeanClass.newInstance();
+ Method startMethod = namingBeanClass.getMethod("start", new Class[]
{});
+ SecurityUtility.setSystemProperty("java.naming.factory.initial",
"org.jnp.interfaces.NamingContextFactory");
+ startMethod.invoke(namingBean, new Object[] {});
+ }
+ catch (Exception e)
+ {
+ SimpleJNDIServer.println("Cannot find NamingBeanImpl: must be running jdk
1.4");
+ };
String host = InetAddress.getLocalHost().getHostAddress();
jserver = new Main();
- jserver.setNamingInfo(namingBean);
+ if (namingBean != null)
+ {
+ Method setNamingInfoMethod =
jserver.getClass().getMethod("setNamingInfo", new Class[] {namingBeanClass});
+ setNamingInfoMethod.invoke(jserver, new Object[] {namingBean});
+ }
jserver.setPort(detectorPort);
jserver.setBindAddress(host);
jserver.setRmiPort(31000);
Modified:
remoting2/branches/2.x/src/tests/org/jboss/test/remoting/detection/jndi/deadlock/Server.java
===================================================================
---
remoting2/branches/2.x/src/tests/org/jboss/test/remoting/detection/jndi/deadlock/Server.java 2008-09-08
06:18:18 UTC (rev 4551)
+++
remoting2/branches/2.x/src/tests/org/jboss/test/remoting/detection/jndi/deadlock/Server.java 2008-09-08
06:19:23 UTC (rev 4552)
@@ -30,17 +30,19 @@
import org.jboss.remoting.ServerInvoker;
import org.jboss.remoting.callback.InvokerCallbackHandler;
import org.jboss.remoting.detection.jndi.JNDIDetector;
+import org.jboss.remoting.samples.detection.jndi.SimpleJNDIServer;
import org.jboss.remoting.security.SSLSocketBuilder;
import org.jboss.remoting.transport.Connector;
import org.jboss.remoting.transport.sslmultiplex.SSLMultiplexServerInvoker;
import org.jboss.remoting.util.SecurityUtility;
import org.jnp.server.Main;
-import org.jnp.server.NamingBeanImpl;
import javax.management.MBeanServer;
import javax.management.MBeanServerFactory;
import javax.management.ObjectName;
import javax.net.ServerSocketFactory;
+
+import java.lang.reflect.Method;
import java.net.InetAddress;
import java.net.UnknownHostException;
import java.util.HashMap;
@@ -219,14 +221,29 @@
private void startJNDIServer() throws Exception
{
- SecurityUtility.setSystemProperty("java.naming.factory.initial",
"org.jnp.interfaces.NamingContextFactory");
- NamingBeanImpl namingBean = new NamingBeanImpl();
- namingBean.start();
+ Object namingBean = null;
+ Class namingBeanClass = null;
+ try
+ {
+ namingBeanClass = Class.forName("org.jnp.server.NamingBeanImpl");
+ namingBean = namingBeanClass.newInstance();
+ Method startMethod = namingBeanClass.getMethod("start", new Class[]
{});
+ SecurityUtility.setSystemProperty("java.naming.factory.initial",
"org.jnp.interfaces.NamingContextFactory");
+ startMethod.invoke(namingBean, new Object[] {});
+ }
+ catch (Exception e)
+ {
+ SimpleJNDIServer.println("Cannot find NamingBeanImpl: must be running jdk
1.4");
+ }
String host = InetAddress.getLocalHost().getHostAddress();
Main jserver = new Main();
- jserver.setNamingInfo(namingBean);
+ if (namingBean != null)
+ {
+ Method setNamingInfoMethod =
jserver.getClass().getMethod("setNamingInfo", new Class[] {namingBeanClass});
+ setNamingInfoMethod.invoke(jserver, new Object[] {namingBean});
+ }
jserver.setPort(2410);
jserver.setBindAddress(host);
jserver.setRmiPort(31000);
Modified:
remoting2/branches/2.x/src/tests/org/jboss/test/remoting/detection/jndi/deadlock3/Server.java
===================================================================
---
remoting2/branches/2.x/src/tests/org/jboss/test/remoting/detection/jndi/deadlock3/Server.java 2008-09-08
06:18:18 UTC (rev 4551)
+++
remoting2/branches/2.x/src/tests/org/jboss/test/remoting/detection/jndi/deadlock3/Server.java 2008-09-08
06:19:23 UTC (rev 4552)
@@ -30,17 +30,19 @@
import org.jboss.remoting.ServerInvoker;
import org.jboss.remoting.callback.InvokerCallbackHandler;
import org.jboss.remoting.detection.jndi.JNDIDetector;
+import org.jboss.remoting.samples.detection.jndi.SimpleJNDIServer;
import org.jboss.remoting.security.SSLSocketBuilder;
import org.jboss.remoting.transport.Connector;
import org.jboss.remoting.transport.sslmultiplex.SSLMultiplexServerInvoker;
import org.jboss.remoting.util.SecurityUtility;
import org.jnp.server.Main;
-import org.jnp.server.NamingBeanImpl;
import javax.management.MBeanServer;
import javax.management.MBeanServerFactory;
import javax.management.ObjectName;
import javax.net.ServerSocketFactory;
+
+import java.lang.reflect.Method;
import java.net.InetAddress;
import java.net.UnknownHostException;
import java.util.HashMap;
@@ -192,14 +194,29 @@
private void startJNDIServer() throws Exception
{
- SecurityUtility.setSystemProperty("java.naming.factory.initial",
"org.jnp.interfaces.NamingContextFactory");
- NamingBeanImpl namingBean = new NamingBeanImpl();
- namingBean.start();
+ Object namingBean = null;
+ Class namingBeanClass = null;
+ try
+ {
+ namingBeanClass = Class.forName("org.jnp.server.NamingBeanImpl");
+ namingBean = namingBeanClass.newInstance();
+ Method startMethod = namingBeanClass.getMethod("start", new Class[]
{});
+ SecurityUtility.setSystemProperty("java.naming.factory.initial",
"org.jnp.interfaces.NamingContextFactory");
+ startMethod.invoke(namingBean, new Object[] {});
+ }
+ catch (Exception e)
+ {
+ SimpleJNDIServer.println("Cannot find NamingBeanImpl: must be running jdk
1.4");
+ }
String host = InetAddress.getLocalHost().getHostAddress();
Main jserver = new Main();
- jserver.setNamingInfo(namingBean);
+ if (namingBean != null)
+ {
+ Method setNamingInfoMethod =
jserver.getClass().getMethod("setNamingInfo", new Class[] {namingBeanClass});
+ setNamingInfoMethod.invoke(jserver, new Object[] {namingBean});
+ }
jserver.setPort(2410);
jserver.setBindAddress(host);
jserver.setRmiPort(31000);
Modified:
remoting2/branches/2.x/src/tests/org/jboss/test/remoting/detection/jndi/startup/JNDIDetectorServer.java
===================================================================
---
remoting2/branches/2.x/src/tests/org/jboss/test/remoting/detection/jndi/startup/JNDIDetectorServer.java 2008-09-08
06:18:18 UTC (rev 4551)
+++
remoting2/branches/2.x/src/tests/org/jboss/test/remoting/detection/jndi/startup/JNDIDetectorServer.java 2008-09-08
06:19:23 UTC (rev 4552)
@@ -26,16 +26,17 @@
import org.jboss.remoting.InvokerLocator;
import org.jboss.remoting.detection.jndi.JNDIDetector;
import org.jboss.remoting.network.NetworkRegistry;
+import org.jboss.remoting.samples.detection.jndi.SimpleJNDIServer;
import org.jboss.remoting.transport.Connector;
import org.jboss.remoting.util.SecurityUtility;
import org.jboss.test.remoting.TestUtil;
import org.jboss.test.remoting.transport.mock.MockServerInvocationHandler;
import org.jnp.server.Main;
-import org.jnp.server.NamingBeanImpl;
-
import javax.management.MBeanServer;
import javax.management.MBeanServerFactory;
import javax.management.ObjectName;
+
+import java.lang.reflect.Method;
import java.net.InetAddress;
/**
@@ -54,14 +55,29 @@
public void setUp() throws Exception
{
// start JNDI server
- SecurityUtility.setSystemProperty("java.naming.factory.initial",
"org.jnp.interfaces.NamingContextFactory");
- NamingBeanImpl namingBean = new NamingBeanImpl();
- namingBean.start();
+ Object namingBean = null;
+ Class namingBeanClass = null;
+ try
+ {
+ namingBeanClass = Class.forName("org.jnp.server.NamingBeanImpl");
+ namingBean = namingBeanClass.newInstance();
+ Method startMethod = namingBeanClass.getMethod("start", new Class[]
{});
+ SecurityUtility.setSystemProperty("java.naming.factory.initial",
"org.jnp.interfaces.NamingContextFactory");
+ startMethod.invoke(namingBean, new Object[] {});
+ }
+ catch (Exception e)
+ {
+ SimpleJNDIServer.println("Cannot find NamingBeanImpl: must be running jdk
1.4");
+ }
int port = 1099;
String host = InetAddress.getLocalHost().getHostName();
Main JNDIServer = new Main();
- JNDIServer.setNamingInfo(namingBean);
+ if (namingBean != null)
+ {
+ Method setNamingInfoMethod =
JNDIServer.getClass().getMethod("setNamingInfo", new Class[]
{namingBeanClass});
+ setNamingInfoMethod.invoke(JNDIServer, new Object[] {namingBean});
+ }
JNDIServer.setPort(port);
JNDIServer.setBindAddress(host);
JNDIServer.start();