001    /**
002     *  Licensed to the Apache Software Foundation (ASF) under one or more
003     *  contributor license agreements.  See the NOTICE file distributed with
004     *  this work for additional information regarding copyright ownership.
005     *  The ASF licenses this file to You under the Apache License, Version 2.0
006     *  (the "License"); you may not use this file except in compliance with
007     *  the License.  You may obtain a copy of the License at
008     *
009     *     http://www.apache.org/licenses/LICENSE-2.0
010     *
011     *  Unless required by applicable law or agreed to in writing, software
012     *  distributed under the License is distributed on an "AS IS" BASIS,
013     *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014     *  See the License for the specific language governing permissions and
015     *  limitations under the License.
016     */
017    package org.apache.geronimo.axis.client;
018    
019    import java.lang.reflect.Method;
020    import java.lang.reflect.Modifier;
021    
022    import net.sf.cglib.proxy.CallbackFilter;
023    
024    /**
025     * @version $Rev: 476049 $ $Date: 2006-11-16 23:35:17 -0500 (Thu, 16 Nov 2006) $
026     */
027    public class NoOverrideCallbackFilter implements CallbackFilter {
028        private Class superClass;
029    
030        public NoOverrideCallbackFilter(Class superClass) {
031            this.superClass = superClass;
032        }
033    
034        public int accept(Method method) {
035            // we don't intercept non-public methods like finalize
036            if (!Modifier.isPublic(method.getModifiers())) {
037                return 0;
038            }
039    
040            if (method.getName().equals("remove") && Modifier.isAbstract(method.getModifiers())) {
041                return 1;
042            }
043    
044            try {
045                // if the super class defined this method don't intercept
046                superClass.getMethod(method.getName(), method.getParameterTypes());
047                return 0;
048            } catch (Throwable e) {
049                return 1;
050            }
051        }
052        
053        public boolean equals(Object other) {
054            if (other == null) {
055                return false;
056            }
057            if (other == this) {
058                return true;
059            }
060    
061            NoOverrideCallbackFilter otherFilter = null;
062            if (other instanceof NoOverrideCallbackFilter) {
063                otherFilter = (NoOverrideCallbackFilter) other;
064            }
065            else {
066                return false;
067            }
068                        
069          return superClass.equals(otherFilter.superClass);
070        }
071    
072        public int hashCode()
073        {
074          return superClass.hashCode();
075        }
076        
077    }