public interface ProxyService
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
return CompletableFuture
) will be proxied using asynchronous intra-cluster
communication. To make a remote call on a proxy service, get an instance of the ProxyFactory
for the service
type using getProxyFactory(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.
Modifier and Type | Method and Description |
---|---|
<T> ProxyFactory<T> |
getProxyFactory(Class<T> type,
Serializer serializer)
Returns a new proxy factory for the given type.
|
<T> void |
registerProxyService(Class<? super T> type,
T proxy,
Serializer serializer)
Registers a proxy service.
|
void |
unregisterProxyService(Class<?> type)
Unregisters the proxy service of the given type.
|
<T> ProxyFactory<T> getProxyFactory(Class<T> type, Serializer serializer)
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.
T
- the proxy typetype
- the proxy typeserializer
- the proxy serializerIllegalArgumentException
- if the type
is not an interface<T> void registerProxyService(Class<? super T> type, T proxy, Serializer serializer)
The proxy type
passed to this method must be an interface. The proxy
should be an implementation
of that interface on which methods will be called when proxy calls from other nodes are received.
T
- the proxy typetype
- the proxy typeproxy
- the proxy serviceserializer
- the proxy serializerIllegalArgumentException
- if the type
is not an interfacevoid unregisterProxyService(Class<?> type)
Once the proxy service has been unregistered, calls to the proxy instance on this node will fail.
type
- the proxy service type to unregister