Class 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 Detail

      • servicetype

        protected java.lang.Class<?> servicetype
        The service type.
      • idleservices

        protected java.util.Map<IService,​ITimer> idleservices
        Map of idle services.
      • allservices

        protected java.util.Set<IService> allservices
        All services.
      • queue

        protected java.util.List<java.lang.Object[]> queue
        A queue of open requests.
      • componentname

        protected java.lang.String componentname
        The worker component name.
    • 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 interface java.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 class java.lang.Object