KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > avalon > fortress > ContainerManager


1 /*
2  * Copyright 2003-2004 The Apache Software Foundation
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  * http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
12  * implied.
13  *
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */

17
18 package org.apache.avalon.fortress;
19
20 /**
21  * The ContainerManager is a single point of contact to manage your Container
22  * resources. It takes care of creating the other managers that a Container
23  * needs to use, as well as initializing the Container. It is designed to be
24  * directly instantiated by whatever class needs to initialize your system.
25  *
26  * <p>
27  * The ContainerManager provides some constants used in the initial
28  * <code>Parameters</code> passed into the ContainerManager. The
29  * ContainerManager uses these values to create all the pieces necessary
30  * for the Container. Below is a table that describes what those options
31  * are.
32  * </p>
33  *
34  * <p>You can think of a ContainerManager is a pocket universe for a impl and its
35  * components.</p>
36  *
37  * <p><b>Case 1: Use by a servlet or other "root" entity</b></p>
38  *
39  * <pre>
40  * <code>
41  * FortressConfig config = new FortressConfig();
42  * config.setContainerClass( Thread.currentThread().getContextClassLoader().loadClass( "org.apache.avalon.fortress.test.TestContainer" ) );
43  * config.setContextDirectory( "./" );
44  * config.setWorkDirectory( "./" );
45  * config.setContainerConfiguration( "resource://org.apache.avalon.fortress/test/ContainerProfile.xconf" );
46  * config.setLoggerManagerConfiguration( "resource://org.apache.avalon.fortress/test/ContainerProfile.xlog" );
47  *
48  * ContextManager contextManager = config.getContext();
49  * ContainerManager containerManager = new DefaultContainerManager( contextManager );
50  * ContainerUtil.initialize( containerManager );
51  * </code>
52  * </pre>
53  *
54  * Then, for example, wait for a request and pass it on to the impl:
55  *
56  * <pre>
57  * <code>
58  * TestContainer impl = (TestContainer) containerManager.getContainer();
59  * impl.handleRequest( ... );
60  * </code>
61  * </pre>
62  *
63  * When done, dispose of the managers.
64  *
65  * <pre>
66  * <code>
67  * ContainerUtil.dispose( containerManager );
68  * ContainerUtil.dispose( contextManager );
69  * </code>
70  * </pre>
71  *
72  * @author <a HREF="mailto:dev@avalon.apache.org">The Avalon Team</a>
73  * @version CVS $Revision: 1.9 $ $Date: 2004/02/28 15:16:24 $
74  * @see ContainerManagerConstants for the contract surrounding the ContainerManager context
75  */

76 public interface ContainerManager
77 {
78     /**
79      * Get a reference to the managed Container. This instance is typically cast to
80      * the interface used to interact with the impl.
81      *
82      * @return the container implementation
83      */

84     Object JavaDoc getContainer();
85 }
86
Popular Tags