public class MethodMatcher extends java.lang.Object
MethodSignature
against a
method pattern (this is primarily used by interceptor factories
). A method pattern consists of a name pattern and an optional
parameters pattern.
The name pattern matches against the method name, and can be one of the following:
perform
*form
per*
*erfo*
.
*
The parameters pattern follows the name pattern and is optional. It is used to check the number of parameters, or their types. When the parameters pattern is omitted, then the number and types of parameters are not considred when matching methods.
The parameters pattern, when present, is contained within open and closed parenthis after the method pattern. Inside the parenthesis may be a number, indicating the exact number of method parameters to match against. Alternately, a comma-seperated list of Java types is used, which matches against a method that takes the exact set of parameters. Examples:
perform()
-- method with no parameters
perform(2)
-- method with two parameters
perform(java.util.List, int)
- method taking a List and an int parameter
Constructor and Description |
---|
MethodMatcher() |
MethodMatcher(java.lang.Object defaultValue)
Constructor that takes a default value returned when no stored method pattern matches the
input to
get(MethodSignature) . |
Modifier and Type | Method and Description |
---|---|
java.lang.Object |
get(MethodSignature sig)
Returns a pattern value prevoiusly stored via
put(String, Object) . |
void |
put(java.lang.String methodPattern,
java.lang.Object patternValue)
Stores a pattern and an associated value.
|
public MethodMatcher(java.lang.Object defaultValue)
get(MethodSignature)
.public MethodMatcher()
public void put(java.lang.String methodPattern, java.lang.Object patternValue)
get(MethodSignature)
.methodPattern
- a pattern that is used to recognize methodspatternValue
- a value associated with the patternpublic java.lang.Object get(MethodSignature sig)
put(String, Object)
. Iterates over
the patterns stored, in the order in which they were stored, until a match is found.sig
- the MethodSignature to find a matching pattern for