Jini and Network Computing/Using Jini Exporters
The net.jini.export package provides a power feature in Jini 2.0 and later. The foundation of this package is the net.jini.export.Exporter interface. An instance of this interface provides the ability to export and unexport a single object used for remote access.
Method Signature | Javadoc Summary |
---|---|
public java.rmi.Remote export( java.rmi.Remote impl ); | Exports the specified remote object and returns a proxy that can be used to invoke remote methods on the exported remote object. |
public boolean unexport(boolean force); |
Unexports the remote object that was exported by this Exporter such that it will no longer receive remote method invocations that were made possible as a result of exporting it with this Exporter. |
Typically, an instance of an Exporter will be obtained using the net.jini.config.Configuration implementation established at service startup. The section on Using Configuration Files has more information on how a Configuration instance is typically obtained.
There are many types of scenarios for using an Exporter. Your particular circumstances will largely govern whether a single exported object can be used by all external references, or if you need to have multiple exports of the same object. As noted above, each export will require a separate Exporter, and for any Remote object exported, you will need to maintain a strong reference to the Exporter, if unexporting will be done and the Remote object, if it will be reused by other remote clients at a later time.
Distributed Garbage Collection (DGC) provides the ability for you to export a remote reference to a local object, send the reference back to a remote client, and to then have the Remote object be unexported and reclaimed when the remote client finishes using the remote object, or otherwise can no longer maintain its reference to that object because of network partitioning or other failures that keep it from updating its lease.
Some types of applications utilize a single Remote object for all clients. Other types of applications will, in fact, export a single object reference for remote use, one per remote client. In the former case, DGC is not needed, and can create problems because of its attempts to manage leases. In the later case, either DGC, or some other type of lease based lifecycle management needs to occur.