Class ServiceHandler
- java.lang.Object
-
- jadex.platform.service.servicepool.ServiceHandler
-
- All Implemented Interfaces:
java.lang.reflect.InvocationHandler
public class ServiceHandler extends java.lang.Object implements java.lang.reflect.InvocationHandlerThe service handler is used as service implementation for proxy services. Incoming calls will be served by instances from the pool.
-
-
Field Summary
Fields Modifier and Type Field Description protected java.util.Set<IService>allservicesAll services.protected IClockServiceclockThe clock service.protected IInternalAccesscomponentThe component.protected java.lang.StringcomponentnameThe worker component name.protected java.util.Map<IService,ITimer>idleservicesMap of idle services.protected CreationInfoinfoThe creation info.protected java.util.List<java.lang.Object[]>queueA queue of open requests.protected java.lang.Class<?>servicetypeThe service type.protected IPoolStrategystrategyThe strategy.
-
Constructor Summary
Constructors Constructor Description ServiceHandler(IInternalAccess component, java.lang.Class<?> servicetype, IPoolStrategy strategy, java.lang.String componentname, CreationInfo info)Create a new service handler.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidaddFreeService(IService service)Called when a service becomes idle.protected IFuture<IService>createService()protected IFuture<ITimer>createTimer(long delay, ITimedObject to)Create a timer via the clock service.protected IFuture<IClockService>getClockService()Get the clockservice (cached).IFuture<java.lang.Void>init()Init.java.lang.Objectinvoke(java.lang.Object proxy, java.lang.reflect.Method method, java.lang.Object[] args)Callback of the invocation handler interface.protected voidinvokeService(IService service, java.lang.reflect.Method method, java.lang.Object[] args, Future<?> ret, ServiceCall call)Execute a task on a service.protected IFuture<java.lang.Void>removeService(IService service)Remove a service and the worker.java.lang.StringtoString()Get the string representation.protected IFuture<java.lang.Void>updateWorkerTimer(IService service)Update the worker timer by: - creating a timer (if timeout) - updating the service pool entry for the service (service, timer)
-
-
-
Field Detail
-
component
protected IInternalAccess component
The component.
-
servicetype
protected java.lang.Class<?> servicetype
The service type.
-
allservices
protected java.util.Set<IService> allservices
All services.
-
queue
protected java.util.List<java.lang.Object[]> queue
A queue of open requests.
-
strategy
protected IPoolStrategy strategy
The strategy.
-
componentname
protected java.lang.String componentname
The worker component name.
-
clock
protected IClockService clock
The clock service.
-
info
protected CreationInfo info
The creation info.
-
-
Constructor Detail
-
ServiceHandler
public ServiceHandler(IInternalAccess component, java.lang.Class<?> servicetype, IPoolStrategy strategy, java.lang.String componentname, CreationInfo info)
Create a new service handler.
-
-
Method Detail
-
init
public IFuture<java.lang.Void> init()
Init.
-
invoke
public java.lang.Object invoke(java.lang.Object proxy, java.lang.reflect.Method method, java.lang.Object[] args) throws java.lang.ThrowableCallback of the invocation handler interface.- Specified by:
invokein interfacejava.lang.reflect.InvocationHandler- Throws:
java.lang.Throwable
-
addFreeService
protected void addFreeService(IService service)
Called when a service becomes idle.
-
updateWorkerTimer
protected IFuture<java.lang.Void> updateWorkerTimer(IService service)
Update the worker timer by: - creating a timer (if timeout) - updating the service pool entry for the service (service, timer)
-
invokeService
protected void invokeService(IService service, java.lang.reflect.Method method, java.lang.Object[] args, Future<?> ret, ServiceCall call)
Execute a task on a service.
-
removeService
protected IFuture<java.lang.Void> removeService(IService service)
Remove a service and the worker.
-
getClockService
protected IFuture<IClockService> getClockService()
Get the clockservice (cached).
-
createTimer
protected IFuture<ITimer> createTimer(long delay, ITimedObject to)
Create a timer via the clock service.
-
toString
public java.lang.String toString()
Get the string representation.- Overrides:
toStringin classjava.lang.Object
-
-