java.lang.Object
com.pervasive.datarush.commons.util.SimpleRMI
For internal use only; public as a matter of implementation. Provides a
simple, stripped-down RMI mechanism. This does not have a concept of
distributed garbage collection or distributed objects. Rather, all remotable
objects are stateless singletons. All method input objects are mashalled via
Java serialization. Method returns and exceptions are also marshalled via
java serialization. Note that there is special handling for a methods
returning InputStreams or OutputStreams:
- OutputStreams: these are returned as a "live" object. That is, the client is handled back a stream to which they can write data. As the client writes bytes to the stream, data is streamed over the socket to the object that was returned from the remote service.
- InputStreams: these are returned as a "live" object. That is, the client is handled back a stream from which they can read data. As the client requests bytes from the stream, data is requested from the object that was returned from the remote service.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classRegistry of services.static interfaceServer-side implementations may implement this interface to receive notifications of server start and stop -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic <T> TcreateClient(Class<T> clazz, InetSocketAddress address) Creates a remote client proxy to the given address.static <T> TcreateClient(Class<T> clazz, InetSocketAddress address, NetworkConfiguration netConfig) Creates a remote client proxy to the given address.static <T> TcreateLocalClient(Class<T> clazz, T target) Returns a local client proxy to the given service.static GenericTCPServercreateServer(SimpleRMI.Registry registry) Creates a server that can host the list of services listed in the given registry.static ObjectgetLocalClientTarget(Object client) Returns the underlying implementation of a local client proxystatic NetworkConfigurationgetNetworkConfiguration(Object remoteClient) Returns the network configuration for the given proxy.static InetSocketAddressgetRemoteClientAddress(Object remoteClient) Returns the remote client address for the given proxy.static booleanisRemoteProxy(Object client) Returns whether the given client is a remote proxy handlerstatic <T> TtransferNetworkConfiguration(Object from, T to) Returns a new remote client, obtaining a network configuration from another remote interfacestatic <T> TwithNetworkConfiguration(T remoteClient, NetworkConfiguration socketProvider) Returns a new remote client, specifying the socket factory to use
-
Constructor Details
-
SimpleRMI
public SimpleRMI()
-
-
Method Details
-
createServer
Creates a server that can host the list of services listed in the given registry.- Parameters:
registry- the registry- Returns:
- a new server. the server will be started.
-
createClient
Creates a remote client proxy to the given address.- Type Parameters:
T- the service interface- Parameters:
clazz- the service interfaceaddress- the address to connect to. must be the host and port of a server that contains a registered implementation of the given service interface.- Returns:
- a remote client proxy
-
createClient
public static <T> T createClient(Class<T> clazz, InetSocketAddress address, NetworkConfiguration netConfig) Creates a remote client proxy to the given address.- Type Parameters:
T- the service interface- Parameters:
clazz- the service interfaceaddress- the address to connect to. must be the host and port of a server that contains a registered implementation of the given service interface.netConfig- the network configuration to use- Returns:
- a remote client proxy
-
getRemoteClientAddress
Returns the remote client address for the given proxy.- Parameters:
remoteClient- the remote client proxy.- Returns:
- the remote client address for the given proxy or null if the remoteClient is not a remote proxy
-
getNetworkConfiguration
Returns the network configuration for the given proxy.- Parameters:
remoteClient- the remote client proxy.- Returns:
- the network configuration for the given proxy or null if the client is not a remote client proxy
-
transferNetworkConfiguration
Returns a new remote client, obtaining a network configuration from another remote interface- Parameters:
from- the remote interface from which to obtain the network configurationto- the remote client that we want to set the network configuration on- Returns:
- a new remote client
-
withNetworkConfiguration
Returns a new remote client, specifying the socket factory to use- Parameters:
remoteClient- the remote client proxysocketProvider- the provider to use- Returns:
- a new remote client
-
isRemoteProxy
Returns whether the given client is a remote proxy handler- Parameters:
client- the client- Returns:
- true if the client is a remote proxy handler;
-
createLocalClient
Returns a local client proxy to the given service. The returned client will emulate remote by serializing/deserializing all inputs/outputs and exceptions.- Type Parameters:
T- the service interface- Parameters:
clazz- the service interfacetarget- the service implementation- Returns:
- a local client proxy
-
getLocalClientTarget
Returns the underlying implementation of a local client proxy- Parameters:
client- the local client proxy. Must be an object returned bycreateLocalClient(Class, Object)- Returns:
- the underlying implementation of a local client proxy
-