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.defaults;
011
012 import org.picocontainer.ComponentAdapter;
013 import org.picocontainer.Parameter;
014 import org.picocontainer.PicoIntrospectionException;
015
016 /**
017 * @author Aslak Hellesøy
018 * @see org.picocontainer.gems.HotSwappingComponentAdapterFactory for a more feature-rich version of the class
019 * @since 1.2, moved from package {@link org.picocontainer.alternatives}
020 */
021 public class ImplementationHidingComponentAdapterFactory extends DecoratingComponentAdapterFactory {
022 private final boolean strict;
023
024 /**
025 * For serialisation only. Do not use this constructor explicitly.
026 */
027 public ImplementationHidingComponentAdapterFactory() {
028 this(null);
029 }
030
031 public ImplementationHidingComponentAdapterFactory(ComponentAdapterFactory delegate, boolean strict) {
032 super(delegate);
033 this.strict = strict;
034 }
035
036 public ImplementationHidingComponentAdapterFactory(ComponentAdapterFactory delegate) {
037 this(delegate, true);
038 }
039
040 public ComponentAdapter createComponentAdapter(Object componentKey, Class componentImplementation, Parameter[] parameters) throws PicoIntrospectionException, AssignabilityRegistrationException, NotConcreteRegistrationException {
041 return new ImplementationHidingComponentAdapter(super.createComponentAdapter(componentKey, componentImplementation, parameters), strict);
042 }
043 }