站内搜索: 请输入搜索关键词
当前页面: 在线文档首页 > Spring Framework 1.2.9 API 文档英文版

AbstractRegexpMethodPointcut (Spring Framework) - Spring Framework 1.2.9 API 文档英文版


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, ClassFilter, MethodMatcher, Pointcut
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()
          Return the ClassFilter for this pointcut.
 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 - 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

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 - the candidate target class
Returns:
whether the advice should apply to the given target class

getClassFilter

public final ClassFilter getClassFilter()
Description copied from interface: Pointcut
Return the ClassFilter for this pointcut.

Specified by:
getClassFilter in interface Pointcut
Overrides:
getClassFilter in class StaticMethodMatcherPointcut
Returns:
the ClassFilter (never null)


Copyright (c) 2002-2007 The Spring Framework Project.