Class ResolveInterceptor

  • All Implemented Interfaces:
    IServiceInvocationInterceptor

    public class ResolveInterceptor
    extends AbstractApplicableInterceptor
    The resolve interceptor is responsible for determining the object on which the method invocation is finally performed. Checks whether the object is a ServiceInfo. In this case it delegates method calls of I(Internal)Service to the automatically created BasicService instance and all other calls to the domain object. // todo: much annotation stuff and injection of objects to the pojo.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected IInternalAccess ia
      The component.
      protected static java.lang.reflect.Method INVOKE_METHOD  
      static java.util.Set<java.lang.reflect.Method> SERVICEMETHODS
      The static map of subinterceptors (method -> interceptor).
      protected static java.lang.reflect.Method SHUTDOWN_METHOD  
      protected static java.lang.reflect.Method START_METHOD  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected java.lang.Object convertFromJsonString​(java.lang.String val, java.lang.Class<?> type)
      Convert json to object representation.
      protected java.lang.Object convertFromString​(java.lang.String val, java.lang.Class<?> type)
      Convert to object representation.
      protected java.lang.Object convertParameter​(java.lang.Object value, java.lang.reflect.Type targettype)
      Convert a parameter to a target type.
      protected java.lang.String convertToJsonString​(java.lang.Object val)
      Convert an object to the json string representation.
      IFuture<java.lang.Void> execute​(ServiceInvocationContext sic)
      Execute the interceptor.
      protected Tuple2<java.lang.reflect.Method,​java.lang.Object[]> findMethod​(java.lang.Object[] params, ClassInfo[] argtypes, java.lang.Class<?> serclazz, java.lang.String methodname)
      Find the correct method by its name and parameter values.
      protected java.lang.Object[] generateParameters​(java.lang.Object[] vals, java.lang.reflect.Method m)
      Generate call parameters.
      protected IFuture<java.lang.Void> invokeDoubleMethod​(ServiceInvocationContext sic, ServiceInfo si, java.lang.reflect.Method m, java.lang.Class<? extends java.lang.annotation.Annotation> annotation, boolean firstorig, boolean ignorenotfound)
      Invoke double methods.
      protected boolean isSupportedBasicType​(java.lang.Class<?> type)
      Test if basic converter can handle this type.
      protected java.lang.reflect.Method searchMethod​(java.lang.Class<?> impl, java.lang.Class<? extends java.lang.annotation.Annotation> annotation)
      Search an annotation method.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • SERVICEMETHODS

        public static final java.util.Set<java.lang.reflect.Method> SERVICEMETHODS
        The static map of subinterceptors (method -> interceptor).
      • START_METHOD

        protected static final java.lang.reflect.Method START_METHOD
      • SHUTDOWN_METHOD

        protected static final java.lang.reflect.Method SHUTDOWN_METHOD
      • INVOKE_METHOD

        protected static final java.lang.reflect.Method INVOKE_METHOD
    • Constructor Detail

      • ResolveInterceptor

        public ResolveInterceptor​(IInternalAccess ia)
        Create a new ResolveInterceptor.
    • Method Detail

      • execute

        public IFuture<java.lang.Void> execute​(ServiceInvocationContext sic)
        Execute the interceptor.
        Parameters:
        context - The invocation context.
      • searchMethod

        protected java.lang.reflect.Method searchMethod​(java.lang.Class<?> impl,
                                                        java.lang.Class<? extends java.lang.annotation.Annotation> annotation)
        Search an annotation method.
      • invokeDoubleMethod

        protected IFuture<java.lang.Void> invokeDoubleMethod​(ServiceInvocationContext sic,
                                                             ServiceInfo si,
                                                             java.lang.reflect.Method m,
                                                             java.lang.Class<? extends java.lang.annotation.Annotation> annotation,
                                                             boolean firstorig,
                                                             boolean ignorenotfound)
        Invoke double methods. The boolean 'firstorig' determines if basicservice method is called first.
      • findMethod

        protected Tuple2<java.lang.reflect.Method,​java.lang.Object[]> findMethod​(java.lang.Object[] params,
                                                                                       ClassInfo[] argtypes,
                                                                                       java.lang.Class<?> serclazz,
                                                                                       java.lang.String methodname)
        Find the correct method by its name and parameter values. The parameter values are half-evaluated, i.e. if they are deserialized as far as possible. Still serialized parameters are saved as SerialiedObject. Those are deserialized using the parameter class as hint.
        Parameters:
        decparams - Partially decoded parameters.
        serclazz - The target class.
        methodname - The method name
        Returns:
        The method and further decoded parameters.
      • generateParameters

        protected java.lang.Object[] generateParameters​(java.lang.Object[] vals,
                                                        java.lang.reflect.Method m)
                                                 throws java.lang.Exception
        Generate call parameters.
        Parameters:
        vals - The current parameters.
        Returns:
        The adapted method call parameters.
        Throws:
        java.lang.Exception
      • convertParameter

        protected java.lang.Object convertParameter​(java.lang.Object value,
                                                    java.lang.reflect.Type targettype)
                                             throws java.lang.Exception
        Convert a parameter to a target type.
        Throws:
        java.lang.Exception
      • convertToJsonString

        protected java.lang.String convertToJsonString​(java.lang.Object val)
        Convert an object to the json string representation.
        Parameters:
        val - The value.
        Returns:
        The string representation.
      • convertFromJsonString

        protected java.lang.Object convertFromJsonString​(java.lang.String val,
                                                         java.lang.Class<?> type)
        Convert json to object representation.
        Parameters:
        val - The json value.
        Returns:
        The object.
      • convertFromString

        protected java.lang.Object convertFromString​(java.lang.String val,
                                                     java.lang.Class<?> type)
        Convert to object representation.
        Parameters:
        val - The string value.
        Returns:
        The object.
      • isSupportedBasicType

        protected boolean isSupportedBasicType​(java.lang.Class<?> type)
        Test if basic converter can handle this type.
        Parameters:
        type - The type.
        Returns:
        True if it can handle this type.