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: * Original code by *
09: *****************************************************************************/package org.picocontainer.behaviors;
10:
11: import org.picocontainer.ComponentAdapter;
12: import org.picocontainer.Parameter;
13: import org.picocontainer.PicoCompositionException;
14: import org.picocontainer.ComponentMonitor;
15: import org.picocontainer.LifecycleStrategy;
16: import org.picocontainer.Characteristics;
17: import org.picocontainer.behaviors.AbstractBehaviorFactory;
18: import org.picocontainer.behaviors.PropertyApplicator;
19:
20: import java.util.Properties;
21:
22: /**
23: * A {@link org.picocontainer.ComponentFactory} that creates
24: * {@link PropertyApplicator} instances.
25: *
26: * @author Aslak Hellesøy
27: */
28: public final class PropertyApplying extends AbstractBehaviorFactory {
29:
30: public <T> ComponentAdapter<T> createComponentAdapter(
31: ComponentMonitor componentMonitor,
32: LifecycleStrategy lifecycleStrategy,
33: Properties componentProperties, Object componentKey,
34: Class<T> componentImplementation, Parameter... parameters)
35: throws PicoCompositionException {
36: ComponentAdapter<?> decoratedAdapter = super
37: .createComponentAdapter(componentMonitor,
38: lifecycleStrategy, componentProperties,
39: componentKey, componentImplementation,
40: parameters);
41: removePropertiesIfPresent(componentProperties,
42: Characteristics.PROPERTY_APPLYING);
43: return new PropertyApplicator(decoratedAdapter);
44: }
45:
46: public <T> ComponentAdapter<T> addComponentAdapter(
47: ComponentMonitor componentMonitor,
48: LifecycleStrategy lifecycleStrategy,
49: Properties componentProperties, ComponentAdapter<T> adapter) {
50: removePropertiesIfPresent(componentProperties,
51: Characteristics.PROPERTY_APPLYING);
52: return new PropertyApplicator(super.addComponentAdapter(
53: componentMonitor, lifecycleStrategy,
54: componentProperties, adapter));
55: }
56: }
|