Class ProvidedServiceFeature
java.lang.Object
jadex.providedservice.impl.service.ProvidedServiceFeature
- All Implemented Interfaces:
jadex.execution.impl.ILifecycle
,IProvidedServiceFeature
public abstract class ProvidedServiceFeature
extends Object
implements jadex.execution.impl.ILifecycle, IProvidedServiceFeature
-
Field Summary
FieldsModifier and TypeFieldDescriptionThe pojo service map (pojo -> proxy).protected jadex.core.impl.Component
protected Map
<IServiceIdentifier, ProvidedServiceInfo> The map of provided service infos.protected Map
<IServiceIdentifier, MethodListenerHandler> The map of provided service infos.protected Map
<Class<?>, Collection<IInternalService>> The map of platform services. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
addMethodInvocationListener
(IServiceIdentifier sid, jadex.common.MethodInfo mi, IMethodInvocationListener listener) Add a method invocation handler.static void
addPojoServiceProxy
(Object pojo, IService proxy) Add a service proxy.void
addProvidedInterceptors
(AbstractServiceInvocationHandler handler, Object service, IServiceInvocationInterceptor[] ics, jadex.core.impl.Component ia, String proxytype, IServiceIdentifier sid) Add the standard and custom interceptors.protected void
addService
(IInternalService service, ProvidedServiceInfo info) Add a service.protected static ServiceInvocationHandler
createProvidedHandler
(String name, jadex.core.impl.Component ia, Class<?> type, Object service, ProvidedServiceInfo info) Create a basic invocation handler for a provided service.createProvidedServiceProxy
(jadex.core.impl.Component ia, Object service, String name, Class<?> type, IServiceInvocationInterceptor[] ics, ProvidedServiceInfo info) Static method for creating a standard service proxy for a provided service.jadex.future.IFuture
<Object> createServiceImplementation
(ProvidedServiceInfo info, jadex.common.IValueFetcher fetcher) Create a service implementation from description.protected Collection
<IInternalService> Get all services in a single collection.jadex.core.impl.Component
static IService
getPojoServiceProxy
(Object pojo) Get the proxy of a pojo service.Get the provided service implementation object by id.<T> T
getProvidedService
(Class<T> clazz) Get provided (declared) service.getProvidedService
(String name) Get provided (declared) service.protected ProvidedServiceInfo
Get the provided service info for a service.Get the provided service implementation object by id.<T> T
getProvidedServiceRawImpl
(Class<T> clazz) Get the raw implementation of the provided service.Get the provided service implementation object by name.<T> T[]
getProvidedServices
(Class<T> clazz) Get provided (declared) service.boolean
hasMethodListeners
(IServiceIdentifier sid, jadex.common.MethodInfo mi) Test if service and method has listeners.protected jadex.future.IFuture
<Void> Init a service, i.e.protected jadex.future.IFuture
<Void> initServices
(Iterator<IInternalService> services) Init the services one by one.static boolean
isProvidedServiceProxy
(Object service) Test if a service is a provided service proxy.void
notifyMethodListeners
(IServiceIdentifier sid, boolean start, Object proxy, Method method, Object[] args, Object callid, ServiceInvocationContext context) Notify listeners that a service method has been called.jadex.future.IFuture
<Void> onEnd()
Called when the feature is shutdowned.jadex.future.IFuture
<Void> onStart()
void
removeMethodInvocationListener
(IServiceIdentifier sid, jadex.common.MethodInfo mi, IMethodInvocationListener listener) Remove a method invocation handler.static void
Remove a pojo - proxy pair.protected void
removeService
(IInternalService service) Remove a service.jadex.future.IFuture
<Void> serviceShutdowned
(IInternalService service) Called after a service has been shutdowned.jadex.future.IFuture
<Void> serviceStarted
(IInternalService service) Called after a service has been started.protected jadex.future.IFuture
<Void> shutdownServices
(Iterator<IInternalService> services) Shutdown the services one by one.
-
Field Details
-
self
protected jadex.core.impl.Component self -
services
The map of platform services. -
serviceinfos
The map of provided service infos. (sid -> provided service info) -
servicelisteners
The map of provided service infos. (sid -> method listener) -
pojoproxies
The pojo service map (pojo -> proxy).
-
-
Constructor Details
-
ProvidedServiceFeature
protected ProvidedServiceFeature(jadex.core.impl.Component self)
-
-
Method Details
-
loadModel
-
onStart
- Specified by:
onStart
in interfacejadex.execution.impl.ILifecycle
-
onEnd
Called when the feature is shutdowned.- Specified by:
onEnd
in interfacejadex.execution.impl.ILifecycle
-
shutdownServices
Shutdown the services one by one. -
removeService
Remove a service.- Parameters:
service
- The service object.info
- The service info.
-
serviceShutdowned
Called after a service has been shutdowned. todo!!! -
createServiceImplementation
public jadex.future.IFuture<Object> createServiceImplementation(ProvidedServiceInfo info, jadex.common.IValueFetcher fetcher) Create a service implementation from description. -
addService
Add a service.- Parameters:
service
- The service object.info
- The service info.
-
getAllServices
Get all services in a single collection. -
initServices
Init the services one by one. -
initService
Init a service, i.e. set the component (internal access) and call startService. -
serviceStarted
Called after a service has been started. -
getProvidedServices
Get provided (declared) service.- Specified by:
getProvidedServices
in interfaceIProvidedServiceFeature
- Parameters:
clazz
- The interface.- Returns:
- The service.
-
getProvidedService
Get provided (declared) service.- Specified by:
getProvidedService
in interfaceIProvidedServiceFeature
- Parameters:
name
- The service name.- Returns:
- The service.
-
getProvidedService
Get the provided service implementation object by id.- Specified by:
getProvidedService
in interfaceIProvidedServiceFeature
- Parameters:
name
- The service identifier.- Returns:
- The service.
-
getProvidedServiceRawImpl
Get the provided service implementation object by name.- Specified by:
getProvidedServiceRawImpl
in interfaceIProvidedServiceFeature
- Parameters:
name
- The service name.- Returns:
- The service.
-
getProvidedServiceRawImpl
Get the raw implementation of the provided service.- Specified by:
getProvidedServiceRawImpl
in interfaceIProvidedServiceFeature
- Parameters:
clazz
- The class.- Returns:
- The raw object.
-
getProvidedService
Get provided (declared) service.- Specified by:
getProvidedService
in interfaceIProvidedServiceFeature
- Parameters:
clazz
- The interface.- Returns:
- The service.
-
getProvidedServiceRawImpl
Get the provided service implementation object by id.- Specified by:
getProvidedServiceRawImpl
in interfaceIProvidedServiceFeature
- Parameters:
name
- The service identifier.- Returns:
- The service.
-
getProvidedServiceInfo
Get the provided service info for a service.- Parameters:
sid
- The service identifier.- Returns:
- The provided service info.
-
getComponent
public jadex.core.impl.Component getComponent() -
addMethodInvocationListener
public void addMethodInvocationListener(IServiceIdentifier sid, jadex.common.MethodInfo mi, IMethodInvocationListener listener) Add a method invocation handler.- Specified by:
addMethodInvocationListener
in interfaceIProvidedServiceFeature
- Parameters:
sid
- The service identifier.mi
- The method info.listener
- The method listener.
-
removeMethodInvocationListener
public void removeMethodInvocationListener(IServiceIdentifier sid, jadex.common.MethodInfo mi, IMethodInvocationListener listener) Remove a method invocation handler.- Specified by:
removeMethodInvocationListener
in interfaceIProvidedServiceFeature
- Parameters:
sid
- The service identifier.mi
- The method info.listener
- The method listener.
-
notifyMethodListeners
public void notifyMethodListeners(IServiceIdentifier sid, boolean start, Object proxy, Method method, Object[] args, Object callid, ServiceInvocationContext context) Notify listeners that a service method has been called. -
hasMethodListeners
Test if service and method has listeners. -
addPojoServiceProxy
Add a service proxy.- Parameters:
pojo
- The pojo.proxy
- The proxy.
-
removePojoServiceProxy
Remove a pojo - proxy pair.- Parameters:
sid
- The service identifier.
-
getPojoServiceProxy
Get the proxy of a pojo service.- Parameters:
pojo
- The pojo service.- Returns:
- The proxy of the service.
-
isProvidedServiceProxy
Test if a service is a provided service proxy.- Parameters:
service
- The service.- Returns:
- True, if is provided service proxy.
-
createProvidedServiceProxy
public IInternalService createProvidedServiceProxy(jadex.core.impl.Component ia, Object service, String name, Class<?> type, IServiceInvocationInterceptor[] ics, ProvidedServiceInfo info) Static method for creating a standard service proxy for a provided service. -
addProvidedInterceptors
public void addProvidedInterceptors(AbstractServiceInvocationHandler handler, Object service, IServiceInvocationInterceptor[] ics, jadex.core.impl.Component ia, String proxytype, IServiceIdentifier sid) Add the standard and custom interceptors. -
createProvidedHandler
protected static ServiceInvocationHandler createProvidedHandler(String name, jadex.core.impl.Component ia, Class<?> type, Object service, ProvidedServiceInfo info) Create a basic invocation handler for a provided service.
-