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.InvocationHandler
The 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>
allservices
All services.protected IClockService
clock
The clock service.protected IInternalAccess
component
The component.protected java.lang.String
componentname
The worker component name.protected java.util.Map<IService,ITimer>
idleservices
Map of idle services.protected CreationInfo
info
The creation info.protected java.util.List<java.lang.Object[]>
queue
A queue of open requests.protected java.lang.Class<?>
servicetype
The service type.protected IPoolStrategy
strategy
The 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 void
addFreeService(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.Object
invoke(java.lang.Object proxy, java.lang.reflect.Method method, java.lang.Object[] args)
Callback of the invocation handler interface.protected void
invokeService(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.String
toString()
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.Throwable
Callback of the invocation handler interface.- Specified by:
invoke
in 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:
toString
in classjava.lang.Object
-
-