Class BasicServiceInvocationHandler

  • All Implemented Interfaces:
    ISwitchCall, java.lang.reflect.InvocationHandler

    public class BasicServiceInvocationHandler
    extends java.lang.Object
    implements java.lang.reflect.InvocationHandler, ISwitchCall
    Basic service invocation interceptor. It has a multi collection of interceptors per method. Executes the list of interceptors one by one. In case no handler can be found a fallback handler is used.
    • Field Detail

      • PROXYTYPE_RAW

        public static final java.lang.String PROXYTYPE_RAW
        The raw proxy type (i.e. no proxy).
        See Also:
        Constant Field Values
      • PROXYTYPE_DIRECT

        public static final java.lang.String PROXYTYPE_DIRECT
        The direct proxy type (supports custom interceptors, but uses caller thread).
        See Also:
        Constant Field Values
      • PROXYTYPE_DECOUPLED

        public static final java.lang.String PROXYTYPE_DECOUPLED
        The (default) decoupled proxy type (decouples from caller thread to component thread).
        See Also:
        Constant Field Values
      • service

        protected java.lang.Object service
        The service.
      • logger

        protected java.util.logging.Logger logger
        The logger for errors/warnings.
      • required

        protected boolean required
        The flag if the proxy is required (provided otherwise).
      • switchcall

        protected boolean switchcall
        The flag if a switchcall should be done.
      • pojoproxies

        protected static java.util.Map<java.lang.Object,​IService> pojoproxies
        The pojo service map (pojo -> proxy).
    • Constructor Detail

      • BasicServiceInvocationHandler

        public BasicServiceInvocationHandler​(IInternalAccess comp,
                                             IServiceIdentifier sid,
                                             java.util.logging.Logger logger,
                                             boolean required)
        Create a new invocation handler.
      • BasicServiceInvocationHandler

        public BasicServiceInvocationHandler​(IInternalAccess comp,
                                             IService service,
                                             java.util.logging.Logger logger,
                                             boolean required)
        Create a new invocation handler.
      • BasicServiceInvocationHandler

        public BasicServiceInvocationHandler​(IInternalAccess comp,
                                             ServiceInfo service,
                                             java.util.logging.Logger logger)
        Create a new invocation handler.
    • Method Detail

      • invoke

        public java.lang.Object invoke​(java.lang.Object proxy,
                                       java.lang.reflect.Method method,
                                       java.lang.Object[] args)
                                throws java.lang.Throwable
        A proxy method has been invoked.
        Specified by:
        invoke in interface java.lang.reflect.InvocationHandler
        Throws:
        java.lang.Throwable
      • getServiceIdentifier

        public IServiceIdentifier getServiceIdentifier()
        Get the sid.
        Returns:
        the sid.
      • getService

        public java.lang.Object getService()
        Get the service.
        Returns:
        The service.
      • getDomainService

        public java.lang.Object getDomainService()
        Get the domain service.
        Returns:
        The domain service.
      • addFirstServiceInterceptor

        public void addFirstServiceInterceptor​(IServiceInvocationInterceptor interceptor)
        Add an interceptor. Must be synchronized as invoke() is called from arbitrary threads.
      • addServiceInterceptor

        public void addServiceInterceptor​(IServiceInvocationInterceptor interceptor,
                                          int pos)
        Add an interceptor. Must be synchronized as invoke() is called from arbitrary threads.
      • addServiceInterceptor

        public void addServiceInterceptor​(IServiceInvocationInterceptor interceptor)
        Add an interceptor. Must be synchronized as invoke() is called from arbitrary threads.
      • removeServiceInterceptor

        public void removeServiceInterceptor​(IServiceInvocationInterceptor interceptor)
        Remove an interceptor. Must be synchronized as invoke() is called from arbitrary threads.
      • getInterceptors

        public IServiceInvocationInterceptor[] getInterceptors()
        Get interceptors. Must be synchronized as invoke() is called from arbitrary threads.
      • hashCode

        public int hashCode()
        Return the hash code.
        Overrides:
        hashCode in class java.lang.Object
      • equals

        public boolean equals​(java.lang.Object obj)
        Test if two objects are equal.
        Overrides:
        equals in class java.lang.Object
      • toString

        public java.lang.String toString()
        Get a string representation.
        Overrides:
        toString in class java.lang.Object
      • addPojoServiceProxy

        public static void addPojoServiceProxy​(java.lang.Object pojo,
                                               IService proxy)
        Add a service proxy.
        Parameters:
        pojo - The pojo.
        proxy - The proxy.
      • removePojoServiceProxy

        public static void removePojoServiceProxy​(IServiceIdentifier sid)
        Remove a pojo - proxy pair.
        Parameters:
        sid - The service identifier.
      • getPojoServiceProxy

        public static IService getPojoServiceProxy​(java.lang.Object pojo)
        Get the proxy of a pojo service.
        Parameters:
        pojo - The pojo service.
        Returns:
        The proxy of the service.
      • isSwitchCall

        public boolean isSwitchCall()
        Check if a switch call should be done.
        Specified by:
        isSwitchCall in interface ISwitchCall
        Returns:
        True, if switch should be done.
      • isRequired

        public boolean isRequired()
        Check if the handler is for a required service proxy.
      • isRequiredServiceProxy

        public static boolean isRequiredServiceProxy​(java.lang.Object service)
        Test if a service is a required service proxy.
        Parameters:
        service - The service.
        Returns:
        True, if is required service proxy.
      • isProvidedServiceProxy

        public static boolean isProvidedServiceProxy​(java.lang.Object service)
        Test if a service is a provided service proxy.
        Parameters:
        service - The service.
        Returns:
        True, if is provided service proxy.