001: /*
002: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003: *
004: * Copyright 1997-2008 Sun Microsystems, Inc. All rights reserved.
005: *
006: * The contents of this file are subject to the terms of either the GNU
007: * General Public License Version 2 only ("GPL") or the Common Development
008: * and Distribution License("CDDL") (collectively, the "License"). You
009: * may not use this file except in compliance with the License. You can obtain
010: * a copy of the License at https://glassfish.dev.java.net/public/CDDL+GPL.html
011: * or glassfish/bootstrap/legal/LICENSE.txt. See the License for the specific
012: * language governing permissions and limitations under the License.
013: *
014: * When distributing the software, include this License Header Notice in each
015: * file and include the License file at glassfish/bootstrap/legal/LICENSE.txt.
016: * Sun designates this particular file as subject to the "Classpath" exception
017: * as provided by Sun in the GPL Version 2 section of the License file that
018: * accompanied this code. If applicable, add the following below the License
019: * Header, with the fields enclosed by brackets [] replaced by your own
020: * identifying information: "Portions Copyrighted [year]
021: * [name of copyright owner]"
022: *
023: * Contributor(s):
024: *
025: * If you wish your version of this file to be governed by only the CDDL or
026: * only the GPL Version 2, indicate your decision by adding "[Contributor]
027: * elects to include this software in this distribution under the [CDDL or GPL
028: * Version 2] license." If you don't indicate a single choice of license, a
029: * recipient has the option to distribute your version of this file under
030: * either the CDDL, the GPL Version 2 or to extend the choice of license to
031: * its licensees as provided above. However, if you add GPL Version 2 code
032: * and therefore, elected the GPL Version 2 license, then the option applies
033: * only if the new code is made subject to such option by the copyright
034: * holder.
035: */
036: /*
037: * CompConfigUtils.java
038: */
039: package com.sun.jbi.jsf.util;
040:
041: import com.sun.jbi.jsf.bean.CompConfigBean;
042: import com.sun.jbi.jsf.bean.ConfigPropertyGroup;
043: import com.sun.jbi.ui.common.JBIAdminCommands;
044: import com.sun.webui.jsf.component.PropertySheet;
045: import java.util.ArrayList;
046: import java.util.List;
047: import java.util.Properties;
048: import java.util.logging.Level;
049: import java.util.logging.Logger;
050: import org.w3c.dom.Document;
051:
052: /**
053: * Component Configuration Utilities.
054: *
055: * @author Sun Microsystems Inc.
056: */
057:
058: public final class CompConfigUtils {
059:
060: /**
061: * Gets the Configuration attribute of the CompConfigUtils class
062: *
063: * @param aCompName Description of Parameter
064: * @param anInstance Description of Parameter
065: * @return The Configuration value
066: */
067: public static Properties getConfiguration(String aCompName,
068: String anInstance) {
069: Properties result = null;
070: sLog.fine("CompConfigUtils.getConfiguration(" + aCompName
071: + ", " + anInstance + ")");
072:
073: try {
074: JBIAdminCommands jac = BeanUtilities.getClient();
075:
076: result = jac.getComponentConfiguration(aCompName,
077: anInstance);
078:
079: sLog.fine("CompConfigUtils.getConfiguration(...), result="
080: + result);
081:
082: } catch (com.sun.jbi.ui.common.JBIRemoteException jrEx) {
083: sLog
084: .log(
085: Level.FINE,
086: ("CompConfigUtils.getConfiguration(...) caught jrEx=" + jrEx),
087: jrEx);
088: }
089: return result;
090: }
091:
092: /**
093: * Gets the ConfigurationData attribute of the CompConfigUtils class
094: *
095: * @param aCompName Description of Parameter
096: * @param anInstance Description of Parameter
097: * @return The ConfigurationData value
098: */
099: public static String getConfigurationData(String aCompName,
100: String anInstance) {
101: String result = null;
102: sLog.fine("CompConfigUtils.getConfigurationData(" + aCompName
103: + ", " + anInstance + ")");
104:
105: try {
106: JBIAdminCommands jac = BeanUtilities.getClient();
107:
108: result = jac.retrieveConfigurationDisplayData(aCompName,
109: anInstance);
110:
111: sLog
112: .fine("CompConfigUtils.getConfigurationData(...), result="
113: + result);
114:
115: } catch (com.sun.jbi.ui.common.JBIRemoteException jrEx) {
116: sLog
117: .log(
118: Level.FINE,
119: ("CompConfigUtils.getConfigurationData(...) caught jrEx=" + jrEx),
120: jrEx);
121: }
122: return result;
123: }
124:
125: /**
126: * Gets the ConfigurationSchema attribute of the CompConfigUtils class
127: *
128: * @param aCompName Description of Parameter
129: * @param anInstance Description of Parameter
130: * @return The ConfigurationSchema value
131: */
132: public static String getConfigurationSchema(String aCompName,
133: String anInstance) {
134: String result = null;
135: sLog.fine("CompConfigUtils.getConfigurationSchema(" + aCompName
136: + ", " + anInstance + ")");
137:
138: try {
139: JBIAdminCommands jac = BeanUtilities.getClient();
140:
141: result = jac.retrieveConfigurationDisplaySchema(aCompName,
142: anInstance);
143:
144: sLog
145: .fine("CompConfigUtils.getConfigurationSchema(...), result="
146: + result);
147:
148: } catch (com.sun.jbi.ui.common.JBIRemoteException jrEx) {
149: sLog
150: .log(
151: Level.FINE,
152: ("CompConfigUtils.getConfigurationSchema(...) caught jrEx=" + jrEx),
153: jrEx);
154: }
155: return result;
156: }
157:
158: /**
159: * Gets the Instances attribute of the CompConfigUtils class
160: *
161: * @param aCompName Description of Parameter
162: * @param aCompType Description of Parameter
163: * @return The Instances value
164: */
165: public static List getInstances(String aCompName, String aCompType) {
166: if (JBILogger.isLoggableFiner()) {
167: Object[] args = { aCompName, aCompType, };
168: JBILogger.entering(CN, MN_GET_INSTANCES, args);
169: }
170: ArrayList result = new ArrayList();
171: if (JBILogger.isLoggableFiner()) {
172: JBILogger.exiting(CN, MN_GET_INSTANCES, result);
173: }
174: return result;
175: }
176:
177: /**
178: * Gets the state of the specified component on the specified instance
179: *
180: * @param aCompName the component to be checked
181: * @param aCompType either <code>binding-component</code>, or <code>service-engine</code>
182: * @param anInstance the cluster or standalone server name
183: * @return the state, one of <code>started</code>, <code>stopped</code>
184: * , <code>shutdown</code>, or <code>unknown</code>
185: */
186: public static String getCompState(String aCompName,
187: String aCompType, String anInstance) {
188: String result = null;
189: if (JBILogger.isLoggableFiner()) {
190: Object[] args = { aCompName, aCompType, anInstance, };
191: JBILogger.entering(CN, MN_GET_COMP_STATE, args);
192: }
193:
194: // TBD
195:
196: if (JBILogger.isLoggableFiner()) {
197: JBILogger.exiting(CN, MN_GET_COMP_STATE, result);
198: }
199: return result;
200: }
201:
202: /**
203: * Gets the running state of the specified instance
204: *
205: * @param anInstance to be checked
206: * @return the state, one of <code>running</code>, <code>stopped</code>
207: * , <code>starting</code>, or <code>unknown</code>
208: */
209: public static String getInstanceState(String anInstance) {
210: String result = null;
211: if (JBILogger.isLoggableFiner()) {
212: Object[] args = { anInstance, };
213: JBILogger.entering(CN, MN_GET_INSTANCE_STATE, args);
214: }
215:
216: // TBD
217:
218: if (JBILogger.isLoggableFiner()) {
219: JBILogger.exiting(CN, MN_GET_INSTANCE_STATE, result);
220: }
221: return result;
222: }
223:
224: /**
225: * Determines if the requested type of configuration is supported by the
226: * specified component on the specified instance.
227: *
228: * @param aConfigType Description of Parameter
229: * @param aCompName the component
230: * @param aCompType one of: <code>binding-component</code> or <code>service-engine</code>
231: * @param anInstance the instance
232: * @return true if the specified component (on the specified
233: * instance) supports the requested configuration type
234: */
235: public static boolean isConfigTypeSupported(String aConfigType,
236: String aCompName, String aCompType, String anInstance) {
237: boolean result = false;
238: if (JBILogger.isLoggableFiner()) {
239: Object[] args = { aConfigType, aCompName, aCompType,
240: anInstance, };
241: JBILogger.entering(CN, MN_IS_CONFIG_TYPE_SUPPORTED, args);
242: }
243:
244: // TBD
245:
246: if (JBILogger.isLoggableFiner()) {
247: JBILogger.exiting(CN, MN_IS_CONFIG_TYPE_SUPPORTED,
248: new Boolean(result));
249: }
250: return result;
251: }
252:
253: /**
254: * Sets the requested configuration type property sheet on the component
255: * configuration bean, if possible.
256: *
257: * @param aConfigType The new ConfigPS value
258: * @param aCompName the component
259: * @param aCompType one of: <code>binding-component</code> or <code>service-engine</code>
260: * @param anInstance the instance (or null for configuration type of
261: * <code>installation</code>
262: * @return true if the specified component (on the specified
263: * instance) returns valid data that can be used to initialize the
264: * property sheet.
265: */
266: public static boolean setConfigPS(String aConfigType,
267: String aCompName, String aCompType, String anInstance) {
268: boolean result = false;
269: if (JBILogger.isLoggableFiner()) {
270: Object[] args = { aConfigType, aCompName, aCompType,
271: anInstance, };
272: JBILogger.entering(CN, MN_SET_CONFIG_PS, args);
273: }
274:
275: // TBD
276: if (CONFIG_TYPE_APPLICATION.equals(aConfigType)) {
277: } else if (CONFIG_TYPE_INSTALLATION.equals(aConfigType)) {
278: Document jbiDocument = ValidationUtilities
279: .getConfigExtensionJbiDocument();
280:
281: // this code gets called only after successful
282: // archive validation, so there will be
283: // a jbi.xml document
284:
285: List<ConfigPropertyGroup> configGroups = ValidationUtilities
286: .getConfigExtensions(jbiDocument);
287:
288: PropertySheet installConfigPS;
289: if (null != configGroups) {
290: installConfigPS = JSFUtils.getCompInstallationConfigPS(
291: aCompName, aCompType, configGroups);
292: } else {
293: installConfigPS = JSFUtils.getNoConfigPS(aConfigType,
294: aCompName, aCompType);
295: }
296:
297: CompConfigBean compConfigBean = BeanUtilities
298: .getCompConfigBean();
299: compConfigBean.setCompInstallationConfigPS(installConfigPS);
300: } else if (CONFIG_TYPE_RUNTIME.equals(aConfigType)) {
301: } else {
302: }
303:
304: if (JBILogger.isLoggableFiner()) {
305: JBILogger
306: .exiting(CN, MN_SET_CONFIG_PS, new Boolean(result));
307: }
308: return result;
309: }
310:
311: /**
312: * Description of the Method
313: *
314: * @param aCompName Description of Parameter
315: * @param aCompType Description of Parameter
316: * @param anInstancesList Description of Parameter
317: * @param aPrevSelectedInstance Description of Parameter
318: * @return Description of the Returned Value
319: */
320: public static String selectCurrentInstance(String aCompName,
321: String aCompType, List anInstancesList,
322: String aPrevSelectedInstance) {
323: if (JBILogger.isLoggableFiner()) {
324: Object[] args = { aCompName, aCompType, anInstancesList,
325: aPrevSelectedInstance, };
326: JBILogger.entering(CN, MN_SELECT_CURRENT_INSTANCE, args);
327: }
328:
329: String result = null;
330:
331: // TBD
332:
333: if (JBILogger.isLoggableFiner()) {
334: JBILogger.exiting(CN, MN_SELECT_CURRENT_INSTANCE, result);
335: }
336: return result;
337: }
338:
339: /**
340: * prevents instantiation
341: */
342: private CompConfigUtils() {
343: }
344:
345: /**
346: * used with <code>setConfigPS</code> for a configuration type parameter
347: * for <code>application</code> type.
348: */
349: public static final String CONFIG_TYPE_APPLICATION = "application";
350:
351: /**
352: * used with <code>setConfigPS</code> for a configuration type parameter
353: * for <code>installation</code> type.
354: */
355: public static final String CONFIG_TYPE_INSTALLATION = "installation";
356:
357: /**
358: * used with <code>setConfigPS</code> for a configuration type parameter
359: * for <code>runtime</code> type.
360: */
361: public static final String CONFIG_TYPE_RUNTIME = "runtime";
362:
363: /**
364: * Controls printing of diagnostic messages to the log
365: */
366: private static Logger sLog = JBILogger.getInstance();
367:
368: private static final String CN = CompConfigUtils.class.getName();
369: private static final String MN_GET_COMP_STATE = "getCompState";
370: private static final String MN_GET_INSTANCES = "getInstances";
371: private static final String MN_GET_INSTANCE_STATE = "getInstanceState";
372: private static final String MN_IS_CONFIG_TYPE_SUPPORTED = "isConfigTypeSupported";
373: private static final String MN_SELECT_CURRENT_INSTANCE = "selectCurrentInstance";
374: private static final String MN_SET_CONFIG_PS = "setConfigPS";
375:
376: }
|