KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > picocontainer > gems > adapters > 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.adapters;
12
13 import com.thoughtworks.proxy.ProxyFactory;
14 import com.thoughtworks.proxy.factory.StandardProxyFactory;
15
16 import org.picocontainer.ComponentAdapter;
17 import org.picocontainer.Parameter;
18 import org.picocontainer.PicoIntrospectionException;
19 import org.picocontainer.defaults.AssignabilityRegistrationException;
20 import org.picocontainer.defaults.ComponentAdapterFactory;
21 import org.picocontainer.defaults.DecoratingComponentAdapterFactory;
22 import org.picocontainer.defaults.DefaultComponentAdapterFactory;
23 import org.picocontainer.defaults.NotConcreteRegistrationException;
24
25
26 /**
27  * Hides implementation.
28  *
29  * @author Paul Hammant
30  * @author Aslak Hellesøy
31  * @version $Revision: 2252 $
32  * @see HotSwappingComponentAdapter
33  */

34 public class HotSwappingComponentAdapterFactory extends DecoratingComponentAdapterFactory {
35     private final ProxyFactory proxyFactory;
36
37     public HotSwappingComponentAdapterFactory() {
38         this(new DefaultComponentAdapterFactory());
39     }
40
41     public HotSwappingComponentAdapterFactory(ComponentAdapterFactory delegate) {
42         this(delegate, new StandardProxyFactory());
43     }
44
45     public HotSwappingComponentAdapterFactory(ComponentAdapterFactory delegate, ProxyFactory proxyFactory) {
46         super(delegate);
47         this.proxyFactory = proxyFactory;
48     }
49
50     public ComponentAdapter createComponentAdapter(Object JavaDoc componentKey, Class JavaDoc componentImplementation, 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