public class BrokerImpl extends Object implements Broker, DOMRpcProviderService, DOMRpcService, AutoCloseable
Broker.ConsumerSession, Broker.ProviderSession
Constructor and Description |
---|
BrokerImpl(DOMRpcRouter router,
com.google.common.collect.ClassToInstanceMap<BrokerService> services) |
BrokerImpl(DOMRpcService rpcService,
DOMRpcProviderService rpcProvider,
com.google.common.collect.ClassToInstanceMap<BrokerService> services) |
Modifier and Type | Method and Description |
---|---|
void |
close() |
protected void |
consumerSessionClosed(org.opendaylight.controller.sal.dom.broker.ConsumerContextImpl consumerContextImpl) |
AutoCloseable |
getDeactivator()
Gets deactivator.
|
protected <T extends BrokerService> |
getGlobalService(Class<T> service) |
com.google.common.util.concurrent.CheckedFuture<DOMRpcResult,DOMRpcException> |
invokeRpc(org.opendaylight.yangtools.yang.model.api.SchemaPath type,
org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode<?,?> input)
Initiate invocation of an RPC.
|
Broker.ConsumerSession |
registerConsumer(Consumer consumer)
Registers the
Consumer , which will use the SAL layer. |
Broker.ConsumerSession |
registerConsumer(Consumer consumer,
org.osgi.framework.BundleContext ctx) |
Broker.ProviderSession |
registerProvider(Provider provider)
Registers the
Provider , which will use the SAL layer. |
Broker.ProviderSession |
registerProvider(Provider provider,
org.osgi.framework.BundleContext ctx) |
<T extends DOMRpcImplementation> |
registerRpcImplementation(T implementation,
DOMRpcIdentifier... rpcs)
Register an
DOMRpcImplementation object with this service. |
<T extends DOMRpcImplementation> |
registerRpcImplementation(T implementation,
Set<DOMRpcIdentifier> rpcs)
Register an
DOMRpcImplementation object with this service. |
<T extends DOMRpcAvailabilityListener> |
registerRpcListener(T listener)
Register a
DOMRpcAvailabilityListener with this service to receive notifications
about RPC implementations becoming (un)available. |
void |
setDeactivator(AutoCloseable deactivator)
Sets deactivator.
|
public BrokerImpl(DOMRpcRouter router, com.google.common.collect.ClassToInstanceMap<BrokerService> services)
public BrokerImpl(DOMRpcService rpcService, DOMRpcProviderService rpcProvider, com.google.common.collect.ClassToInstanceMap<BrokerService> services)
public Broker.ConsumerSession registerConsumer(Consumer consumer, org.osgi.framework.BundleContext ctx)
registerConsumer
in interface Broker
public Broker.ConsumerSession registerConsumer(Consumer consumer)
Broker
Consumer
, which will use the SAL layer.
During the registration, the broker obtains the initial functionality
from consumer, using the Consumer.getConsumerFunctionality()
, and
register that functionality into system and concrete infrastructure
services.
Note that consumer could register additional functionality at later point by using service and functionality specific APIs.
The consumer is required to use returned session for all communication
with broker or one of the broker services. The session is announced to
the consumer by invoking
Consumer#onSessionInitiated(ConsumerSession)
.
registerConsumer
in interface Broker
consumer
- Consumer to be registered.public Broker.ProviderSession registerProvider(Provider provider, org.osgi.framework.BundleContext ctx)
registerProvider
in interface Broker
public Broker.ProviderSession registerProvider(Provider provider)
Broker
Provider
, which will use the SAL layer.
During the registration, the broker obtains the initial functionality
from consumer, using the Provider.getProviderFunctionality()
, and
register that functionality into system and concrete infrastructure
services.
The consumer is required to use returned session for all
communication with broker or one of the broker services. The session is
announced to the consumer by invoking
Provider#onSessionInitiated(ProviderSession)
.
registerProvider
in interface Broker
provider
- Provider to be registered.protected void consumerSessionClosed(org.opendaylight.controller.sal.dom.broker.ConsumerContextImpl consumerContextImpl)
public void close() throws Exception
close
in interface AutoCloseable
Exception
public AutoCloseable getDeactivator()
public void setDeactivator(AutoCloseable deactivator)
deactivator
- the deactivator to setprotected <T extends BrokerService> com.google.common.base.Optional<T> getGlobalService(Class<T> service)
@Nonnull public <T extends DOMRpcImplementation> DOMRpcImplementationRegistration<T> registerRpcImplementation(@Nonnull T implementation, @Nonnull DOMRpcIdentifier... rpcs)
DOMRpcProviderService
DOMRpcImplementation
object with this service.registerRpcImplementation
in interface DOMRpcProviderService
implementation
- RPC implementation, must not be nullrpcs
- Array of supported RPC identifiers. Must not be null, empty, or contain a null element.
Each identifier is added exactly once, no matter how many times it occurs.DOMRpcImplementationRegistration
object, guaranteed to be non-null.@Nonnull public <T extends DOMRpcImplementation> DOMRpcImplementationRegistration<T> registerRpcImplementation(@Nonnull T implementation, @Nonnull Set<DOMRpcIdentifier> rpcs)
DOMRpcProviderService
DOMRpcImplementation
object with this service.registerRpcImplementation
in interface DOMRpcProviderService
implementation
- RPC implementation, must not be nullrpcs
- Set of supported RPC identifiers. Must not be null, empty, or contain a null element.DOMRpcImplementationRegistration
object, guaranteed to be non-null.@Nonnull public com.google.common.util.concurrent.CheckedFuture<DOMRpcResult,DOMRpcException> invokeRpc(@Nonnull org.opendaylight.yangtools.yang.model.api.SchemaPath type, @Nullable org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode<?,?> input)
DOMRpcService
invokeRpc
in interface DOMRpcService
type
- SchemaPath of the RPC to be invokedinput
- Input arguments, null if the RPC does not take any.CheckedFuture
which will return either a result structure,
or report a subclass of DOMRpcException
reporting a transport
error.@Nonnull public <T extends DOMRpcAvailabilityListener> org.opendaylight.yangtools.concepts.ListenerRegistration<T> registerRpcListener(@Nonnull T listener)
DOMRpcService
DOMRpcAvailabilityListener
with this service to receive notifications
about RPC implementations becoming (un)available. The listener will be invoked with the
current implementations reported and will be kept uptodate as implementations come and go.
Users should note that using a listener does not necessarily mean that
DOMRpcService.invokeRpc(SchemaPath, NormalizedNode)
will not report a failure due to
DOMRpcImplementationNotAvailableException
and need to be ready to handle it.
Implementations of this interface are encouraged to take reasonable precautions to prevent this scenario from occurring.
registerRpcListener
in interface DOMRpcService
listener
- DOMRpcAvailabilityListener
instance to registerListenerRegistration
representing this registration. Performing
a ListenerRegistration.close()
will cancel it. Returned object
is guaranteed to be non-null.Copyright © 2019 OpenDaylight. All rights reserved.