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.gems.behaviors;
10:
11: import org.picocontainer.LifecycleStrategy;
12: import org.picocontainer.ComponentAdapter;
13: import org.picocontainer.Parameter;
14: import org.picocontainer.PicoCompositionException;
15: import org.picocontainer.ComponentMonitor;
16: import org.picocontainer.Characteristics;
17: import org.picocontainer.behaviors.AbstractBehaviorFactory;
18:
19: import java.util.Properties;
20:
21: public class AsmImplementationHiding extends AbstractBehaviorFactory {
22:
23: public ComponentAdapter createComponentAdapter(
24: ComponentMonitor componentMonitor,
25: LifecycleStrategy lifecycleStrategy,
26: Properties componentProperties, Object componentKey,
27: Class componentImplementation, Parameter... parameters)
28: throws PicoCompositionException {
29: if (AbstractBehaviorFactory.removePropertiesIfPresent(
30: componentProperties, Characteristics.NO_HIDE_IMPL)) {
31: return super .createComponentAdapter(componentMonitor,
32: lifecycleStrategy, componentProperties,
33: componentKey, componentImplementation, parameters);
34: }
35: AbstractBehaviorFactory.removePropertiesIfPresent(
36: componentProperties, Characteristics.HIDE_IMPL);
37: ComponentAdapter componentAdapter = super
38: .createComponentAdapter(componentMonitor,
39: lifecycleStrategy, componentProperties,
40: componentKey, componentImplementation,
41: parameters);
42: return new HiddenImplementation(componentAdapter);
43: }
44:
45: public ComponentAdapter addComponentAdapter(
46: ComponentMonitor componentMonitor,
47: LifecycleStrategy lifecycleStrategy,
48: Properties componentProperties, ComponentAdapter adapter) {
49: if (AbstractBehaviorFactory.removePropertiesIfPresent(
50: componentProperties, Characteristics.NO_HIDE_IMPL)) {
51: return super .addComponentAdapter(componentMonitor,
52: lifecycleStrategy, componentProperties, adapter);
53: }
54: AbstractBehaviorFactory.removePropertiesIfPresent(
55: componentProperties, Characteristics.HIDE_IMPL);
56: return new HiddenImplementation(super.addComponentAdapter(
57: componentMonitor, lifecycleStrategy,
58: componentProperties, adapter));
59: }
60: }
|