public class RefCountingBus extends Object implements Bus
Bus
instances. The wrapped
instance is activated only to the first call to activate()
and
deactivated only when as many deactivate()
calls are received as
have been activate calls received.Modifier and Type | Class and Description |
---|---|
static interface |
RefCountingBus.DeactivationHandler
A handler that will be called once the underlying bus will really be
deactivated.
|
Bus.NotificationReceiver
Activatable.State
Constructor and Description |
---|
RefCountingBus(Bus bus,
RefCountingBus.DeactivationHandler handler)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
activate()
Activates all resources that belong to a specific object.
|
void |
addNotificationReceiver(Bus.NotificationReceiver receiver)
Registers a local observer for notifications.
|
void |
deactivate()
Deactivate all resources that are owned by a specific object in order to
correctly tear down.
|
Bus |
getContainedBus()
Returns the underlying bus that is handled with reference counting.
|
SocketOptions |
getSocketOptions()
Returns the current socket configuration of the bus.
|
URI |
getTransportUri()
Return the URI describing the transport manifested by this bus.
|
void |
handleOutgoing(NotificationType.Notification notification)
Handles a notification to be sent over the bus.
|
boolean |
isActive()
Tells whether this class is currently active or not.
|
void |
removeNotificationReceiver(Bus.NotificationReceiver receiver)
Removes a local observer for notifications if registered before.
|
public RefCountingBus(Bus bus, RefCountingBus.DeactivationHandler handler)
bus
- bus to managehandler
- handler to be called on deactivation of the buspublic void activate() throws RSBException
Activatable
activate
in interface Activatable
RSBException
- generic error related to RSBpublic boolean isActive()
Activatable
isActive
in interface Activatable
true
if activepublic void deactivate() throws RSBException, InterruptedException
Activatable
deactivate
in interface Activatable
RSBException
- generic error related to RSBInterruptedException
- interrupted while waiting for proper deactivation. Object
might be in an undefined state nowpublic SocketOptions getSocketOptions()
Bus
getSocketOptions
in interface Bus
public void handleOutgoing(NotificationType.Notification notification) throws RSBException
Bus
Bus.NotificationReceiver
and to all registered BusConnection
s.handleOutgoing
in interface Bus
notification
- the notification to distributeRSBException
- error during dispatchingpublic void addNotificationReceiver(Bus.NotificationReceiver receiver)
Bus
addNotificationReceiver
in interface Bus
receiver
- the receiver to registerpublic void removeNotificationReceiver(Bus.NotificationReceiver receiver)
Bus
removeNotificationReceiver
in interface Bus
receiver
- the receiver to removepublic Bus getContainedBus()
Activatable.activate()
or Activatable.deactivate()
on this
instance!public URI getTransportUri()
Bus
getTransportUri
in interface Bus
null
Copyright © 2018 CoR-Lab. All rights reserved.