Class JoinPointHelper


  • public final class JoinPointHelper
    extends java.lang.Object
    The Class JoinPointHelper.
    Since:
    23.10.2008
    Version:
    $Revision: 1.24 $
    Author:
    oliver
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.lang.String getArgAsShortString​(java.lang.Object obj)
      Gets the arg as short string.
      static java.lang.String getArgAsString​(java.lang.Object obj)
      Gets the arg as string.
      static java.lang.String getArgsAsShortString​(java.lang.Object[] args)
      Gets the args as short string.
      static java.lang.String getArgsAsString​(java.lang.Object[] args)
      Gets the args as string.
      static java.lang.String getAsLongString​(org.aspectj.lang.JoinPoint joinpoint)
      Gets the as long string.
      static java.lang.String getAsShortString​(org.aspectj.lang.JoinPoint joinpoint)
      Gets the as short string.
      static java.lang.String getAsString​(org.aspectj.lang.JoinPoint joinpoint)
      Gets the given joinpoint as string.
      static java.lang.Class<?> getCallerClass()
      Gets the caller class by examing the stacktrace.
      static java.lang.Class<?> getCallerClass​(java.lang.Class<?>... excluded)
      Gets the caller class by examing the stacktrace.
      static java.lang.StackTraceElement getCallerOf​(org.aspectj.lang.JoinPoint jp)
      Gets the caller of the given joinpoint.
      static java.lang.StackTraceElement getCallerOf​(org.aspectj.lang.JoinPoint jp, java.util.regex.Pattern... excluded)
      Gets the caller of the given joinpoint.
      static java.lang.annotation.Annotation getClassAnnotation​(org.aspectj.lang.JoinPoint jp, java.lang.Class<? extends java.lang.annotation.Annotation> annotationClass)
      Returns the annotation for the given JoinPoint.
      static java.lang.annotation.Annotation[][] getParameterAnnotations​(org.aspectj.lang.JoinPoint joinpoint)
      Gets the parameter annotations.
      static boolean isInnerClass​(org.aspectj.lang.JoinPoint jp)
      The Java compiler generates something like OuterClass$InnerClass as name for the inner class.
      static boolean isInnerClass​(org.aspectj.lang.Signature sig)
      The Java compiler generates something like OuterClass$InnerClass as name for the inner class.
      • Methods inherited from class java.lang.Object

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

      • getAsString

        public static java.lang.String getAsString​(org.aspectj.lang.JoinPoint joinpoint)
        Gets the given joinpoint as string.
        Parameters:
        joinpoint - the joinpoint
        Returns:
        the as string
      • getAsShortString

        public static java.lang.String getAsShortString​(org.aspectj.lang.JoinPoint joinpoint)
        Gets the as short string.
        Parameters:
        joinpoint - the joinpoint
        Returns:
        the as short string
      • getAsLongString

        public static java.lang.String getAsLongString​(org.aspectj.lang.JoinPoint joinpoint)
        Gets the as long string.
        Parameters:
        joinpoint - the joinpoint
        Returns:
        the as short string
      • getParameterAnnotations

        @MayReturnNull
        public static java.lang.annotation.Annotation[][] getParameterAnnotations​(org.aspectj.lang.JoinPoint joinpoint)
        Gets the parameter annotations.
        Parameters:
        joinpoint - should be a Method- or Constructor-Signature
        Returns:
        the annotations of a method or constructor, otherwise null
      • getClassAnnotation

        @MayReturnNull
        public static java.lang.annotation.Annotation getClassAnnotation​(org.aspectj.lang.JoinPoint jp,
                                                                         java.lang.Class<? extends java.lang.annotation.Annotation> annotationClass)
        Returns the annotation for the given JoinPoint.
        Parameters:
        jp - the JoinPoint
        annotationClass - the wanted annotation
        Returns:
        the annotation (if found) or null
        Since:
        1.0
      • getArgsAsString

        @NullArgsAllowed
        public static java.lang.String getArgsAsString​(java.lang.Object[] args)
        Gets the args as string.
        Parameters:
        args - the args
        Returns:
        the args as string
      • getArgsAsShortString

        @NullArgsAllowed
        public static java.lang.String getArgsAsShortString​(java.lang.Object[] args)
        Gets the args as short string. If the resulting argument string will be too long it will be abbreviated.
        Parameters:
        args - the args
        Returns:
        the args as short string
        Since:
        1.4.1
      • getArgAsString

        @NullArgsAllowed
        public static java.lang.String getArgAsString​(java.lang.Object obj)
        Gets the arg as string.
        Parameters:
        obj - the obj
        Returns:
        the arg as string
      • getArgAsShortString

        @NullArgsAllowed
        public static java.lang.String getArgAsShortString​(java.lang.Object obj)
        Gets the arg as short string.
        Parameters:
        obj - the obj
        Returns:
        the arg as short string
        Since:
        1.4.1
      • isInnerClass

        public static boolean isInnerClass​(org.aspectj.lang.JoinPoint jp)
        The Java compiler generates something like OuterClass$InnerClass as name for the inner class. So if a name contains a '$' it is probably an inner class.
        Parameters:
        jp - the jp
        Returns:
        true if joinpoint belongs to an inner class
      • isInnerClass

        public static boolean isInnerClass​(org.aspectj.lang.Signature sig)
        The Java compiler generates something like OuterClass$InnerClass as name for the inner class. So if a name contains a '$' it is probably an inner class.
        Parameters:
        sig - the sig
        Returns:
        true if signature belongs to an inner class
      • getCallerClass

        public static java.lang.Class<?> getCallerClass()
        Gets the caller class by examing the stacktrace.

        Sometime the caller of the method is an aspect. Because normally you do not want the aspect it is filtered out. If you really want it call getCallerOf(JoinPoint, Pattern...) direct with an empty pattern argument.

        Returns:
        the caller of a joinpoint
        See Also:
        getCallerOf(JoinPoint, Pattern...)
      • getCallerClass

        public static java.lang.Class<?> getCallerClass​(java.lang.Class<?>... excluded)
        Gets the caller class by examing the stacktrace.

        Sometime the caller of the method is an aspect. With this method you have the chance to list the aspects which should be ignored.

        Parameters:
        excluded - the excluded
        Returns:
        the caller of a joinpoint
      • getCallerOf

        public static java.lang.StackTraceElement getCallerOf​(org.aspectj.lang.JoinPoint jp)
        Gets the caller of the given joinpoint. For a call joinpoint you have "this" as attribute which gives you the caller. But for an execution joinpoint "this" is not the caller but the object of execution. If you want the caller of the excution joinpoint call this method here.

        Sometime the caller of the method is an aspect. Because normally you do not want the aspect it is filtered out. If you really want it call getCallerOf(JoinPoint, Pattern...) direct with an empty pattern argument.

        Parameters:
        jp - the (execution) joinpoint
        Returns:
        the caller of the given joinpoint
        See Also:
        getCallerOf(JoinPoint, Pattern...)
      • getCallerOf

        public static java.lang.StackTraceElement getCallerOf​(org.aspectj.lang.JoinPoint jp,
                                                              java.util.regex.Pattern... excluded)
        Gets the caller of the given joinpoint. For a call joinpoint you have "this" as attribute which gives you the caller. But for an execution joinpoint "this" is not the caller but the object of execution. If you want the caller of the excution joinpoint call this method here.
        Parameters:
        jp - the (execution) joinpoint
        excluded - a list of filters which should be not considered as caller
        Returns:
        the caller of