The Spring Framework

org.springframework.aop.support
Class AbstractRegexpMethodPointcut

java.lang.Object
  extended by org.springframework.aop.support.StaticMethodMatcher
      extended by org.springframework.aop.support.StaticMethodMatcherPointcut
          extended by org.springframework.aop.support.AbstractRegexpMethodPointcut
All Implemented Interfaces:
Serializable, MethodMatcher, Pointcut
Direct Known Subclasses:
JdkRegexpMethodPointcut

public abstract class AbstractRegexpMethodPointcut
extends StaticMethodMatcherPointcut
implements Serializable

Abstract base regular expression pointcut bean. JavaBean properties are:

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 method in this class will be invoked again on the client side 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
 
Fields inherited from interface org.springframework.aop.MethodMatcher
TRUE
 
Constructor Summary
AbstractRegexpMethodPointcut()
           
 
Method Summary
 boolean equals(Object other)
           
 String[] getExcludedPatterns()
          Returns the regular expressions for exclusion matching.
 String[] getPatterns()
          Return the regular expressions for method matching.
 int hashCode()
           
protected abstract  void initExcludedPatternRepresentation(String[] excludedPatterns)
           
protected abstract  void initPatternRepresentation(String[] patterns)
          Subclasses must implement this to initialize regexp pointcuts.
 boolean matches(Method method, Class targetClass)
          Try to match the regular expression against the fully qualified name of the method's declaring class, plus the name of the method.
protected abstract  boolean matches(String pattern, int patternIndex)
          Does the pattern at the given index match this string?
protected abstract  boolean matchesExclusion(String pattern, int patternIndex)
          Does the exclusion pattern at the given index match this string?
 void setExcludedPattern(String excludedPattern)
          Convenience method when we have only a single exclusion pattern.
 void setExcludedPatterns(String[] excludedPatterns)
          Set the regular expressions defining methods to match for exclusion.
 void setPattern(String pattern)
          Convenience method when we have only a single pattern.
 void setPatterns(String[] patterns)
          Set the regular expressions defining methods to match.
 String toString()
           
 
Methods inherited from class org.springframework.aop.support.StaticMethodMatcherPointcut
getClassFilter, getMethodMatcher, setClassFilter
 
Methods inherited from class org.springframework.aop.support.StaticMethodMatcher
isRuntime, matches
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

AbstractRegexpMethodPointcut

public AbstractRegexpMethodPointcut()
Method Detail

setPattern

public void setPattern(String pattern)
Convenience method when we have only a single pattern. Use either this method or setPatterns(java.lang.String[]), not both.

See Also:
setPatterns(java.lang.String[])

setPatterns

public void setPatterns(String[] patterns)
Set the regular expressions defining methods to match. Matching will be the union of all these; if any match, the pointcut matches.


getPatterns

public String[] getPatterns()
Return the regular expressions for method matching.


setExcludedPattern

public void setExcludedPattern(String excludedPattern)
Convenience method when we have only a single exclusion pattern. Use either this method or setExcludedPatterns(java.lang.String[]), not both.

See Also:
setExcludedPatterns(java.lang.String[])

setExcludedPatterns

public void setExcludedPatterns(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.


getExcludedPatterns

public String[] getExcludedPatterns()
Returns the regular expressions for exclusion matching.


matches

public final boolean matches(Method method,
                             Class targetClass)
Try to match the regular expression against the fully qualified name of the method's declaring class, plus the name of the method. Note that the declaring class is that class that originally declared the method, not necessarily the class that's currently exposing it.

For example, "java.lang.Object.hashCode" matches any subclass of Object's hashCode() method.

Specified by:
matches in interface MethodMatcher
Parameters:
method - the candidate method
targetClass - the target class (may be null, in which case the candidate class must be taken to be the method's declaring class)
Returns:
whether or not this method matches statically

initPatternRepresentation

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

This method will be invoked from the setPatterns method, and also on deserialization.

Parameters:
patterns - the patterns to initialize
Throws:
IllegalArgumentException - in case of an invalid pattern

initExcludedPatternRepresentation

protected abstract void initExcludedPatternRepresentation(String[] excludedPatterns)
                                                   throws IllegalArgumentException
Throws:
IllegalArgumentException

matches

protected abstract boolean matches(String pattern,
                                   int patternIndex)
Does the pattern at the given index match this string?

Parameters:
pattern - String pattern to match
patternIndex - index of pattern from 0
Returns:
true if there is a match, else false.

matchesExclusion

protected abstract boolean matchesExclusion(String pattern,
                                            int patternIndex)
Does the exclusion pattern at the given index match this string?

Parameters:
pattern - String pattern to match.
patternIndex - index of pattern starting from 0.
Returns:
true if there is a match, else false.

equals

public boolean equals(Object other)
Overrides:
equals in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object

toString

public String toString()
Overrides:
toString in class Object

The Spring Framework

Copyright © 2002-2007 The Spring Framework.