/* Copyright 2004 Acegi Technology Pty Limited
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package net.sf.acegisecurity.intercept.method;

import net.sf.acegisecurity.ConfigAttributeDefinition;

import org.aopalliance.intercept.MethodInvocation;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;


/**
 * Abstract implementation of <Code>MethodDefinitionSource</code>.
 *
 * @author Ben Alex
 * @version $Id$
 */
public abstract class AbstractMethodDefinitionSource
    implements MethodDefinitionSource {
    //~ Static fields/initializers =============================================

    private static final Log logger = LogFactory.getLog(AbstractMethodDefinitionSource.class);

    //~ Methods ================================================================

    public ConfigAttributeDefinition getAttributes(Object object)
        throws IllegalArgumentException {
        if ((object == null) || !this.supports(object.getClass())) {
            throw new IllegalArgumentException(
                "Object must be a MethodInvocation");
        }

        return this.lookupAttributes((MethodInvocation) object);
    }

    public boolean supports(Class clazz) {
        if (MethodInvocation.class.isAssignableFrom(clazz)) {
            return true;
        } else {
            return false;
        }
    }

    /**
     * Performs the actual lookup of the relevant
     * <code>ConfigAttributeDefinition</code> for the specified
     * <code>MethodInvocation</code>.
     * 
     * <P>
     * Provided so subclasses need only to provide one basic method to properly
     * interface with the <code>MethodDefinitionSource</code>.
     * </p>
     *
     * @return the <code>ConfigAttributeDefinition</code> that applies to the
     *         specified <code>MethodInvocation</code>
     */
    protected abstract ConfigAttributeDefinition lookupAttributes(
        MethodInvocation mi);
}

@@ -2200,16 +2200,268 @@
  * %3C/p%3E%0A
+     * %0A     * %3Cp%3E%0A     * Returns %3Ccode%3Enull%3C/code%3E if there are no matching attributes for the%0A     * method invocation.%0A     * %3C/p%3E%0A     *%0A     * @param mi the method being invoked for which configuration attributes%0A     *        should be looked up%0A
      *%0A 

Improve documentation for abstract contract.