KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > picocontainer > gems > HotSwappingComponentAdapterFactory


1 /*****************************************************************************
2  * Copyright (c) PicoContainer Organization. All rights reserved. *
3  * ------------------------------------------------------------------------- *
4  * The software in this package is published under the terms of the BSD *
5  * style license a copy of which has been included with this distribution in *
6  * the LICENSE.txt file. *
7  * *
8  * Idea by Rachel Davies, Original code by Aslak Hellesoy and Paul Hammant *
9  *****************************************************************************/

10
11 package org.picocontainer.gems;
12
13 import com.thoughtworks.proxy.ProxyFactory;
14 import com.thoughtworks.proxy.factory.StandardProxyFactory;
15 import org.picocontainer.ComponentAdapter;
16 import org.picocontainer.Parameter;
17 import org.picocontainer.PicoIntrospectionException;
18 import org.picocontainer.defaults.AssignabilityRegistrationException;
19 import org.picocontainer.defaults.ComponentAdapterFactory;
20 import org.picocontainer.defaults.DecoratingComponentAdapterFactory;
21 import org.picocontainer.defaults.DefaultComponentAdapterFactory;
22 import org.picocontainer.defaults.NotConcreteRegistrationException;
23
24 /**
25  * Hides implementation.
26  *
27  * @author Paul Hammant
28  * @author Aslak Hellesøy
29  * @version $Revision: 2002 $
30  * @see HotSwappingComponentAdapter
31  */

32 public class HotSwappingComponentAdapterFactory extends DecoratingComponentAdapterFactory {
33     private final ProxyFactory proxyFactory;
34
35     public HotSwappingComponentAdapterFactory() {
36         this(new DefaultComponentAdapterFactory());
37     }
38
39     public HotSwappingComponentAdapterFactory(ComponentAdapterFactory delegate) {
40         this(delegate, new StandardProxyFactory());
41     }
42
43     public HotSwappingComponentAdapterFactory(ComponentAdapterFactory delegate, ProxyFactory proxyFactory) {
44         super(delegate);
45         this.proxyFactory = proxyFactory;
46     }
47
48     public ComponentAdapter createComponentAdapter(Object JavaDoc componentKey,
49                                                    Class JavaDoc componentImplementation,
50                                                    Parameter[] parameters)
51             throws PicoIntrospectionException, AssignabilityRegistrationException, NotConcreteRegistrationException {
52         ComponentAdapter componentAdapter = super.createComponentAdapter(componentKey, componentImplementation, parameters);
53         return new HotSwappingComponentAdapter(componentAdapter, proxyFactory);
54     }
55 }
56
Popular Tags