public final class RMIRegistry
extends java.lang.Object
RMIRegistry.Builder
whose instances are constructed by the builder()
factory method.RMIRegistry registry = RMIRegistry.builder().build();
Modifier and Type | Class and Description |
---|---|
static class |
RMIRegistry.Builder
Builder for
RMIRegistry . |
static class |
RMIRegistry.MethodAnnotationRegistry
The method register marks remote methods to be executed according the
preferred invocation policies.
|
Modifier and Type | Method and Description |
---|---|
void |
addCodebase(java.lang.String url)
Add a new static codebase that will be sent to the other machines.
|
void |
addCodebase(java.net.URL url)
Add a new static codebase that will be sent to the other machines.
|
void |
addCodebases(java.lang.Iterable<java.net.URL> urls)
Add new static codebases that will be sent to the other machines.
|
void |
addCodebases(java.lang.String... urls)
Add new static codebases that will be sent to the other machines.
|
void |
addCodebases(java.net.URL... urls)
Add new static codebases that will be sent to the other machines.
|
boolean |
allInvocationFaultsSuppressed()
Gets the suppression state of the RMI faults.
|
void |
attachFaultHandler(RMIFaultHandler o)
Attach a
RMIFaultHandler object |
static RMIRegistry.Builder |
builder()
Creates a new
RMIRegistry.Builder instance, used to configure and
start a new RMIRegistry instance. |
void |
clearCodebasesSet()
Equinvalent to calling
RMIClassLoader.clearCodebasesSet() on the
result of the method getRmiClassLoader() . |
void |
closeAllConnections(java.lang.String host,
int port,
boolean signalFault)
Close all currently active connections to the specified remote socket
(host/port).
|
void |
detachFailureHandler(RMIFaultHandler o)
Detach a
RMIFaultHandler object |
void |
disableListener()
Disable the registry listener.
|
void |
enableListener(int port,
boolean daemon)
Enable the registry listener on the selected port.
|
RMIRegistry |
exportInterface(java.lang.Class<?> remoteIf)
Marks an interface to automatically create remote references for objects that
are sent as arguments for an invocation or as return values.
|
RMIRegistry |
exportInterfaces(java.lang.Class<?>... interfaces)
Exports the specified interfaces as remote.
|
void |
finalize()
Finalizes this registry instance and all its current open connections.
|
void |
finalize(boolean signalHandlersFailures)
Finalizes this registry instance and all its current open connections.
|
RMIAuthenticator |
getAuthenticator()
Gets the rmiAuthenticator of this registry
|
ClassLoaderFactory |
getClassLoaderFactory()
Gets the class loader factory used by this registry to decode remote classes
when code mobility is enabled.
|
java.util.Set<java.net.URL> |
getCodebases()
This will return all the static codebases and all the received codebases
whose classes are currently instantiated.
|
long |
getHandlerFaultMaxLife()
Gets the
handler maximum life used to simulate connection
failures. |
int |
getLatencyTime()
Gets the estimate of the TCP connection latency time given by the developer.
|
int |
getLeaseTime()
Gets the lease timeout after that the distributed garbage collection
mechanism will remove a non-named object from the registry.
|
int |
getListenerPort()
Gets the port on which the listener was started on last time
|
RMIRegistry.MethodAnnotationRegistry |
getMethodAnnotationRegistry()
Gets the
RMIRegistry.MethodAnnotationRegistry instance bound to this registry. |
java.lang.Class<java.lang.Exception> |
getRemoteExceptionReplace()
Gets the
RemoteException replacing class set by invoking the
replaceRemoteException(Class) method. |
java.util.List<java.lang.Class<?>> |
getRemoteInterfaces(java.lang.Class<?> cls)
Gets the remote interfaces implemented by the specified class and its
super-classes
|
java.util.List<java.lang.Class<?>> |
getRemoteInterfaces(java.lang.Object object)
Gets the remote interfaces implemented by the class of the specified object
|
java.util.List<java.lang.Class<?>> |
getRemoteInterfaces(java.lang.String objectId)
Gets the remote interfaces implemented by the class of the remote object
associated to the specified object identifier
|
java.lang.Object |
getRemoteObject(java.lang.String objectId)
Gets a published remote object by identifier
|
java.lang.String |
getRemoteObjectId(java.lang.Object object)
Gets the identifier of a remote object published on this registry
|
RMIClassLoader |
getRmiClassLoader()
Returns the
RMIClassLoader instance used to load classes from remote
codebase. |
RMIHandler |
getRMIHandler(java.lang.String host,
int port)
Gets an
handler for the specified host. |
RMIHandler |
getRMIHandler(java.lang.String host,
int port,
boolean newConnection)
Gets an
handler for the specified host. |
int |
getSkeletonInvocationCacheSize()
Gets the size of invocations cache for each skeleton.
|
boolean |
getStateConsistencyOnFaultEnabled()
Gets the enabling status of the mechanism that guarantees the status
consistency between stubs and remote objects after a connection fault.
|
java.lang.Object |
getStub(java.lang.String address,
int port,
java.lang.String objectId)
Gets a stub for the specified object identifier representing a remote object
on a remote machine.
|
java.lang.Object |
getStub(java.lang.String address,
int port,
java.lang.String objectId,
java.lang.Class<?>... stubInterfaces)
Builds a stub for the specified object identifier on the specified host
respect to the given interface.
|
java.lang.String |
getStubHost(java.lang.Object stub)
Gets the remote host of the specified RMI stub.
|
java.lang.String |
getStubObjectIdentifier(java.lang.Object stub)
Gets the object identifier of the specified RMI stub.
|
int |
getStubPort(java.lang.Object stub)
Gets the remote host port of the specified RMI stub.
|
StubRetriever |
getStubRetriever()
Gets a
StubRetriever instance linked to this registry |
boolean |
isAutomaticReferencingEnabled()
Returns the status of the automatic referencing.
|
boolean |
isCodeDownloadingEnabled()
Gets the code mobility enable flag
|
boolean |
isMultiConnectionMode()
Gets the multi-connection mode enable state.
|
boolean |
isRemote(java.lang.Class<?> remoteIf)
Check if a class is marked for automatic referencing.
|
java.lang.String |
publish(java.lang.Object object)
Publish the given object respect to the specified interface.
|
void |
publish(java.lang.String name,
java.lang.Object object)
Publish the given object respect to the specified interface.
|
void |
removeAuthentication(java.lang.String host,
int port)
Removes authentication details for a remote host
|
void |
removeCodebase(java.net.URL url)
Removes a static codebase previously added.
|
void |
replaceRemoteException(java.lang.Class<java.lang.Exception> exceptionClass)
Let the stubs to throw the specified exception alternatively to
RemoteException on communication errors. |
void |
setAuthentication(java.lang.String host,
int port,
java.lang.String authId,
java.lang.String authPassphrase)
Adds authentication details for a remote host
|
void |
setCodeDownloadingEnabled(boolean codeMobilityEnabled) |
void |
setLatencyTime(int latencyTime)
Sets an estimate of the TCP connection latency time.
|
void |
setMultiConnectionMode(boolean multiConnectionMode)
Enables or disables multi-connection mode.
|
void |
unexportInterface(java.lang.Class<?> remoteIf)
Remove a automatic referencing mark for the interface.
|
void |
unpublish(java.lang.Object object)
Unpublish an object respect to the given interface
|
public static RMIRegistry.Builder builder()
RMIRegistry.Builder
instance, used to configure and
start a new RMIRegistry
instance.RMIRegistry.Builder
instancepublic void replaceRemoteException(java.lang.Class<java.lang.Exception> exceptionClass)
RemoteException
on communication errors.exceptionClass
- the alternative exception class or null if the
RemoteException
must not be replaced.public java.lang.Class<java.lang.Exception> getRemoteExceptionReplace()
RemoteException
replacing class set by invoking the
replaceRemoteException(Class)
method.RemoteException
or null if RemoteException
is not
currently replaced.public boolean allInvocationFaultsSuppressed()
RMIRegistry.Builder.suppressAllInvocationFaults(boolean)
public void setMultiConnectionMode(boolean multiConnectionMode)
multiConnectionMode
- true to enable, false to disableRMIRegistry.Builder.setMultiConnectionMode(boolean)
public boolean isMultiConnectionMode()
setMultiConnectionMode(boolean)
public int getSkeletonInvocationCacheSize()
RMIRegistry.Builder.setSkeletonInvocationCacheSize(int)
for more details.public boolean getStateConsistencyOnFaultEnabled()
RMIRegistry.Builder.setStateConsistencyOnFaultEnabled(boolean)
for more details.public long getHandlerFaultMaxLife()
handler
maximum life used to simulate connection
failures. See RMIRegistry.Builder.setHandlerFaultMaxLife(long)
for more details.handler
life before a connection
failure is simulated, in milliseconds.public boolean isAutomaticReferencingEnabled()
RMIRegistry.Builder.setAutomaticReferencingEnabled(boolean)
for more
information.public ClassLoaderFactory getClassLoaderFactory()
ClassLoaderFactory
used by this registrypublic int getLeaseTime()
public int getLatencyTime()
RMIRegistry.Builder.setLatencyTime(int)
public void setLatencyTime(int latencyTime)
latencyTime
- a time in millisecondsRMIRegistry.Builder.setLatencyTime(int)
public void setCodeDownloadingEnabled(boolean codeMobilityEnabled)
public boolean isCodeDownloadingEnabled()
public void clearCodebasesSet()
RMIClassLoader.clearCodebasesSet()
on the
result of the method getRmiClassLoader()
.public java.util.Set<java.net.URL> getCodebases()
public void addCodebases(java.lang.Iterable<java.net.URL> urls)
urls
- the codebases to addaddCodebase(URL)
public void addCodebases(java.net.URL... urls)
urls
- the codebases to addaddCodebase(URL)
public void addCodebase(java.net.URL url)
url
- the codebase to addpublic void addCodebases(java.lang.String... urls) throws java.net.MalformedURLException
urls
- the codebases to addjava.net.MalformedURLException
- if any of the specified URLs is malformedaddCodebase(URL)
public void addCodebase(java.lang.String url) throws java.net.MalformedURLException
url
- the codebase to addjava.net.MalformedURLException
- if the specified URL is malformedpublic void removeCodebase(java.net.URL url)
url
- the URL of the codebaseaddCodebase(URL)
public RMIClassLoader getRmiClassLoader()
RMIClassLoader
instance used to load classes from remote
codebase. This instance can be used to load specific classes that are not in
the current classpath.RMIClassLoader
instance used by this registrypublic void setAuthentication(java.lang.String host, int port, java.lang.String authId, java.lang.String authPassphrase)
host
- the remote hostport
- the remote portauthId
- the authentication identifierauthPassphrase
- the authentication pass-phrasepublic void removeAuthentication(java.lang.String host, int port)
host
- the remote hostport
- the remote portpublic void finalize()
finalize
in class java.lang.Object
public void finalize(boolean signalHandlersFailures)
signalHandlersFailures
- set to true if all the RMIHandler
instances created by this registry should send
a signal to the attached fault handlers
public StubRetriever getStubRetriever()
StubRetriever
instance linked to this registryStubRetriever
objectpublic java.lang.Object getStub(java.lang.String address, int port, java.lang.String objectId, java.lang.Class<?>... stubInterfaces)
getStub(String, int, String)
method in most real and complex
applications.newProxyInstance
method.address
- the host addressport
- the host portobjectId
- the remote object identifierstubInterfaces
- the interfaces implemented by the stubgetStub(String, int, String)
public java.lang.Object getStub(java.lang.String address, int port, java.lang.String objectId) throws java.net.UnknownHostException, java.io.IOException, java.lang.InterruptedException
newProxyInstance
method.address
- the host addressport
- the host portobjectId
- the object identifierjava.net.UnknownHostException
- if the remote host cannot be foundjava.io.IOException
- if an I/O error occurs while contacting the
remote machinejava.lang.InterruptedException
- if the current thread is interrupted during
operationgetStub(String, int, String, Class...)
public RMIHandler getRMIHandler(java.lang.String host, int port) throws java.io.IOException
handler
for the specified host. If it has not been
created, then creates it. If any handler
already exists
and multi-connection mode
is
disabled, gets one of them. If multi-connection mode
is enabled, this method creates a new, never used,
handler
.host
- the host addressport
- the host portjava.net.UnknownHostException
- if the host address cannot be resolvedjava.io.IOException
- if I/O errors occurgetRMIHandler(String, int, boolean)
public RMIHandler getRMIHandler(java.lang.String host, int port, boolean newConnection) throws java.io.IOException
handler
for the specified host. If it has not been
created, then creates it. If a new connection must be created, this method
returns a new, never used, handler
.host
- the host addressport
- the host portnewConnection
- set to true to create a new handler without getting an
already existing onejava.net.UnknownHostException
- if the host address cannot be resolvedjava.io.IOException
- if I/O errors occursgetRMIHandler(String, int)
public void closeAllConnections(java.lang.String host, int port, boolean signalFault)
host
- the string address of the remote hostport
- the port of the remote socketsignalFault
- set to true if each handler
connected
to the remote host should send a signal to the
fault handlers
instances attached
to this registry
public void enableListener(int port, boolean daemon) throws java.io.IOException
port
- the port to start the listener ondaemon
- if true, the listener is started as daemon, that is it will be
stopped when all other non-daemon threads in the application
will be terminated.java.io.IOException
- if I/O errors occurpublic void disableListener()
public int getListenerPort()
public RMIAuthenticator getAuthenticator()
public void publish(java.lang.String name, java.lang.Object object)
name
- the identifier to use for this serviceobject
- the implementation of the service to publishjava.lang.IllegalArgumentException
- if the specified identifier was already
bound or if the objectId parameter matches
the automatic referencing objectId pattern
that is /\#[0-9]+/public java.lang.String publish(java.lang.Object object)
object
- the implementation of the service to publishpublic void unpublish(java.lang.Object object)
object
- the object to unpublishpublic void attachFaultHandler(RMIFaultHandler o)
RMIFaultHandler
objecto
- the fault handlerpublic void detachFailureHandler(RMIFaultHandler o)
RMIFaultHandler
objecto
- the fault handlerpublic java.lang.Object getRemoteObject(java.lang.String objectId)
objectId
- object identifierpublic java.lang.String getRemoteObjectId(java.lang.Object object)
object
- the published object referencepublic RMIRegistry exportInterfaces(java.lang.Class<?>... interfaces)
exportInterface(Class)
method for each specified interface.interfaces
- the interfaces to exportexportInterface(Class)
public RMIRegistry exportInterface(java.lang.Class<?> remoteIf)
remoteIf
- the interface to markpublic void unexportInterface(java.lang.Class<?> remoteIf)
exportInterface(Class)
method. All the objects
automatically referenced until this call, remains published in the registry.remoteIf
- the interface to unmarkpublic boolean isRemote(java.lang.Class<?> remoteIf)
Remote
interface or if it was exported or if it extends,
directly or indirectly, an interface that was exported on this registry to be
remote.exportInterface(Class)
method.remoteIf
- the interface to checkpublic java.util.List<java.lang.Class<?>> getRemoteInterfaces(java.lang.String objectId)
objectId
- the object identifierpublic java.util.List<java.lang.Class<?>> getRemoteInterfaces(java.lang.Object object)
object
- the objectpublic java.util.List<java.lang.Class<?>> getRemoteInterfaces(java.lang.Class<?> cls)
cls
- the classpublic java.lang.String getStubHost(java.lang.Object stub)
stub
- the RMI stubjava.lang.IllegalArgumentException
- if the specified object is not an RMI stubpublic int getStubPort(java.lang.Object stub)
stub
- the RMI stubjava.lang.IllegalArgumentException
- if the specified object is not an RMI stubpublic java.lang.String getStubObjectIdentifier(java.lang.Object stub)
stub
- the RMI stubjava.lang.IllegalArgumentException
- if the specified object is not an RMI stubpublic RMIRegistry.MethodAnnotationRegistry getMethodAnnotationRegistry()
RMIRegistry.MethodAnnotationRegistry
instance bound to this registry.RMIRegistry.MethodAnnotationRegistry
instance