Pointcut bean for simple method name matches, as alternative to regexp patterns.
Does not handle overloaded methods: all methods *with a given name will be eligible.
| Method from org.springframework.aop.support.NameMatchMethodPointcut Detail: |
public NameMatchMethodPointcut addMethodName(String name) {
// TODO in a future release, consider a way of letting proxies
// cause advice changed events.
this.mappedNames.add(name);
return this;
}
Add another eligible method name, in addition to those already named.
Like the set methods, this method is for use when configuring proxies,
before a proxy is used.
NB: This method does not work after the proxy is in
use, as advice chains will be cached. |
public boolean equals(Object other) {
if (this == other) {
return true;
}
return (other instanceof NameMatchMethodPointcut &&
ObjectUtils.nullSafeEquals(this.mappedNames, ((NameMatchMethodPointcut) other).mappedNames));
}
|
public int hashCode() {
return (this.mappedNames != null ? this.mappedNames.hashCode() : 0);
}
|
protected boolean isMatch(String methodName,
String mappedName) {
return PatternMatchUtils.simpleMatch(mappedName, methodName);
}
Return if the given method name matches the mapped name.
The default implementation checks for "xxx*", "*xxx" and "*xxx*" matches,
as well as direct equality. Can be overridden in subclasses. |
public boolean matches(Method method,
Class targetClass) {
for (int i = 0; i < this.mappedNames.size(); i++) {
String mappedName = (String) this.mappedNames.get(i);
if (mappedName.equals(method.getName()) || isMatch(method.getName(), mappedName)) {
return true;
}
}
return false;
}
|
public void setMappedName(String mappedName) {
setMappedNames(new String[] { mappedName });
}
Convenience method when we have only a single method name to match.
Use either this method or setMappedNames, not both. |
public void setMappedNames(String[] mappedNames) {
this.mappedNames = new LinkedList();
if (mappedNames != null) {
for (int i = 0; i < mappedNames.length; i++) {
this.mappedNames.add(mappedNames[i]);
}
}
}
Set the method names defining methods to match.
Matching will be the union of all these; if any match,
the pointcut matches. |