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 * Idea by Rachel Davies, Original code by Aslak Hellesoy and Paul Hammant * 009 *****************************************************************************/ 010 011 package org.picocontainer.defaults; 012 013 import org.picocontainer.ComponentAdapter; 014 import org.picocontainer.ComponentMonitor; 015 import org.picocontainer.Parameter; 016 import org.picocontainer.PicoIntrospectionException; 017 018 /** 019 * @author Jon Tirsén 020 * @version $Revision: 2654 $ 021 */ 022 public class ConstructorInjectionComponentAdapterFactory extends MonitoringComponentAdapterFactory { 023 private final boolean allowNonPublicClasses; 024 private LifecycleStrategy lifecycleStrategy; 025 026 public ConstructorInjectionComponentAdapterFactory(boolean allowNonPublicClasses, 027 ComponentMonitor monitor, LifecycleStrategy lifecycleStrategy) { 028 this.allowNonPublicClasses = allowNonPublicClasses; 029 this.changeMonitor(monitor); 030 this.lifecycleStrategy = lifecycleStrategy; 031 } 032 033 public ConstructorInjectionComponentAdapterFactory(boolean allowNonPublicClasses, ComponentMonitor monitor) { 034 this(allowNonPublicClasses, monitor, new DefaultLifecycleStrategy(monitor)); 035 } 036 037 public ConstructorInjectionComponentAdapterFactory(boolean allowNonPublicClasses, LifecycleStrategy lifecycleStrategy) { 038 this(allowNonPublicClasses, new DelegatingComponentMonitor(), lifecycleStrategy); 039 } 040 041 public ConstructorInjectionComponentAdapterFactory(boolean allowNonPublicClasses) { 042 this(allowNonPublicClasses, new DelegatingComponentMonitor()); 043 } 044 045 public ConstructorInjectionComponentAdapterFactory() { 046 this(false); 047 } 048 049 public ComponentAdapter createComponentAdapter(Object componentKey, 050 Class componentImplementation, 051 Parameter[] parameters) 052 throws PicoIntrospectionException, AssignabilityRegistrationException, NotConcreteRegistrationException { 053 return new ConstructorInjectionComponentAdapter(componentKey, componentImplementation, parameters, 054 allowNonPublicClasses, currentMonitor(), lifecycleStrategy); 055 } 056 }