summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CHANGES4
-rwxr-xr-xjava/allTests.py1
-rw-r--r--java/build.xml9
-rw-r--r--java/src/Ice/InitializationData.java5
-rw-r--r--java/src/Ice/PluginManagerI.java2
-rw-r--r--java/src/IceBox/ServiceManagerI.java2
-rw-r--r--java/src/IceInternal/BasicStream.java8
-rw-r--r--java/src/IceInternal/Instance.java8
-rw-r--r--java/src/IceInternal/ObjectInputStream.java7
-rw-r--r--java/src/IceInternal/ProtocolPluginFacade.java5
-rw-r--r--java/src/IceInternal/ProtocolPluginFacadeI.java9
-rw-r--r--java/src/IceInternal/UdpTransceiver.java4
-rw-r--r--java/src/IceInternal/Util.java53
-rw-r--r--java/src/IceSSL/Instance.java4
-rw-r--r--java/test/Ice/classLoader/AbstractClassI.java20
-rw-r--r--java/test/Ice/classLoader/AllTests.java208
-rw-r--r--java/test/Ice/classLoader/CertificateVerifierI.java18
-rw-r--r--java/test/Ice/classLoader/Client.java37
-rw-r--r--java/test/Ice/classLoader/InitialI.java51
-rw-r--r--java/test/Ice/classLoader/PasswordCallbackI.java28
-rw-r--r--java/test/Ice/classLoader/PluginFactoryI.java29
-rw-r--r--java/test/Ice/classLoader/Server.java41
-rw-r--r--java/test/Ice/classLoader/Test.ice39
-rwxr-xr-xjava/test/Ice/classLoader/run.py25
24 files changed, 586 insertions, 31 deletions
diff --git a/CHANGES b/CHANGES
index f9473675569..23ef65c5399 100644
--- a/CHANGES
+++ b/CHANGES
@@ -246,6 +246,10 @@ C++ Changes
Java Changes
============
+- Added the "classLoader" member to Ice.InitializationData, which
+ allows you to supply a custom class loader that Ice will use when
+ it loads plug-ins, user exceptions, concrete Slice classes, etc.
+
- Fixed a bug in the implementation of ice_invoke_async.
- The Freeze classes are now stored in a separate JAR file named
diff --git a/java/allTests.py b/java/allTests.py
index 9e77db706b8..94ce71eade5 100755
--- a/java/allTests.py
+++ b/java/allTests.py
@@ -59,6 +59,7 @@ tests = [
("Ice/serialize", ["core"]),
("Ice/defaultServant", ["core"]),
("Ice/threadPoolPriority", ["core"]),
+ ("Ice/classLoader", ["core"]),
("IceBox/configuration", ["core", "noipv6"]),
("Freeze/dbmap", ["once"]),
("Freeze/complex", ["once"]),
diff --git a/java/build.xml b/java/build.xml
index 1966e24bc69..b8125bb6586 100644
--- a/java/build.xml
+++ b/java/build.xml
@@ -247,9 +247,6 @@
<includepath>
<pathelement path="${slice.dir}" />
</includepath>
- <fileset dir="test/Ice/udp">
- <include name="Test.ice" />
- </fileset>
<fileset dir="test/Ice/adapterDeactivation">
<include name="Test.ice" />
</fileset>
@@ -259,6 +256,9 @@
<fileset dir="test/Ice/binding">
<include name="Test.ice" />
</fileset>
+ <fileset dir="test/Ice/classLoader">
+ <include name="Test.ice" />
+ </fileset>
<fileset dir="test/Ice/custom">
<include name="Test.ice" />
</fileset>
@@ -328,6 +328,9 @@
<fileset dir="test/Ice/threadPoolPriority">
<include name="Test.ice" />
</fileset>
+ <fileset dir="test/Ice/udp">
+ <include name="Test.ice" />
+ </fileset>
<fileset dir="test/Freeze/complex">
<include name="Complex.ice" />
</fileset>
diff --git a/java/src/Ice/InitializationData.java b/java/src/Ice/InitializationData.java
index 18395f54dac..7c89724bac1 100644
--- a/java/src/Ice/InitializationData.java
+++ b/java/src/Ice/InitializationData.java
@@ -67,4 +67,9 @@ public final class InitializationData implements Cloneable
* The thread hook for the communicator.
**/
public ThreadNotification threadHook;
+
+ /**
+ * The custom class loader for the communicator.
+ **/
+ public ClassLoader classLoader;
}
diff --git a/java/src/Ice/PluginManagerI.java b/java/src/Ice/PluginManagerI.java
index dbba9f1a117..4d5bbdb9b0a 100644
--- a/java/src/Ice/PluginManagerI.java
+++ b/java/src/Ice/PluginManagerI.java
@@ -311,7 +311,7 @@ public final class PluginManagerI implements PluginManager
PluginFactory pluginFactory = null;
try
{
- Class<?> c = IceInternal.Util.findClass(className);
+ Class<?> c = IceInternal.Util.getInstance(_communicator).findClass(className);
if(c == null)
{
PluginInitializationException e = new PluginInitializationException();
diff --git a/java/src/IceBox/ServiceManagerI.java b/java/src/IceBox/ServiceManagerI.java
index 0f12e9263e3..e5571b291e7 100644
--- a/java/src/IceBox/ServiceManagerI.java
+++ b/java/src/IceBox/ServiceManagerI.java
@@ -481,7 +481,7 @@ public class ServiceManagerI extends _ServiceManagerDisp
info.args = args;
try
{
- Class<?> c = IceInternal.Util.findClass(className);
+ Class<?> c = IceInternal.Util.findClass(className, null);
if(c == null)
{
FailureException e = new FailureException();
diff --git a/java/src/IceInternal/BasicStream.java b/java/src/IceInternal/BasicStream.java
index 77112002911..fbe4c8702b5 100644
--- a/java/src/IceInternal/BasicStream.java
+++ b/java/src/IceInternal/BasicStream.java
@@ -821,7 +821,7 @@ public class BasicStream
try
{
InputStreamWrapper w = new InputStreamWrapper(sz, this);
- ObjectInputStream in = new ObjectInputStream(w);
+ ObjectInputStream in = new ObjectInputStream(_instance, w);
return (java.io.Serializable)in.readObject();
}
catch(java.lang.Exception ex)
@@ -2349,7 +2349,7 @@ public class BasicStream
getConcreteClass(String className)
throws LinkageError
{
- Class<?> c = Util.findClass(className);
+ Class<?> c = _instance.findClass(className);
if(c != null)
{
@@ -2536,13 +2536,13 @@ public class BasicStream
{
Class<?> cls;
Class<?>[] types = new Class<?>[1];
- cls = Util.findClass("org.apache.tools.bzip2.CBZip2InputStream");
+ cls = IceInternal.Util.findClass("org.apache.tools.bzip2.CBZip2InputStream", null);
if(cls != null)
{
types[0] = java.io.InputStream.class;
_bzInputStreamCtor = cls.getDeclaredConstructor(types);
}
- cls = Util.findClass("org.apache.tools.bzip2.CBZip2OutputStream");
+ cls = IceInternal.Util.findClass("org.apache.tools.bzip2.CBZip2OutputStream", null);
if(cls != null)
{
types = new Class[2];
diff --git a/java/src/IceInternal/Instance.java b/java/src/IceInternal/Instance.java
index 9d85fa10fb7..697dca8bc8a 100644
--- a/java/src/IceInternal/Instance.java
+++ b/java/src/IceInternal/Instance.java
@@ -524,6 +524,12 @@ public final class Instance
_initData.logger = logger;
}
+ public Class<?>
+ findClass(String className)
+ {
+ return Util.findClass(className, _initData.classLoader);
+ }
+
//
// Only for use by Ice.CommunicatorI
//
@@ -1034,7 +1040,7 @@ public final class Instance
Class<?> cls = null;
try
{
- cls = Util.findClass(className);
+ cls = findClass(className);
}
catch(java.lang.Exception ex)
{
diff --git a/java/src/IceInternal/ObjectInputStream.java b/java/src/IceInternal/ObjectInputStream.java
index e5fa8e0b45a..fc0168fadc1 100644
--- a/java/src/IceInternal/ObjectInputStream.java
+++ b/java/src/IceInternal/ObjectInputStream.java
@@ -18,10 +18,11 @@ package IceInternal;
public class ObjectInputStream extends java.io.ObjectInputStream
{
public
- ObjectInputStream(java.io.InputStream in)
+ ObjectInputStream(Instance instance, java.io.InputStream in)
throws java.io.IOException
{
super(in);
+ _instance = instance;
}
protected Class<?>
@@ -30,7 +31,7 @@ public class ObjectInputStream extends java.io.ObjectInputStream
{
try
{
- Class<?> c = Util.findClass(cls.getName());
+ Class<?> c = _instance.findClass(cls.getName());
if(c != null)
{
return c;
@@ -42,4 +43,6 @@ public class ObjectInputStream extends java.io.ObjectInputStream
throw new ClassNotFoundException("unable to resolve class " + cls.getName(), ex);
}
}
+
+ private Instance _instance;
}
diff --git a/java/src/IceInternal/ProtocolPluginFacade.java b/java/src/IceInternal/ProtocolPluginFacade.java
index c591ee80046..5019b1bf426 100644
--- a/java/src/IceInternal/ProtocolPluginFacade.java
+++ b/java/src/IceInternal/ProtocolPluginFacade.java
@@ -47,4 +47,9 @@ public interface ProtocolPluginFacade
// Get an EndpointFactory.
//
EndpointFactory getEndpointFactory(short type);
+
+ //
+ // Look up a Java class by name.
+ //
+ Class<?> findClass(String className);
}
diff --git a/java/src/IceInternal/ProtocolPluginFacadeI.java b/java/src/IceInternal/ProtocolPluginFacadeI.java
index c02c4282c1d..fd9768c451c 100644
--- a/java/src/IceInternal/ProtocolPluginFacadeI.java
+++ b/java/src/IceInternal/ProtocolPluginFacadeI.java
@@ -87,6 +87,15 @@ public class ProtocolPluginFacadeI implements ProtocolPluginFacade
return _instance.endpointFactoryManager().get(type);
}
+ //
+ // Look up a Java class by name.
+ //
+ public Class<?>
+ findClass(String className)
+ {
+ return _instance.findClass(className);
+ }
+
private Instance _instance;
private Ice.Communicator _communicator;
}
diff --git a/java/src/IceInternal/UdpTransceiver.java b/java/src/IceInternal/UdpTransceiver.java
index 8a5cd336ad8..49146a1383a 100644
--- a/java/src/IceInternal/UdpTransceiver.java
+++ b/java/src/IceInternal/UdpTransceiver.java
@@ -457,7 +457,7 @@ final class UdpTransceiver implements Transceiver
{
Class<?> cls;
- cls = Util.findClass("java.net.PlainDatagramSocketImpl");
+ cls = Util.findClass("java.net.PlainDatagramSocketImpl", null);
if(cls == null)
{
throw new Ice.SocketException();
@@ -474,7 +474,7 @@ final class UdpTransceiver implements Transceiver
m.setAccessible(true);
m.invoke(socketImpl);
- cls = Util.findClass("sun.nio.ch.DatagramChannelImpl");
+ cls = Util.findClass("sun.nio.ch.DatagramChannelImpl", null);
if(cls == null)
{
throw new Ice.SocketException();
diff --git a/java/src/IceInternal/Util.java b/java/src/IceInternal/Util.java
index 15c8ed0d181..a9eebf126d2 100644
--- a/java/src/IceInternal/Util.java
+++ b/java/src/IceInternal/Util.java
@@ -61,44 +61,66 @@ public final class Util
}
public static Class<?>
- findClass(String className)
+ findClass(String className, ClassLoader cl)
throws LinkageError
{
- Class<?> c = null;
-
+ //
+ // Try to load the class using the given class loader (if any). If that fails (or
+ // none is provided), we try to load the class a few more ways before giving up.
//
// Calling Class.forName() doesn't always work. For example, if Ice.jar is installed
// as an extension (in $JAVA_HOME/jre/lib/ext), calling Class.forName(name) uses the
// extension class loader, which will not look in CLASSPATH for the target class.
//
- // First we try using the system class loader (which knows about CLASSPATH). Next we
- // try the current thread's class loader, and finally we fall back to Class.forName().
+
+ Class<?> c = null;
+
+ if(cl != null)
+ {
+ c = loadClass(className, cl);
+ }
+
//
- try
+ // Try using the system class loader (which knows about CLASSPATH).
+ //
+ if(c == null)
{
try
{
- ClassLoader cl = ClassLoader.getSystemClassLoader();
+ cl = ClassLoader.getSystemClassLoader();
if(cl != null)
{
- c = findClass(className, cl);
+ c = loadClass(className, cl);
}
}
catch(SecurityException ex)
{
}
+ }
- if(c == null)
+ //
+ // Try using the current thread's class loader.
+ //
+ if(c == null)
+ {
+ try
{
- try
- {
- c = findClass(className, Thread.currentThread().getContextClassLoader());
- }
- catch(SecurityException ex)
+ cl = Thread.currentThread().getContextClassLoader();
+ if(cl != null)
{
+ c = loadClass(className, cl);
}
}
+ catch(SecurityException ex)
+ {
+ }
+ }
+ //
+ // Fall back to Class.forName().
+ //
+ try
+ {
if(c == null)
{
c = Class.forName(className);
@@ -113,9 +135,10 @@ public final class Util
}
private static Class<?>
- findClass(String className, ClassLoader cl)
+ loadClass(String className, ClassLoader cl)
throws LinkageError
{
+ assert(cl != null);
try
{
return cl.loadClass(className);
diff --git a/java/src/IceSSL/Instance.java b/java/src/IceSSL/Instance.java
index 76ad215de76..ee33751ae49 100644
--- a/java/src/IceSSL/Instance.java
+++ b/java/src/IceSSL/Instance.java
@@ -114,7 +114,7 @@ class Instance
Class<?> cls = null;
try
{
- cls = IceInternal.Util.findClass(certVerifierClass);
+ cls = _facade.findClass(certVerifierClass);
}
catch(Throwable ex)
{
@@ -153,7 +153,7 @@ class Instance
Class<?> cls = null;
try
{
- cls = IceInternal.Util.findClass(passwordCallbackClass);
+ cls = _facade.findClass(passwordCallbackClass);
}
catch(Throwable ex)
{
diff --git a/java/test/Ice/classLoader/AbstractClassI.java b/java/test/Ice/classLoader/AbstractClassI.java
new file mode 100644
index 00000000000..701c3da3fb2
--- /dev/null
+++ b/java/test/Ice/classLoader/AbstractClassI.java
@@ -0,0 +1,20 @@
+// **********************************************************************
+//
+// Copyright (c) 2003-2009 ZeroC, Inc. All rights reserved.
+//
+// This copy of Ice is licensed to you under the terms described in the
+// ICE_LICENSE file included in this distribution.
+//
+// **********************************************************************
+
+package test.Ice.classLoader;
+
+import test.Ice.classLoader.Test.AbstractClass;
+
+class AbstractClassI extends AbstractClass
+{
+ public void
+ op(Ice.Current current)
+ {
+ }
+}
diff --git a/java/test/Ice/classLoader/AllTests.java b/java/test/Ice/classLoader/AllTests.java
new file mode 100644
index 00000000000..b8d5a5783ff
--- /dev/null
+++ b/java/test/Ice/classLoader/AllTests.java
@@ -0,0 +1,208 @@
+// **********************************************************************
+//
+// Copyright (c) 2003-2009 ZeroC, Inc. All rights reserved.
+//
+// This copy of Ice is licensed to you under the terms described in the
+// ICE_LICENSE file included in this distribution.
+//
+// **********************************************************************
+
+package test.Ice.classLoader;
+
+import java.io.PrintWriter;
+
+import test.Ice.classLoader.Test.AbstractClass;
+import test.Ice.classLoader.Test.ConcreteClass;
+import test.Ice.classLoader.Test.E;
+import test.Ice.classLoader.Test.InitialPrx;
+import test.Ice.classLoader.Test.InitialPrxHelper;
+
+public class AllTests
+{
+ private static class MyObjectFactory implements Ice.ObjectFactory
+ {
+ public Ice.Object create(String type)
+ {
+ if(type.equals("::Test::AbstractClass"))
+ {
+ return new AbstractClassI();
+ }
+
+ assert (false); // Should never be reached
+ return null;
+ }
+
+ public void destroy()
+ {
+ // Nothing to do
+ }
+ }
+
+ private static class MyClassLoader extends ClassLoader
+ {
+ protected Class<?> loadClass(String name, boolean resolve)
+ throws ClassNotFoundException
+ {
+ _names.add(name);
+ return super.loadClass(name, resolve);
+ }
+
+ void reset()
+ {
+ _names.clear();
+ }
+
+ boolean check(String name)
+ {
+ return _names.contains(name);
+ }
+
+ private java.util.List<String> _names = new java.util.LinkedList<String>();
+ }
+
+ private static void
+ test(boolean b)
+ {
+ if(!b)
+ {
+ throw new RuntimeException();
+ }
+ }
+
+ public static void
+ allTests(boolean collocated, PrintWriter out, Ice.InitializationData initData)
+ {
+ //
+ // Verify that the class loader is used for Slice packages.
+ //
+ {
+ out.print("testing package... ");
+ out.flush();
+ Ice.InitializationData init = (Ice.InitializationData)initData.clone();
+ MyClassLoader classLoader = new MyClassLoader();
+ init.classLoader = classLoader;
+ Ice.Communicator communicator = Ice.Util.initialize(init);
+ test(classLoader.check("test.Ice.classLoader.Test._Marker"));
+ communicator.destroy();
+ out.println("ok");
+ }
+
+ //
+ // Verify that the class loader is used for Ice plug-ins.
+ //
+ {
+ out.print("testing plug-in... ");
+ out.flush();
+ Ice.InitializationData init = (Ice.InitializationData)initData.clone();
+ init.properties = (Ice.Properties)initData.properties._clone();
+ init.properties.setProperty("Ice.Plugin.Test", "test.Ice.classLoader.PluginFactoryI");
+ MyClassLoader classLoader = new MyClassLoader();
+ init.classLoader = classLoader;
+ Ice.Communicator communicator = Ice.Util.initialize(init);
+ test(classLoader.check("test.Ice.classLoader.PluginFactoryI"));
+ communicator.destroy();
+ out.println("ok");
+ }
+
+ //
+ // Verify that the class loader is used for IceSSL certificate verifiers and password callbacks.
+ //
+ if(initData.properties.getProperty("Ice.Default.Protocol").equals("ssl"))
+ {
+ out.print("testing IceSSL certificate verifier and password callback... ");
+ out.flush();
+ Ice.InitializationData init = (Ice.InitializationData)initData.clone();
+ init.properties = (Ice.Properties)initData.properties._clone();
+ init.properties.setProperty("IceSSL.CertVerifier", "test.Ice.classLoader.CertificateVerifierI");
+ init.properties.setProperty("IceSSL.PasswordCallback", "test.Ice.classLoader.PasswordCallbackI");
+ MyClassLoader classLoader = new MyClassLoader();
+ init.classLoader = classLoader;
+ Ice.Communicator communicator = Ice.Util.initialize(init);
+ test(classLoader.check("test.Ice.classLoader.CertificateVerifierI"));
+ test(classLoader.check("test.Ice.classLoader.PasswordCallbackI"));
+ communicator.destroy();
+ out.println("ok");
+ }
+
+ //
+ // Marshaling tests.
+ //
+ {
+ Ice.InitializationData init = (Ice.InitializationData)initData.clone();
+ MyClassLoader classLoader = new MyClassLoader();
+ init.classLoader = classLoader;
+ Ice.Communicator communicator = Ice.Util.initialize(init);
+
+ String ref = "initial:default -p 12010";
+ Ice.ObjectPrx base = communicator.stringToProxy(ref);
+ test(base != null);
+
+ InitialPrx initial = InitialPrxHelper.checkedCast(base);
+ test(initial != null);
+
+ //
+ // Verify that the class loader is used for concrete classes.
+ //
+ {
+ out.print("testing concrete class... ");
+ out.flush();
+ ConcreteClass cc = initial.getConcreteClass();
+ test(cc != null);
+ test(classLoader.check("Test.ConcreteClass"));
+ test(classLoader.check("test.Ice.classLoader.Test.ConcreteClass"));
+ classLoader.reset();
+ out.println("ok");
+ }
+
+ //
+ // Verify that the class loader is invoked when a factory is not installed, and is
+ // not invoked when a factory is installed.
+ //
+ {
+ out.print("testing abstract class... ");
+ out.flush();
+
+ try
+ {
+ initial.getAbstractClass();
+ }
+ catch(Ice.NoObjectFactoryException ex)
+ {
+ // Expected.
+ }
+ test(classLoader.check("Test.AbstractClass"));
+ test(classLoader.check("test.Ice.classLoader.Test.AbstractClass"));
+ classLoader.reset();
+
+ communicator.addObjectFactory(new MyObjectFactory(), "::Test::AbstractClass");
+ AbstractClass ac = initial.getAbstractClass();
+ test(ac != null);
+ test(!classLoader.check("Test.AbstractClass"));
+ test(!classLoader.check("test.Ice.classLoader.Test.AbstractClass"));
+ classLoader.reset();
+
+ out.println("ok");
+ }
+
+ //
+ // Verify that the class loader is used for user exceptions.
+ //
+ out.print("testing user exception... ");
+ out.flush();
+ try
+ {
+ initial.throwException();
+ test(false);
+ }
+ catch(E ex)
+ {
+ }
+ test(classLoader.check("Test.E"));
+ test(classLoader.check("test.Ice.classLoader.Test.E"));
+ out.println("ok");
+
+ initial.shutdown();
+ communicator.destroy();
+ }
+ }
+}
diff --git a/java/test/Ice/classLoader/CertificateVerifierI.java b/java/test/Ice/classLoader/CertificateVerifierI.java
new file mode 100644
index 00000000000..b5439bd7e80
--- /dev/null
+++ b/java/test/Ice/classLoader/CertificateVerifierI.java
@@ -0,0 +1,18 @@
+// **********************************************************************
+//
+// Copyright (c) 2003-2009 ZeroC, Inc. All rights reserved.
+//
+// This copy of Ice is licensed to you under the terms described in the
+// ICE_LICENSE file included in this distribution.
+//
+// **********************************************************************
+
+package test.Ice.classLoader;
+
+public class CertificateVerifierI implements IceSSL.CertificateVerifier
+{
+ public boolean verify(IceSSL.ConnectionInfo info)
+ {
+ return true;
+ }
+}
diff --git a/java/test/Ice/classLoader/Client.java b/java/test/Ice/classLoader/Client.java
new file mode 100644
index 00000000000..6febef6417e
--- /dev/null
+++ b/java/test/Ice/classLoader/Client.java
@@ -0,0 +1,37 @@
+// **********************************************************************
+//
+// Copyright (c) 2003-2009 ZeroC, Inc. All rights reserved.
+//
+// This copy of Ice is licensed to you under the terms described in the
+// ICE_LICENSE file included in this distribution.
+//
+// **********************************************************************
+
+package test.Ice.classLoader;
+
+public class Client extends test.Util.Application
+{
+ public int run(String[] args)
+ {
+ AllTests.allTests(false, getWriter(), _initData);
+ return 0;
+ }
+
+ protected Ice.InitializationData getInitData(Ice.StringSeqHolder argsH)
+ {
+ _initData = new Ice.InitializationData();
+ _initData.properties = Ice.Util.createProperties(argsH);
+ _initData.properties.setProperty("Ice.Package.Test", "test.Ice.classLoader");
+ return _initData;
+ }
+
+ public static void main(String[] args)
+ {
+ Client app = new Client();
+ int result = app.main("Client", args);
+ System.gc();
+ System.exit(result);
+ }
+
+ private Ice.InitializationData _initData;
+}
diff --git a/java/test/Ice/classLoader/InitialI.java b/java/test/Ice/classLoader/InitialI.java
new file mode 100644
index 00000000000..2b8b87caefd
--- /dev/null
+++ b/java/test/Ice/classLoader/InitialI.java
@@ -0,0 +1,51 @@
+// **********************************************************************
+//
+// Copyright (c) 2003-2009 ZeroC, Inc. All rights reserved.
+//
+// This copy of Ice is licensed to you under the terms described in the
+// ICE_LICENSE file included in this distribution.
+//
+// **********************************************************************
+
+package test.Ice.classLoader;
+
+import test.Ice.classLoader.Test.AbstractClass;
+import test.Ice.classLoader.Test.ConcreteClass;
+import test.Ice.classLoader.Test.E;
+import test.Ice.classLoader.Test._InitialDisp;
+
+public final class InitialI extends _InitialDisp
+{
+ public
+ InitialI(Ice.ObjectAdapter adapter)
+ {
+ _adapter = adapter;
+ }
+
+ public ConcreteClass
+ getConcreteClass(Ice.Current current)
+ {
+ return new ConcreteClass();
+ }
+
+ public AbstractClass
+ getAbstractClass(Ice.Current current)
+ {
+ return new AbstractClassI();
+ }
+
+ public void
+ throwException(Ice.Current current)
+ throws E
+ {
+ throw new E();
+ }
+
+ public void
+ shutdown(Ice.Current current)
+ {
+ _adapter.getCommunicator().shutdown();
+ }
+
+ private Ice.ObjectAdapter _adapter;
+}
diff --git a/java/test/Ice/classLoader/PasswordCallbackI.java b/java/test/Ice/classLoader/PasswordCallbackI.java
new file mode 100644
index 00000000000..3fc9260e8de
--- /dev/null
+++ b/java/test/Ice/classLoader/PasswordCallbackI.java
@@ -0,0 +1,28 @@
+// **********************************************************************
+//
+// Copyright (c) 2003-2009 ZeroC, Inc. All rights reserved.
+//
+// This copy of Ice is licensed to you under the terms described in the
+// ICE_LICENSE file included in this distribution.
+//
+// **********************************************************************
+
+package test.Ice.classLoader;
+
+public class PasswordCallbackI implements IceSSL.PasswordCallback
+{
+ public char[] getPassword(String alias)
+ {
+ return "password".toCharArray();
+ }
+
+ public char[] getTruststorePassword()
+ {
+ return "password".toCharArray();
+ }
+
+ public char[] getKeystorePassword()
+ {
+ return "password".toCharArray();
+ }
+}
diff --git a/java/test/Ice/classLoader/PluginFactoryI.java b/java/test/Ice/classLoader/PluginFactoryI.java
new file mode 100644
index 00000000000..4ace4a2bcd7
--- /dev/null
+++ b/java/test/Ice/classLoader/PluginFactoryI.java
@@ -0,0 +1,29 @@
+// **********************************************************************
+//
+// Copyright (c) 2003-2009 ZeroC, Inc. All rights reserved.
+//
+// This copy of Ice is licensed to you under the terms described in the
+// ICE_LICENSE file included in this distribution.
+//
+// **********************************************************************
+
+package test.Ice.classLoader;
+
+public class PluginFactoryI implements Ice.PluginFactory
+{
+ static class PluginI implements Ice.Plugin
+ {
+ public void initialize()
+ {
+ }
+
+ public void destroy()
+ {
+ }
+ }
+
+ public Ice.Plugin create(Ice.Communicator communicator, String name, String[] args)
+ {
+ return new PluginI();
+ }
+}
diff --git a/java/test/Ice/classLoader/Server.java b/java/test/Ice/classLoader/Server.java
new file mode 100644
index 00000000000..fa68d032e53
--- /dev/null
+++ b/java/test/Ice/classLoader/Server.java
@@ -0,0 +1,41 @@
+// **********************************************************************
+//
+// Copyright (c) 2003-2009 ZeroC, Inc. All rights reserved.
+//
+// This copy of Ice is licensed to you under the terms described in the
+// ICE_LICENSE file included in this distribution.
+//
+// **********************************************************************
+
+package test.Ice.classLoader;
+
+public class Server extends test.Util.Application
+{
+ public int run(String[] args)
+ {
+ Ice.Communicator communicator = communicator();
+ Ice.ObjectAdapter adapter = communicator.createObjectAdapter("TestAdapter");
+ Ice.Object object = new InitialI(adapter);
+ adapter.add(object, communicator.stringToIdentity("initial"));
+ adapter.activate();
+
+ return WAIT;
+ }
+
+ protected Ice.InitializationData getInitData(Ice.StringSeqHolder argsH)
+ {
+ Ice.InitializationData initData = new Ice.InitializationData();
+ initData.properties = Ice.Util.createProperties(argsH);
+ initData.properties.setProperty("Ice.Package.Test", "test.Ice.classLoader");
+ initData.properties.setProperty("TestAdapter.Endpoints", "default -p 12010");
+ return initData;
+ }
+
+ public static void main(String[] args)
+ {
+ Server app = new Server();
+ int result = app.main("Server", args);
+ System.gc();
+ System.exit(result);
+ }
+}
diff --git a/java/test/Ice/classLoader/Test.ice b/java/test/Ice/classLoader/Test.ice
new file mode 100644
index 00000000000..b1dbd09b8fc
--- /dev/null
+++ b/java/test/Ice/classLoader/Test.ice
@@ -0,0 +1,39 @@
+// **********************************************************************
+//
+// Copyright (c) 2003-2009 ZeroC, Inc. All rights reserved.
+//
+// This copy of Ice is licensed to you under the terms described in the
+// ICE_LICENSE file included in this distribution.
+//
+// **********************************************************************
+
+#ifndef TEST_ICE
+#define TEST_ICE
+
+[["java:package:test.Ice.classLoader"]]
+module Test
+{
+
+class ConcreteClass
+{
+ int i;
+};
+
+class AbstractClass
+{
+ void op();
+};
+
+exception E {};
+
+interface Initial
+{
+ ConcreteClass getConcreteClass();
+ AbstractClass getAbstractClass();
+ void throwException() throws E;
+ void shutdown();
+};
+
+};
+
+#endif
diff --git a/java/test/Ice/classLoader/run.py b/java/test/Ice/classLoader/run.py
new file mode 100755
index 00000000000..56d48e628de
--- /dev/null
+++ b/java/test/Ice/classLoader/run.py
@@ -0,0 +1,25 @@
+#!/usr/bin/env python
+# **********************************************************************
+#
+# Copyright (c) 2003-2009 ZeroC, Inc. All rights reserved.
+#
+# This copy of Ice is licensed to you under the terms described in the
+# ICE_LICENSE file included in this distribution.
+#
+# **********************************************************************
+
+import os, sys
+
+path = [ ".", "..", "../..", "../../..", "../../../.." ]
+head = os.path.dirname(sys.argv[0])
+if len(head) > 0:
+ path = [os.path.join(head, p) for p in path]
+path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ]
+if len(path) == 0:
+ raise "can't find toplevel directory!"
+sys.path.append(os.path.join(path[0]))
+from scripts import *
+
+TestUtil.clientServerTest()
+
+TestUtil.cleanup()