public class BusCache extends Object
Bus
instances based on the required SocketOptions
.
This class is thread-safe. For longer synchronized blocks use
getSynchronizer()
.Constructor and Description |
---|
BusCache() |
Modifier and Type | Method and Description |
---|---|
Bus |
get(SocketOptions options)
Returns a
Bus instance for the given options or null
if no such instance is cached. |
Object |
getSynchronizer()
Clients may use the returned instance to synchronize on.
|
boolean |
hasBus(SocketOptions options)
Indicates whether a
Bus instance with the given options is
available or not. |
void |
register(Bus bus)
Registers a new bus instance in the cache.
|
void |
register(Bus bus,
boolean replace)
Registers a new bus instance in the cache and allows overriding existing
instances.
|
void |
unregister(Bus bus)
Removes a bus from the cache if it was present.
|
public Object getSynchronizer()
public void register(Bus bus)
bus
- bus to registerIllegalArgumentException
- there is already a bus with the given optionspublic void register(Bus bus, boolean replace)
bus
- bus to registersreplace
- if true
, replace existing instances with the same
options instead of throwing an exceptionIllegalArgumentException
- there is already a bus with the given options and replacing
was not requestedpublic void unregister(Bus bus)
bus
- the bus to removepublic Bus get(SocketOptions options)
Bus
instance for the given options or null
if no such instance is cached.options
- options to look upBus
instance or null
public boolean hasBus(SocketOptions options)
Bus
instance with the given options is
available or not.options
- options to look uptrue
if available, else false
Copyright © 2018 CoR-Lab. All rights reserved.