Package jadex.bridge.service.search
Class ServiceRegistry
- java.lang.Object
- 
- jadex.bridge.service.search.ServiceRegistry
 
- 
- All Implemented Interfaces:
- IServiceRegistry
 
 public class ServiceRegistry extends java.lang.Object implements IServiceRegistry Local service registry. - Search fetches services by types and excludes some according to the scope. - Allows for adding persistent queries.
- 
- 
Field SummaryFields Modifier and Type Field Description protected java.util.Map<IComponentIdentifier,java.util.Set<IServiceIdentifier>>excludedservicesThe excluded services cache.protected Indexer<IServiceIdentifier>indexerThe service indexer.protected java.util.Map<IServiceIdentifier,IService>localserviceproxiesMap for looking up local services using the service identifier.protected java.util.concurrent.locks.ReadWriteLockproxyrwlockRead-Write Lock for proxy map.protected Indexer<ServiceQueryInfo<?>>queriesThe persistent service queries.protected java.util.List<ISubscriptionIntermediateFuture<QueryEvent>>querysubsThe query change subscribers.protected java.util.concurrent.locks.ReadWriteLockrwlockRead-Write Lock
 - 
Constructor SummaryConstructors Constructor Description ServiceRegistry()Create a new registry.
 - 
Method SummaryAll Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddExcludedComponent(IComponentIdentifier cid)Add an excluded component.voidaddLocalService(IService service)Add a local service to the registry.<T> ISubscriptionIntermediateFuture<T>addQuery(ServiceQuery<T> query)Add a service query to the registry.voidaddService(IServiceIdentifier service)Add a service to the registry.protected booleancheckLifecycleVisibility(ServiceQuery<?> query, IServiceIdentifier ser)Test if a service is visible, i.e.protected booleancheckPublicationScope(ServiceQuery<?> query, IServiceIdentifier ser)Check if service is ok with respect to publication scope.protected IFuture<java.lang.Void>checkQueries(IServiceIdentifier ser, int eventtype)Check the persistent queries for a new service.protected booleancheckRestrictions(ServiceQuery<?> query, IServiceIdentifier ser)Check the services according additional restrictions like scope.protected booleancheckSearchScope(ServiceQuery<?> query, IServiceIdentifier ser)Check if service is ok with respect to search scope of caller.protected voiddispatchQueryEvent(ServiceQueryInfo<?> queryinfo, IServiceIdentifier ser, int eventtype)java.util.Set<ServiceQueryInfo<?>>getAllQueries()Get all queries.java.util.Set<IServiceIdentifier>getAllServices()Get all services.static java.lang.StringgetApplicationName(IComponentIdentifier cid)Get the application name.static java.lang.StringgetDotName(IComponentIdentifier cid)Get the name without @ replaced by dot.protected Indexer<IServiceIdentifier>getIndexer()Get the indexer.IServicegetLocalService(IServiceIdentifier serviceid)Returns the service proxy of a local service identified by service ID.java.util.concurrent.locks.ReadWriteLockgetLock()Returns the lock on the registry.static IServiceRegistrygetRegistry(IComponentIdentifier platform)Get the registry from a component.static IServiceRegistrygetRegistry(IInternalAccess ia)Get the registry from a component.protected java.util.Set<IServiceIdentifier>getServices()Get all services.protected java.util.Set<IServiceIdentifier>getServices(ServiceQuery<?> query)Get services per query.static java.lang.StringgetSubcomponentName(IComponentIdentifier cid)Get the subcomponent name.protected voidnotifyQueryListeners(QueryEvent event)Notify all listeners.voidremoveExcludedComponent(IComponentIdentifier cid)Remove an excluded component.voidremoveQueries(IComponentIdentifier owner)Remove all service queries of a specific component from the registry.voidremoveQueriesOfPlatform(IComponentIdentifier platform)Remove all service queries of a specific platform from the registry.voidremoveQuery(ServiceQuery<?> query)Remove a service query from the registry.voidremoveService(IServiceIdentifier service)Remove a service from the registry.voidremoveServices(IComponentIdentifier platform)Remove services of a platform from the registry.IServiceIdentifiersearchService(ServiceQuery<?> query)Search for services.java.util.Set<IServiceIdentifier>searchServices(ServiceQuery<?> query)Search for services.ISubscriptionIntermediateFuture<QueryEvent>subscribeToQueries()Subscribe for query events.voidupdateService(IServiceIdentifier service)Updates a service if the service meta-information has changes.voidupdateService(IServiceIdentifier service, java.lang.String propname)Updates a service if the service meta-information has changes.
 
- 
- 
- 
Field Detail- 
rwlockprotected java.util.concurrent.locks.ReadWriteLock rwlock Read-Write Lock
 - 
indexerprotected Indexer<IServiceIdentifier> indexer The service indexer.
 - 
queriesprotected Indexer<ServiceQueryInfo<?>> queries The persistent service queries.
 - 
excludedservicesprotected java.util.Map<IComponentIdentifier,java.util.Set<IServiceIdentifier>> excludedservices The excluded services cache.
 - 
proxyrwlockprotected java.util.concurrent.locks.ReadWriteLock proxyrwlock Read-Write Lock for proxy map.
 - 
localserviceproxiesprotected java.util.Map<IServiceIdentifier,IService> localserviceproxies Map for looking up local services using the service identifier.
 - 
querysubsprotected java.util.List<ISubscriptionIntermediateFuture<QueryEvent>> querysubs The query change subscribers.
 
- 
 - 
Method Detail- 
searchServicepublic IServiceIdentifier searchService(ServiceQuery<?> query) Search for services.- Specified by:
- searchServicein interface- IServiceRegistry
 
 - 
searchServicespublic java.util.Set<IServiceIdentifier> searchServices(ServiceQuery<?> query) Search for services.- Specified by:
- searchServicesin interface- IServiceRegistry
 
 - 
addServicepublic void addService(IServiceIdentifier service) Add a service to the registry.- Specified by:
- addServicein interface- IServiceRegistry
- Parameters:
- service- The service.
 
 - 
addLocalServicepublic void addLocalService(IService service) Add a local service to the registry.- Specified by:
- addLocalServicein interface- IServiceRegistry
- Parameters:
- service- The local service.
 
 - 
updateServicepublic void updateService(IServiceIdentifier service) Updates a service if the service meta-information has changes.- Specified by:
- updateServicein interface- IServiceRegistry
- Parameters:
- service- The service.
 
 - 
updateServicepublic void updateService(IServiceIdentifier service, java.lang.String propname) Updates a service if the service meta-information has changes.- Parameters:
- service- The service (null = all).
 
 - 
removeServicepublic void removeService(IServiceIdentifier service) Remove a service from the registry.- Specified by:
- removeServicein interface- IServiceRegistry
- Parameters:
- sid- The service id.
 
 - 
removeServicespublic void removeServices(IComponentIdentifier platform) Remove services of a platform from the registry.- Specified by:
- removeServicesin interface- IServiceRegistry
- Parameters:
- platform- The platform, null for everything.
 
 - 
getLocalServicepublic IService getLocalService(IServiceIdentifier serviceid) Returns the service proxy of a local service identified by service ID.- Specified by:
- getLocalServicein interface- IServiceRegistry
- Parameters:
- serviceid- The service ID.
- Returns:
- The service proxy.
 
 - 
getAllServicespublic java.util.Set<IServiceIdentifier> getAllServices() Get all services.- Specified by:
- getAllServicesin interface- IServiceRegistry
- Returns:
- All services (copy).
 
 - 
getAllQueriespublic java.util.Set<ServiceQueryInfo<?>> getAllQueries() Get all queries.- Specified by:
- getAllQueriesin interface- IServiceRegistry
- Returns:
- All queries (copy).
 
 - 
getLockpublic java.util.concurrent.locks.ReadWriteLock getLock() Returns the lock on the registry. Care must be taken to perform proper unlocking to avoid permanently blocking the registry. Note that the lock is reentrant, so operations can be performed while the lock is held.- Specified by:
- getLockin interface- IServiceRegistry
- Returns:
- The registry lock.
 
 - 
addQuerypublic <T> ISubscriptionIntermediateFuture<T> addQuery(ServiceQuery<T> query) Add a service query to the registry.- Specified by:
- addQueryin interface- IServiceRegistry
- Parameters:
- query- ServiceQuery.
 
 - 
removeQuerypublic void removeQuery(ServiceQuery<?> query) Remove a service query from the registry.- Specified by:
- removeQueryin interface- IServiceRegistry
- Parameters:
- query- ServiceQuery.
 
 - 
removeQueriespublic void removeQueries(IComponentIdentifier owner) Remove all service queries of a specific component from the registry.- Specified by:
- removeQueriesin interface- IServiceRegistry
- Parameters:
- owner- The query owner.
 
 - 
removeQueriesOfPlatformpublic void removeQueriesOfPlatform(IComponentIdentifier platform) Remove all service queries of a specific platform from the registry.- Specified by:
- removeQueriesOfPlatformin interface- IServiceRegistry
- Parameters:
- platform- The platform from which the query owner comes.
 
 - 
addExcludedComponentpublic void addExcludedComponent(IComponentIdentifier cid) Add an excluded component.- Specified by:
- addExcludedComponentin interface- IServiceRegistry
- Parameters:
- The- component identifier.
 
 - 
removeExcludedComponentpublic void removeExcludedComponent(IComponentIdentifier cid) Remove an excluded component.- Specified by:
- removeExcludedComponentin interface- IServiceRegistry
- Parameters:
- The- component identifier.
 
 - 
checkLifecycleVisibilityprotected boolean checkLifecycleVisibility(ServiceQuery<?> query, IServiceIdentifier ser) Test if a service is visible, i.e. visible after init for all components or visible for subcomponents also during init.- Parameters:
- query- The query.
- ser- The service.
- Returns:
- True if is included.
 
 - 
checkQueriesprotected IFuture<java.lang.Void> checkQueries(IServiceIdentifier ser, int eventtype) Check the persistent queries for a new service.- Parameters:
- ser- The service.
- removed- Indicates if the query was removed.
 
 - 
dispatchQueryEventprotected void dispatchQueryEvent(ServiceQueryInfo<?> queryinfo, IServiceIdentifier ser, int eventtype) 
 - 
checkRestrictionsprotected boolean checkRestrictions(ServiceQuery<?> query, IServiceIdentifier ser) Check the services according additional restrictions like scope.- Parameters:
- query- The query.
- ser- The service.
- Returns:
- True, if service passes tests.
 
 - 
checkSearchScopeprotected boolean checkSearchScope(ServiceQuery<?> query, IServiceIdentifier ser) Check if service is ok with respect to search scope of caller.
 - 
checkPublicationScopeprotected boolean checkPublicationScope(ServiceQuery<?> query, IServiceIdentifier ser) Check if service is ok with respect to publication scope.
 - 
getServicesprotected java.util.Set<IServiceIdentifier> getServices() Get all services.- Returns:
- The services.
 
 - 
getServicesprotected java.util.Set<IServiceIdentifier> getServices(ServiceQuery<?> query) Get services per query. Uses not the full query spec and does not check scope and filter.- Parameters:
- query- The query.
- Returns:
- First matching service or null.
 
 - 
getRegistrypublic static IServiceRegistry getRegistry(IComponentIdentifier platform) Get the registry from a component.
 - 
getRegistrypublic static IServiceRegistry getRegistry(IInternalAccess ia) Get the registry from a component.
 - 
getApplicationNamepublic static java.lang.String getApplicationName(IComponentIdentifier cid) Get the application name. Equals the local component name in case it is a child of the platform. broadcast@awa.plat1 -> awa- Returns:
- The application name.
 
 - 
getSubcomponentNamepublic static java.lang.String getSubcomponentName(IComponentIdentifier cid) Get the subcomponent name.- Parameters:
- cid- The component id.
- Returns:
- The subcomponent name.
 
 - 
subscribeToQueriespublic ISubscriptionIntermediateFuture<QueryEvent> subscribeToQueries() Subscribe for query events.- Specified by:
- subscribeToQueriesin interface- IServiceRegistry
 
 - 
notifyQueryListenersprotected void notifyQueryListeners(QueryEvent event) Notify all listeners.- Parameters:
- fut-
- type-
 
 - 
getDotNamepublic static java.lang.String getDotName(IComponentIdentifier cid) Get the name without @ replaced by dot.
 - 
getIndexerprotected Indexer<IServiceIdentifier> getIndexer() Get the indexer.- Returns:
- the indexer
 
 
- 
 
-