Java Dynamic Management Kit 3.2 Programming Guide
[ Previous ][ Fast Back ]Chapter 13. Class and Library Loading Service[ Fast Forward ][ Next ]

Using the Library Loading Service

The RMI network class loader implements the findLibrary() method of the java.lang.ClassLoader class to allow the loading of dynamic native libraries. The basic operation of the service is described in Library Loaders in Chapter 12.

Libpath in RMI Network Class Server

The NetClassServerImpl class libpath property specifies the directory in which the search for native libraries will begin. Example 13-6 shows the command to start the RMI network class loader, specifying /class_server/lib/libs1 and /class_server/lib/libs2 as example search directories.

Example 13-6. Starting the Class and Library Server
java
-Dlibpath=/class_server/lib/libs1:/class_server/lib/libs2
com.sun.jaw.impl.server.rmi.NetClassServerImpl

The library path contains two library directories, libs1 and libs2. These are located in the /class_server/lib/ directories. No library should appear twice in any class server as the first one found through the library path will always be returned. Example 13-7 shows an example hierarchy for the libraries on the RMI network class server.

Example 13-7. Library Hierarchy in the RMI Network Class Server
Library hierarchy on remote server:

/class_server/lib/libs1/libA.so

/class_server/lib/libs2/SunOS/sparc/5.7/lib/libB.so
                       \WindowsNT\x86\4.0\lib\B.dll

Libpath in RMI Network Class Loader

The library path property specifies the directory into which the required library will be copied before the RMI network class loader loads it into memory. Example 13-8 shows the code to set the directory property of the network class loader instantiated in Example 13-3.

Example 13-8. Setting the libpath property
Vector libpath = new Vector();
libpath.addElement(new String("/tmp"));
ncl.setLibPaths(libpath);

Loading a Library From the Class Server

Where an m-bean has been loaded from a class server, it must invoke the System.loadLibrary() to load libraries from the class srever. Example 13-9 shows code for an m-bean loading libraries from the class server.

Example 13-9. Loading a Library From the Class Server
System.loadLibrary("A");
// loads /class_server/lib/libs1/libA.so

System.loadLibrary(this.getClass(),"libs2","B");

// loads /class_server/lib/libs2/SunOS/sparc/5.7/lib/libB.so
// if the agent runs on Solaris 7

// loads \class_server\lib\libs2\WindowsNT\x86\4.0\lib\B.dll
// if the agent runs on Windows NT 4.0


[ Previous ][ Home ][ Next ]
Class and Library Loader[ Up ]Security Manager