KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > jcorporate > expresso > kernel > internal > ContainerImplBase


1 /* ====================================================================
2  * The Jcorporate Apache Style Software License, Version 1.2 05-07-2002
3  *
4  * Copyright (c) 1995-2003 Jcorporate Ltd. All rights reserved.
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions
8  * are met:
9  *
10  * 1. Redistributions of source code must retain the above copyright
11  * notice, this list of conditions and the following disclaimer.
12  *
13  * 2. Redistributions in binary form must reproduce the above copyright
14  * notice, this list of conditions and the following disclaimer in
15  * the documentation and/or other materials provided with the
16  * distribution.
17  *
18  * 3. The end-user documentation included with the redistribution,
19  * if any, must include the following acknowledgment:
20  * "This product includes software developed by Jcorporate Ltd.
21  * (http://www.jcorporate.com/)."
22  * Alternately, this acknowledgment may appear in the software itself,
23  * if and wherever such third-party acknowledgments normally appear.
24  *
25  * 4. "Jcorporate" and product names such as "Expresso" must
26  * not be used to endorse or promote products derived from this
27  * software without prior written permission. For written permission,
28  * please contact info@jcorporate.com.
29  *
30  * 5. Products derived from this software may not be called "Expresso",
31  * or other Jcorporate product names; nor may "Expresso" or other
32  * Jcorporate product names appear in their name, without prior
33  * written permission of Jcorporate Ltd.
34  *
35  * 6. No product derived from this software may compete in the same
36  * market space, i.e. framework, without prior written permission
37  * of Jcorporate Ltd. For written permission, please contact
38  * partners@jcorporate.com.
39  *
40  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
41  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
42  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
43  * DISCLAIMED. IN NO EVENT SHALL JCORPORATE LTD OR ITS CONTRIBUTORS
44  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
45  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
46  * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
47  * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
48  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
49  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
50  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51  * SUCH DAMAGE.
52  * ====================================================================
53  *
54  * This software consists of voluntary contributions made by many
55  * individuals on behalf of the Jcorporate Ltd. Contributions back
56  * to the project(s) are encouraged when you make modifications.
57  * Please send them to support@jcorporate.com. For more information
58  * on Jcorporate Ltd. and its products, please see
59  * <http://www.jcorporate.com/>.
60  *
61  * Portions of this software are based upon other open source
62  * products and are subject to their respective licenses.
63  */

64 package com.jcorporate.expresso.kernel.internal;
65
66 import com.jcorporate.expresso.kernel.ComponentContainer;
67 import com.jcorporate.expresso.kernel.Containable;
68 import com.jcorporate.expresso.kernel.ExpressoComponent;
69 import com.jcorporate.expresso.kernel.InstallLog;
70 import com.jcorporate.expresso.kernel.InstallationOptions;
71
72 import java.util.Map JavaDoc;
73
74 /**
75  * This class provides a basic implementation of the ComponentContainer interface.
76  * the majority of the information such as how container references are stored are implemented
77  * by the subclass
78  *
79  * @author Michael Rimov
80  * @version $Revision: 1.6 $ on $Date: 2004/11/17 20:48:16 $
81  * @since Expresso 5.1
82  */

83
84 abstract public class ContainerImplBase implements ComponentContainer {
85     ComponentContainer parent;
86     Containable nested;
87
88     public ContainerImplBase() {
89         parent = null;
90         nested = null;
91     }
92
93     /**
94      * Locates an Expresso Service for use by a client.
95      *
96      * @param componentName the name of the service to locate.
97      * @return ExpressoService.
98      * @throws IllegalArgumentException if the service cannot be found.
99      * @throws IllegalStateException if the service exists, but is not in a
100      * 'runnable' state due to some configuration error or other unforeseen
101      * issue.
102      */

103     abstract public ExpressoComponent locateComponent(String JavaDoc componentName);
104
105     /**
106      * Query the container to see if a particular service name is installed
107      * in the system
108      *
109      * @param componentName the name of the component to query for.
110      * @return true if the service is installed and running.
111      */

112     abstract public boolean isComponentExists(String JavaDoc componentName);
113
114
115     /**
116      * To register the component for control by the Component Manager. This will
117      * in essense transfer the control of ther service to the Component Manager.
118      * This will often be called by the Configuration Bootstrap system.
119      *
120      * @param newComponent the component to install
121      */

122     abstract public void addComponent(ExpressoComponent newComponent);
123
124     /**
125      * Removes a component from this container.
126      *
127      * @param componentName The name of the component to remove.
128      */

129     abstract public void removeComponent(String JavaDoc componentName);
130
131
132     /**
133      * Install a component into the system. If newComponent implements <code>
134      * installable</code> then it shall be installed. After that, the component
135      * is added.
136      *
137      * @param newComponent An instance of the component to install.
138      * @param log a Logger-like interface to a component tha records the process
139      * of the installation including any errors, etc.
140      * @param installOptions the installation options
141      */

142     abstract public void installComponent(ExpressoComponent newComponent,
143                                           InstallationOptions installOptions,
144                                           InstallLog log);
145
146
147     /**
148      * Uninstalls the component. If the component implements <code>
149      * installable</code> then it shall be uninstalled. After that, it shall
150      * be removed.
151      *
152      * @param componentName the name of the component to uninstall
153      * @param log a Logger-like interface to a component tha records the process
154      * of the installation including any errors, etc.
155      * @param installOptions the Installation Options bean
156      */

157     abstract public void uninstallComponent(String JavaDoc componentName, InstallationOptions installOptions, InstallLog log);
158
159     /**
160      * Retrieves a list of instances of all contained ExpressoComponents. Use
161      * this for iterating through the components of a current 'context'. Do not
162      * attempt to modify the map given. Either add or remove a component through
163      * the addComponent or removeComponent methods.
164      *
165      * @return Read only map of the components.
166      */

167     abstract public Map JavaDoc getChildComponents();
168
169     public void destroyContainer() {
170
171     }
172
173     /**
174      * Return the 'wrapped' container ExpressoComponent.
175      *
176      * @return <code>Containable</code>
177      */

178     public Containable getContainerComponent() {
179         return nested;
180     }
181
182     /**
183      * Sets the nested component. This is usually called by the system
184      * factory.
185      *
186      * @param newComponent the component that is the 'container' for this implementation
187      */

188     public void setContainerComponent(Containable newComponent) {
189         nested = newComponent;
190     }
191
192     /**
193      * Return the parent container
194      *
195      * @return ContainerImpl interface
196      */

197     public ComponentContainer getParentContainer() {
198         return parent;
199     }
200
201     /**
202      * Set the parent container of this container
203      *
204      * @param newParent the new Parent Container
205      */

206     public void setParentContainer(ComponentContainer newParent) {
207         parent = newParent;
208     }
209
210 }
Popular Tags