Package jodd.proxetta

Class ProxyTarget


  • public final class ProxyTarget
    extends java.lang.Object
    Marker class for proxy implementations.
    • Constructor Summary

      Constructors 
      Constructor Description
      ProxyTarget()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.lang.Object argument​(int index)
      Inserts value of method argument specified by 1-based index.
      static int argumentsCount()
      Inserts total number of method's arguments.
      static java.lang.Class argumentType​(int index)
      Inserts type of method argument specified by 1-based index.
      static java.lang.Object[] createArgumentsArray()
      Creates array of arguments values.
      static java.lang.Class[] createArgumentsClassArray()
      Creates array of arguments types.
      static ProxyTargetInfo info()
      Inserts populated ProxyTargetInfo instance.
      static java.lang.Object invoke()
      Inserts the invocation of target method and getting the invocation results.
      static java.lang.Class returnType()
      Inserts return type of target method.
      static java.lang.Object returnValue​(java.lang.Object value)
      Prepares return value.
      static void setArgument​(java.lang.Object value, int index)
      Assigns new value for an argument specified by 1-based index.
      static java.lang.Object target()
      Inserts proxy (i.e.
      static java.lang.Class targetClass()
      Inserts target class.
      static java.lang.Object targetClassAnnotation​(java.lang.String annotationClassName, java.lang.String element)
      Inserts targets class annotation value.
      static java.lang.Object targetMethodAnnotation​(java.lang.String annotationClassName, java.lang.String element)
      Inserts targets method annotation value.
      static java.lang.String targetMethodDescription()
      Inserts target method description, bytecode alike, without method name.
      static java.lang.String targetMethodName()
      Inserts target method name.
      static java.lang.String targetMethodSignature()
      Inserts target method signature, java alike, including the method name.
      • Methods inherited from class java.lang.Object

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

      • ProxyTarget

        public ProxyTarget()
    • Method Detail

      • invoke

        public static java.lang.Object invoke()
        Inserts the invocation of target method and getting the invocation results. Small types are converted to wrappers. If method is void, null is used for return value.
      • argumentsCount

        public static int argumentsCount()
        Inserts total number of method's arguments.
      • argumentType

        public static java.lang.Class argumentType​(int index)
        Inserts type of method argument specified by 1-based index. Works correctly with null argument values.
        See Also:
        createArgumentsClassArray()
      • argument

        public static java.lang.Object argument​(int index)
        Inserts value of method argument specified by 1-based index.
        See Also:
        createArgumentsArray()
      • setArgument

        public static void setArgument​(java.lang.Object value,
                                       int index)
        Assigns new value for an argument specified by 1-based index.
      • createArgumentsArray

        public static java.lang.Object[] createArgumentsArray()
        Creates array of arguments values. It is more safely then to get one argument at time, since the returned array has correct length. Equals to: new Object[] {arg1, arg2,...}
        See Also:
        createArgumentsClassArray(), argument(int)
      • createArgumentsClassArray

        public static java.lang.Class[] createArgumentsClassArray()
        Creates array of arguments types. Works correctly with null argument values. Equals to: new Class[] {Arg1Type.class, Arg2Type.class...}
        See Also:
        createArgumentsArray(), argumentType(int)
      • returnType

        public static java.lang.Class returnType()
        Inserts return type of target method. null is used for void.
      • returnValue

        public static java.lang.Object returnValue​(java.lang.Object value)
        Prepares return value. Must be used as last method call:
             ...
             return ProxyTarget.returnValue(xxx);
         
        Used when returning values in general case, when return type may be either primitive or an object. Also, must be used when returning null for primitives.
      • target

        public static java.lang.Object target()
        Inserts proxy (i.e. target) instance.
      • targetClass

        public static java.lang.Class targetClass()
        Inserts target class.
      • targetMethodName

        public static java.lang.String targetMethodName()
        Inserts target method name. Useful for reflection.
      • targetMethodSignature

        public static java.lang.String targetMethodSignature()
        Inserts target method signature, java alike, including the method name. Useful for identifying the method, since it is unique for class.
        See Also:
        targetMethodDescription()
      • targetMethodDescription

        public static java.lang.String targetMethodDescription()
        Inserts target method description, bytecode alike, without method name. May be used for identifying the method.
        See Also:
        targetMethodSignature()
      • targetMethodAnnotation

        public static java.lang.Object targetMethodAnnotation​(java.lang.String annotationClassName,
                                                              java.lang.String element)
        Inserts targets method annotation value. Inserts null if annotation or element is missing.
      • targetClassAnnotation

        public static java.lang.Object targetClassAnnotation​(java.lang.String annotationClassName,
                                                             java.lang.String element)
        Inserts targets class annotation value. Inserts null if annotation or element is missing.