KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > nanocontainer > aop > dynaop > ComponentAspect


1 /*****************************************************************************
2  * Copyright (c) PicoContainer Organization. All rights reserved. *
3  * ------------------------------------------------------------------------- *
4  * The software in this package is published under the terms of the BSD *
5  * style license a copy of which has been included with this distribution in *
6  * the LICENSE.txt file. *
7  * *
8  * Idea by Rachel Davies, Original code by various *
9  *****************************************************************************/

10 package org.nanocontainer.aop.dynaop;
11
12 import dynaop.Aspects;
13 import org.nanocontainer.aop.ComponentPointcut;
14
15 /**
16  * Aspect that applies to the set of components matched by a
17  * <code>org.nanocontainer.aop.ComponentPointcut</code>.
18  *
19  * @author Stephen Molitor
20  * @version $Revision: 3144 $
21  */

22 abstract class ComponentAspect {
23
24     private final ComponentPointcut componentPointcut;
25
26     /**
27      * Creates a new <code>ComponentAspect</code> with the given component
28      * pointcut.
29      *
30      * @param componentPointcut the component pointcut.
31      */

32     ComponentAspect(ComponentPointcut componentPointcut) {
33         this.componentPointcut = componentPointcut;
34     }
35
36     /**
37      * Registers this aspect with <code>aspects</code> if the component
38      * pointcut passed to the constructor picks the <code>componentKey</code>.
39      * Template method that calls <code>doRegisterAspect</code> if the
40      * component key matches.
41      *
42      * @param componentKey the component key to match against.
43      * @param aspects the <code>dynaop.Aspects</code> collection.
44      */

45     final void registerAspect(Object JavaDoc componentKey, Aspects aspects) {
46         if (componentPointcut.picks(componentKey)) {
47             doRegisterAspect(componentKey, aspects);
48         }
49     }
50
51     /**
52      * Called by <code>registerAspect</code> to
53      *
54      * @param componentKey
55      * @param aspects
56      */

57     abstract void doRegisterAspect(Object JavaDoc componentKey, Aspects aspects);
58
59 }
Popular Tags