KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > springframework > aop > TrueMethodMatcher


1 /*
2  * Copyright 2002-2006 the original author or authors.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16
17 package org.springframework.aop;
18
19 import java.io.Serializable JavaDoc;
20 import java.lang.reflect.Method JavaDoc;
21
22 /**
23  * Canonical MethodMatcher instance that matches all methods.
24  *
25  * @author Rod Johnson
26  */

27 class TrueMethodMatcher implements MethodMatcher, Serializable JavaDoc {
28     
29     public static final TrueMethodMatcher INSTANCE = new TrueMethodMatcher();
30     
31     /**
32      * Enforce Singleton pattern.
33      */

34     private TrueMethodMatcher() {
35     }
36
37     public boolean isRuntime() {
38         return false;
39     }
40
41     public boolean matches(Method JavaDoc method, Class JavaDoc targetClass) {
42         return true;
43     }
44
45     public boolean matches(Method JavaDoc method, Class JavaDoc targetClass, Object JavaDoc[] args) {
46         // Should never be invoked as isRuntime returns false.
47
throw new UnsupportedOperationException JavaDoc();
48     }
49     
50     /**
51      * Required to support serialization. Replaces with canonical
52      * instance on deserialization, protecting Singleton pattern.
53      * Alternative to overriding <code>equals()</code>.
54      */

55     private Object JavaDoc readResolve() {
56         return INSTANCE;
57     }
58     
59     public String JavaDoc toString() {
60         return "MethodMatcher.TRUE";
61     }
62
63 }
64
Popular Tags