All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.nanocontainer.aop.dynaop..svn.text-base.ComponentAspect.svn-base Maven / Gradle / Ivy

/*****************************************************************************
 * Copyright (c) PicoContainer Organization. All rights reserved.            *
 * ------------------------------------------------------------------------- *
 * The software in this package is published under the terms of the BSD      *
 * style license a copy of which has been included with this distribution in *
 * the LICENSE.txt file.                                                     *
 *                                                                           *
 * Idea by Rachel Davies, Original code by various                           *
 *****************************************************************************/
package org.nanocontainer.aop.dynaop;

import dynaop.Aspects;
import org.nanocontainer.aop.ComponentPointcut;

/**
 * Aspect that applies to the set of components matched by a
 * org.nanocontainer.aop.ComponentPointcut.
 *
 * @author Stephen Molitor
 * @version $Revision$
 */
abstract class ComponentAspect {

    private final ComponentPointcut componentPointcut;

    /**
     * Creates a new ComponentAspect with the given component
     * pointcut.
     *
     * @param componentPointcut the component pointcut.
     */
    ComponentAspect(ComponentPointcut componentPointcut) {
        this.componentPointcut = componentPointcut;
    }

    /**
     * Registers this aspect with aspects if the component
     * pointcut passed to the constructor picks the componentKey.
     * Template method that calls doRegisterAspect if the
     * component key matches.
     *
     * @param componentKey the component key to match against.
     * @param aspects      the dynaop.Aspects collection.
     */
    final void registerAspect(Object componentKey, Aspects aspects) {
        if (componentPointcut.picks(componentKey)) {
            doRegisterAspect(componentKey, aspects);
        }
    }

    /**
     * Called by registerAspect to
     *
     * @param componentKey
     * @param aspects
     */
    abstract void doRegisterAspect(Object componentKey, Aspects aspects);

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy