public class SynchronizedServiceRegistry extends java.lang.Object implements IServiceRegistry
| Modifier and Type | Field and Description |
|---|---|
protected IServiceRegistry |
delegate
The service registry calls are delegated to.
|
protected java.util.concurrent.locks.ReentrantLock |
lock
Flag that a writer is performing updates.
|
protected int |
readercnt
The reader count.
|
protected boolean |
syncglobal
Flag if global searches should be synchronized.
|
protected java.util.List<Tuple2<IResultCommand<IFuture<java.lang.Void>,java.lang.Void>,Future<java.lang.Void>>> |
writeactions
The scheduled write actions (deferred when readers are currrently reading).
|
| Constructor and Description |
|---|
SynchronizedServiceRegistry(boolean syncglobal,
IServiceRegistry delegate)
Create a new SynchronizedMultiServiceRegistry.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addEventListener(IRegistryListener listener)
Add an event listener.
|
void |
addExcludedComponent(IComponentIdentifier cid)
Add an excluded component.
|
<T> ISubscriptionIntermediateFuture<T> |
addQuery(ServiceQuery<T> query)
Add a service query to the registry.
|
IFuture<java.lang.Void> |
addService(ClassInfo key,
IService service)
Add a service to the registry.
|
<T> java.util.Set<ServiceQueryInfo<T>> |
getQueries(ClassInfo type)
Get queries per type.
|
static SynchronizedServiceRegistry |
getRegistry(IComponentIdentifier platform)
Get the registry from a component.
|
static SynchronizedServiceRegistry |
getRegistry(IInternalAccess ia)
Get the registry from a component.
|
java.util.Map<ClassInfo,java.util.Set<IService>> |
getServiceMap()
todo: WARNING: dangerous method that exposes the internal data structure
Get the service map.
|
java.util.Iterator<IService> |
getServices(ClassInfo type)
Get the services per type.
|
IServiceRegistry |
getSubregistry(IComponentIdentifier cid)
Get a subregistry.
|
boolean |
isIncluded(IComponentIdentifier cid,
IService ser)
Test if a service is included.
|
protected void |
lock()
Method that tries to get the lock and blocks otherwise (will terminate blocking after 3 seconds forcefully).
|
protected void |
performWrites()
Perform the scheduled write actions.
|
protected java.lang.Object |
readActionSync(IResultCommand<java.lang.Object,java.lang.Void> command,
java.lang.String op) |
protected void |
readerDec()
Get the lock and decrement the readers variable.
|
protected void |
readerInc(java.lang.String op)
Get the lock and increment the readers variable.
|
void |
removeEventListener(IRegistryListener listener)
Remove an event listener.
|
IFuture<java.lang.Void> |
removeExcludedComponent(IComponentIdentifier cid)
Remove an excluded component.
|
void |
removeQueries(IComponentIdentifier owner)
Remove all service queries of a specific component from the registry.
|
<T> void |
removeQuery(ServiceQuery<T> query)
Remove a service query from the registry.
|
void |
removeService(ClassInfo key,
IService service)
Remove a service from the registry.
|
void |
removeSubregistry(IComponentIdentifier cid)
Remove an existing registry.
|
<T> IFuture<T> |
searchGlobalService(ClassInfo type,
IComponentIdentifier cid,
IAsyncFilter<T> filter)
Search for services.
|
<T> ISubscriptionIntermediateFuture<T> |
searchGlobalServices(ClassInfo type,
IComponentIdentifier cid,
IAsyncFilter<T> filter)
Search for services.
|
<T> T |
searchService(ClassInfo type,
IComponentIdentifier cid,
java.lang.String scope)
Search for services.
|
<T> T |
searchService(ClassInfo type,
IComponentIdentifier cid,
java.lang.String scope,
boolean excluded)
Search for services.
|
<T> IFuture<T> |
searchService(ClassInfo type,
IComponentIdentifier cid,
java.lang.String scope,
IAsyncFilter<T> filter)
Search for service.
|
<T> T |
searchService(ClassInfo type,
IComponentIdentifier cid,
java.lang.String scope,
IFilter<T> filter)
Search for service.
|
<T> java.util.Collection<T> |
searchServices(ClassInfo type,
IComponentIdentifier cid,
java.lang.String scope)
Search for services.
|
<T> ISubscriptionIntermediateFuture<T> |
searchServices(ClassInfo type,
IComponentIdentifier cid,
java.lang.String scope,
IAsyncFilter<T> filter)
Search for services.
|
<T> java.util.Collection<T> |
searchServices(ClassInfo type,
IComponentIdentifier cid,
java.lang.String scope,
IFilter<T> filter)
Search for service.
|
protected void |
unlock()
Method that unlocks the lock.
|
protected IFuture<java.lang.Void> |
writeAction(IResultCommand<IFuture<java.lang.Void>,java.lang.Void> command) |
protected int readercnt
protected java.util.concurrent.locks.ReentrantLock lock
protected java.util.List<Tuple2<IResultCommand<IFuture<java.lang.Void>,java.lang.Void>,Future<java.lang.Void>>> writeactions
protected IServiceRegistry delegate
protected boolean syncglobal
public SynchronizedServiceRegistry(boolean syncglobal,
IServiceRegistry delegate)
protected void lock()
protected void unlock()
protected IFuture<java.lang.Void> writeAction(IResultCommand<IFuture<java.lang.Void>,java.lang.Void> command)
command - protected java.lang.Object readActionSync(IResultCommand<java.lang.Object,java.lang.Void> command, java.lang.String op)
command - public IFuture<java.lang.Void> addService(ClassInfo key, IService service)
addService in interface IServiceRegistrysid - The service id.public void removeService(ClassInfo key, IService service)
removeService in interface IServiceRegistrysid - The service id.public <T> ISubscriptionIntermediateFuture<T> addQuery(ServiceQuery<T> query)
addQuery in interface IServiceRegistryquery - ServiceQuery.public <T> void removeQuery(ServiceQuery<T> query)
removeQuery in interface IServiceRegistryquery - ServiceQuery.public void removeQueries(IComponentIdentifier owner)
removeQueries in interface IServiceRegistryowner - The query owner.public <T> T searchService(ClassInfo type, IComponentIdentifier cid, java.lang.String scope)
searchService in interface IServiceRegistrypublic <T> T searchService(ClassInfo type, IComponentIdentifier cid, java.lang.String scope, boolean excluded)
searchService in interface IServiceRegistrypublic <T> java.util.Collection<T> searchServices(ClassInfo type, IComponentIdentifier cid, java.lang.String scope)
searchServices in interface IServiceRegistrypublic <T> T searchService(ClassInfo type, IComponentIdentifier cid, java.lang.String scope, IFilter<T> filter)
searchService in interface IServiceRegistrypublic <T> java.util.Collection<T> searchServices(ClassInfo type, IComponentIdentifier cid, java.lang.String scope, IFilter<T> filter)
searchServices in interface IServiceRegistrypublic <T> IFuture<T> searchService(ClassInfo type, IComponentIdentifier cid, java.lang.String scope, IAsyncFilter<T> filter)
searchService in interface IServiceRegistrypublic <T> ISubscriptionIntermediateFuture<T> searchServices(ClassInfo type, IComponentIdentifier cid, java.lang.String scope, IAsyncFilter<T> filter)
searchServices in interface IServiceRegistrypublic <T> IFuture<T> searchGlobalService(ClassInfo type, IComponentIdentifier cid, IAsyncFilter<T> filter)
searchGlobalService in interface IServiceRegistrypublic <T> ISubscriptionIntermediateFuture<T> searchGlobalServices(ClassInfo type, IComponentIdentifier cid, IAsyncFilter<T> filter)
searchGlobalServices in interface IServiceRegistrypublic static SynchronizedServiceRegistry getRegistry(IComponentIdentifier platform)
public static SynchronizedServiceRegistry getRegistry(IInternalAccess ia)
protected void readerInc(java.lang.String op)
protected void readerDec()
protected void performWrites()
public java.util.Iterator<IService> getServices(ClassInfo type)
getServices in interface IServiceRegistrytype - The type.public void addExcludedComponent(IComponentIdentifier cid)
addExcludedComponent in interface IServiceRegistryThe - component identifier.public IFuture<java.lang.Void> removeExcludedComponent(IComponentIdentifier cid)
removeExcludedComponent in interface IServiceRegistryThe - component identifier.public boolean isIncluded(IComponentIdentifier cid, IService ser)
isIncluded in interface IServiceRegistryser - The service.public java.util.Map<ClassInfo,java.util.Set<IService>> getServiceMap()
getServiceMap in interface IServiceRegistrypublic <T> java.util.Set<ServiceQueryInfo<T>> getQueries(ClassInfo type)
getQueries in interface IServiceRegistrytype - The interface type. If type is null all services are returned.public void addEventListener(IRegistryListener listener)
addEventListener in interface IServiceRegistrylistener - The listener.public void removeEventListener(IRegistryListener listener)
removeEventListener in interface IServiceRegistrylistener - The listener.public IServiceRegistry getSubregistry(IComponentIdentifier cid)
getSubregistry in interface IServiceRegistrycid - The platform id.public void removeSubregistry(IComponentIdentifier cid)
removeSubregistry in interface IServiceRegistrycid - The component id to remove.