org.eodisp.remote.application
Class RemoteAppModule

java.lang.Object
  extended by org.eodisp.remote.application.RemoteAppModule
All Implemented Interfaces:
org.eodisp.util.AppModule

public class RemoteAppModule
extends java.lang.Object
implements org.eodisp.util.AppModule

An application module implementation that configures, starts up and shuts down the network infrastructure of a Java application. So far, it supports TCP and JXTA transport. The JXTA transport is specifically configured for EODiSP applications (see newDefaultJxtaConfiguration()).

Version:
$Id:$
Author:
ibirrer

Field Summary
static java.lang.String ID
          The Id of this Application Module.
(package private) static org.apache.log4j.Logger logger
          Log4J logger for this class
 
Constructor Summary
RemoteAppModule(int defaultTcpListeningPort)
           
 
Method Summary
 java.rmi.Remote export(java.rmi.Remote objectToExport)
          Exports the given remote object on all transports defined in the configuration (so far JXTA and/or TCP).
 java.rmi.Remote export(java.rmi.Remote objectToExport, RemoteConfiguration.TransportType transportType)
          Exports the given remote object on all transports defined in the configuration (so far JXTA and/or TCP).
 java.rmi.Remote exportAndRegister(java.rmi.Remote objectToExport, java.lang.String registryKey)
          Exports the given remote object on all transports defined in the configuration (so far JXTA and/or TCP).
 java.util.Map<RemoteConfiguration.TransportType,java.net.URI> getEndpointUris()
           
 RemoteConfiguration.TransportType getFavoriteTransport()
           
 java.lang.String getId()
           
 JxtaNetworkManager getJxtaNetworkManager()
           
 java.net.URI getLocalUri(RemoteConfiguration.TransportType transportType)
           
 JeriRegistry getRegistry()
          Returns the (single) registry on which remote objects can be registered for this application.
 JeriRegistry getRegistry(RemoteConfiguration.TransportType transportType)
          Returns the (single) registry on which remote objects can be registered for this application.
 JeriRegistry getRegistry(java.net.URI uri)
          Returns the registry of the JVM at the given location.
 java.util.Map<RemoteConfiguration.TransportType,JeriRegistry> getRegistryProxies()
           
protected  NetworkConfigurator newDefaultJxtaConfiguration()
          Returns a pre-configured JXTA network configurator that is suitable for most EODiSP applications that do not act as a rendezvous or relay.
 void postShutdown(org.eodisp.util.RootApp rootApp)
          
 void preStartup(org.eodisp.util.RootApp rootApp)
          
 void registerConfiguration(org.eodisp.util.RootApp rootApp)
          
 void shutdown(org.eodisp.util.RootApp rootApp)
          
 void startup(org.eodisp.util.RootApp rootApp)
          
 boolean unexport(java.rmi.Remote objectToUnexport, RemoteConfiguration.TransportType transportType, boolean force)
           
 boolean unexportAll(java.rmi.Remote objectToUnexport, boolean force)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ID

public static final java.lang.String ID
The Id of this Application Module.


logger

static org.apache.log4j.Logger logger
Log4J logger for this class

Constructor Detail

RemoteAppModule

public RemoteAppModule(int defaultTcpListeningPort)
Method Detail

getId

public java.lang.String getId()
Specified by:
getId in interface org.eodisp.util.AppModule

registerConfiguration

public void registerConfiguration(org.eodisp.util.RootApp rootApp)
                           throws java.lang.Exception

Specified by:
registerConfiguration in interface org.eodisp.util.AppModule
Throws:
java.lang.Exception

preStartup

public void preStartup(org.eodisp.util.RootApp rootApp)
                throws java.lang.Exception

Sets JXTA logger to only log ERROR message unless set otherwise before

Specified by:
preStartup in interface org.eodisp.util.AppModule
Throws:
java.lang.Exception

startup

public void startup(org.eodisp.util.RootApp rootApp)
             throws net.jxta.exception.PeerGroupException,
                    java.io.IOException,
                    org.eodisp.util.configuration.ConfigurationException

Specified by:
startup in interface org.eodisp.util.AppModule
Throws:
net.jxta.exception.PeerGroupException
java.io.IOException
org.eodisp.util.configuration.ConfigurationException

newDefaultJxtaConfiguration

protected NetworkConfigurator newDefaultJxtaConfiguration()
Returns a pre-configured JXTA network configurator that is suitable for most EODiSP applications that do not act as a rendezvous or relay. The following changes are made to the standard edge network configurator (see NetworkConfigurator.newNetworkConfiguratorEdge()):

The relay and rendezvous seeds are configured as follows:

The tcp configuration is changed as follows:

Tcp Port 0
Tcp Start Port -1 (Disables port range feature)
Tcp End Port -1 (Disables port range feature)

Note that the returned configurator can not be readily used. At least the name and description should be set before using it.

Returns:
A pre-configured network configurator suitable for EODiSP applications.

getFavoriteTransport

public RemoteConfiguration.TransportType getFavoriteTransport()

postShutdown

public void postShutdown(org.eodisp.util.RootApp rootApp)
                  throws java.lang.Exception

Specified by:
postShutdown in interface org.eodisp.util.AppModule
Throws:
java.lang.Exception

shutdown

public void shutdown(org.eodisp.util.RootApp rootApp)
              throws java.lang.Exception

Specified by:
shutdown in interface org.eodisp.util.AppModule
Throws:
java.lang.Exception

unexport

public boolean unexport(java.rmi.Remote objectToUnexport,
                        RemoteConfiguration.TransportType transportType,
                        boolean force)
Parameters:
objectToUnexport - the object that shall be unexported
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:
java.lang.IllegalStateException - if an object has not been exported with this Exporter instance

unexportAll

public boolean unexportAll(java.rmi.Remote objectToUnexport,
                           boolean force)

export

public java.rmi.Remote export(java.rmi.Remote objectToExport)
Exports the given remote object on all transports defined in the configuration (so far JXTA and/or TCP).

Parameters:
remote - the remote object to export
Returns:
A proxy that can to the exported remote object. If more than one transport is given, the remote proxy is always a proxy that uses the JXTA transport. If JXTA transport is not present a proxy fro an arbitrary transport is returned. Returns null if export failed for all transports.

export

public java.rmi.Remote export(java.rmi.Remote objectToExport,
                              RemoteConfiguration.TransportType transportType)
Exports the given remote object on all transports defined in the configuration (so far JXTA and/or TCP).

Parameters:
objectToExport - the remote object to export
transportType - the transport that shall be used for the returned proxy
Returns:
The proxy of the exported object for the transport given by transportType

exportAndRegister

public java.rmi.Remote exportAndRegister(java.rmi.Remote objectToExport,
                                         java.lang.String registryKey)
Exports the given remote object on all transports defined in the configuration (so far JXTA and/or TCP).

Parameters:
remote - the remote object to export
Returns:
A proxy that can to the exported remote object. If more than one transport is given, the remote proxy is always a proxy that uses the JXTA transport. If JXTA transport is not present a proxy fro an arbitrary transport is returned. Returns null if export failed for all transports.
Throws:
java.rmi.RemoteException

getRegistry

public JeriRegistry getRegistry()
Returns the (single) registry on which remote objects can be registered for this application.

Returns:
A proxy to the registry.

getRegistryProxies

public java.util.Map<RemoteConfiguration.TransportType,JeriRegistry> getRegistryProxies()

getRegistry

public JeriRegistry getRegistry(RemoteConfiguration.TransportType transportType)
Returns the (single) registry on which remote objects can be registered for this application.

Returns:
A proxy to the registry.

getRegistry

public JeriRegistry getRegistry(java.net.URI uri)
                         throws java.net.URISyntaxException
Returns the registry of the JVM at the given location. A timeout method constraint is added to the returned proxy. The timeout can be configured by RemoteConfiguration#getJeriConnecionTimeout().

Parameters:
uri - the URI where registry is exported. E.g: tcp://examplehost.org:7900.
Returns:
the the registry of the JVM at the given location.
Throws:
java.net.URISyntaxException - Thrown if any of the following is true:
  • The scheme of the given URI is not supported. Supported schemes are: tcp and urn:jxta
  • If no port or no host is given for a tcp URI
  • If the given peer id URI is not a valid peer id. See IDFactory.fromURI(java.net.URI)

getLocalUri

public java.net.URI getLocalUri(RemoteConfiguration.TransportType transportType)

getEndpointUris

public java.util.Map<RemoteConfiguration.TransportType,java.net.URI> getEndpointUris()

getJxtaNetworkManager

public JxtaNetworkManager getJxtaNetworkManager()