JBoss Remoting SVN: r4490 - remoting2/branches/2.x/src/tests/org/jboss/test/remoting/marshall/dynamic/remote/classloaders.
by jboss-remoting-commits@lists.jboss.org
Author: ron.sigal(a)jboss.com
Date: 2008-08-09 21:32:01 -0400 (Sat, 09 Aug 2008)
New Revision: 4490
Modified:
remoting2/branches/2.x/src/tests/org/jboss/test/remoting/marshall/dynamic/remote/classloaders/InjectedClassloadersTestCase.java
Log:
JBREM-1000: Gets random port for loader port.
Modified: remoting2/branches/2.x/src/tests/org/jboss/test/remoting/marshall/dynamic/remote/classloaders/InjectedClassloadersTestCase.java
===================================================================
--- remoting2/branches/2.x/src/tests/org/jboss/test/remoting/marshall/dynamic/remote/classloaders/InjectedClassloadersTestCase.java 2008-08-10 01:25:46 UTC (rev 4489)
+++ remoting2/branches/2.x/src/tests/org/jboss/test/remoting/marshall/dynamic/remote/classloaders/InjectedClassloadersTestCase.java 2008-08-10 01:32:01 UTC (rev 4490)
@@ -238,8 +238,9 @@
{
host = InetAddress.getLocalHost().getHostAddress();
port = PortUtil.findFreePort(host);
+ String loaderPort = Integer.toString(PortUtil.findFreePort(host));
locatorURI = getTransport() + "://" + host + ":" + port;
- locatorURI += "/?" + InvokerLocator.LOADER_PORT + "=4444";
+ locatorURI += "/?" + InvokerLocator.LOADER_PORT + "=" + loaderPort;
serverLocator = new InvokerLocator(locatorURI);
HashMap config = new HashMap();
config.put(InvokerLocator.FORCE_REMOTE, "true");
@@ -266,7 +267,7 @@
serverParameters.put(Remoting.REMOTE_CLASS_LOADERS, classLoaders);
serverConfiguration.setServerParameters(serverParameters);
Map invokerLocatorParameters = new HashMap();
- invokerLocatorParameters.put(InvokerLocator.LOADER_PORT, "4444");
+ invokerLocatorParameters.put(InvokerLocator.LOADER_PORT, loaderPort);
serverConfiguration.setInvokerLocatorParameters(invokerLocatorParameters);
connector = new Connector(config);
connector.setServerConfiguration(serverConfiguration);
16 years, 4 months
JBoss Remoting SVN: r4489 - remoting2/branches/2.x/src/tests/org/jboss/test/remoting/marshall/dynamic/remote/classloaders.
by jboss-remoting-commits@lists.jboss.org
Author: ron.sigal(a)jboss.com
Date: 2008-08-09 21:25:46 -0400 (Sat, 09 Aug 2008)
New Revision: 4489
Modified:
remoting2/branches/2.x/src/tests/org/jboss/test/remoting/marshall/dynamic/remote/classloaders/InjectedClassloadersTestCase.java
Log:
JBREM-1000: Get jboss-remoting-loading-tests.jar address from System property "loader.path".
Modified: remoting2/branches/2.x/src/tests/org/jboss/test/remoting/marshall/dynamic/remote/classloaders/InjectedClassloadersTestCase.java
===================================================================
--- remoting2/branches/2.x/src/tests/org/jboss/test/remoting/marshall/dynamic/remote/classloaders/InjectedClassloadersTestCase.java 2008-08-09 17:35:41 UTC (rev 4488)
+++ remoting2/branches/2.x/src/tests/org/jboss/test/remoting/marshall/dynamic/remote/classloaders/InjectedClassloadersTestCase.java 2008-08-10 01:25:46 UTC (rev 4489)
@@ -22,6 +22,9 @@
package org.jboss.test.remoting.marshall.dynamic.remote.classloaders;
import java.net.InetAddress;
+import java.security.AccessController;
+import java.security.PrivilegedActionException;
+import java.security.PrivilegedExceptionAction;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
@@ -59,7 +62,7 @@
public class InjectedClassloadersTestCase extends TestCase
{
private static Logger log = Logger.getLogger(InjectedClassloadersTestCase.class);
- private static String jarFileName = "C:/cygwin/home/rsigal/workspace/JBossRemoting-2.x/output/lib/jboss-remoting-loading-tests.jar";
+ private static String jarFileName;
private static String targetClassName = "org.jboss.test.remoting.marshall.dynamic.remote.classloaders.ResponseImpl";
private static final int BY_DIRECT_INJECTION = 1;
@@ -109,6 +112,8 @@
PatternLayout layout = new PatternLayout(pattern);
ConsoleAppender consoleAppender = new ConsoleAppender(layout);
Logger.getRootLogger().addAppender(consoleAppender);
+
+ jarFileName = getSystemProperty("loader.path");
ClassLoader cl = new TestClassLoader2(getClass().getClassLoader(), jarFileName, targetClassName);
Class c = Class.forName(targetClassName, false, cl);
RESPONSE_VALUE = c.newInstance();
@@ -294,6 +299,28 @@
}
+ private String getSystemProperty(final String name)
+ {
+ String value = null;
+ try
+ {
+ value = (String)AccessController.doPrivileged( new PrivilegedExceptionAction()
+ {
+ public Object run() throws Exception
+ {
+ return System.getProperty(name);
+ }
+ });
+ }
+ catch (PrivilegedActionException e)
+ {
+ throw (RuntimeException) e.getCause();
+ }
+
+ return value;
+ }
+
+
static class TestInvocationHandler implements ServerInvocationHandler
{
public void addListener(InvokerCallbackHandler callbackHandler) {}
16 years, 4 months
JBoss Remoting SVN: r4488 - remoting2/branches/2.x.
by jboss-remoting-commits@lists.jboss.org
Author: ron.sigal(a)jboss.com
Date: 2008-08-09 13:35:41 -0400 (Sat, 09 Aug 2008)
New Revision: 4488
Modified:
remoting2/branches/2.x/build.xml
Log:
JBREM-1006: Turned on execution of http chunked tests.
Modified: remoting2/branches/2.x/build.xml
===================================================================
--- remoting2/branches/2.x/build.xml 2008-08-09 08:12:48 UTC (rev 4487)
+++ remoting2/branches/2.x/build.xml 2008-08-09 17:35:41 UTC (rev 4488)
@@ -989,6 +989,13 @@
<param name="classpath" value="tests.classpath"/>
<param name="version" value="jbossweb"/>
</antcall>
+ <antcall target="tests.functional.main.http.isJDK5.core" inheritrefs="true">
+ <param name="remoting.metadata.key" value="remoting.metadata"/>
+ <param name="metadata" value="serializationtype=${serialization}"/>
+ <param name="jboss-junit-configuration" value="${serialization}_serialization_jbossweb"/>
+ <param name="classpath" value="tests.classpath"/>
+ <param name="version" value="jbossweb"/>
+ </antcall>
<antcall target="tests.functional.main.http.security" inheritrefs="true">
<param name="remoting.metadata.key" value="remoting.metadata"/>
<param name="metadata" value="serializationtype=${serialization}"/>
@@ -1006,6 +1013,13 @@
<param name="classpath" value="tests.classpath.tomcat"/>
<param name="version" value="tomcat"/>
</antcall>
+ <antcall target="tests.functional.main.http.isJDK5.core" inheritrefs="true">
+ <param name="remoting.metadata.key" value="remoting.metadata"/>
+ <param name="metadata" value="serializationtype=${serialization}"/>
+ <param name="jboss-junit-configuration" value="${serialization}_serialization_tomcat"/>
+ <param name="classpath" value="tests.classpath.tomcat"/>
+ <param name="version" value="tomcat"/>
+ </antcall>
<antcall target="tests.functional.main.http.security" inheritrefs="true">
<param name="remoting.metadata.key" value="remoting.metadata"/>
<param name="metadata" value="serializationtype=${serialization}"/>
@@ -1208,14 +1222,14 @@
</junit>
</target>
- <target name="tests.functional.main.isJDK5.core" depends="tests.jars" unless="isJDK4">
+ <target name="tests.functional.main.http.isJDK5.core" unless="isJDK4">
<mkdir dir="${output.tests.results}"/>
<mkdir dir="${output.tests.tmp}"/>
<junit printsummary="true" fork="yes" includeantruntime="true" tempdir="${output.tests.tmp}">
<jvmarg value="-Dloader.path=${output.lib.dir}/jboss-remoting-loading-tests.jar"/>
<jvmarg value="-D${remoting.metadata.key}=${metadata}"/>
<classpath>
- <path refid="tests.classpath"/>
+ <path refid="${classpath}"/>
</classpath>
<sysproperty key="${java.security.manager.key}" value="${java.security.manager}"/>
<sysproperty key="java.security.policy" value="${java.security.policy}"/>
16 years, 4 months
JBoss Remoting SVN: r4487 - remoting2/branches/2.x/src/tests/org/jboss/test/remoting/marshall/dynamic/remote/classloaders.
by jboss-remoting-commits@lists.jboss.org
Author: ron.sigal(a)jboss.com
Date: 2008-08-09 04:12:48 -0400 (Sat, 09 Aug 2008)
New Revision: 4487
Modified:
remoting2/branches/2.x/src/tests/org/jboss/test/remoting/marshall/dynamic/remote/classloaders/InjectedClassloadersTestCase.java
Log:
JBREM-1000: Added javadoc.
Modified: remoting2/branches/2.x/src/tests/org/jboss/test/remoting/marshall/dynamic/remote/classloaders/InjectedClassloadersTestCase.java
===================================================================
--- remoting2/branches/2.x/src/tests/org/jboss/test/remoting/marshall/dynamic/remote/classloaders/InjectedClassloadersTestCase.java 2008-08-09 08:12:13 UTC (rev 4486)
+++ remoting2/branches/2.x/src/tests/org/jboss/test/remoting/marshall/dynamic/remote/classloaders/InjectedClassloadersTestCase.java 2008-08-09 08:12:48 UTC (rev 4487)
@@ -47,6 +47,15 @@
import org.jboss.remoting.transport.PortUtil;
+/**
+ * Unit test for JBREM-1000.
+ *
+ * @author <a href="ron.sigal(a)jboss.com">Ron Sigal</a>
+ * @version $Revision: 1.1 $
+ * <p>
+ * Copyright Aug 9, 2008
+ * </p>
+ */
public class InjectedClassloadersTestCase extends TestCase
{
private static Logger log = Logger.getLogger(InjectedClassloadersTestCase.class);
16 years, 4 months
JBoss Remoting SVN: r4486 - in remoting2/branches/2.x/src/tests/org/jboss/test/remoting/marshall/dynamic/remote: classloaders and 1 other directory.
by jboss-remoting-commits@lists.jboss.org
Author: ron.sigal(a)jboss.com
Date: 2008-08-09 04:12:13 -0400 (Sat, 09 Aug 2008)
New Revision: 4486
Added:
remoting2/branches/2.x/src/tests/org/jboss/test/remoting/marshall/dynamic/remote/classloaders/
remoting2/branches/2.x/src/tests/org/jboss/test/remoting/marshall/dynamic/remote/classloaders/InjectedClassloadersTestCase.java
remoting2/branches/2.x/src/tests/org/jboss/test/remoting/marshall/dynamic/remote/classloaders/Response.java
remoting2/branches/2.x/src/tests/org/jboss/test/remoting/marshall/dynamic/remote/classloaders/ResponseImpl.java
remoting2/branches/2.x/src/tests/org/jboss/test/remoting/marshall/dynamic/remote/classloaders/TestClassLoader1.java
remoting2/branches/2.x/src/tests/org/jboss/test/remoting/marshall/dynamic/remote/classloaders/TestClassLoader2.java
Log:
JBREM-1000: New unit test.
Added: remoting2/branches/2.x/src/tests/org/jboss/test/remoting/marshall/dynamic/remote/classloaders/InjectedClassloadersTestCase.java
===================================================================
--- remoting2/branches/2.x/src/tests/org/jboss/test/remoting/marshall/dynamic/remote/classloaders/InjectedClassloadersTestCase.java (rev 0)
+++ remoting2/branches/2.x/src/tests/org/jboss/test/remoting/marshall/dynamic/remote/classloaders/InjectedClassloadersTestCase.java 2008-08-09 08:12:13 UTC (rev 4486)
@@ -0,0 +1,299 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, 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.marshall.dynamic.remote.classloaders;
+
+import java.net.InetAddress;
+import java.util.ArrayList;
+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.logging.XLevel;
+import org.jboss.remoting.Client;
+import org.jboss.remoting.InvocationRequest;
+import org.jboss.remoting.InvokerLocator;
+import org.jboss.remoting.Remoting;
+import org.jboss.remoting.ServerConfiguration;
+import org.jboss.remoting.ServerInvocationHandler;
+import org.jboss.remoting.ServerInvoker;
+import org.jboss.remoting.callback.InvokerCallbackHandler;
+import org.jboss.remoting.transport.Connector;
+import org.jboss.remoting.transport.PortUtil;
+
+
+public class InjectedClassloadersTestCase extends TestCase
+{
+ private static Logger log = Logger.getLogger(InjectedClassloadersTestCase.class);
+ private static String jarFileName = "C:/cygwin/home/rsigal/workspace/JBossRemoting-2.x/output/lib/jboss-remoting-loading-tests.jar";
+ private static String targetClassName = "org.jboss.test.remoting.marshall.dynamic.remote.classloaders.ResponseImpl";
+
+ private static final int BY_DIRECT_INJECTION = 1;
+ private static final int BY_SERVER_CONFIGURATION = 2;
+ private static final int BY_CONFIG_MAP = 3;
+
+ private static Object RESPONSE_VALUE;
+ private static boolean firstTime = true;
+
+ protected String host;
+ protected int port;
+ protected String locatorURI;
+ protected InvokerLocator serverLocator;
+ protected Connector connector;
+ protected TestClassLoader1 classLoader1;
+ protected TestClassLoader2 classLoader2;
+ protected TestInvocationHandler invocationHandler;
+
+
+ public static void main(String[] args)
+ {
+ InjectedClassloadersTestCase server = new InjectedClassloadersTestCase();
+ try
+ {
+ server.setUp();
+
+ while(true)
+ {
+ Thread.sleep(5000);
+ }
+ }
+ catch(Exception e)
+ {
+ e.printStackTrace();
+ }
+ }
+
+
+ public void setUp() throws Exception
+ {
+ if (firstTime)
+ {
+ firstTime = false;
+ Logger.getLogger("org.jboss.remoting").setLevel(XLevel.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);
+ ClassLoader cl = new TestClassLoader2(getClass().getClassLoader(), jarFileName, targetClassName);
+ Class c = Class.forName(targetClassName, false, cl);
+ RESPONSE_VALUE = c.newInstance();
+ }
+ }
+
+
+ public void tearDown() throws Exception
+ {
+ if(connector != null)
+ {
+ connector.stop();
+ connector.destroy();
+ }
+ }
+
+
+ public void testByDirectInjection() throws Throwable
+ {
+ log.info("entering " + getName());
+
+ // Start server.
+ setupServer(BY_DIRECT_INJECTION);
+
+ // Create client.
+ InvokerLocator clientLocator = new InvokerLocator(locatorURI);
+ 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");
+
+ // Verify that unmarshaller can get ResponseImpl class.
+ Object response = client.invoke("abc");
+ log.info("response: " + response);
+ assertEquals(targetClassName, response.getClass().getName());
+
+ // Verify that MarshallerLoaderHandler tried both configured classLoaders.
+ assertTrue(classLoader1.queriedForTarget);
+ assertTrue(classLoader2.queriedForTarget);
+
+ client.disconnect();
+ shutdownServer();
+ log.info(getName() + " PASSES");
+ }
+
+
+ public void testByServerConfiguration() throws Throwable
+ {
+ log.info("entering " + getName());
+
+ // Start server.
+ setupServer(BY_SERVER_CONFIGURATION);
+
+ // Create client.
+ InvokerLocator clientLocator = new InvokerLocator(locatorURI);
+ 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");
+
+ // Verify that unmarshaller can get ResponseImpl class.
+ Object response = client.invoke("abc");
+ log.info("response: " + response);
+ assertEquals(targetClassName, response.getClass().getName());
+
+ // Verify that MarshallerLoaderHandler tried both configured classLoaders.
+ assertTrue(classLoader1.queriedForTarget);
+ assertTrue(classLoader2.queriedForTarget);
+
+ client.disconnect();
+ shutdownServer();
+ log.info(getName() + " PASSES");
+ }
+
+
+ public void testByConfigMap() throws Throwable
+ {
+ log.info("entering " + getName());
+
+ // Start server.
+ setupServer(BY_CONFIG_MAP);
+
+ // Create client.
+ InvokerLocator clientLocator = new InvokerLocator(locatorURI);
+ 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");
+
+ // Verify that unmarshaller can get ResponseImpl class.
+ Object response = client.invoke("abc");
+ log.info("response: " + response);
+ assertEquals(targetClassName, response.getClass().getName());
+
+ // Verify that MarshallerLoaderHandler tried both configured classLoaders.
+ assertTrue(classLoader1.queriedForTarget);
+ assertTrue(classLoader2.queriedForTarget);
+
+ 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(int configMethod) throws Exception
+ {
+ host = InetAddress.getLocalHost().getHostAddress();
+ port = PortUtil.findFreePort(host);
+ locatorURI = getTransport() + "://" + host + ":" + port;
+ locatorURI += "/?" + InvokerLocator.LOADER_PORT + "=4444";
+ serverLocator = new InvokerLocator(locatorURI);
+ HashMap config = new HashMap();
+ config.put(InvokerLocator.FORCE_REMOTE, "true");
+ addExtraServerConfig(config);
+
+ ArrayList classLoaders = new ArrayList();
+ classLoader1 = new TestClassLoader1(targetClassName);
+ classLoader2 = new TestClassLoader2(getClass().getClassLoader(), jarFileName, targetClassName);
+ classLoaders.add(classLoader1);
+ classLoaders.add(classLoader2);
+
+ switch (configMethod)
+ {
+ case BY_DIRECT_INJECTION:
+ log.info("injecting: BY_DIRECT_INJECTION");
+ connector = new Connector(serverLocator, config);
+ connector.setRemoteClassLoaders(classLoaders);
+ break;
+
+ case BY_SERVER_CONFIGURATION:
+ log.info("injecting: BY_SERVER_CONFIGURATION");
+ ServerConfiguration serverConfiguration = new ServerConfiguration(getTransport());
+ Map serverParameters = new HashMap();
+ serverParameters.put(Remoting.REMOTE_CLASS_LOADERS, classLoaders);
+ serverConfiguration.setServerParameters(serverParameters);
+ Map invokerLocatorParameters = new HashMap();
+ invokerLocatorParameters.put(InvokerLocator.LOADER_PORT, "4444");
+ serverConfiguration.setInvokerLocatorParameters(invokerLocatorParameters);
+ connector = new Connector(config);
+ connector.setServerConfiguration(serverConfiguration);
+ break;
+
+ case BY_CONFIG_MAP:
+ log.info("injecting: BY_CONFIG_MAP");
+ config.put(Remoting.REMOTE_CLASS_LOADERS, classLoaders);
+ connector = new Connector(locatorURI, config);
+ break;
+
+ default:
+ log.error("unrecognized configMethod: " + configMethod);
+ return;
+ }
+
+ connector.create();
+ invocationHandler = new TestInvocationHandler();
+ connector.addInvocationHandler("test", invocationHandler);
+ connector.start();
+ locatorURI = connector.getInvokerLocator();
+ log.info("Started remoting server with locator uri of: " + locatorURI);
+ }
+
+
+ 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 RESPONSE_VALUE;
+ }
+ public void removeListener(InvokerCallbackHandler callbackHandler) {}
+ public void setMBeanServer(MBeanServer server) {}
+ public void setInvoker(ServerInvoker invoker) {}
+ }
+}
\ No newline at end of file
Added: remoting2/branches/2.x/src/tests/org/jboss/test/remoting/marshall/dynamic/remote/classloaders/Response.java
===================================================================
--- remoting2/branches/2.x/src/tests/org/jboss/test/remoting/marshall/dynamic/remote/classloaders/Response.java (rev 0)
+++ remoting2/branches/2.x/src/tests/org/jboss/test/remoting/marshall/dynamic/remote/classloaders/Response.java 2008-08-09 08:12:13 UTC (rev 4486)
@@ -0,0 +1,36 @@
+
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, 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.marshall.dynamic.remote.classloaders;
+
+/**
+ * @author <a href="ron.sigal(a)jboss.com">Ron Sigal</a>
+ * @version $Revision: 1.1 $
+ * <p>
+ * Copyright Aug 8, 2008
+ * </p>
+ */
+public interface Response
+{
+ public Object getResult();
+}
+
Added: remoting2/branches/2.x/src/tests/org/jboss/test/remoting/marshall/dynamic/remote/classloaders/ResponseImpl.java
===================================================================
--- remoting2/branches/2.x/src/tests/org/jboss/test/remoting/marshall/dynamic/remote/classloaders/ResponseImpl.java (rev 0)
+++ remoting2/branches/2.x/src/tests/org/jboss/test/remoting/marshall/dynamic/remote/classloaders/ResponseImpl.java 2008-08-09 08:12:13 UTC (rev 4486)
@@ -0,0 +1,44 @@
+
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, 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.marshall.dynamic.remote.classloaders;
+
+import java.io.Serializable;
+
+/**
+ * @author <a href="ron.sigal(a)jboss.com">Ron Sigal</a>
+ * @version $Revision: 1.1 $
+ * <p>
+ * Copyright Aug 8, 2008
+ * </p>
+ */
+public class ResponseImpl implements Response, Serializable
+{
+ /** The serialVersionUID */
+ private static final long serialVersionUID = -1012825226667853526L;
+
+ public Object getResult()
+ {
+ return "result";
+ }
+}
+
Added: remoting2/branches/2.x/src/tests/org/jboss/test/remoting/marshall/dynamic/remote/classloaders/TestClassLoader1.java
===================================================================
--- remoting2/branches/2.x/src/tests/org/jboss/test/remoting/marshall/dynamic/remote/classloaders/TestClassLoader1.java (rev 0)
+++ remoting2/branches/2.x/src/tests/org/jboss/test/remoting/marshall/dynamic/remote/classloaders/TestClassLoader1.java 2008-08-09 08:12:13 UTC (rev 4486)
@@ -0,0 +1,72 @@
+
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, 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.marshall.dynamic.remote.classloaders;
+
+import java.io.InputStream;
+
+import org.apache.log4j.Logger;
+
+/**
+ * @author <a href="ron.sigal(a)jboss.com">Ron Sigal</a>
+ * @version $Revision: 1.1 $
+ * <p>
+ * Copyright Aug 8, 2008
+ * </p>
+ */
+public class TestClassLoader1 extends ClassLoader
+{
+ public boolean queriedForTarget;
+
+ private static Logger log = Logger.getLogger(TestClassLoader1.class);
+
+ private String targetClassName;
+ private String targetClassFileName;
+
+ public TestClassLoader1(String targetClassName)
+ {
+ this.targetClassName = targetClassName;
+ this.targetClassFileName = targetClassName.replace('.', '/') + ".class";
+ }
+
+ protected Class loadClass(String name, boolean resolve) throws ClassNotFoundException
+ {
+ log.info(this + " queried for class: " + name);
+ if (targetClassName.equals(name))
+ {
+ queriedForTarget = true;
+ }
+ return null;
+ }
+
+ public InputStream getResourceAsStream(String name)
+ {
+ log.info(this + " queried for resource InputStream: " + name);
+ if (targetClassFileName.equals(name))
+ {
+ log.info(this + " looking for resource InputStream: " + name);
+ queriedForTarget = true;
+ }
+ return null;
+ }
+}
+
Added: remoting2/branches/2.x/src/tests/org/jboss/test/remoting/marshall/dynamic/remote/classloaders/TestClassLoader2.java
===================================================================
--- remoting2/branches/2.x/src/tests/org/jboss/test/remoting/marshall/dynamic/remote/classloaders/TestClassLoader2.java (rev 0)
+++ remoting2/branches/2.x/src/tests/org/jboss/test/remoting/marshall/dynamic/remote/classloaders/TestClassLoader2.java 2008-08-09 08:12:13 UTC (rev 4486)
@@ -0,0 +1,178 @@
+
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, 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.marshall.dynamic.remote.classloaders;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.jar.JarInputStream;
+import java.util.zip.ZipEntry;
+
+import org.apache.log4j.Logger;
+
+/**
+ * @author <a href="ron.sigal(a)jboss.com">Ron Sigal</a>
+ * @version $Revision: 1.1 $
+ * <p>
+ * Copyright Aug 8, 2008
+ * </p>
+ */
+public class TestClassLoader2 extends ClassLoader
+{
+ public boolean queriedForTarget;
+
+ private static Logger log = Logger.getLogger(TestClassLoader2.class);
+
+ private String jarFileName;
+ private String targetClassName;
+ private String targetClassFileName;
+
+
+ public static void main(String[] args)
+ {
+ String jarFileName = "C:/cygwin/home/rsigal/workspace/JBossRemoting-2.x/output/lib/jboss-remoting-loading-tests.jar";
+ String className = "org.jboss.test.remoting.marshall.dynamic.remote.classloaders.ResponseImpl";
+ ClassLoader cl = TestClassLoader2.class.getClassLoader();
+ TestClassLoader2 tcl2 = new TestClassLoader2(cl, jarFileName, className);
+ try
+ {
+ Class c = tcl2.loadClass(className);
+ Object o = c.newInstance();
+ log.info("new object: " + o);
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ }
+
+
+ public TestClassLoader2(ClassLoader parent, String jarFileName, String targetClassName)
+ {
+ super(parent);
+ this.jarFileName = jarFileName;
+ this.targetClassName = targetClassName;
+ this.targetClassFileName = targetClassName.replace('.', '/') + ".class";
+ }
+
+
+ public InputStream getResourceAsStream(String name)
+ {
+ try
+ {
+ log.info(this + " queried for resource InputStream: " + name);
+ if (targetClassFileName.equals(name))
+ {
+ log.info(this + " looking for resource InputStream: " + name);
+ queriedForTarget = true;
+ byte[] bytecode = loadByteCodeFromClassFileName(name);
+ log.info(this + " returning resource InputStream: " + name);
+ return new ByteArrayInputStream(bytecode);
+ }
+ else
+ {
+ return super.getResourceAsStream(name);
+ }
+ }
+ catch (Exception e)
+ {
+ log.error(this + " unable to find resource: " + name);
+ return null;
+ }
+ }
+
+
+ protected Class loadClass(String name, boolean resolve) throws ClassNotFoundException
+ {
+ try
+ {
+ log.info(this + " queried for class: " + name);
+ if (targetClassName.equals(name))
+ {
+ log.info(this + " loading class: " + name);
+ queriedForTarget = true;
+ byte[] bytes = loadByteCodeFromClassName(name);
+ Class c = defineClass(name, bytes, 0, bytes.length);
+ if (resolve)
+ {
+ resolveClass(c);
+ }
+ return c;
+ }
+ else
+ {
+ return super.loadClass(name, resolve);
+ }
+ }
+ catch (IOException e)
+ {
+ throw new ClassNotFoundException(name);
+ }
+ }
+
+
+ private byte[] loadByteCodeFromClassName(String classname)
+ throws ClassNotFoundException, IOException
+ {
+ String classFileName = classname.replace('.', '/') + ".class";
+ return loadByteCodeFromClassFileName(classFileName);
+ }
+
+
+ private byte[] loadByteCodeFromClassFileName(String classFileName)
+ throws ClassNotFoundException, IOException
+ {
+ File file = new File(jarFileName);
+ JarInputStream jis = new JarInputStream(new FileInputStream(file));
+ ZipEntry entry = jis.getNextEntry();
+
+ try
+ {
+ while (entry != null)
+ {
+ log.info("name: " + entry.getName());
+ if (classFileName.equals(entry.getName()))
+ break;
+ entry = jis.getNextEntry();
+ }
+ log.info("size: " + entry.getSize());
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ byte[] tmp = new byte[1024];
+ int read = 0;
+ while( (read = jis.read(tmp)) > 0 )
+ {
+ baos.write(tmp, 0, read);
+ }
+ byte[] bytecode = baos.toByteArray();
+ return bytecode;
+ }
+ finally
+ {
+ if( jis != null )
+ jis.close();
+ }
+ }
+}
16 years, 4 months
JBoss Remoting SVN: r4485 - remoting2/branches/2.x.
by jboss-remoting-commits@lists.jboss.org
Author: ron.sigal(a)jboss.com
Date: 2008-08-09 04:11:26 -0400 (Sat, 09 Aug 2008)
New Revision: 4485
Modified:
remoting2/branches/2.x/build.xml
Log:
JBREM-1000: Added ResponseImpl to jboss-remoting-loading-tests.jar.
Modified: remoting2/branches/2.x/build.xml
===================================================================
--- remoting2/branches/2.x/build.xml 2008-08-09 08:08:27 UTC (rev 4484)
+++ remoting2/branches/2.x/build.xml 2008-08-09 08:11:26 UTC (rev 4485)
@@ -577,6 +577,7 @@
<exclude name="org/jboss/test/remoting/marshall/dynamic/remote/**/Test*Marshaller*"/>
<exclude name="org/jboss/test/remoting/marshall/dynamic/remote/**/TestWrapper*"/>
<exclude name="org/jboss/test/remoting/marshall/dynamic/remote/**/TestObject*"/>
+ <exclude name="org/jboss/test/remoting/marshall/dynamic/remote/**/ResponseImpl*"/>
</fileset>
</jar>
<jar jarfile="${output.lib.dir}/jboss-remoting-loading-tests.jar"
@@ -585,6 +586,7 @@
<include name="org/jboss/test/remoting/marshall/dynamic/remote/**/Test*Marshaller*"/>
<include name="org/jboss/test/remoting/marshall/dynamic/remote/**/TestWrapper*"/>
<include name="org/jboss/test/remoting/marshall/dynamic/remote/**/TestObject*"/>
+ <include name="org/jboss/test/remoting/marshall/dynamic/remote/classloaders/ResponseImpl.class"/>
</fileset>
</jar>
16 years, 4 months
JBoss Remoting SVN: r4484 - remoting2/branches/2.x/src/etc.
by jboss-remoting-commits@lists.jboss.org
Author: ron.sigal(a)jboss.com
Date: 2008-08-09 04:08:27 -0400 (Sat, 09 Aug 2008)
New Revision: 4484
Modified:
remoting2/branches/2.x/src/etc/remoting.security.policy.tests.marshal
Log:
JBREM-1000: Added permission to read jboss-remoting-loading-tests.jar.
Modified: remoting2/branches/2.x/src/etc/remoting.security.policy.tests.marshal
===================================================================
--- remoting2/branches/2.x/src/etc/remoting.security.policy.tests.marshal 2008-08-09 08:07:43 UTC (rev 4483)
+++ remoting2/branches/2.x/src/etc/remoting.security.policy.tests.marshal 2008-08-09 08:08:27 UTC (rev 4484)
@@ -51,6 +51,7 @@
// Used by the descendents of org.jboss.test.remoting.shutdown.ShutdownTestParent.
permission java.io.FilePermission "<<ALL FILES>>", "execute";
+ permission java.io.FilePermission "${build.home}${/}output${/}lib${/}jboss-remoting-loading-tests.jar", "read";
permission java.lang.reflect.ReflectPermission "suppressAccessChecks";
16 years, 4 months
JBoss Remoting SVN: r4483 - remoting2/branches/2.x/src/etc.
by jboss-remoting-commits@lists.jboss.org
Author: ron.sigal(a)jboss.com
Date: 2008-08-09 04:07:43 -0400 (Sat, 09 Aug 2008)
New Revision: 4483
Modified:
remoting2/branches/2.x/src/etc/remoting.security.policy.core
Log:
JBREM-1000: Added "setContextClassLoader" RuntimePermission for Connector.
Modified: remoting2/branches/2.x/src/etc/remoting.security.policy.core
===================================================================
--- remoting2/branches/2.x/src/etc/remoting.security.policy.core 2008-08-09 08:06:04 UTC (rev 4482)
+++ remoting2/branches/2.x/src/etc/remoting.security.policy.core 2008-08-09 08:07:43 UTC (rev 4483)
@@ -158,6 +158,7 @@
// Used by remote class loading system
permission java.lang.RuntimePermission "createClassLoader";
permission java.lang.RuntimePermission "getClassLoader";
+ permission java.lang.RuntimePermission "setContextClassLoader";
// Used by:
// org.jboss.remoting.security.SSLSocketBuilder
16 years, 4 months
JBoss Remoting SVN: r4482 - remoting2/branches/2.x/src/main/org/jboss/remoting/transport.
by jboss-remoting-commits@lists.jboss.org
Author: ron.sigal(a)jboss.com
Date: 2008-08-09 04:06:04 -0400 (Sat, 09 Aug 2008)
New Revision: 4482
Modified:
remoting2/branches/2.x/src/main/org/jboss/remoting/transport/Connector.java
Log:
JBREM-1000: Replaced class repositories with classloaders.
Modified: remoting2/branches/2.x/src/main/org/jboss/remoting/transport/Connector.java
===================================================================
--- remoting2/branches/2.x/src/main/org/jboss/remoting/transport/Connector.java 2008-08-09 08:01:58 UTC (rev 4481)
+++ remoting2/branches/2.x/src/main/org/jboss/remoting/transport/Connector.java 2008-08-09 08:06:04 UTC (rev 4482)
@@ -26,6 +26,7 @@
import org.jboss.remoting.ConnectionListener;
import org.jboss.remoting.InvokerLocator;
import org.jboss.remoting.InvokerRegistry;
+import org.jboss.remoting.Remoting;
import org.jboss.remoting.ServerConfiguration;
import org.jboss.remoting.ServerInvocationHandler;
import org.jboss.remoting.ServerInvocationHandlerWrapper;
@@ -141,6 +142,7 @@
private Connector marshallerLoaderConnector = null;
private boolean isMarshallerLoader = false;
+ private List remoteClassLoaders;
private boolean isStarted = false;
private boolean isCreated = false;
@@ -471,6 +473,18 @@
// keep the local cache in synch
locatorURI = invoker.getLocator().getLocatorURI();
+ if (remoteClassLoaders == null)
+ {
+ Object o = configuration.get(Remoting.REMOTE_CLASS_LOADERS);
+ if (o instanceof List)
+ {
+ setRemoteClassLoaders((List) o);
+ }
+ else
+ {
+ log.warn("value of " + Remoting.REMOTE_CLASS_LOADERS + " must be a List");
+ }
+ }
if (!isMarshallerLoader)
{
@@ -508,8 +522,7 @@
// if loaderLocator is null, then probably not defined to have loader service (i.e. no loader port specified)
if (loaderLocator != null)
{
- List repositories = getLoaderRepositories();
- marshallerLoader = MarshallLoaderFactory.createMarshallLoader(loaderLocator, repositories, server);
+ marshallerLoader = MarshallLoaderFactory.createMarshallLoader(loaderLocator, remoteClassLoaders, server);
}
return marshallerLoader;
}
@@ -973,41 +986,6 @@
}
}
- private List getLoaderRepositories()
- {
- if (xml == null)
- {
- return null;
- }
-
- NodeList repositoryNodes = xml.getElementsByTagName("repository");
- if (repositoryNodes.getLength() == 0)
- {
- return null;
- }
-
- List repositories = new ArrayList();
- for (int i = 0; i < repositoryNodes.getLength(); i++)
- {
- Node node = repositoryNodes.item(i);
- String repositoryName = node.getFirstChild().getNodeValue();
-
- try
- {
- ObjectName objName = new ObjectName(repositoryName);
- repositories.add(objName);
- log.info("repository: " + repositoryName);
- }
- catch (MalformedObjectNameException e)
- {
- log.debug("repository name is not an object name: " + repositoryName);
- continue;
- }
- }
-
- return repositories;
- }
-
private ServerInvocationHandler createHandlerProxy(ObjectName objName)
{
ServerInvocationHandler handler;
@@ -1459,4 +1437,17 @@
{
this.serverConfiguration = serverConfig;
}
+
+ public void setRemoteClassLoaders(List classLoaders)
+ {
+ if (classLoaders == null)
+ return;
+
+ SecurityManager sm = System.getSecurityManager();
+ if (sm != null)
+ {
+ sm.checkPermission(new RuntimePermission("setContextClassLoader"));
+ }
+ this.remoteClassLoaders = classLoaders;
+ }
}
16 years, 4 months
JBoss Remoting SVN: r4481 - remoting2/branches/2.x/src/main/org/jboss/remoting/marshal.
by jboss-remoting-commits@lists.jboss.org
Author: ron.sigal(a)jboss.com
Date: 2008-08-09 04:01:58 -0400 (Sat, 09 Aug 2008)
New Revision: 4481
Modified:
remoting2/branches/2.x/src/main/org/jboss/remoting/marshal/MarshallLoaderFactory.java
Log:
JBREM-1000: Replaced class repositories with classloaders.
Modified: remoting2/branches/2.x/src/main/org/jboss/remoting/marshal/MarshallLoaderFactory.java
===================================================================
--- remoting2/branches/2.x/src/main/org/jboss/remoting/marshal/MarshallLoaderFactory.java 2008-08-09 08:01:20 UTC (rev 4480)
+++ remoting2/branches/2.x/src/main/org/jboss/remoting/marshal/MarshallLoaderFactory.java 2008-08-09 08:01:58 UTC (rev 4481)
@@ -47,11 +47,11 @@
* listen on. Will return null if can not create the connector.
*
* @param locator
- * @param repositories
+ * @param classLoaders
* @param mbeanServer
* @return
*/
- public static Connector createMarshallLoader(InvokerLocator locator, List repositories, MBeanServer mbeanServer)
+ public static Connector createMarshallLoader(InvokerLocator locator, List classLoaders, MBeanServer mbeanServer)
{
Connector marshallerConnector = null;
try
@@ -60,7 +60,7 @@
marshallerConnector.setInvokerLocator(locator.getLocatorURI());
marshallerConnector.start();
- MarshallerLoaderHandler loader = new MarshallerLoaderHandler(repositories);
+ MarshallerLoaderHandler loader = new MarshallerLoaderHandler(classLoaders);
marshallerConnector.addInvocationHandler("loader", loader);
// Set after Connector.addInvocationHandler(), which also sets MBeanServer.
16 years, 4 months