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 *****************************************************************************/ 009 package org.picocontainer.injectors; 010 011 import org.picocontainer.ComponentMonitor; 012 import org.picocontainer.ComponentAdapter; 013 import org.picocontainer.LifecycleStrategy; 014 import org.picocontainer.Parameter; 015 import org.picocontainer.PicoCompositionException; 016 import org.picocontainer.Characteristics; 017 import org.picocontainer.behaviors.AbstractBehaviorFactory; 018 019 import java.util.Properties; 020 021 /** @author Paul Hammant */ 022 @SuppressWarnings("serial") 023 public class MultiInjection extends AbstractInjectionFactory { 024 private final String setterPrefix; 025 026 public MultiInjection(String setterPrefix) { 027 this.setterPrefix = setterPrefix; 028 } 029 030 public MultiInjection() { 031 this("set"); 032 } 033 034 public <T> ComponentAdapter<T> createComponentAdapter(ComponentMonitor monitor, 035 LifecycleStrategy lifecycleStrategy, 036 Properties componentProperties, 037 Object componentKey, 038 Class<T> componentImplementation, 039 Parameter... parameters) throws PicoCompositionException { 040 boolean useNames = AbstractBehaviorFactory.arePropertiesPresent(componentProperties, Characteristics.USE_NAMES, true); 041 return wrapLifeCycle(new MultiInjector(componentKey, componentImplementation, parameters, monitor, setterPrefix, useNames), lifecycleStrategy); 042 } 043 }