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: import com.sun.jbi.JBIProvider;
040: import com.sun.jbi.EnvironmentContext;
041:
042: /**
043: * DeploymentConfigurationFactory defines the configuration parameters required for
044: * DEPLOYMENT. Any new parameters would require updates to this class.
045: *
046: * @author Sun Microsystems, Inc.
047: */
048: public class DeploymentConfigurationFactory extends
049: ConfigurationFactory {
050: /** Attribute Names */
051: public static final String SERVICE_UNIT_TIMEOUT = "serviceUnitTimeout";
052: public static final String DEPLOYMENT_TIMEOUT = "deploymentTimeout";
053: public static final String ENABLE_AUTO_DEPLOY = "autoDeployEnabled";
054: public static final String ENABLE_AUTO_REDEPLOY = "autoRedeployEnabled";
055: public static final String ENABLE_AUTO_UNDEPLOY = "autoUndeployEnabled";
056: public static final String START_ON_DEPLOY = "startOnDeploy";
057: public static final String START_ON_VERIFY = "startOnVerify";
058: public static final String AUTO_DEPLOY_DIR = "autoDeployDir";
059:
060: private static final String AUTO_DEPLOY_DIR_NAME = "autodeploy";
061:
062: private static final int sNumAttributes = 8;
063:
064: /**
065: * Constructor
066: *
067: * @param defProps - default properties
068: */
069: public DeploymentConfigurationFactory(Properties defProps) {
070: super (defProps, ConfigurationCategory.Deployment);
071: }
072:
073: /**
074: *
075: */
076: public ModelMBeanAttributeInfo[] createMBeanAttributeInfo() {
077: ModelMBeanAttributeInfo[] attributeInfos = new ModelMBeanAttributeInfo[sNumAttributes];
078: DescriptorSupport descr;
079: String attrDescr;
080:
081: // -- Service Unit Timeout
082: descr = new DescriptorSupport();
083: attrDescr = getString(LocalStringKeys.SERVICE_UNIT_TIMEOUT_DESCR);
084: descr.setAttributeName(SERVICE_UNIT_TIMEOUT);
085: descr
086: .setDisplayName(getString(LocalStringKeys.SERVICE_UNIT_TIMEOUT_DISPLAY_NAME));
087: descr
088: .setDisplayNameId(getToken(LocalStringKeys.SERVICE_UNIT_TIMEOUT_DISPLAY_NAME));
089: descr
090: .setDescriptionId(getToken(LocalStringKeys.SERVICE_UNIT_TIMEOUT_DESCR));
091: descr
092: .setToolTip(getString(LocalStringKeys.SERVICE_UNIT_TIMEOUT_TOOLTIP));
093: descr
094: .setToolTipId(getToken(LocalStringKeys.SERVICE_UNIT_TIMEOUT_TOOLTIP));
095: descr.setResourceBundleName("com.sun.jbi.management");
096: descr.setIsStatic(false);
097: descr.setIsPassword(false);
098:
099: // Check the defaults file
100: String defValue = mDefaults.getProperty(
101: getQualifiedKey(SERVICE_UNIT_TIMEOUT), "0");
102: descr.setDefault(Integer.parseInt(defValue));
103: descr.setMinValue(0);
104: descr.setMaxValue(Integer.MAX_VALUE);
105: descr.setUnit("milliseconds");
106:
107: attributeInfos[0] = new ModelMBeanAttributeInfo(
108: // name type descr R W isIs Descriptor
109: SERVICE_UNIT_TIMEOUT, "int", attrDescr, true, true,
110: false, descr);
111:
112: // -- Deployment Timeout
113: descr = new DescriptorSupport();
114: attrDescr = getString(LocalStringKeys.DEPLOYMENT_TIMEOUT_DESCR);
115: descr.setAttributeName(DEPLOYMENT_TIMEOUT);
116: descr
117: .setDisplayName(getString(LocalStringKeys.DEPLOYMENT_TIMEOUT_DISPLAY_NAME));
118: descr
119: .setDisplayNameId(getToken(LocalStringKeys.DEPLOYMENT_TIMEOUT_DISPLAY_NAME));
120: descr
121: .setDescriptionId(getToken(LocalStringKeys.DEPLOYMENT_TIMEOUT_DESCR));
122: descr
123: .setToolTip(getString(LocalStringKeys.DEPLOYMENT_TIMEOUT_TOOLTIP));
124: descr
125: .setToolTipId(getToken(LocalStringKeys.DEPLOYMENT_TIMEOUT_TOOLTIP));
126: descr.setResourceBundleName("com.sun.jbi.management");
127: descr.setIsStatic(false);
128: descr.setIsPassword(false);
129:
130: defValue = mDefaults.getProperty(
131: getQualifiedKey(DEPLOYMENT_TIMEOUT), "0");
132: descr.setDefault(Integer.parseInt(defValue));
133: descr.setMinValue(0);
134: descr.setMaxValue(Integer.MAX_VALUE);
135: descr.setUnit("milliseconds");
136:
137: attributeInfos[1] = new ModelMBeanAttributeInfo(
138: // name type descr R W isIs Descriptor
139: DEPLOYMENT_TIMEOUT, "int", attrDescr, true, true,
140: false, descr);
141:
142: // auto-deploy Enabled
143: descr = new DescriptorSupport();
144: attrDescr = getString(LocalStringKeys.ENABLE_AUTO_DEPLOY_DESCR);
145: descr.setAttributeName(ENABLE_AUTO_DEPLOY);
146: descr
147: .setDisplayName(getString(LocalStringKeys.ENABLE_AUTO_DEPLOY_DISPLAY_NAME));
148: descr
149: .setDisplayNameId(getToken(LocalStringKeys.ENABLE_AUTO_DEPLOY_DISPLAY_NAME));
150: descr
151: .setDescriptionId(getToken(LocalStringKeys.ENABLE_AUTO_DEPLOY_DESCR));
152: descr
153: .setToolTip(getString(LocalStringKeys.ENABLE_AUTO_DEPLOY_TOOLTIP));
154: descr
155: .setToolTipId(getToken(LocalStringKeys.ENABLE_AUTO_DEPLOY_TOOLTIP));
156: descr.setResourceBundleName("com.sun.jbi.management");
157: descr.setIsStatic(false);
158: descr.setIsPassword(false);
159: String defEnableAutoDeploy = mDefaults.getProperty(
160: getQualifiedKey(ENABLE_AUTO_DEPLOY), "true");
161: boolean autoDeployEnabled = Boolean
162: .parseBoolean(defEnableAutoDeploy);
163: descr.setDefault(autoDeployEnabled);
164:
165: attributeInfos[2] = new ModelMBeanAttributeInfo(
166: // name type descr R W isIs Descriptor
167: ENABLE_AUTO_DEPLOY, "boolean", attrDescr, true, true,
168: true, descr);
169:
170: // - auto-undeploy enabled
171: // This property is dependent on the auto-deploy enabled property. i.e.
172: // autoDeployEnabled autoUndeployEnabled effective autoUndeployEnabled
173: // 0 0 0
174: // 0 1 0
175: // 1 0 0
176: // 1 1 1
177:
178: descr = new DescriptorSupport();
179: attrDescr = getString(LocalStringKeys.ENABLE_AUTO_UNDEPLOY_DESCR);
180: descr.setAttributeName(ENABLE_AUTO_UNDEPLOY);
181: descr
182: .setDisplayName(getString(LocalStringKeys.ENABLE_AUTO_UNDEPLOY_DISPLAY_NAME));
183: descr
184: .setDisplayNameId(getToken(LocalStringKeys.ENABLE_AUTO_UNDEPLOY_DISPLAY_NAME));
185: descr
186: .setDescriptionId(getToken(LocalStringKeys.ENABLE_AUTO_UNDEPLOY_DESCR));
187: descr
188: .setToolTip(getString(LocalStringKeys.ENABLE_AUTO_UNDEPLOY_TOOLTIP));
189: descr
190: .setToolTipId(getToken(LocalStringKeys.ENABLE_AUTO_UNDEPLOY_TOOLTIP));
191: descr.setResourceBundleName("com.sun.jbi.management");
192: descr.setIsStatic(false);
193: descr.setIsPassword(false);
194: String defEnableAutoUndeploy = mDefaults.getProperty(
195: getQualifiedKey(ENABLE_AUTO_UNDEPLOY), "true");
196: boolean autoUndeployEnabled = Boolean
197: .parseBoolean(defEnableAutoUndeploy)
198: && autoDeployEnabled;
199: descr.setDefault(autoUndeployEnabled);
200:
201: attributeInfos[3] = new ModelMBeanAttributeInfo(
202: // name type descr R W isIs Descriptor
203: ENABLE_AUTO_UNDEPLOY, "boolean", attrDescr, true, true,
204: true, descr);
205:
206: // - auto-redeploy enabled
207: // This property is dependent on the auto-deploy and auto-undeploy enabled property. i.e.
208: // autoDeployEnabled autoUndeployEnabled autoRedeployEnabled effective
209: // autoRedeployEnabled
210: // 0 0 0 0
211: // 0 0 1 0
212: // 0 1 0 0
213: // 0 1 1 0
214: // 1 0 0 0
215: // 1 0 1 0
216: // 1 1 0 0
217: // 1 1 1 1
218:
219: descr = new DescriptorSupport();
220: attrDescr = getString(LocalStringKeys.ENABLE_AUTO_REDEPLOY_DESCR);
221: descr.setAttributeName(ENABLE_AUTO_REDEPLOY);
222: descr
223: .setDisplayName(getString(LocalStringKeys.ENABLE_AUTO_REDEPLOY_DISPLAY_NAME));
224: descr
225: .setDisplayNameId(getToken(LocalStringKeys.ENABLE_AUTO_REDEPLOY_DISPLAY_NAME));
226: descr
227: .setDescriptionId(getToken(LocalStringKeys.ENABLE_AUTO_REDEPLOY_DESCR));
228: descr
229: .setToolTip(getString(LocalStringKeys.ENABLE_AUTO_REDEPLOY_TOOLTIP));
230: descr
231: .setToolTipId(getToken(LocalStringKeys.ENABLE_AUTO_REDEPLOY_TOOLTIP));
232: descr.setResourceBundleName("com.sun.jbi.management");
233: descr.setIsStatic(false);
234: descr.setIsPassword(false);
235: String defEnableAutoRedeploy = mDefaults.getProperty(
236: getQualifiedKey(ENABLE_AUTO_REDEPLOY), "true");
237: boolean autoRedeployEnabled = Boolean
238: .parseBoolean(defEnableAutoRedeploy)
239: && autoDeployEnabled && autoUndeployEnabled;
240: descr.setDefault(autoRedeployEnabled);
241:
242: attributeInfos[4] = new ModelMBeanAttributeInfo(
243: // name type descr R W isIs Descriptor
244: ENABLE_AUTO_REDEPLOY, "boolean", attrDescr, true, true,
245: true, descr);
246:
247: // Auto Deploy directory
248: descr = new DescriptorSupport();
249: attrDescr = getString(LocalStringKeys.AUTO_DEPLOY_DIR_DESCR);
250: descr.setAttributeName(AUTO_DEPLOY_DIR);
251: descr
252: .setDisplayName(getString(LocalStringKeys.AUTO_DEPLOY_DIR_DISPLAY_NAME));
253: descr
254: .setDisplayNameId(getToken(LocalStringKeys.AUTO_DEPLOY_DIR_DISPLAY_NAME));
255: descr
256: .setDescriptionId(getToken(LocalStringKeys.AUTO_DEPLOY_DIR_DESCR));
257: descr
258: .setToolTip(getString(LocalStringKeys.AUTO_DEPLOY_DIR_TOOLTIP));
259: descr
260: .setToolTipId(getToken(LocalStringKeys.AUTO_DEPLOY_DIR_TOOLTIP));
261: descr.setResourceBundleName("com.sun.jbi.management");
262: descr.setIsStatic(true);
263: descr.setIsPassword(false);
264: descr.setDefault(getAutoDeployDir());
265:
266: attributeInfos[5] = new ModelMBeanAttributeInfo(
267: // name type descr R W isIs Descriptor
268: AUTO_DEPLOY_DIR, "java.lang.String", attrDescr, true,
269: false, false, descr);
270:
271: // Start on deploy
272: descr = new DescriptorSupport();
273: attrDescr = getString(LocalStringKeys.START_ON_DEPLOY_DESCR);
274: descr.setAttributeName(START_ON_DEPLOY);
275: descr
276: .setDisplayName(getString(LocalStringKeys.START_ON_DEPLOY_DISPLAY_NAME));
277: descr
278: .setDisplayNameId(getToken(LocalStringKeys.START_ON_DEPLOY_DISPLAY_NAME));
279: descr
280: .setDescriptionId(getToken(LocalStringKeys.START_ON_DEPLOY_DESCR));
281: descr
282: .setToolTip(getString(LocalStringKeys.START_ON_DEPLOY_TOOLTIP));
283: descr
284: .setToolTipId(getToken(LocalStringKeys.START_ON_DEPLOY_TOOLTIP));
285: descr.setResourceBundleName("com.sun.jbi.management");
286: descr.setIsStatic(false);
287: descr.setIsPassword(false);
288: String defStartOnDeploy = mDefaults.getProperty(
289: getQualifiedKey(START_ON_DEPLOY), "true");
290: descr.setDefault(Boolean.parseBoolean(defStartOnDeploy));
291: descr.setDefault(true);
292:
293: attributeInfos[6] = new ModelMBeanAttributeInfo(
294: // name type descr R W isIs Descriptor
295: START_ON_DEPLOY, "boolean", attrDescr, true, true,
296: true, descr);
297:
298: // Start on deploy
299: descr = new DescriptorSupport();
300: attrDescr = getString(LocalStringKeys.START_ON_VERIFY_DESCR);
301: descr.setAttributeName(START_ON_VERIFY);
302: descr
303: .setDisplayName(getString(LocalStringKeys.START_ON_VERIFY_DISPLAY_NAME));
304: descr
305: .setDisplayNameId(getToken(LocalStringKeys.START_ON_VERIFY_DISPLAY_NAME));
306: descr
307: .setDescriptionId(getToken(LocalStringKeys.START_ON_VERIFY_DESCR));
308: descr
309: .setToolTip(getString(LocalStringKeys.START_ON_VERIFY_TOOLTIP));
310: descr
311: .setToolTipId(getToken(LocalStringKeys.START_ON_VERIFY_TOOLTIP));
312: descr.setResourceBundleName("com.sun.jbi.management");
313: descr.setIsStatic(false);
314: descr.setIsPassword(false);
315: String defStartOnVerify = mDefaults.getProperty(
316: getQualifiedKey(START_ON_VERIFY), "true");
317: descr.setDefault(Boolean.parseBoolean(defStartOnVerify));
318: descr.setDefault(true);
319:
320: attributeInfos[7] = new ModelMBeanAttributeInfo(
321: // name type descr R W isIs Descriptor
322: START_ON_VERIFY, "boolean", attrDescr, true, true,
323: true, descr);
324:
325: return attributeInfos;
326: }
327:
328: /*--------------------------------------------------------------------------------*\
329: * private helpers *
330: \*--------------------------------------------------------------------------------*/
331:
332: /**
333: * @return the abosolute path to the auto-deploy directory
334: */
335: private String getAutoDeployDir() {
336: // -- Default JBI autodeploy dir
337: com.sun.jbi.EnvironmentContext envCtx = com.sun.jbi.util.EnvironmentAccess
338: .getContext();
339: StringBuffer deployDir = new StringBuffer(envCtx
340: .getJbiInstanceRoot());
341: deployDir.append(java.io.File.separator);
342: deployDir.append(AUTO_DEPLOY_DIR_NAME);
343:
344: String defDeployDir = mDefaults.getProperty(
345: getQualifiedKey(AUTO_DEPLOY_DIR), deployDir.toString());
346:
347: String absDeployDir = com.sun.jbi.management.util.PropertyFilter
348: .filterProperties(defDeployDir);
349:
350: if (absDeployDir != null) {
351: absDeployDir = absDeployDir.replace('\\', '/');
352: }
353:
354: return absDeployDir;
355: }
356: }
|