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.ComponentMonitor;
14: import org.picocontainer.LifecycleStrategy;
15: import org.picocontainer.Characteristics;
16: import org.picocontainer.behaviors.AbstractBehaviorFactory;
17:
18: import java.util.Properties;
19:
20: /**
21: * @author Aslak Hellesøy
22: */
23: public class Locking extends AbstractBehaviorFactory {
24:
25: public ComponentAdapter createComponentAdapter(
26: ComponentMonitor componentMonitor,
27: LifecycleStrategy lifecycleStrategy,
28: Properties componentProperties, Object componentKey,
29: Class componentImplementation, Parameter... parameters) {
30: removePropertiesIfPresent(componentProperties,
31: Characteristics.SYNCHRONIZE);
32: return new Locked(super .createComponentAdapter(
33: componentMonitor, lifecycleStrategy,
34: componentProperties, componentKey,
35: componentImplementation, parameters));
36: }
37:
38: public ComponentAdapter addComponentAdapter(
39: ComponentMonitor componentMonitor,
40: LifecycleStrategy lifecycleStrategy,
41: Properties componentProperties, ComponentAdapter adapter) {
42: removePropertiesIfPresent(componentProperties,
43: Characteristics.SYNCHRONIZE);
44: return new Synchronized(super.addComponentAdapter(
45: componentMonitor, lifecycleStrategy,
46: componentProperties, adapter));
47: }
48: }
|