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.
| Method from org.springframework.aop.support.AbstractRegexpMethodPointcut Detail: |
public boolean equals(Object other) {
if (this == other) {
return true;
}
if (!(other instanceof AbstractRegexpMethodPointcut)) {
return false;
}
AbstractRegexpMethodPointcut otherPointcut = (AbstractRegexpMethodPointcut) other;
return (Arrays.equals(this.patterns, otherPointcut.patterns) &&
Arrays.equals(this.excludedPatterns, otherPointcut.excludedPatterns));
}
|
public String[] getExcludedPatterns() {
return this.excludedPatterns;
}
Returns the regular expressions for exclusion matching. |
public String[] getPatterns() {
return this.patterns;
}
Return the regular expressions for method matching. |
public int hashCode() {
int result = 27;
for (int i = 0; i < this.patterns.length; i++) {
String pattern = this.patterns[i];
result = 13 * result + pattern.hashCode();
}
for (int i = 0; i < this.excludedPatterns.length; i++) {
String excludedPattern = this.excludedPatterns[i];
result = 13 * result + excludedPattern.hashCode();
}
return result;
}
|
abstract protected void initExcludedPatternRepresentation(String[] excludedPatterns) throws IllegalArgumentException
|
abstract protected 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. |
public boolean matches(Method method,
Class targetClass) {
return ((targetClass != null && matchesPattern(targetClass.getName() + "." + method.getName())) ||
matchesPattern(method.getDeclaringClass().getName() + "." + method.getName()));
}
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. |
abstract protected boolean matches(String pattern,
int patternIndex)
Does the pattern at the given index match this string? |
abstract protected boolean matchesExclusion(String pattern,
int patternIndex)
Does the exclusion pattern at the given index match this string? |
protected boolean matchesPattern(String signatureString) {
for (int i = 0; i < this.patterns.length; i++) {
boolean matched = matches(signatureString, i);
if (matched) {
for (int j = 0; j < this.excludedPatterns.length; j++) {
boolean excluded = matchesExclusion(signatureString, j);
if (excluded) {
return false;
}
}
return true;
}
}
return false;
}
Match the specified candidate against the configured patterns. |
public void setExcludedPattern(String excludedPattern) {
setExcludedPatterns(new String[] {excludedPattern});
}
Convenience method when we have only a single exclusion pattern.
Use either this method or #setExcludedPatterns , not both. |
public void setExcludedPatterns(String[] excludedPatterns) {
Assert.notEmpty(excludedPatterns, "'excludedPatterns' must not be empty");
this.excludedPatterns = new String[excludedPatterns.length];
for (int i = 0; i < excludedPatterns.length; i++) {
this.excludedPatterns[i] = StringUtils.trimWhitespace(excludedPatterns[i]);
}
initExcludedPatternRepresentation(this.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. |
public void setPattern(String pattern) {
setPatterns(new String[] {pattern});
}
Convenience method when we have only a single pattern.
Use either this method or #setPatterns , not both. |
public void setPatterns(String[] patterns) {
Assert.notEmpty(patterns, "'patterns' must not be empty");
this.patterns = new String[patterns.length];
for (int i = 0; i < patterns.length; i++) {
this.patterns[i] = StringUtils.trimWhitespace(patterns[i]);
}
initPatternRepresentation(this.patterns);
}
Set the regular expressions defining methods to match.
Matching will be the union of all these; if any match,
the pointcut matches. |
public String toString() {
return getClass().getName() + ": patterns " + ObjectUtils.nullSafeToString(this.patterns) +
", excluded patterns " + ObjectUtils.nullSafeToString(this.excludedPatterns);
}
|