Class ServiceRegistry
java.lang.Object
jadex.providedservice.impl.search.ServiceRegistry
- All Implemented Interfaces:
IServiceRegistry
Local service registry.
- todo?: clean up queries of terminated components. Currently removes queries when
an event occurs and scheduling on component thread does not work any longer.
- Search fetches services by types and excludes some according to the scope.
- Allows for adding persistent queries.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected Indexer
<IServiceIdentifier> The service indexer.protected Map
<IServiceIdentifier, IService> Map for looking up local services using the service identifier.protected ReadWriteLock
Read-Write Lock for proxy map.protected Indexer
<ServiceQueryInfo<?>> The persistent service queries.protected List
<jadex.future.SubscriptionIntermediateFuture<QueryEvent>> The query change subscribers.protected static ServiceRegistry
protected ReadWriteLock
Read-Write Lock -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
addLocalService
(IService service) Add a local service to the registry.<T> jadex.future.ISubscriptionIntermediateFuture
<T> addQuery
(ServiceQuery<T> query) Add a service query to the registry.void
addService
(IServiceIdentifier service) Add a service to the registry.protected boolean
checkPublicationScope
(ServiceQuery<?> query, IServiceIdentifier ser) Check if service is ok with respect to publication scope.protected jadex.future.IFuture
<Void> checkQueries
(IServiceIdentifier ser, int eventtype) Check the persistent queries for a new service.protected boolean
checkRestrictions
(ServiceQuery<?> query, IServiceIdentifier ser) Check the services according additional restrictions like scope.protected boolean
checkSearchScope
(ServiceQuery<?> query, IServiceIdentifier ser) Check if service is ok with respect to search scope of caller.protected void
dispatchQueryEvent
(ServiceQueryInfo<?> queryinfo, IServiceIdentifier ser, int eventtype) Set
<ServiceQueryInfo<?>> Get all queries.Get all services.protected Indexer
<IServiceIdentifier> Get the indexer.getLocalService
(IServiceIdentifier serviceid) Returns the service proxy of a local service identified by service ID.getLock()
Returns the lock on the registry.static IServiceRegistry
Get the registry from a component.protected Set
<IServiceIdentifier> Get all services.protected Set
<IServiceIdentifier> getServices
(ServiceQuery<?> query) Get services per query.protected void
notifyQueryListeners
(QueryEvent event) Notify all listeners.void
removeQuery
(ServiceQuery<?> query) Remove a service query from the registry.void
removeService
(IServiceIdentifier service) Remove a service from the registry.searchService
(ServiceQuery<?> query) Search for services.searchServices
(ServiceQuery<?> query) Search for services.jadex.future.ISubscriptionIntermediateFuture
<QueryEvent> Subscribe for query events.void
updateService
(IServiceIdentifier service) Updates a service if the service meta-information has changes.void
updateService
(IServiceIdentifier service, String propname) Updates a service if the service meta-information has changes.
-
Field Details
-
registry
-
rwlock
Read-Write Lock -
indexer
The service indexer. -
queries
The persistent service queries. -
proxyrwlock
Read-Write Lock for proxy map. -
localserviceproxies
Map for looking up local services using the service identifier. -
querysubs
The query change subscribers.
-
-
Constructor Details
-
ServiceRegistry
public ServiceRegistry()Create a new registry.
-
-
Method Details
-
getRegistry
Get the registry from a component. -
searchService
Search for services.- Specified by:
searchService
in interfaceIServiceRegistry
-
searchServices
Search for services.- Specified by:
searchServices
in interfaceIServiceRegistry
-
addService
Add a service to the registry.- Specified by:
addService
in interfaceIServiceRegistry
- Parameters:
service
- The service.
-
addLocalService
Add a local service to the registry.- Specified by:
addLocalService
in interfaceIServiceRegistry
- Parameters:
service
- The local service.
-
updateService
Updates a service if the service meta-information has changes.- Specified by:
updateService
in interfaceIServiceRegistry
- Parameters:
service
- The service.
-
updateService
Updates a service if the service meta-information has changes.- Parameters:
service
- The service (null = all).
-
removeService
Remove a service from the registry.- Specified by:
removeService
in interfaceIServiceRegistry
- Parameters:
service
- The service.sid
- The service id.
-
getLocalService
Returns the service proxy of a local service identified by service ID.- Specified by:
getLocalService
in interfaceIServiceRegistry
- Parameters:
serviceid
- The service ID.- Returns:
- The service proxy.
-
getAllServices
Get all services.- Specified by:
getAllServices
in interfaceIServiceRegistry
- Returns:
- All services (copy).
-
getAllQueries
Get all queries.- Specified by:
getAllQueries
in interfaceIServiceRegistry
- Returns:
- All queries (copy).
-
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:
getLock
in interfaceIServiceRegistry
- Returns:
- The registry lock.
-
addQuery
Add a service query to the registry.- Specified by:
addQuery
in interfaceIServiceRegistry
- Parameters:
query
- ServiceQuery.
-
removeQuery
Remove a service query from the registry.- Specified by:
removeQuery
in interfaceIServiceRegistry
- Parameters:
query
- ServiceQuery.
-
checkQueries
Check the persistent queries for a new service.- Parameters:
ser
- The service.removed
- Indicates if the query was removed.
-
dispatchQueryEvent
protected void dispatchQueryEvent(ServiceQueryInfo<?> queryinfo, IServiceIdentifier ser, int eventtype) -
checkRestrictions
Check the services according additional restrictions like scope.- Parameters:
query
- The query.ser
- The service.- Returns:
- True, if service passes tests.
-
checkSearchScope
Check if service is ok with respect to search scope of caller. -
checkPublicationScope
Check if service is ok with respect to publication scope. -
getServices
Get all services.- Returns:
- The services.
-
getServices
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.
-
subscribeToQueries
Subscribe for query events.- Specified by:
subscribeToQueries
in interfaceIServiceRegistry
-
notifyQueryListeners
Notify all listeners.- Parameters:
fut
-type
-
-
getIndexer
Get the indexer.- Returns:
- the indexer
-