net.jini.jrmp
Class JrmpExporter

java.lang.Object
  extended by net.jini.jrmp.JrmpExporter
All Implemented Interfaces:
Exporter

public final class JrmpExporter
extends Object
implements Exporter

A JrmpExporter contains the information necessary to export a single remote object to the JRMP runtime. It acts as an adapter between existing methods for (un)exporting remote objects over JRMP (e.g, UnicastRemoteObject.exportObject(Remote), Activatable.exportObject(Remote, ActivationID, int)) and the Exporter interface.

An object exported via a JrmpExporter can customize the following properties that govern invocation behavior and other characteristics of the exported remote object and its stub:

This exporter is a front-end adapter on top of UnicastRemoteObject and Activatable; exporting remote objects through this exporter is equivalent to doing so directly via the various exportObject methods defined by the aforementioned classes.

Since:
2.0
Author:
Sun Microsystems, Inc.
Implementation Specifics:

This implementation uses the Logger named net.jini.jrmp.JrmpExporter to log information at the following levels:

Level Description
FINE successful export of object
FINE attempted unexport of object

Constructor Summary
JrmpExporter()
          Creates an exporter for a non-activatable JRMP "unicast" remote object that exports on an anonymous port and does not use custom socket factories.
JrmpExporter(ActivationID id, int port)
          Creates an exporter for an activatable JRMP remote object with the given activation ID that exports on the specified TCP port and does not use custom socket factories.
JrmpExporter(ActivationID id, int port, RMIClientSocketFactory csf, RMIServerSocketFactory ssf)
          Creates an exporter for an activatable JRMP remote object with the given activation ID that exports on the specified TCP port and uses sockets created by the given custom socket factories.
JrmpExporter(int port)
          Creates an exporter for a non-activatable JRMP "unicast" remote object that exports on the specified TCP port and does not use custom socket factories.
JrmpExporter(int port, RMIClientSocketFactory csf, RMIServerSocketFactory ssf)
          Creates an exporter for a non-activatable JRMP "unicast" remote object that exports on the specified TCP port and uses sockets created by the given custom socket factories.
 
Method Summary
 Remote export(Remote impl)
          Exports a remote object, impl, to the JRMP runtime and returns a proxy (stub) for the remote object.
 ActivationID getActivationID()
          Returns the activation ID associated with the object exported by this exporter, or null if activation is not being used with this exporter.
 RMIClientSocketFactory getClientSocketFactory()
          Returns the client socket factory for this exporter, or null if none (in which case Socket objects are created directly).
 int getPort()
          Returns the port used by this exporter, or zero if an anonymous port is used.
 RMIServerSocketFactory getServerSocketFactory()
          Returns the server socket factory for this exporter, or null if none (in which case java.net.ServerSocket objects are created directly).
 String toString()
          Returns the string representation for this exporter.
 boolean unexport(boolean force)
          Unexports the remote object exported via this exporter's export method such that the object can no longer accept incoming remote calls that were possible as a result of exporting via this exporter.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

JrmpExporter

public JrmpExporter()
Creates an exporter for a non-activatable JRMP "unicast" remote object that exports on an anonymous port and does not use custom socket factories.


JrmpExporter

public JrmpExporter(int port)
Creates an exporter for a non-activatable JRMP "unicast" remote object that exports on the specified TCP port and does not use custom socket factories.

Parameters:
port - number of the port on which an exported object will receive calls (if zero, an anonymous port will be chosen)

JrmpExporter

public JrmpExporter(int port,
                    RMIClientSocketFactory csf,
                    RMIServerSocketFactory ssf)
Creates an exporter for a non-activatable JRMP "unicast" remote object that exports on the specified TCP port and uses sockets created by the given custom socket factories.

Parameters:
port - number of the port on which an exported object will receive calls (if zero, an anonymous port will be chosen)
csf - client-side socket factory (if null, the global JRMP socket factory or, if necessary, the default global JRMP socket factory will be used to create client-side sockets)
ssf - server-side socket factory (if null, the global JRMP socket factory or, if necessary, the default global JRMP socket factory will be used to create server-side sockets)

JrmpExporter

public JrmpExporter(ActivationID id,
                    int port)
Creates an exporter for an activatable JRMP remote object with the given activation ID that exports on the specified TCP port and does not use custom socket factories.

Parameters:
id - activation ID associated with the object to export
port - number of the port on which an exported object will receive calls (if zero, an anonymous port will be chosen)
Throws:
NullPointerException - if id is null

JrmpExporter

public JrmpExporter(ActivationID id,
                    int port,
                    RMIClientSocketFactory csf,
                    RMIServerSocketFactory ssf)
Creates an exporter for an activatable JRMP remote object with the given activation ID that exports on the specified TCP port and uses sockets created by the given custom socket factories.

Parameters:
id - activation ID associated with the object to export
port - number of the port on which an exported object will receive calls (if zero, an anonymous port will be chosen)
csf - client-side socket factory (if null, the global JRMP socket factory or, if necessary, the default global JRMP socket factory will be used to create client-side sockets)
ssf - server-side socket factory (if null, the global JRMP socket factory or, if necessary, the default global JRMP socket factory will be used to create server-side sockets)
Throws:
NullPointerException - if id is null
Method Detail

getPort

public int getPort()
Returns the port used by this exporter, or zero if an anonymous port is used.

Returns:
port number, or zero if anonymous

getClientSocketFactory

public RMIClientSocketFactory getClientSocketFactory()
Returns the client socket factory for this exporter, or null if none (in which case Socket objects are created directly).

Returns:
client socket factory, or null if none

getServerSocketFactory

public RMIServerSocketFactory getServerSocketFactory()
Returns the server socket factory for this exporter, or null if none (in which case java.net.ServerSocket objects are created directly).

Returns:
server socket factory, or null if none

getActivationID

public ActivationID getActivationID()
Returns the activation ID associated with the object exported by this exporter, or null if activation is not being used with this exporter.

Returns:
activation ID, or null if none

export

public Remote export(Remote impl)
              throws ExportException
Exports a remote object, impl, to the JRMP runtime and returns a proxy (stub) for the remote object. This method cannot be called more than once to export a remote object or an IllegalStateException will be thrown.

If this exporter was created with a constructor that accepted a java.rmi.activation.ActivationID, then calling this method is equivalent to invoking java.rmi.activation.Activatable.exportObject with the appropriate impl, ActivationID, port, RMIClientSocketFactory, and RMIServerSocketFactory values. Otherwise, calling this method is equivalent to invoking java.rmi.server.UnicastRemoteObject.exportObject with the appropriate impl, port, RMIClientSocketFactory, and RMIServerSocketFactory values.

Specified by:
export in interface Exporter
Parameters:
impl - a remote object to export
Returns:
a proxy for the remote object
Throws:
NullPointerException - if impl is null
IllegalStateException - if an object has already been exported with this Exporter instance
ExportException - if a problem occurs exporting the object

unexport

public boolean unexport(boolean force)
Unexports the remote object exported via this exporter's export method such that the object can no longer accept incoming remote calls that were possible as a result of exporting via this exporter.

If force is true, the object is forcibly unexported even if there are pending or in progress calls to the remote object via this exporter. If force is false, the object is only unexported if there are no pending or in progress calls to the remote object via this exporter. This method is equivalent to calling java.rmi.activation.Activatable.unexportObject or java.rmi.server.UnicastRemoteObject.unexportObject and passing the "impl" that was previously passed to this exporter's export method, depending on whether or not this exporter was created with a constructor that accepted a java.rmi.activation.ActivationID value.

The return value is true if the object is (or was previously) unexported, and false if the object is still exported.

Specified by:
unexport in interface Exporter
Parameters:
force - if true, the remote object will be unexported even if there are remote calls pending or in progress; if false, the remote object may only be unexported if there are no known remote calls pending or in progress
Returns:
true if the remote object is unexported when this method returns and false otherwise
Throws:
IllegalStateException - if an object has not been exported with this Exporter instance

toString

public String toString()
Returns the string representation for this exporter.

Overrides:
toString in class Object
Returns:
the string representation for this exporter


Copyright 2007, multiple authors.
Licensed under the Apache License, Version 2.0, see the NOTICE file for attributions.