Class GenericExporter

java.lang.Object
com.gigaspaces.lrmi.GenericExporter
All Implemented Interfaces:
Serializable, Exporter

public class GenericExporter extends Object implements Exporter, Serializable
This class provides generic exporting of multiple remote objects such that it can receive remote or local method invocations, and later for unexporting that same remote object.

Details of the export and unexport behavior, including the underlying transport communication protocols used for remote invocation and additional remote invocation semantics, are defined by the particular implementation of ITransportConfig configuration object.

When the object exported by export(Remote) method, the return value is dynamic proxy(SmartStub) which represents a direct reference to the exported object.
If the exported stub is located in Local VM with remote object, every invoked method will have a direct reference call on remote object, otherwise the stub was serialized and moved out side of local VM.
If the exported stub was never serialized and no reference left pointing to this stub, this stub will be collected by GC without calling explicitly unexport(boolean) method.

Working with GenericExporter,

  • No need to create RMI stubs by rmic compiler.
  • Ability to define OneWayRemoteCall annotation on desired remote method. The remote interface method with defined OneWayRemoteCall annotation will be called as one-way(async) remote call without return value and without being blocking while the remote call will be execute by Remote implementation.
  • Every invoked method on exported stub will be performed with direct reference method call, if the stub is located in local VM with obj-impl.

    Steps to create distributed RPC service.

    • Define remote interface
    • Implement the remote interface
    • Create an instance of GenericExporter with appropriate ITransportConfig configuration object.
    • export the impl-obj with GenericExporter.
    • unexport to remove the remote object, from the runtime of underlying transport protocol.
     
     Example:
    
     public interface IRemoteHello
        extends Remote
     {
             String say( String name )
               throws RemoteException;
  • Since:
    5.2
    Author:
    Igor Goldenberg
    See Also:
    • Constructor Summary

      Constructors
      Constructor
      Description
      Constructor.
    • Method Summary

      Modifier and Type
      Method
      Description
      protected boolean
      Unexport the desired obj from the underlying transport protocol and remove the obj from the manage cache.
      export(Remote impl)
      Exports the specified remote object and returns a proxy that can be used to invoke remote methods on the exported remote object.
      export(Remote impl, boolean allowCache)
      Exports the specified remote object and returns a proxy that can be used to invoke remote methods on the exported remote object.
      export(Remote impl, ITransportConfig config, boolean allowCache)
      Exports the specified remote object with desired ITransportConfig configuration object and returns a proxy that can be used to invoke remote methods on the exported remote object.
       
      boolean
      Returns true if the provided obj exported by GenericExporter.
      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.
      boolean
      Removes the remote object, obj, from the runtime of underlying transport protocol.

      Methods inherited from class java.lang.Object

      clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Details

      • GenericExporter

        public GenericExporter(ITransportConfig config)
        Constructor.
        Parameters:
        config - The configuration object for this exporter. All exported objects will be used by ITransportConfig.
    • Method Details

      • getConfiguration

        public ITransportConfig getConfiguration()
        Returns:
        the transport configuration for this exporter instance.
      • export

        public Remote export(Remote impl) throws ExportException
        Exports the specified remote object and returns a proxy that can be used to invoke remote methods on the exported remote object. This method must only be invoked once on a given Exporter instance.

        The returned proxy implements an implementation-specific set of remote interfaces of the remote object and may also implement additional implementation-specific interfaces.

        A remote interface is an interface that extends the interface java.rmi.Remote and whose methods each declare at least one exception whose type is java.rmi.RemoteException or one of its superclasses.

        If the impl object already exported, returns the same proxy instance representing this impl

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

        public Remote export(Remote impl, boolean allowCache) throws ExportException
        Exports the specified remote object and returns a proxy that can be used to invoke remote methods on the exported remote object. This method must only be invoked once on a given Exporter instance.

        The returned proxy implements an implementation-specific set of remote interfaces of the remote object and may also implement additional implementation-specific interfaces.

        A remote interface is an interface that extends the interface java.rmi.Remote and whose methods each declare at least one exception whose type is java.rmi.RemoteException or one of its superclasses.

        If the impl object already exported, returns the same proxy instance representing this impl

        Parameters:
        impl - a remote object to export
        allowCache - allow the exported object to cached when serialized over the network
        Returns:
        a proxy for the remote object
        Throws:
        ExportException - if a problem occurs exporting the object
        SecurityException - if a SecurityException occurs exporting the object
        IllegalArgumentException - if impl is null
        IllegalStateException - if an object has already been exported with this Exporter instance
      • export

        public Remote export(Remote impl, ITransportConfig config, boolean allowCache) throws ExportException
        Exports the specified remote object with desired ITransportConfig configuration object and returns a proxy that can be used to invoke remote methods on the exported remote object. This method must only be invoked once on a given Exporter instance.

        The returned proxy implements an implementation-specific set of remote interfaces of the remote object and may also implement additional implementation-specific interfaces.

        A remote interface is an interface that extends the interface java.rmi.Remote and whose methods each declare at least one exception whose type is java.rmi.RemoteException or one of its superclasses.

        If the impl object already exported, returns the same proxy instance representing this impl

        Parameters:
        config - the configuration object to export the impl object.
        impl - a remote object to export
        Returns:
        a proxy for the remote object
        Throws:
        ExportException - if a problem occurs exporting the object
        SecurityException - if a SecurityException occurs exporting the object
        IllegalArgumentException - if impl is null
        IllegalStateException - if an object has already been exported with this Exporter instance
      • _unexport

        protected boolean _unexport(Remote obj)
        Unexport the desired obj from the underlying transport protocol and remove the obj from the manage cache.
      • unexport

        public boolean unexport(Remote obj)
        Removes the remote object, obj, from the runtime of underlying transport protocol. If successful, the object can no longer accept incoming RMI calls. If the force parameter is true, the object is forcibly unexported even if there are pending calls to the remote object or the remote object still has calls in progress. If the force parameter is false, the object is only unexported if there are no pending or in progress calls to the object.
        Parameters:
        obj - the remote object to be unexported pending or in-progress calls; if false, only unexports the object if there are no pending or in-progress calls
        Returns:
        true if operation is successful, false otherwise
      • unexport

        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. The unexport operation may not occur if the force argument is false. This method must only be invoked after the export method has been invoked on this Exporter instance to export a remote object successfully.

        This method returns true if upon return, the remote object is no longer exported with this Exporter, and false if the remote object remains exported with this Exporter. This method will always return true if it has returned true previously.

        The force parameter serves to indicate whether or not the caller desires the unexport to occur even if there are known remote calls pending or in progress to the remote object that were made possible by this Exporter:

        • If force is true, then the remote object will be forcibly unexported even if there are remote calls pending or in progress, and this method will return true.
        • If force is false, then this acts as a hint to the implementation that the remote object should not be unexported if there are known remote calls pending or in progress, and this method will either unexport the remote object and return true or not unexport the remote object and return false. If the implementation detects that there are indeed remote calls pending or in progress, then it should return false; otherwise, it must return true. If the implementation does not support being able to unexport conditionally based on knowledge of remote calls pending or in progress, then it must implement this method as if force were always true.

        If the remote object is unexported as a result of this method, then the implementation may (and should, if possible) prevent remote calls in progress from being able to communicate their results successfully.

        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
      • isExported

        public boolean isExported(Remote obj)
        Returns true if the provided obj exported by GenericExporter.
        Parameters:
        obj - the object to check.
        Returns:
        true if provided obj exported and manage by GenericExporter.