01: /*****************************************************************************
02: * Copyright (c) PicoContainer Organization. All rights reserved. *
03: * ------------------------------------------------------------------------- *
04: * The software in this package is published under the terms of the BSD *
05: * style license a copy of which has been included with this distribution in *
06: * the LICENSE.txt file. *
07: * *
08: * Idea by Rachel Davies, Original code by various *
09: *****************************************************************************/package org.nanocontainer.aop.defaults;
10:
11: import org.nanocontainer.aop.AspectsApplicator;
12: import org.picocontainer.ComponentAdapter;
13: import org.picocontainer.Parameter;
14: import org.picocontainer.PicoIntrospectionException;
15: import org.picocontainer.defaults.AssignabilityRegistrationException;
16: import org.picocontainer.defaults.ComponentAdapterFactory;
17: import org.picocontainer.defaults.DecoratingComponentAdapterFactory;
18: import org.picocontainer.defaults.DefaultComponentAdapterFactory;
19: import org.picocontainer.defaults.NotConcreteRegistrationException;
20:
21: /**
22: * Produces component adapters that apply aspects to components.
23: *
24: * @author Stephen Molitor
25: * @version $Revision: 3144 $
26: */
27: public class AspectsComponentAdapterFactory extends
28: 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(
43: AspectsApplicator aspectsApplicator,
44: ComponentAdapterFactory delegate) {
45: super (delegate);
46: this .aspectsApplicator = aspectsApplicator;
47: }
48:
49: /**
50: * Creates a new <code>AspectsComponentAdapterFactory</code>. The factory
51: * will produce <code>AspectsComponentAdapter</code> objects that will use
52: * <code>aspectsApplicator</code> to apply aspects to components produced
53: * by a
54: * <code>org.picocontainer.defaults.DefaultComponentAdapterFactory</code>.
55: *
56: * @param aspectsApplicator used to apply the aspects.
57: */
58: public AspectsComponentAdapterFactory(
59: AspectsApplicator aspectsApplicator) {
60: this (aspectsApplicator, new DefaultComponentAdapterFactory());
61: }
62:
63: public ComponentAdapter createComponentAdapter(Object componentKey,
64: Class componentImplementation, Parameter[] parameters)
65: throws PicoIntrospectionException,
66: AssignabilityRegistrationException,
67: NotConcreteRegistrationException {
68: return new AspectsComponentAdapter(aspectsApplicator, super
69: .createComponentAdapter(componentKey,
70: componentImplementation, parameters));
71: }
72:
73: }
|