KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > geronimo > axis > client > NoOverrideCallbackFilter


1 /**
2  * Licensed to the Apache Software Foundation (ASF) under one or more
3  * contributor license agreements. See the NOTICE file distributed with
4  * this work for additional information regarding copyright ownership.
5  * The ASF licenses this file to You under the Apache License, Version 2.0
6  * (the "License"); you may not use this file except in compliance with
7  * the License. You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */

17 package org.apache.geronimo.axis.client;
18
19 import java.lang.reflect.Method JavaDoc;
20 import java.lang.reflect.Modifier JavaDoc;
21
22 import net.sf.cglib.proxy.CallbackFilter;
23
24 /**
25  * @version $Rev: 476049 $ $Date: 2006-11-16 23:35:17 -0500 (Thu, 16 Nov 2006) $
26  */

27 public class NoOverrideCallbackFilter implements CallbackFilter {
28     private Class JavaDoc superClass;
29
30     public NoOverrideCallbackFilter(Class JavaDoc superClass) {
31         this.superClass = superClass;
32     }
33
34     public int accept(Method JavaDoc method) {
35         // we don't intercept non-public methods like finalize
36
if (!Modifier.isPublic(method.getModifiers())) {
37             return 0;
38         }
39
40         if (method.getName().equals("remove") && Modifier.isAbstract(method.getModifiers())) {
41             return 1;
42         }
43
44         try {
45             // if the super class defined this method don't intercept
46
superClass.getMethod(method.getName(), method.getParameterTypes());
47             return 0;
48         } catch (Throwable JavaDoc e) {
49             return 1;
50         }
51     }
52     
53     public boolean equals(Object JavaDoc other) {
54         if (other == null) {
55             return false;
56         }
57         if (other == this) {
58             return true;
59         }
60
61         NoOverrideCallbackFilter otherFilter = null;
62         if (other instanceof NoOverrideCallbackFilter) {
63             otherFilter = (NoOverrideCallbackFilter) other;
64         }
65         else {
66             return false;
67         }
68                     
69       return superClass.equals(otherFilter.superClass);
70     }
71
72     public int hashCode()
73     {
74       return superClass.hashCode();
75     }
76     
77 }
78
Popular Tags