001 /*****************************************************************************
002 * Copyright (C) PicoContainer Organization. All rights reserved. *
003 * ------------------------------------------------------------------------- *
004 * The software in this package is published under the terms of the BSD *
005 * style license a copy of which has been included with this distribution in *
006 * the LICENSE.txt file. *
007 * *
008 * Original code by *
009 *****************************************************************************/
010 package org.picocontainer.behaviors;
011
012 import org.picocontainer.ComponentAdapter;
013 import org.picocontainer.Parameter;
014 import org.picocontainer.ComponentMonitor;
015 import org.picocontainer.LifecycleStrategy;
016 import org.picocontainer.Characteristics;
017 import org.picocontainer.behaviors.AbstractBehaviorFactory;
018
019 import java.util.Properties;
020
021 /**
022 * @author Aslak Hellesøy
023 */
024 public class Locking extends AbstractBehaviorFactory {
025
026 public ComponentAdapter createComponentAdapter(ComponentMonitor componentMonitor,
027 LifecycleStrategy lifecycleStrategy,
028 Properties componentProperties,
029 Object componentKey,
030 Class componentImplementation,
031 Parameter... parameters) {
032 removePropertiesIfPresent(componentProperties, Characteristics.SYNCHRONIZE);
033 return new Locked(super.createComponentAdapter(
034 componentMonitor,
035 lifecycleStrategy,
036 componentProperties,
037 componentKey,
038 componentImplementation,
039 parameters));
040 }
041
042 public ComponentAdapter addComponentAdapter(ComponentMonitor componentMonitor,
043 LifecycleStrategy lifecycleStrategy,
044 Properties componentProperties,
045 ComponentAdapter adapter) {
046 removePropertiesIfPresent(componentProperties, Characteristics.SYNCHRONIZE);
047 return new Synchronized(super.addComponentAdapter(componentMonitor,
048 lifecycleStrategy,
049 componentProperties,
050 adapter));
051 }
052 }