KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > nanocontainer > aop > dynaop > ContainerLoader


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 various *
9  *****************************************************************************/

10 package org.nanocontainer.aop.dynaop;
11
12 import org.picocontainer.PicoContainer;
13 import org.picocontainer.PicoInitializationException;
14
15 /**
16  * Loads a <code>PicoContainer</code> 'late'. Used to create a late-loading
17  * <code>PicoContainer</code> proxy which is passed to
18  * <code>dynaop.MixinFactory</code> and <code>dynaop.InterceptorFactory</code>
19  * objects whose mixin or interceptor advice is a component in the container,
20  * specified by component key. The container object may be created after the
21  * advice factories.
22  *
23  * @author Stephen Molitor
24  * @version $Revision: 3144 $
25  */

26 class ContainerLoader {
27
28     private PicoContainer container;
29
30     /**
31      * Gets the Pico container. The <code>setContainer</code> method must have
32      * been called prior to calling this method.
33      *
34      * @return the loaded <code>PicoContainer</code> object.
35      * @throws PicoInitializationException if the container has not been set.
36      */

37     PicoContainer getContainer() {
38         if (container == null) {
39             throw new PicoInitializationException("Container has not been set");
40         }
41         return container;
42     }
43
44     /**
45      * Sets the container.
46      *
47      * @param container the <code>PicoContainer</code>.
48      */

49     void setContainer(PicoContainer container) {
50         this.container = container;
51     }
52
53 }
Popular Tags