RAD Singletons in Java
A module developer creates a singleton to represent an interface. This interface can be accessed easily. For example, the zonemgr
module defines a singleton interface, ZoneInfo. It contains information about the zone that contains the RAD instance with which you are communicating.
In Java, you need to compile the code with the language binding in the CLASSPATH
. RAD Java Language bindings are in the system/management/rad/client/rad-java
package.
The JAR files for the various bindings are installed in /usr/lib/rad/java
. Each major interface version is accessible in a JAR file which is named after the source ADR document and it's major version number. For example, to access major version 1 of the zonemgr
API, use /usr/lib/rad/java/zonemgr_1.jar
. Symbolic links are provided as an indication of the default version a client should use.
Example 2-17 Java Language – Obtaining a Reference to a RAD Singleton
import com.oracle.solaris.rad.connect.Connection; import com.oracle.solaris.rad.zonemgr.ZoneInfo; Connection con = Connection.connectUnix(); System.out.println("Connected: " + con.toString()); ZoneInfo zi = con.getObject(new ZoneInfo()); System.out.println("ZoneInfo: " + zi.getname());
In this example, you have performed the following:
-
Imported ZoneInfo and
Connection
from thezonemgr
binding and therad.connect
package -
Connected to the local RAD instance
-
Obtained a remote object reference directly by using a proxy instance
After you have the remote reference, you can access the properties and the methods directly. In the RAD Java implementation, all properties are accessed using the getter
or setter
syntax. Thus, you invoke getname
() to access the name
property.