Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## net.jini.jrmp
Class JrmpExporter

    java.lang.Object
      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:

- `port`: the port number for the `ServerSocket` on which the JRMP runtime will listen for incoming calls to the exported object.
- `RMIClientSocketFactory`: the factory object used by client stubs to create `Socket` objects over which to issue calls to the exported object. If `null`, then the global JRMP socket factory will be used (i.e., the value returned by `RMISocketFactory.getSocketFactory()`), or if there isn't one set, then the default global JRMP socket factory will be used (i.e., the value returned by `RMISocketFactory.getDefaultSocketFactory()`).
- `RMIServerSocketFactory`: the factory object used by the JRMP runtime to create `ServerSocket` objects over which to receive calls to the exported object. If `null`, then the global JRMP socket factory will be used, or if there isn't one set, then the default global JRMP socket factory will be used. The default global JRMP socket factory returns a `ServerSocket` for an anonymous port if passed a port number of zero.
- `ActivationID`: the `ActivationID` identifying this remote object to the activation system, or `null` if the remote object is not to be exported as activatable.

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
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)

### 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)

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.

  Returns:
    the string representation for this exporter

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2004 Sun Microsystems, Inc. All rights reserved