org.springframework.aop.support
Class AbstractRegexpMethodPointcut

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

public abstract class AbstractRegexpMethodPointcut
extends StaticMethodMatcherPointcut
implements ClassFilter, 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
See Also:
Perl5RegexpMethodPointcut, JdkRegexpMethodPointcut, Serialized Form

Field Summary
protected  Log logger
          Transient as it's reinitialized on deserialization.
 
Fields inherited from interface org.springframework.aop.ClassFilter
TRUE
 
Fields inherited from interface org.springframework.aop.Pointcut
TRUE
 
Fields inherited from interface org.springframework.aop.MethodMatcher
TRUE
 
Constructor Summary
AbstractRegexpMethodPointcut()
           
 
Method Summary
 ClassFilter getClassFilter()
           
 String[] getPatterns()
          Return the regular expressions for method matching.
protected abstract  void initPatternRepresentation(String[] patterns)
          Subclasses must implement this to initialize regexp pointcuts.
 boolean matches(Class clazz)
          Should the pointcut apply to the given interface or target class?
 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?
 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.
 
Methods inherited from class org.springframework.aop.support.StaticMethodMatcherPointcut
getMethodMatcher, setClassFilter
 
Methods inherited from class org.springframework.aop.support.StaticMethodMatcher
isRuntime, matches
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

protected transient Log logger
Transient as it's reinitialized on deserialization.

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, 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.

Parameters:
patterns - regular expressions describing methods to match

getPatterns

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


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

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:
whether there's a match

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 - 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

matches

public boolean matches(Class clazz)
Description copied from interface: ClassFilter
Should the pointcut apply to the given interface or target class?

Specified by:
matches in interface ClassFilter
Parameters:
clazz - candidate target class
Returns:
whether the advice should apply to this candidate target class

getClassFilter

public final ClassFilter getClassFilter()
Specified by:
getClassFilter in interface Pointcut
Overrides:
getClassFilter in class StaticMethodMatcherPointcut


Copyright (C) 2003-2004 The Spring Framework Project.