KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > jcorporate > expresso > services > controller > Configuration


1 /* ====================================================================
2  * The Jcorporate Apache Style Software License, Version 1.2 05-07-2002
3  *
4  * Copyright (c) 1995-2002 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
65 package com.jcorporate.expresso.services.controller;
66
67 import com.jcorporate.expresso.core.controller.ControllerException;
68 import com.jcorporate.expresso.core.controller.ControllerRequest;
69 import com.jcorporate.expresso.core.controller.ControllerResponse;
70 import com.jcorporate.expresso.core.controller.Input;
71 import com.jcorporate.expresso.core.controller.SecureIfSetController;
72 import com.jcorporate.expresso.core.controller.State;
73 import com.jcorporate.expresso.core.controller.Transition;
74 import com.jcorporate.expresso.kernel.DefaultContainerImpl;
75 import com.jcorporate.expresso.kernel.RootContainer;
76 import com.jcorporate.expresso.kernel.SystemFactory;
77 import com.jcorporate.expresso.kernel.digester.ComponentMetadataConfig;
78 import com.jcorporate.expresso.kernel.digester.ExpressoServicesConfig;
79 import com.jcorporate.expresso.services.controller.configuration.ShowComponent;
80 import com.jcorporate.expresso.services.controller.configuration.ShowContainerTree;
81
82
83 /**
84  * This is a management controller that allows configuration of the
85  * expresso-services.xml file
86  *
87  * @author Michael Rimov
88  */

89
90 public class Configuration extends SecureIfSetController {
91
92     /**
93      * Session identifier that stores the current Expresso runtime we're managing
94      */

95     public static final String JavaDoc CURRENT_RUNTIME_KEY = Configuration.class.getName()
96             + ".curRuntimeKey";
97
98
99     public static final String JavaDoc STATE_SHOW_FILE = "showConfigurationFile";
100     public static final String JavaDoc STATE_SWITCH_RUNTIME = "switchRuntime";
101     public static final String JavaDoc STATE_SHOW_STATUS = "showContainerStatus";
102     public static final String JavaDoc STATE_SHOW_RUNTIME = "showRuntime";
103     public static final String JavaDoc STATE_SHOW_COMPONENT = "showComponent";
104     public static final String JavaDoc STATE_PROMPT_CREATE_RUNTIME = "promptCreateRuntime";
105     public static final String JavaDoc STATE_PROCESS_CREATE_RUNTIME = "processCreateRuntime";
106
107     /**
108      * Default constructor, creates all the various states, etc.
109      */

110     public Configuration() {
111         super();
112         this.setSchema(com.jcorporate.expresso.core.ExpressoSchema.class);
113
114         State s = new State(STATE_SHOW_FILE, "Show Configuration File");
115         this.addState(s);
116
117         s = new State(STATE_SWITCH_RUNTIME, "Switch Runtimes");
118         s.addRequiredParameter("runtimeName");
119
120         s = new State(STATE_SHOW_STATUS, "Show Container Status State");
121         this.addState(s);
122
123         s = new ShowContainerTree();
124         this.addState(s);
125
126         s = new State(STATE_SHOW_RUNTIME, "Show Runtime Information");
127         this.addState(s);
128
129         //External state for displaying the component and handling various
130
//methods.
131
s = new ShowComponent();
132         this.addState(s);
133
134         s = new State("promptCreateRuntime", "Prompt Create Runtime");
135         this.addState(s);
136
137         s = new State("processCreateRuntime", "Create Runtime");
138         this.addState(s);
139
140         s = new State("summary", "Configuration Start Page");
141         this.addState(s);
142
143         this.setInitialState("summary");
144     }
145
146
147     /**
148      * @param request the controller request object
149      * @param response the controller response object
150      */

151     public void runShowConfigurationFileState(ControllerRequest request,
152                                               ControllerResponse response) {
153
154     }
155
156     /**
157      * Show basic running container status including a list of current
158      * ExpressoRuntimes that are operating within this Virtual Machine.
159      *
160      * @param request The <code>ControllerRequest</code> object that is
161      * @param response the controller response object
162      */

163     public void showContainerStatusState(ControllerRequest request,
164                                          ControllerResponse response) {
165
166     }
167
168
169     /**
170      * @param request the controller request object
171      * @param response the controller response object
172      */

173     public void runSwitchRuntimeState(ControllerRequest request,
174                                       ControllerResponse response) {
175
176     }
177
178
179     /**
180      * @param request the controller request object
181      * @param response the controller response object
182      */

183     public void runShowContainerStatusState(ControllerRequest request,
184                                             ControllerResponse response) {
185
186
187     }
188
189     /**
190      * @param request the controller request object
191      * @param response the controller response object
192      */

193     public void runShowComponentState(ControllerRequest request,
194                                       ControllerResponse response) {
195
196     }
197
198
199     /**
200      * @param request the controller request object
201      * @param response the controller response object
202      */

203     public void runSummaryState(ControllerRequest request,
204                                 ControllerResponse response) {
205         response.setTitle("Expresso Runtime Configuration");
206
207     }
208
209     /**
210      * @param request the controller request object
211      * @param response the controller response object
212      * @throws ControllerException upon error
213      */

214     public void runPromptCreateRuntime(ControllerRequest request,
215                                        ControllerResponse response) throws ControllerException {
216         response.setTitle("Create New Runtime");
217         Input i = new Input("runtimeName", "Runtime Name(Leave Blank For Default)");
218         Transition t = new Transition(STATE_PROCESS_CREATE_RUNTIME, this);
219         response.add(i);
220         response.add(t);
221
222     }
223
224     /**
225      * todo what is this method for? is it useful?
226      *
227      * @param request the controller request object
228      * @param response the controller response object
229      * @throws ControllerException upon error
230      */

231     public void runProcessCreateRuntime(ControllerRequest request,
232                                         ControllerResponse response) throws ControllerException {
233         RootContainer rc = new RootContainer();
234         rc.setContainerImplementation(new DefaultContainerImpl());
235         rc.setExpressoServicesConfig(new ExpressoServicesConfig());
236 // rc.getExpressoServicesConfig().
237

238         // does this do something useful??
239
SystemFactory.getInstance();
240         rc.getMetadataLocation();
241         new ComponentMetadataConfig();
242     }
243
244 }
Popular Tags