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 java.util.HashMap; 013 import java.util.Map; 014 015 import org.picocontainer.ComponentAdapter; 016 import org.picocontainer.Parameter; 017 import org.picocontainer.PicoIntrospectionException; 018 019 /** 020 * A {@link ComponentAdapterFactory} that creates 021 * {@link BeanPropertyComponentAdapter} instances. 022 * 023 * @author Aslak Hellesøy 024 * @version $Revision: 2320 $ 025 * @since 1.0 026 */ 027 public class BeanPropertyComponentAdapterFactory extends DecoratingComponentAdapterFactory { 028 private Map adapterCache = new HashMap(); 029 030 /** 031 * Construct a BeanPropertyComponentAdapterFactory. 032 * 033 * @param delegate the wrapped factory. 034 */ 035 public BeanPropertyComponentAdapterFactory(ComponentAdapterFactory delegate) { 036 super(delegate); 037 } 038 039 /** 040 * {@inheritDoc} 041 */ 042 public ComponentAdapter createComponentAdapter(Object componentKey, Class componentImplementation, Parameter[] parameters) throws PicoIntrospectionException, AssignabilityRegistrationException, NotConcreteRegistrationException { 043 ComponentAdapter decoratedAdapter = super.createComponentAdapter(componentKey, componentImplementation, parameters); 044 BeanPropertyComponentAdapter propertyAdapter = new BeanPropertyComponentAdapter(decoratedAdapter); 045 adapterCache.put(componentKey, propertyAdapter); 046 return propertyAdapter; 047 } 048 049 // TODO: What is this method for? It is not used in complete Pico/Nano and caching is normally done by CachingCA ... 050 /** 051 * @deprecated 052 */ 053 public BeanPropertyComponentAdapter getComponentAdapter(Object key) { 054 return (BeanPropertyComponentAdapter) adapterCache.get(key); 055 } 056 }