KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > nanocontainer > aop > defaults > AspectsComponentAdapterFactory


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.defaults;
11
12 import org.nanocontainer.aop.AspectsApplicator;
13 import org.picocontainer.ComponentAdapter;
14 import org.picocontainer.Parameter;
15 import org.picocontainer.PicoIntrospectionException;
16 import org.picocontainer.defaults.AssignabilityRegistrationException;
17 import org.picocontainer.defaults.ComponentAdapterFactory;
18 import org.picocontainer.defaults.DecoratingComponentAdapterFactory;
19 import org.picocontainer.defaults.DefaultComponentAdapterFactory;
20 import org.picocontainer.defaults.NotConcreteRegistrationException;
21
22 /**
23  * Produces component adapters that apply aspects to components.
24  *
25  * @author Stephen Molitor
26  * @version $Revision: 3144 $
27  */

28 public class AspectsComponentAdapterFactory extends DecoratingComponentAdapterFactory {
29
30     private final AspectsApplicator aspectsApplicator;
31
32     /**
33      * Creates a new <code>AspectsComponentAdapterFactory</code>. The factory
34      * will produce <code>AspectsComponentAdapter</code> objects that will use
35      * <code>aspectsApplicator</code> to apply aspects to components produced
36      * by <code>delegate</code>.
37      *
38      * @param aspectsApplicator used to apply the aspects.
39      * @param delegate the real component adapter factory that this factory
40      * delegates to.
41      */

42     public AspectsComponentAdapterFactory(AspectsApplicator aspectsApplicator, ComponentAdapterFactory delegate) {
43         super(delegate);
44         this.aspectsApplicator = aspectsApplicator;
45     }
46
47     /**
48      * Creates a new <code>AspectsComponentAdapterFactory</code>. The factory
49      * will produce <code>AspectsComponentAdapter</code> objects that will use
50      * <code>aspectsApplicator</code> to apply aspects to components produced
51      * by a
52      * <code>org.picocontainer.defaults.DefaultComponentAdapterFactory</code>.
53      *
54      * @param aspectsApplicator used to apply the aspects.
55      */

56     public AspectsComponentAdapterFactory(AspectsApplicator aspectsApplicator) {
57         this(aspectsApplicator, new DefaultComponentAdapterFactory());
58     }
59
60     public ComponentAdapter createComponentAdapter(Object JavaDoc componentKey, Class JavaDoc componentImplementation,
61                                                    Parameter[] parameters) throws PicoIntrospectionException, AssignabilityRegistrationException,
62             NotConcreteRegistrationException {
63         return new AspectsComponentAdapter(aspectsApplicator, super.createComponentAdapter(componentKey,
64                 componentImplementation, parameters));
65     }
66
67 }
Popular Tags