001: /*
002: * BEGIN_HEADER - DO NOT EDIT
003: *
004: * The contents of this file are subject to the terms
005: * of the Common Development and Distribution License
006: * (the "License"). You may not use this file except
007: * in compliance with the License.
008: *
009: * You can obtain a copy of the license at
010: * https://open-esb.dev.java.net/public/CDDLv1.0.html.
011: * See the License for the specific language governing
012: * permissions and limitations under the License.
013: *
014: * When distributing Covered Code, include this CDDL
015: * HEADER in each file and include the License file at
016: * https://open-esb.dev.java.net/public/CDDLv1.0.html.
017: * If applicable add the following below this CDDL HEADER,
018: * with the fields enclosed by brackets "[]" replaced with
019: * your own identifying information: Portions Copyright
020: * [year] [name of copyright owner]
021: */
022:
023: /*
024: * @(#)DynamicRuntimeConfiguration.java
025: * Copyright 2004-2007 Sun Microsystems, Inc. All Rights Reserved.
026: *
027: * END_HEADER - DO NOT EDIT
028: */
029: package com.sun.jbi.management.config;
030:
031: import com.sun.jbi.management.ConfigurationCategory;
032: import com.sun.jbi.management.LocalStringKeys;
033:
034: import java.util.Properties;
035:
036: import javax.management.Descriptor;
037: import javax.management.modelmbean.ModelMBeanAttributeInfo;
038:
039: /**
040: * InstallationConfigurationFactory defines the configuration parameters required for
041: * installation. Any new parameters would require updates to this class.
042: *
043: * @author Sun Microsystems, Inc.
044: */
045: public class InstallationConfigurationFactory extends
046: ConfigurationFactory {
047: public static final String COMPONENT_TIMEOUT = "componentTimeout";
048: public static final String INSTALLATION_TIMEOUT = "installationTimeout";
049: public static final String ENABLE_AUTO_INSTALL = "autoInstallEnabled";
050: public static final String ENABLE_AUTO_REINSTALL = "autoReinstallEnabled";
051: public static final String ENABLE_AUTO_UNINSTALL = "autoUninstallEnabled";
052: public static final String AUTO_INSTALL_DIR = "autoInstallDir";
053:
054: private static final int sNumAttributes = 6;
055:
056: /**
057: * Constructor
058: *
059: * @param defProps - default properties
060: */
061: public InstallationConfigurationFactory(Properties defProps) {
062: super (defProps, ConfigurationCategory.Installation);
063: }
064:
065: /**
066: *
067: */
068: public ModelMBeanAttributeInfo[] createMBeanAttributeInfo() {
069: ModelMBeanAttributeInfo[] attributeInfos = new ModelMBeanAttributeInfo[sNumAttributes];
070: DescriptorSupport descr;
071: String attrName;
072: String attrDescr;
073:
074: // -- Component Timeout
075: descr = new DescriptorSupport();
076: attrDescr = getString(LocalStringKeys.COMPONENT_TIMEOUT_DESCR);
077: descr.setAttributeName(COMPONENT_TIMEOUT);
078: descr
079: .setDisplayName(getString(LocalStringKeys.COMPONENT_TIMEOUT_DISPLAY_NAME));
080: descr
081: .setDisplayNameId(getToken(LocalStringKeys.COMPONENT_TIMEOUT_DISPLAY_NAME));
082: descr
083: .setDescriptionId(getToken(LocalStringKeys.COMPONENT_TIMEOUT_DESCR));
084: descr
085: .setToolTip(getString(LocalStringKeys.COMPONENT_TIMEOUT_TOOLTIP));
086: descr
087: .setToolTipId(getToken(LocalStringKeys.COMPONENT_TIMEOUT_TOOLTIP));
088: descr.setResourceBundleName("com.sun.jbi.management");
089: descr.setIsStatic(false);
090: descr.setIsPassword(false);
091: String defCompTimeout = mDefaults.getProperty(
092: getQualifiedKey(COMPONENT_TIMEOUT), "0");
093: descr.setDefault(Integer.parseInt(defCompTimeout));
094: descr.setMinValue("0");
095: descr.setMaxValue(Integer.MAX_VALUE);
096: descr.setUnit("milliseconds");
097:
098: attributeInfos[0] = new ModelMBeanAttributeInfo(
099: // name type descr R W isIs Descriptor
100: COMPONENT_TIMEOUT, "int", attrDescr, true, true, false,
101: descr);
102:
103: // -- Installation Timeout
104: descr = new DescriptorSupport();
105: attrDescr = getString(LocalStringKeys.INSTALLATION_TIMEOUT_DESCR);
106: descr.setAttributeName(INSTALLATION_TIMEOUT);
107: descr
108: .setDisplayName(getString(LocalStringKeys.INSTALLATION_TIMEOUT_DISPLAY_NAME));
109: descr
110: .setDisplayNameId(getToken(LocalStringKeys.INSTALLATION_TIMEOUT_DISPLAY_NAME));
111: descr
112: .setDescriptionId(getToken(LocalStringKeys.INSTALLATION_TIMEOUT_DESCR));
113: descr
114: .setToolTip(getString(LocalStringKeys.INSTALLATION_TIMEOUT_TOOLTIP));
115: descr
116: .setToolTipId(getToken(LocalStringKeys.INSTALLATION_TIMEOUT_TOOLTIP));
117: descr.setResourceBundleName("com.sun.jbi.management");
118: descr.setIsStatic(false);
119: descr.setIsPassword(false);
120: String defInstTimeout = mDefaults.getProperty(
121: getQualifiedKey(INSTALLATION_TIMEOUT), "0");
122: descr.setDefault(Integer.parseInt(defInstTimeout));
123: descr.setMinValue(0);
124: descr.setMaxValue(Integer.MAX_VALUE);
125: descr.setUnit("milliseconds");
126:
127: attributeInfos[1] = new ModelMBeanAttributeInfo(
128: // name type descr R W isIs Descriptor
129: INSTALLATION_TIMEOUT, "int", attrDescr, true, true,
130: false, descr);
131:
132: // Enable auto-install
133: descr = new DescriptorSupport();
134: attrDescr = getString(LocalStringKeys.ENABLE_AUTO_INSTALL_DESCR);
135: descr.setAttributeName(ENABLE_AUTO_INSTALL);
136: descr
137: .setDisplayName(getString(LocalStringKeys.ENABLE_AUTO_INSTALL_DISPLAY_NAME));
138: descr
139: .setDisplayNameId(getToken(LocalStringKeys.ENABLE_AUTO_INSTALL_DISPLAY_NAME));
140: descr
141: .setDescriptionId(getToken(LocalStringKeys.ENABLE_AUTO_INSTALL_DESCR));
142: descr
143: .setToolTip(getString(LocalStringKeys.ENABLE_AUTO_INSTALL_TOOLTIP));
144: descr
145: .setToolTipId(getToken(LocalStringKeys.ENABLE_AUTO_INSTALL_TOOLTIP));
146: descr.setResourceBundleName("com.sun.jbi.management");
147: descr.setIsStatic(false);
148: descr.setIsPassword(false);
149: String defEnableAutoInstall = mDefaults.getProperty(
150: getQualifiedKey(ENABLE_AUTO_INSTALL), "true");
151: boolean autoInstallEnabled = Boolean
152: .parseBoolean(defEnableAutoInstall);
153: descr.setDefault(autoInstallEnabled);
154:
155: attributeInfos[2] = new ModelMBeanAttributeInfo(
156: // name type descr R W isIs Descriptor
157: ENABLE_AUTO_INSTALL, "boolean", attrDescr, true, true,
158: true, descr);
159:
160: // - auto-uninstall enabled
161: // This property is dependent on the auto-deploy enabled property. i.e.
162: // autoInstallEnabled autoUninstallEnabled effective autoUninstallEnabled
163: // 0 0 0
164: // 0 1 0
165: // 1 0 0
166: // 1 1 1
167:
168: descr = new DescriptorSupport();
169: attrDescr = getString(LocalStringKeys.ENABLE_AUTO_UNINSTALL_DESCR);
170: descr.setAttributeName(ENABLE_AUTO_UNINSTALL);
171: descr
172: .setDisplayName(getString(LocalStringKeys.ENABLE_AUTO_UNINSTALL_DISPLAY_NAME));
173: descr
174: .setDisplayNameId(getToken(LocalStringKeys.ENABLE_AUTO_UNINSTALL_DISPLAY_NAME));
175: descr
176: .setDescriptionId(getToken(LocalStringKeys.ENABLE_AUTO_UNINSTALL_DESCR));
177: descr
178: .setToolTip(getString(LocalStringKeys.ENABLE_AUTO_UNINSTALL_TOOLTIP));
179: descr
180: .setToolTipId(getToken(LocalStringKeys.ENABLE_AUTO_UNINSTALL_TOOLTIP));
181: descr.setResourceBundleName("com.sun.jbi.management");
182: descr.setIsStatic(false);
183: descr.setIsPassword(false);
184: String defEnableAutoUninstall = mDefaults.getProperty(
185: getQualifiedKey(ENABLE_AUTO_UNINSTALL), "true");
186: boolean autoUninstallEnabled = Boolean
187: .parseBoolean(defEnableAutoUninstall)
188: && autoInstallEnabled;
189: descr.setDefault(autoUninstallEnabled);
190:
191: attributeInfos[3] = new ModelMBeanAttributeInfo(
192: // name type descr R W isIs Descriptor
193: ENABLE_AUTO_UNINSTALL, "boolean", attrDescr, true,
194: true, true, descr);
195:
196: // auto-reinstall enabled
197: // This property is dependent on the auto-install and auto-uninstall enabled property. i.e.
198: // autoInstallEnabled autoUninstallEnabled autoReinstallEnabled effective
199: // autoReinstallEnabled
200: // 0 0 0 0
201: // 0 0 1 0
202: // 0 1 0 0
203: // 0 1 1 0
204: // 1 0 0 0
205: // 1 0 1 0
206: // 1 1 0 0
207: // 1 1 1 1
208:
209: descr = new DescriptorSupport();
210: attrDescr = getString(LocalStringKeys.ENABLE_AUTO_REINSTALL_DESCR);
211: descr.setAttributeName(ENABLE_AUTO_REINSTALL);
212: descr
213: .setDisplayName(getString(LocalStringKeys.ENABLE_AUTO_REINSTALL_DISPLAY_NAME));
214: descr
215: .setDisplayNameId(getToken(LocalStringKeys.ENABLE_AUTO_REINSTALL_DISPLAY_NAME));
216: descr
217: .setDescriptionId(getToken(LocalStringKeys.ENABLE_AUTO_REINSTALL_DESCR));
218: descr
219: .setToolTip(getString(LocalStringKeys.ENABLE_AUTO_REINSTALL_TOOLTIP));
220: descr
221: .setToolTipId(getToken(LocalStringKeys.ENABLE_AUTO_REINSTALL_TOOLTIP));
222: descr.setResourceBundleName("com.sun.jbi.management");
223: descr.setIsStatic(false);
224: descr.setIsPassword(false);
225: String defEnableAutoReinstall = mDefaults.getProperty(
226: getQualifiedKey(ENABLE_AUTO_REINSTALL), "true");
227: boolean autoReinstallEnabled = Boolean
228: .parseBoolean(defEnableAutoReinstall)
229: && autoInstallEnabled && autoUninstallEnabled;
230: descr.setDefault(autoReinstallEnabled);
231:
232: attributeInfos[4] = new ModelMBeanAttributeInfo(
233: // name type descr R W isIs Descriptor
234: ENABLE_AUTO_REINSTALL, "boolean", attrDescr, true,
235: true, true, descr);
236:
237: // Auto Install directory
238: descr = new DescriptorSupport();
239: attrDescr = getString(LocalStringKeys.AUTO_INSTALL_DIR_DESCR);
240: descr.setAttributeName(AUTO_INSTALL_DIR);
241: descr
242: .setDisplayName(getString(LocalStringKeys.AUTO_INSTALL_DIR_DISPLAY_NAME));
243: descr
244: .setDisplayNameId(getToken(LocalStringKeys.AUTO_INSTALL_DIR_DISPLAY_NAME));
245: descr
246: .setDescriptionId(getToken(LocalStringKeys.AUTO_INSTALL_DIR_DESCR));
247: descr
248: .setToolTip(getString(LocalStringKeys.AUTO_INSTALL_DIR_TOOLTIP));
249: descr
250: .setToolTipId(getToken(LocalStringKeys.AUTO_INSTALL_DIR_TOOLTIP));
251: descr.setResourceBundleName("com.sun.jbi.management");
252: descr.setIsStatic(true);
253: descr.setIsPassword(false);
254: descr.setDefault(getAutoInstallDir());
255:
256: attributeInfos[5] = new ModelMBeanAttributeInfo(
257: // name type descr R W isIs Descriptor
258: AUTO_INSTALL_DIR, "java.lang.String", attrDescr, true,
259: false, false, descr);
260:
261: return attributeInfos;
262: }
263:
264: /*--------------------------------------------------------------------------------*\
265: * private helpers *
266: \*--------------------------------------------------------------------------------*/
267:
268: /**
269: * @return the abosolute path to the auto-install directory
270: */
271: private String getAutoInstallDir() {
272: // JBI autoinstall directory
273: com.sun.jbi.EnvironmentContext envCtx = com.sun.jbi.util.EnvironmentAccess
274: .getContext();
275: StringBuffer installDir = new StringBuffer(envCtx
276: .getJbiInstanceRoot());
277: installDir.append(java.io.File.separator);
278: installDir
279: .append(com.sun.jbi.management.system.AutoAdminTask.AUTOINSTALL_DIR);
280:
281: String defInstallDir = mDefaults.getProperty(
282: getQualifiedKey(AUTO_INSTALL_DIR), installDir
283: .toString());
284:
285: String absInstalldir = com.sun.jbi.management.util.PropertyFilter
286: .filterProperties(defInstallDir);
287:
288: if (absInstalldir != null) {
289: absInstalldir = absInstalldir.replace('\\', '/');
290: }
291:
292: return absInstalldir;
293: }
294: }
|