public class ProvidedServicesComponentFeature extends AbstractComponentFeature implements IProvidedServicesFeature
Modifier and Type | Field and Description |
---|---|
protected java.util.Map<IServiceIdentifier,ProvidedServiceInfo> |
serviceinfos
The map of provided service infos.
|
protected java.util.Map<IServiceIdentifier,MethodListenerHandler> |
servicelisteners
The map of provided service infos.
|
protected java.util.Map<java.lang.Class<?>,java.util.Collection<IInternalService>> |
services
The map of platform services.
|
Constructor and Description |
---|
ProvidedServicesComponentFeature(IInternalAccess component,
ComponentCreationInfo cinfo)
Factory method constructor for instance level.
|
Modifier and Type | Method and Description |
---|---|
void |
addInterceptor(IServiceInvocationInterceptor interceptor,
java.lang.Object service,
int pos)
Add a service interceptor.
|
void |
addMethodInvocationListener(IServiceIdentifier sid,
MethodInfo mi,
IMethodInvocationListener listener)
Add a method invocation handler.
|
protected IFuture<java.lang.Void> |
addService(IInternalService service,
ProvidedServiceInfo info)
Add a service.
|
IFuture<java.lang.Void> |
addService(java.lang.String name,
java.lang.Class<?> type,
java.lang.Object service)
Add a service to the platform.
|
IFuture<java.lang.Void> |
addService(java.lang.String name,
java.lang.Class<?> type,
java.lang.Object service,
PublishInfo pi,
java.lang.String scope)
Add a service to the platform.
|
IFuture<java.lang.Void> |
addService(java.lang.String name,
java.lang.Class<?> type,
java.lang.Object service,
java.lang.String proxytype)
Add a service to the platform.
|
IFuture<java.lang.Void> |
addService(java.lang.String name,
java.lang.Class<?> type,
java.lang.String proxytype,
IServiceInvocationInterceptor[] ics,
java.lang.Object service,
ProvidedServiceInfo info,
java.lang.String scope)
Add a service to the component.
|
protected java.lang.Object |
createServiceImplementation(ProvidedServiceInfo info,
IValueFetcher fetcher)
Create a service implementation from description.
|
protected java.util.Collection<IInternalService> |
getAllServices()
Get all services in a single collection.
|
IServiceInvocationInterceptor[] |
getInterceptors(java.lang.Object service)
Get the interceptors of a service.
|
<T> T |
getProvidedService(java.lang.Class<T> clazz)
Get provided (declared) service.
|
java.lang.Object |
getProvidedService(IServiceIdentifier sid)
Get the provided service implementation object by id.
|
IService |
getProvidedService(java.lang.String name)
Get provided (declared) service.
|
protected ProvidedServiceInfo |
getProvidedServiceInfo(IServiceIdentifier sid)
Get the provided service info for a service.
|
<T> T |
getProvidedServiceRawImpl(java.lang.Class<T> clazz)
Get the raw implementation of the provided service.
|
java.lang.Object |
getProvidedServiceRawImpl(IServiceIdentifier sid)
Get the provided service implementation object by id.
|
java.lang.Object |
getProvidedServiceRawImpl(java.lang.String name)
Get the provided service implementation object by name.
|
<T> T[] |
getProvidedServices(java.lang.Class<T> clazz)
Get provided (declared) service.
|
static IFuture<IPublishService> |
getPublishService(IInternalAccess instance,
java.lang.String type,
java.lang.String scope,
java.util.Iterator<IPublishService> services)
Get the publish service for a publish type (e.g.
|
java.util.Map<java.lang.Class<?>,java.util.Collection<IInternalService>> |
getServices()
Get the services.
|
IFuture<java.lang.Class<?>> |
getServiceType(IServiceIdentifier sid) |
IFuture<java.util.Collection<java.lang.Class<?>>> |
getServiceTypes(IServiceIdentifier sid) |
boolean |
hasMethodListeners(IServiceIdentifier sid,
MethodInfo mi)
Test if service and method has listeners.
|
boolean |
hasUserBody()
Check if the feature potentially executed user code in body.
|
IFuture<java.lang.Void> |
init()
Initialize the feature.
|
protected IFuture<java.lang.Void> |
initService(IInternalService is)
Init a service, i.e.
|
protected IFuture<java.lang.Void> |
initServices(java.util.Iterator<IInternalService> services)
Init the services one by one.
|
void |
notifyMethodListeners(IServiceIdentifier sid,
boolean start,
java.lang.Object proxy,
java.lang.reflect.Method method,
java.lang.Object[] args,
java.lang.Object callid,
ServiceInvocationContext context)
Notify listeners that a service method has been called.
|
void |
removeInterceptor(IServiceInvocationInterceptor interceptor,
java.lang.Object service)
Remove a service interceptor.
|
void |
removeMethodInvocationListener(IServiceIdentifier sid,
MethodInfo mi,
IMethodInvocationListener listener)
Remove a method invocation handler.
|
protected void |
removeService(IInternalService service)
Remove a service.
|
IFuture<java.lang.Void> |
removeService(IServiceIdentifier sid)
Removes a service from the platform (shutdowns also the service).
|
IFuture<java.lang.Void> |
serviceShutdowned(IInternalService service)
Called after a service has been shutdowned.
|
IFuture<java.lang.Void> |
serviceStarted(IInternalService service)
Called after a service has been started.
|
IFuture<java.lang.Void> |
shutdown()
Called when the feature is shutdowned.
|
protected IFuture<java.lang.Void> |
shutdownServices(java.util.Iterator<IInternalService> services)
Shutdown the services one by one.
|
protected java.util.Map<java.lang.Class<?>,java.util.Collection<IInternalService>> services
protected java.util.Map<IServiceIdentifier,MethodListenerHandler> servicelisteners
protected java.util.Map<IServiceIdentifier,ProvidedServiceInfo> serviceinfos
public ProvidedServicesComponentFeature(IInternalAccess component, ComponentCreationInfo cinfo)
public IFuture<java.lang.Void> init()
public boolean hasUserBody()
public IFuture<java.lang.Void> shutdown()
protected IFuture<java.lang.Void> addService(IInternalService service, ProvidedServiceInfo info)
service
- The service object.info
- The service info.protected ProvidedServiceInfo getProvidedServiceInfo(IServiceIdentifier sid)
sid
- The service identifier.protected void removeService(IInternalService service)
service
- The service object.info
- The service info.protected java.lang.Object createServiceImplementation(ProvidedServiceInfo info, IValueFetcher fetcher) throws java.lang.Exception
java.lang.Exception
protected java.util.Collection<IInternalService> getAllServices()
protected IFuture<java.lang.Void> initServices(java.util.Iterator<IInternalService> services)
protected IFuture<java.lang.Void> initService(IInternalService is)
public IFuture<java.lang.Void> serviceStarted(IInternalService service)
public IFuture<java.lang.Void> serviceShutdowned(IInternalService service)
public static IFuture<IPublishService> getPublishService(IInternalAccess instance, java.lang.String type, java.lang.String scope, java.util.Iterator<IPublishService> services)
type
- The type.services
- The iterator of publish services (can be null).protected IFuture<java.lang.Void> shutdownServices(java.util.Iterator<IInternalService> services)
public IService getProvidedService(java.lang.String name)
getProvidedService
in interface IProvidedServicesFeature
name
- The service name.public <T> T getProvidedServiceRawImpl(java.lang.Class<T> clazz)
getProvidedServiceRawImpl
in interface IProvidedServicesFeature
clazz
- The class.public java.lang.Object getProvidedServiceRawImpl(java.lang.String name)
getProvidedServiceRawImpl
in interface IProvidedServicesFeature
name
- The service name.public java.lang.Object getProvidedService(IServiceIdentifier sid)
getProvidedService
in interface IProvidedServicesFeature
name
- The service identifier.public java.lang.Object getProvidedServiceRawImpl(IServiceIdentifier sid)
getProvidedServiceRawImpl
in interface IProvidedServicesFeature
name
- The service identifier.public <T> T[] getProvidedServices(java.lang.Class<T> clazz)
getProvidedServices
in interface IProvidedServicesFeature
clazz
- The interface.public <T> T getProvidedService(java.lang.Class<T> clazz)
getProvidedService
in interface IProvidedServicesFeature
clazz
- The interface.public java.util.Map<java.lang.Class<?>,java.util.Collection<IInternalService>> getServices()
public IFuture<java.lang.Void> addService(java.lang.String name, java.lang.Class<?> type, java.lang.Object service)
addService
in interface IProvidedServicesFeature
type
- The public service interface.service
- The service.public IFuture<java.lang.Void> addService(java.lang.String name, java.lang.Class<?> type, java.lang.Object service, java.lang.String proxytype)
addService
in interface IProvidedServicesFeature
type
- The public service interface.service
- The service.type
- The proxy type (@see{BasicServiceInvocationHandler}).public IFuture<java.lang.Void> addService(java.lang.String name, java.lang.Class<?> type, java.lang.Object service, PublishInfo pi, java.lang.String scope)
addService
in interface IProvidedServicesFeature
type
- The public service interface.service
- The service.scope
- The service scope.public IFuture<java.lang.Void> removeService(IServiceIdentifier sid)
removeService
in interface IProvidedServicesFeature
service
- The service.public IFuture<java.util.Collection<java.lang.Class<?>>> getServiceTypes(IServiceIdentifier sid)
public IFuture<java.lang.Class<?>> getServiceType(IServiceIdentifier sid)
public IFuture<java.lang.Void> addService(java.lang.String name, java.lang.Class<?> type, java.lang.String proxytype, IServiceInvocationInterceptor[] ics, java.lang.Object service, ProvidedServiceInfo info, java.lang.String scope)
type
- The service interface.service
- The service.proxytype
- The proxy type (@see{BasicServiceInvocationHandler}).public void addMethodInvocationListener(IServiceIdentifier sid, MethodInfo mi, IMethodInvocationListener listener)
addMethodInvocationListener
in interface IProvidedServicesFeature
sid
- The service identifier.mi
- The method info.listener
- The method listener.public void removeMethodInvocationListener(IServiceIdentifier sid, MethodInfo mi, IMethodInvocationListener listener)
removeMethodInvocationListener
in interface IProvidedServicesFeature
sid
- The service identifier.mi
- The method info.listener
- The method listener.public void notifyMethodListeners(IServiceIdentifier sid, boolean start, java.lang.Object proxy, java.lang.reflect.Method method, java.lang.Object[] args, java.lang.Object callid, ServiceInvocationContext context)
notifyMethodListeners
in interface IProvidedServicesFeature
public boolean hasMethodListeners(IServiceIdentifier sid, MethodInfo mi)
hasMethodListeners
in interface IProvidedServicesFeature
sid
- The service identifier.mi
- The method info.public void addInterceptor(IServiceInvocationInterceptor interceptor, java.lang.Object service, int pos)
addInterceptor
in interface IProvidedServicesFeature
interceptor
- The interceptor.service
- The service.pos
- The position (0=first, -1=last-1, i.e. one before method invocation).public void removeInterceptor(IServiceInvocationInterceptor interceptor, java.lang.Object service)
removeInterceptor
in interface IProvidedServicesFeature
interceptor
- The interceptor.service
- The service.public IServiceInvocationInterceptor[] getInterceptors(java.lang.Object service)
getInterceptors
in interface IProvidedServicesFeature
service
- The service.