Table of Contents Previous Next
Logo
The Ice Run Time in Detail : 32.26 Custom Class Loaders
Copyright © 2003-2010 ZeroC, Inc.

32.26 Custom Class Loaders

Certain features of the Ice for Java run-time necessitate dynamic class loading. Applications with special requirements can supply a custom class loader for Ice to use in the following situations:
• Unmarshaling user exceptions and instances of concrete Slice classes
• Loading Ice plug-ins
• Loading IceSSL certificate verifiers and password callbacks
If an application does not supply a class loader (or if the application-supplied class loader fails to locate a class), the Ice run time attempts to load the class as follows:
• using the system class loader
• using the current thread’s class loader
• using the default class loader (that is, by calling Class.forName)
Note that an application must install object factories for any abstract Slice classes it might receive, regardless of whether the application also installs a custom class loader. Refer to Section 10.14.4 for more information on factories.
To install a custom class loader, set the classLoader member of Ice.InitializationData prior to creating a communicator:
Ice.InitializationData initData = new Ice.InitializationData();
initData.classLoader = new MyClassLoader();
Ice.Communicator communicator =
    Ice.Util.initialize(args, initData);
Section 32.3 discusses communicator initialization in greater detail.

Table of Contents Previous Next
Logo