Interface ProxyService
-
public interface ProxyService
Manages remote proxy services and instances.This service can be used to make arbitrary method calls on remote objects in ONOS. The objects on which the methods are called are referred to as services and are made available to the proxy service by
registering
a service instance. Services must implement an interface which can be used to construct a Java proxy. Proxy interfaces may define either synchronous or asynchronous methods. Synchronous proxy methods will be blocked, and asynchronous proxy methods (which must returnCompletableFuture
) will be proxied using asynchronous intra-cluster communication. To make a remote call on a proxy service, get an instance of theProxyFactory
for the service type usinggetProxyFactory(Class, Serializer)
. The proxy factory is responsible for constructing proxy instances for each node in the cluster. Once a proxy instance is constructed, calls on the proxy instance will be transparently serialized and sent to the associated peer and be executed on the proxy service registered by that peer.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description <T> ProxyFactory<T>
getProxyFactory(java.lang.Class<T> type, Serializer serializer)
Returns a new proxy factory for the given type.<T> void
registerProxyService(java.lang.Class<? super T> type, T proxy, Serializer serializer)
Registers a proxy service.void
unregisterProxyService(java.lang.Class<?> type)
Unregisters the proxy service of the given type.
-
-
-
Method Detail
-
getProxyFactory
<T> ProxyFactory<T> getProxyFactory(java.lang.Class<T> type, Serializer serializer)
Returns a new proxy factory for the given type.The proxy
type
passed to this method must be an interface. The proxy factory can be used to construct proxy instances for different nodes in the cluster.- Type Parameters:
T
- the proxy type- Parameters:
type
- the proxy typeserializer
- the proxy serializer- Returns:
- the proxy factory
- Throws:
java.lang.IllegalArgumentException
- if thetype
is not an interface
-
registerProxyService
<T> void registerProxyService(java.lang.Class<? super T> type, T proxy, Serializer serializer)
Registers a proxy service.The proxy
type
passed to this method must be an interface. Theproxy
should be an implementation of that interface on which methods will be called when proxy calls from other nodes are received.- Type Parameters:
T
- the proxy type- Parameters:
type
- the proxy typeproxy
- the proxy serviceserializer
- the proxy serializer- Throws:
java.lang.IllegalArgumentException
- if thetype
is not an interface
-
unregisterProxyService
void unregisterProxyService(java.lang.Class<?> type)
Unregisters the proxy service of the given type.Once the proxy service has been unregistered, calls to the proxy instance on this node will fail.
- Parameters:
type
- the proxy service type to unregister
-
-