Package jadex.bridge.service.component
Class RequiredServicesComponentFeature
- java.lang.Object
- 
- jadex.bridge.component.impl.AbstractComponentFeature
- 
- jadex.bridge.service.component.RequiredServicesComponentFeature
 
 
- 
- All Implemented Interfaces:
- IComponentFeature,- IExternalComponentFeature,- IExternalRequiredServicesFeature,- IInternalRequiredServicesFeature,- IInternalServiceMonitoringFeature,- IRequiredServicesFeature
 
 public class RequiredServicesComponentFeature extends jadex.bridge.component.impl.AbstractComponentFeature implements IRequiredServicesFeature, IInternalServiceMonitoringFeature, IInternalRequiredServicesFeature Feature for provided services.
- 
- 
Field SummaryFields Modifier and Type Field Description protected java.util.List<Tuple2<ServiceQuery<?>,SubscriptionIntermediateDelegationFuture<?>>>delayedremotequeriesprotected java.util.Map<java.lang.String,RequiredServiceInfo>requiredserviceinfosThe required service infos.protected ISearchQueryManagerServicesqmsprotected java.util.Set<SubscriptionIntermediateFuture<ServiceCallEvent>>subscriptionsThe current subscriptions.
 - 
Constructor SummaryConstructors Constructor Description RequiredServicesComponentFeature(IInternalAccess component, ComponentCreationInfo cinfo)Factory method constructor for instance level.
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description <T> ISubscriptionIntermediateFuture<T>addQuery(ServiceQuery<T> query)Add a service query.<T> ISubscriptionIntermediateFuture<T>addQuery(ServiceQuery<T> query, long timeout)Add a query for a declared required service.<T> ISubscriptionIntermediateFuture<T>addQuery(java.lang.Class<T> type)Add a query for a declared required service.<T> ISubscriptionIntermediateFuture<T>addQuery(java.lang.String name)Add a query for a declared required service.protected voidaddRequiredServiceInfos(RequiredServiceInfo[] requiredservices)Add required services for a given prefix.protected java.lang.ObjectcreateServiceProxy(java.lang.Object service, RequiredServiceInfo info)Create the user-facing object from the received search or query result.protected <T> voidenhanceQuery(ServiceQuery<T> query, boolean multi)Enhance a query before processing.<T> TgetLocalService(java.lang.Class<T> type)Resolve a required service of a given type.<T> TgetLocalService(java.lang.String name)Resolve a declared required service of a given name.<T> TgetLocalService0(java.lang.Class<T> type)Resolve a required service of a given type.<T> java.util.Collection<T>getLocalServices(java.lang.Class<T> type)Resolve a required services of a given type.<T> java.util.Collection<T>getLocalServices(java.lang.String name)Resolve a required services of a given name.<T> TgetRawService(java.lang.Class<T> type)Get a service raw (i.e.<T> java.util.Collection<T>getRawServices(java.lang.Class<T> type)Get a service raw (i.e.<T> IFuture<T>getService(java.lang.Class<T> type)Resolve a required service of a given type.<T> IFuture<T>getService(java.lang.String name)Resolve a declared required service of a given name.ISubscriptionIntermediateFuture<ServiceCallEvent>getServiceEvents()Listen to service call events (call, result and commands).protected RequiredServiceInfogetServiceInfo(java.lang.Class<?> type)Get the required service info for a type.RequiredServiceInfogetServiceInfo(java.lang.String name)Get the required service info for a name.RequiredServiceInfo[]getServiceInfos()Get the required services.protected <T> ServiceQuery<T>getServiceQuery(RequiredServiceInfo info)When searching for declared service -> map required service declaration to service query.<T> ITerminableIntermediateFuture<T>getServices(java.lang.Class<T> type)Resolve a required services of a given type.<T> ITerminableIntermediateFuture<T>getServices(java.lang.String name)Resolve a required services of a given name.booleanhasUserBody()Check if the feature potentially executed user code in body.IFuture<java.lang.Void>init()Init the required servicesbooleanisMonitoring()Check if there is someone monitoring.booleanisRemote(ServiceQuery<?> query)Check if a query is potentially remote.voidpostServiceEvent(ServiceCallEvent event)Post a service call event.<T> TresolveLocalService(ServiceQuery<T> query, RequiredServiceInfo info)Search for matching services and provide first result.<T> java.util.Collection<T>resolveLocalServices(ServiceQuery<T> query, RequiredServiceInfo info)Search for all matching services.<T> ISubscriptionIntermediateFuture<T>resolveQuery(ServiceQuery<T> query, RequiredServiceInfo info)Query for all matching services.<T> ITerminableFuture<T>resolveService(ServiceQuery<T> query, RequiredServiceInfo info)Search for matching services and provide first result.<T> ITerminableIntermediateFuture<T>resolveServices(ServiceQuery<T> query, RequiredServiceInfo info)Search for all matching services.<T> TsearchLocalService(ServiceQuery<T> query)Search for matching services and provide first result.<T> java.util.Collection<T>searchLocalServices(ServiceQuery<T> query)Search for all matching services.<T> IFuture<T>searchService(ServiceQuery<T> query)Search for matching services and provide first result.<T> IFuture<T>searchService(ServiceQuery<T> query, long timeout)Performs a sustained search for a service.<T> ITerminableIntermediateFuture<T>searchServices(ServiceQuery<T> query)Search for all matching services.IFuture<java.lang.Void>shutdown()Called when the feature is shutdowned.
 
- 
- 
- 
Field Detail- 
requiredserviceinfosprotected java.util.Map<java.lang.String,RequiredServiceInfo> requiredserviceinfos The required service infos.
 - 
subscriptionsprotected java.util.Set<SubscriptionIntermediateFuture<ServiceCallEvent>> subscriptions The current subscriptions.
 - 
sqmsprotected ISearchQueryManagerService sqms 
 - 
delayedremotequeriesprotected java.util.List<Tuple2<ServiceQuery<?>,SubscriptionIntermediateDelegationFuture<?>>> delayedremotequeries 
 
- 
 - 
Constructor Detail- 
RequiredServicesComponentFeaturepublic RequiredServicesComponentFeature(IInternalAccess component, ComponentCreationInfo cinfo) Factory method constructor for instance level.
 
- 
 - 
Method Detail- 
initpublic IFuture<java.lang.Void> init() Init the required services- Specified by:
- initin interface- IComponentFeature
- Overrides:
- initin class- jadex.bridge.component.impl.AbstractComponentFeature
 
 - 
hasUserBodypublic boolean hasUserBody() Check if the feature potentially executed user code in body. Allows blocking operations in user bodies by using separate steps for each feature. Non-user-body-features are directly executed for speed. If unsure just return true. ;-)- Specified by:
- hasUserBodyin interface- IComponentFeature
- Overrides:
- hasUserBodyin class- jadex.bridge.component.impl.AbstractComponentFeature
 
 - 
shutdownpublic IFuture<java.lang.Void> shutdown() Called when the feature is shutdowned.- Specified by:
- shutdownin interface- IComponentFeature
- Overrides:
- shutdownin class- jadex.bridge.component.impl.AbstractComponentFeature
 
 - 
addRequiredServiceInfosprotected void addRequiredServiceInfos(RequiredServiceInfo[] requiredservices) Add required services for a given prefix.- Parameters:
- prefix- The name prefix to use.
- required- services The required services to set.
 
 - 
getServicepublic <T> IFuture<T> getService(java.lang.String name) Resolve a declared required service of a given name. Asynchronous method for locally as well as remotely available services.- Specified by:
- getServicein interface- IRequiredServicesFeature
- Parameters:
- name- The service name.
- Returns:
- The service.
 
 - 
getServicepublic <T> IFuture<T> getService(java.lang.Class<T> type) Resolve a required service of a given type. Asynchronous method for locally as well as remotely available services.- Specified by:
- getServicein interface- IRequiredServicesFeature
- Parameters:
- type- The service type.
- Returns:
- The service.
 
 - 
getServicespublic <T> ITerminableIntermediateFuture<T> getServices(java.lang.String name) Resolve a required services of a given name. Asynchronous method for locally as well as remotely available services.- Specified by:
- getServicesin interface- IRequiredServicesFeature
- Parameters:
- name- The services name.
- Returns:
- Each service as an intermediate result and a collection of services as final result.
 
 - 
getServicespublic <T> ITerminableIntermediateFuture<T> getServices(java.lang.Class<T> type) Resolve a required services of a given type. Asynchronous method for locally as well as remotely available services.- Specified by:
- getServicesin interface- IRequiredServicesFeature
- Parameters:
- type- The services type.
- Returns:
- Each service as an intermediate result and a collection of services as final result.
 
 - 
getLocalServicepublic <T> T getLocalService(java.lang.String name) Resolve a declared required service of a given name. Synchronous method only for locally available services.- Specified by:
- getLocalServicein interface- IRequiredServicesFeature
- Parameters:
- name- The service name.
- Returns:
- The service.
 
 - 
getLocalServicepublic <T> T getLocalService(java.lang.Class<T> type) Resolve a required service of a given type. Synchronous method only for locally available services.- Specified by:
- getLocalServicein interface- IRequiredServicesFeature
- Parameters:
- type- The service type.
- Returns:
- The service.
 
 - 
getLocalService0public <T> T getLocalService0(java.lang.Class<T> type) Resolve a required service of a given type. Synchronous method only for locally available services.- Specified by:
- getLocalService0in interface- IRequiredServicesFeature
- Parameters:
- type- The service type.
- Returns:
- The service.
 
 - 
getLocalServicespublic <T> java.util.Collection<T> getLocalServices(java.lang.String name) Resolve a required services of a given name. Synchronous method only for locally available services.- Specified by:
- getLocalServicesin interface- IRequiredServicesFeature
- Parameters:
- name- The services name.
- Returns:
- Each service as an intermediate result and a collection of services as final result.
 
 - 
getLocalServicespublic <T> java.util.Collection<T> getLocalServices(java.lang.Class<T> type) Resolve a required services of a given type. Synchronous method only for locally available services.- Specified by:
- getLocalServicesin interface- IRequiredServicesFeature
- Parameters:
- type- The services type.
- Returns:
- Each service as an intermediate result and a collection of services as final result.
 
 - 
searchServicepublic <T> IFuture<T> searchService(ServiceQuery<T> query) Search for matching services and provide first result.- Specified by:
- searchServicein interface- IExternalRequiredServicesFeature
- Parameters:
- query- The search query.
- Returns:
- Future providing the corresponding service or ServiceNotFoundException when not found.
 
 - 
searchLocalServicepublic <T> T searchLocalService(ServiceQuery<T> query) Search for matching services and provide first result. Synchronous method only for locally available services.- Specified by:
- searchLocalServicein interface- IRequiredServicesFeature
- Parameters:
- query- The search query.
- Returns:
- Future providing the corresponding service or ServiceNotFoundException when not found.
 
 - 
searchServicespublic <T> ITerminableIntermediateFuture<T> searchServices(ServiceQuery<T> query) Search for all matching services.- Specified by:
- searchServicesin interface- IExternalRequiredServicesFeature
- Parameters:
- query- The search query.
- Returns:
- Future providing the corresponding services or ServiceNotFoundException when not found.
 
 - 
searchLocalServicespublic <T> java.util.Collection<T> searchLocalServices(ServiceQuery<T> query) Search for all matching services. Synchronous method only for locally available services.- Specified by:
- searchLocalServicesin interface- IRequiredServicesFeature
- Parameters:
- query- The search query.
- Returns:
- Future providing the corresponding services or ServiceNotFoundException when not found.
 
 - 
searchServicepublic <T> IFuture<T> searchService(ServiceQuery<T> query, long timeout) Performs a sustained search for a service. Attempts to find a service for a maximum duration until timeout occurs.- Specified by:
- searchServicein interface- IRequiredServicesFeature
- Parameters:
- query- The search query.
- timeout- Maximum time period to search, -1 for no wait.
- Returns:
- Service matching the query, exception if service is not found.
 
 - 
addQuerypublic <T> ISubscriptionIntermediateFuture<T> addQuery(ServiceQuery<T> query, long timeout) Add a query for a declared required service. Continuously searches for matching services.- Specified by:
- addQueryin interface- IRequiredServicesFeature
- Parameters:
- name- The name of the required service declaration.
- Returns:
- Future providing the corresponding services as intermediate results.
 
 - 
addQuerypublic <T> ISubscriptionIntermediateFuture<T> addQuery(java.lang.String name) Add a query for a declared required service. Continuously searches for matching services.- Specified by:
- addQueryin interface- IRequiredServicesFeature
- Parameters:
- name- The name of the required service declaration.
- Returns:
- Future providing the corresponding services as intermediate results.
 
 - 
addQuerypublic <T> ISubscriptionIntermediateFuture<T> addQuery(java.lang.Class<T> type) Add a query for a declared required service. Continuously searches for matching services.- Specified by:
- addQueryin interface- IRequiredServicesFeature
- Parameters:
- type- The type of the required service declaration.
- Returns:
- Future providing the corresponding services as intermediate results.
 
 - 
addQuerypublic <T> ISubscriptionIntermediateFuture<T> addQuery(ServiceQuery<T> query) Add a service query. Continuously searches for matching services.- Specified by:
- addQueryin interface- IExternalRequiredServicesFeature
- Parameters:
- query- The search query.
- Returns:
- Future providing the corresponding service or ServiceNotFoundException when not found.
 
 - 
getServiceInfospublic RequiredServiceInfo[] getServiceInfos() Get the required services.- Specified by:
- getServiceInfosin interface- IInternalRequiredServicesFeature
- Returns:
- The required services.
 
 - 
getServiceEventspublic ISubscriptionIntermediateFuture<ServiceCallEvent> getServiceEvents() Listen to service call events (call, result and commands).- Specified by:
- getServiceEventsin interface- IInternalServiceMonitoringFeature
 
 - 
postServiceEventpublic void postServiceEvent(ServiceCallEvent event) Post a service call event.- Specified by:
- postServiceEventin interface- IInternalServiceMonitoringFeature
 
 - 
isMonitoringpublic boolean isMonitoring() Check if there is someone monitoring. To Avoid posting when nobody is listening.- Specified by:
- isMonitoringin interface- IInternalServiceMonitoringFeature
 
 - 
getRawServicepublic <T> T getRawService(java.lang.Class<T> type) Get a service raw (i.e. w/o required proxy).- Specified by:
- getRawServicein interface- IInternalRequiredServicesFeature
- Returns:
- null when not found.
 
 - 
getRawServicespublic <T> java.util.Collection<T> getRawServices(java.lang.Class<T> type) Get a service raw (i.e. w/o required proxy).- Specified by:
- getRawServicesin interface- IInternalRequiredServicesFeature
 
 - 
resolveServicepublic <T> ITerminableFuture<T> resolveService(ServiceQuery<T> query, RequiredServiceInfo info) Search for matching services and provide first result.- Specified by:
- resolveServicein interface- IInternalRequiredServicesFeature
- Parameters:
- query- The search query.
- info- Used for required service proxy configuration -> null for no proxy.
- Returns:
- Future providing the corresponding service or ServiceNotFoundException when not found.
 
 - 
resolveLocalServicepublic <T> T resolveLocalService(ServiceQuery<T> query, RequiredServiceInfo info) Search for matching services and provide first result. Synchronous method only for locally available services.- Specified by:
- resolveLocalServicein interface- IInternalRequiredServicesFeature
- Parameters:
- query- The search query.
- info- Used for required service proxy configuration -> null for no proxy.
- Returns:
- Future providing the corresponding service or ServiceNotFoundException when not found.
 
 - 
resolveServicespublic <T> ITerminableIntermediateFuture<T> resolveServices(ServiceQuery<T> query, RequiredServiceInfo info) Search for all matching services.- Specified by:
- resolveServicesin interface- IInternalRequiredServicesFeature
- Parameters:
- query- The search query.
- info- Used for required service proxy configuration -> null for no proxy.
- Returns:
- Future providing the corresponding services or ServiceNotFoundException when not found.
 
 - 
resolveLocalServicespublic <T> java.util.Collection<T> resolveLocalServices(ServiceQuery<T> query, RequiredServiceInfo info) Search for all matching services. Synchronous method only for locally available services.- Specified by:
- resolveLocalServicesin interface- IInternalRequiredServicesFeature
- Parameters:
- query- The search query.
- info- Used for required service proxy configuration -> null for no proxy.
- Returns:
- Future providing the corresponding services or ServiceNotFoundException when not found.
 
 - 
resolveQuerypublic <T> ISubscriptionIntermediateFuture<T> resolveQuery(ServiceQuery<T> query, RequiredServiceInfo info) Query for all matching services.- Specified by:
- resolveQueryin interface- IInternalRequiredServicesFeature
- Parameters:
- query- The search query.
- info- Used for required service proxy configuration -> null for no proxy.
- Returns:
- Future providing the corresponding services or ServiceNotFoundException when not found.
 
 - 
getServiceQueryprotected <T> ServiceQuery<T> getServiceQuery(RequiredServiceInfo info) When searching for declared service -> map required service declaration to service query.
 - 
getServiceInfopublic RequiredServiceInfo getServiceInfo(java.lang.String name) Get the required service info for a name.- Specified by:
- getServiceInfoin interface- IInternalRequiredServicesFeature
- Parameters:
- name- The required service name.
 
 - 
getServiceInfoprotected RequiredServiceInfo getServiceInfo(java.lang.Class<?> type) Get the required service info for a type.- Parameters:
- type- The required service type.
 
 - 
createServiceProxyprotected java.lang.Object createServiceProxy(java.lang.Object service, RequiredServiceInfo info)Create the user-facing object from the received search or query result. Result may be service object, service identifier (local or remote), or event. User object is either event or service (with or without required proxy).
 - 
enhanceQueryprotected <T> void enhanceQuery(ServiceQuery<T> query, boolean multi) Enhance a query before processing. Does some necessary preprocessing and needs to be called at least once before processing the query.- Parameters:
- query- The query to be enhanced.
 
 - 
isRemotepublic boolean isRemote(ServiceQuery<?> query) Check if a query is potentially remote.- Returns:
- True, if scope is set to a remote scope (e.g. global or network).
 
 
- 
 
-