org.springframework.aop.support

Class AbstractRegexpMethodPointcut

  • All Implemented Interfaces:
    java.io.Serializable, MethodMatcher, Pointcut
    Direct Known Subclasses:
    JdkRegexpMethodPointcut


    public abstract class AbstractRegexpMethodPointcut
    extends StaticMethodMatcherPointcut
    implements java.io.Serializable
    Abstract base regular expression pointcut bean. JavaBean properties are:
    • pattern: regular expression for the fully-qualified method names to match. The exact regexp syntax will depend on the subclass (e.g. Perl5 regular expressions)
    • patterns: alternative property taking a String array of patterns. The result will be the union of these patterns.

    Note: the regular expressions must be a match. For example, .*get.* will match com.mycom.Foo.getBar(). get.* will not.

    This base class is serializable. Subclasses should declare all fields transient; the initPatternRepresentation(java.lang.String[]) method will be invoked again on deserialization.

    Since:
    1.1
    Author:
    Rod Johnson, Juergen Hoeller, Rob Harrop
    See Also:
    JdkRegexpMethodPointcut, Serialized Form
    • Field Summary

      • Fields inherited from interface org.springframework.aop.Pointcut

        TRUE
    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method and Description
      boolean equals(java.lang.Object other) 
      java.lang.String[] getExcludedPatterns()
      Returns the regular expressions for exclusion matching.
      java.lang.String[] getPatterns()
      Return the regular expressions for method matching.
      int hashCode() 
      protected abstract void initExcludedPatternRepresentation(java.lang.String[] patterns)
      Subclasses must implement this to initialize regexp pointcuts.
      protected abstract void initPatternRepresentation(java.lang.String[] patterns)
      Subclasses must implement this to initialize regexp pointcuts.
      boolean matches(java.lang.reflect.Method method, java.lang.Class<?> targetClass)
      Try to match the regular expression against the fully qualified name of the target class as well as against the method's declaring class, plus the name of the method.
      protected abstract boolean matches(java.lang.String pattern, int patternIndex)
      Does the pattern at the given index match the given String?
      protected abstract boolean matchesExclusion(java.lang.String pattern, int patternIndex)
      Does the exclusion pattern at the given index match the given String?
      protected boolean matchesPattern(java.lang.String signatureString)
      Match the specified candidate against the configured patterns.
      void setExcludedPattern(java.lang.String excludedPattern)
      Convenience method when we have only a single exclusion pattern.
      void setExcludedPatterns(java.lang.String... excludedPatterns)
      Set the regular expressions defining methods to match for exclusion.
      void setPattern(java.lang.String pattern)
      Convenience method when we have only a single pattern.
      void setPatterns(java.lang.String... patterns)
      Set the regular expressions defining methods to match.
      java.lang.String toString() 
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • AbstractRegexpMethodPointcut

        public AbstractRegexpMethodPointcut()
    • Method Detail

      • setPatterns

        public void setPatterns(java.lang.String... patterns)
        Set the regular expressions defining methods to match. Matching will be the union of all these; if any match, the pointcut matches.
        See Also:
        setPattern(java.lang.String)
      • getPatterns

        public java.lang.String[] getPatterns()
        Return the regular expressions for method matching.
      • setExcludedPatterns

        public void setExcludedPatterns(java.lang.String... excludedPatterns)
        Set the regular expressions defining methods to match for exclusion. Matching will be the union of all these; if any match, the pointcut matches.
        See Also:
        setExcludedPattern(java.lang.String)
      • getExcludedPatterns

        public java.lang.String[] getExcludedPatterns()
        Returns the regular expressions for exclusion matching.
      • matches

        public boolean matches(java.lang.reflect.Method method,
                               java.lang.Class<?> targetClass)
        Try to match the regular expression against the fully qualified name of the target class as well as against the method's declaring class, plus the name of the method.
        Specified by:
        matches in interface MethodMatcher
        Parameters:
        method - the candidate method
        targetClass - the target class
        Returns:
        whether or not this method matches statically
      • matchesPattern

        protected boolean matchesPattern(java.lang.String signatureString)
        Match the specified candidate against the configured patterns.
        Parameters:
        signatureString - "java.lang.Object.hashCode" style signature
        Returns:
        whether the candidate matches at least one of the specified patterns
      • initPatternRepresentation

        protected abstract void initPatternRepresentation(java.lang.String[] patterns)
                                                   throws java.lang.IllegalArgumentException
        Subclasses must implement this to initialize regexp pointcuts. Can be invoked multiple times.

        This method will be invoked from the setPatterns(java.lang.String...) method, and also on deserialization.

        Parameters:
        patterns - the patterns to initialize
        Throws:
        java.lang.IllegalArgumentException - in case of an invalid pattern
      • initExcludedPatternRepresentation

        protected abstract void initExcludedPatternRepresentation(java.lang.String[] patterns)
                                                           throws java.lang.IllegalArgumentException
        Subclasses must implement this to initialize regexp pointcuts. Can be invoked multiple times.

        This method will be invoked from the setExcludedPatterns(java.lang.String...) method, and also on deserialization.

        Parameters:
        patterns - the patterns to initialize
        Throws:
        java.lang.IllegalArgumentException - in case of an invalid pattern
      • matches

        protected abstract boolean matches(java.lang.String pattern,
                                           int patternIndex)
        Does the pattern at the given index match the given String?
        Parameters:
        pattern - the String pattern to match
        patternIndex - index of pattern (starting from 0)
        Returns:
        true if there is a match, false otherwise
      • matchesExclusion

        protected abstract boolean matchesExclusion(java.lang.String pattern,
                                                    int patternIndex)
        Does the exclusion pattern at the given index match the given String?
        Parameters:
        pattern - the String pattern to match
        patternIndex - index of pattern (starting from 0)
        Returns:
        true if there is a match, false otherwise
      • equals

        public boolean equals(java.lang.Object other)
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object