KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > nanocontainer > reflection > ImplementationHidingNanoPicoContainer


1 /*****************************************************************************
2  * Copyright (C) NanoContainer 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  * Original code by Paul Hammant *
9  *****************************************************************************/

10
11 package org.nanocontainer.reflection;
12
13 import java.io.Serializable JavaDoc;
14
15 import org.nanocontainer.NanoPicoContainer;
16 import org.picocontainer.MutablePicoContainer;
17 import org.picocontainer.PicoContainer;
18 import org.picocontainer.alternatives.ImplementationHidingPicoContainer;
19 import org.picocontainer.defaults.ComponentAdapterFactory;
20 import org.picocontainer.defaults.DefaultComponentAdapterFactory;
21
22 /**
23  * This is a MutablePicoContainer that supports soft composition and hides implementations where it can.
24  * <p/>
25  * In terms of implementation it adopts the behaviour of ImplementationHidingPicoContainer
26  * and DefaulNanoContainer
27  *
28  * @author Paul Hammant
29  * @author Michael Rimov
30  * @version $Revision: 2964 $
31  */

32 public class ImplementationHidingNanoPicoContainer extends AbstractNanoPicoContainer implements NanoPicoContainer, Serializable JavaDoc {
33
34     public ImplementationHidingNanoPicoContainer(ClassLoader JavaDoc classLoader, ComponentAdapterFactory caf, PicoContainer parent) {
35         super(new ImplementationHidingPicoContainer(caf, parent), classLoader);
36     }
37
38
39     public ImplementationHidingNanoPicoContainer(ClassLoader JavaDoc classLoader, PicoContainer parent) {
40         super(new ImplementationHidingPicoContainer(new DefaultComponentAdapterFactory(), parent), classLoader);
41     }
42
43     public ImplementationHidingNanoPicoContainer(PicoContainer pc) {
44         this(ImplementationHidingNanoPicoContainer.class.getClassLoader(), pc);
45     }
46
47     public ImplementationHidingNanoPicoContainer(ClassLoader JavaDoc classLoader) {
48         this(classLoader, null);
49     }
50
51     public ImplementationHidingNanoPicoContainer() {
52         this(ImplementationHidingNanoPicoContainer.class.getClassLoader(), null);
53     }
54
55     /**
56      * Copy Constructor. Makes a new ImplementationHidingNanoPicoContainer with the same
57      * attributes - ClassLoader, child PicoContainer type, ComponentAdapterFactory -
58      * as the parent.
59      * <p><tt>Note:</tt> This constructor is protected because are existing scripts
60      * that call <tt>new ImplementationHidingNanoPicoContainer(PicoContainer)</tt>, and they get this
61      * constructor instead (which has different behavior).</p>
62      * @param parent ImplementationHidingNanoPicoContainer
63      */

64     protected ImplementationHidingNanoPicoContainer(final ImplementationHidingNanoPicoContainer parent) {
65         super(parent.getDelegate().makeChildContainer(), parent.getComponentClassLoader());
66     }
67
68
69     protected AbstractNanoPicoContainer createChildContainer() {
70         return new ImplementationHidingNanoPicoContainer(this);
71     }
72 }
73
Popular Tags