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: * @(#)SystemConfigurationFactory.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: * SystemConfigurationFactory defines the common JBI runtime configuration parameters.
041: * Any new parameters would require updates to this class.
042: *
043: * @author Sun Microsystems, Inc.
044: */
045: public class SystemConfigurationFactory extends ConfigurationFactory {
046: /** Attribute Names */
047: public static final String JBI_HOME = "jbiHome";
048: public static final String DEFAULT_LOG_LEVEL = "defaultLogLevel";
049: public static final String HEART_BEAT_INTERVAL = "heartBeatInterval";
050: public static final String MSG_SVC_STATS_ENABLED = "msgSvcTimingStatisticsEnabled";
051:
052: private static final int sNumAttributes = 4;
053:
054: /**
055: * Constructor
056: *
057: * @param defProps - default properties
058: */
059: public SystemConfigurationFactory(Properties defProps) {
060: super (defProps, ConfigurationCategory.System);
061: }
062:
063: /**
064: *
065: */
066: public ModelMBeanAttributeInfo[] createMBeanAttributeInfo() {
067: ModelMBeanAttributeInfo[] attributeInfos = new ModelMBeanAttributeInfo[sNumAttributes];
068: DescriptorSupport descr;
069: String attrDescr;
070:
071: // -- JBI Home
072: descr = new DescriptorSupport();
073: attrDescr = getString(LocalStringKeys.JBI_HOME_DESCR);
074: descr.setAttributeName(JBI_HOME);
075: descr
076: .setDisplayName(getString(LocalStringKeys.JBI_HOME_DISPLAY_NAME));
077: descr
078: .setDisplayNameId(getToken(LocalStringKeys.JBI_HOME_DISPLAY_NAME));
079: descr
080: .setDescriptionId(getToken(LocalStringKeys.JBI_HOME_DESCR));
081: descr.setToolTip(getString(LocalStringKeys.JBI_HOME_TOOLTIP));
082: descr.setToolTipId(getToken(LocalStringKeys.JBI_HOME_TOOLTIP));
083: descr.setResourceBundleName("com.sun.jbi.management");
084: descr.setIsStatic(true);
085: descr.setIsPassword(false);
086: descr.setDefault(getJbiHome());
087:
088: attributeInfos[0] = new ModelMBeanAttributeInfo(
089: // name type descr R W isIs Descriptor
090: JBI_HOME, "java.lang.String", attrDescr, true, false,
091: false, descr);
092:
093: // -- Default Log Level
094: descr = new DescriptorSupport();
095: attrDescr = getString(LocalStringKeys.DEFAULT_LOG_LEVEL_DESCR);
096: descr.setAttributeName(DEFAULT_LOG_LEVEL);
097: descr
098: .setDisplayName(getString(LocalStringKeys.DEFAULT_LOG_LEVEL_DISPLAY_NAME));
099: descr
100: .setDisplayNameId(getToken(LocalStringKeys.DEFAULT_LOG_LEVEL_DISPLAY_NAME));
101: descr
102: .setDescriptionId(getToken(LocalStringKeys.DEFAULT_LOG_LEVEL_DESCR));
103: descr
104: .setToolTip(getString(LocalStringKeys.DEFAULT_LOG_LEVEL_TOOLTIP));
105: descr
106: .setToolTipId(getToken(LocalStringKeys.DEFAULT_LOG_LEVEL_TOOLTIP));
107: descr.setResourceBundleName("com.sun.jbi.management");
108: descr.setIsStatic(false);
109: descr.setIsPassword(false);
110: descr.setDefault(getDefaultLogLevel());
111: descr
112: .setEnumValue("{SEVERE, WARNING, INFO, CONFIG, FINE, FINER, FINEST}");
113:
114: attributeInfos[1] = new ModelMBeanAttributeInfo(
115: // name type descr R W isIs Descriptor
116: DEFAULT_LOG_LEVEL, "java.lang.String", attrDescr, true,
117: false, false, descr);
118:
119: // Heart Beat
120: descr = new DescriptorSupport();
121: attrDescr = getString(LocalStringKeys.HEART_BEAT_INTERVAL_DESCR);
122: descr.setAttributeName(HEART_BEAT_INTERVAL);
123: descr
124: .setDisplayName(getString(LocalStringKeys.HEART_BEAT_INTERVAL_DISPLAY_NAME));
125: descr
126: .setDisplayNameId(getToken(LocalStringKeys.HEART_BEAT_INTERVAL_DISPLAY_NAME));
127: descr
128: .setDescriptionId(getToken(LocalStringKeys.HEART_BEAT_INTERVAL_DESCR));
129: descr
130: .setToolTip(getString(LocalStringKeys.HEART_BEAT_INTERVAL_TOOLTIP));
131: descr
132: .setToolTipId(getToken(LocalStringKeys.HEART_BEAT_INTERVAL_TOOLTIP));
133: descr.setResourceBundleName("com.sun.jbi.management");
134: descr.setIsStatic(false);
135: descr.setIsPassword(false);
136: String defHeartBeat = mDefaults.getProperty(
137: getQualifiedKey(HEART_BEAT_INTERVAL), "5500");
138: descr.setDefault(Integer.parseInt(defHeartBeat));
139: descr.setMinValue(1000);
140: descr.setMaxValue(Integer.MAX_VALUE);
141: descr.setUnit("milliseconds");
142:
143: attributeInfos[2] = new ModelMBeanAttributeInfo(
144: // name type descr R W isIs Descriptor
145: HEART_BEAT_INTERVAL, "int", attrDescr, true, true,
146: false, descr);
147:
148: // Message Service Timing Statistics
149: descr = new DescriptorSupport();
150: attrDescr = getString(LocalStringKeys.MSG_SVC_STATS_ENABLED_DESCR);
151: descr.setAttributeName(MSG_SVC_STATS_ENABLED);
152: descr
153: .setDisplayName(getString(LocalStringKeys.MSG_SVC_STATS_ENABLED_DISPLAY_NAME));
154: descr
155: .setDisplayNameId(getToken(LocalStringKeys.MSG_SVC_STATS_ENABLED_DISPLAY_NAME));
156: descr
157: .setDescriptionId(getToken(LocalStringKeys.MSG_SVC_STATS_ENABLED_DESCR));
158: descr
159: .setToolTip(getString(LocalStringKeys.MSG_SVC_STATS_ENABLED_TOOLTIP));
160: descr
161: .setToolTipId(getToken(LocalStringKeys.MSG_SVC_STATS_ENABLED_TOOLTIP));
162: descr.setResourceBundleName("com.sun.jbi.management");
163: descr.setIsStatic(false);
164: descr.setIsPassword(false);
165: String defMsgSvcStatsEnabled = mDefaults.getProperty(
166: getQualifiedKey(MSG_SVC_STATS_ENABLED), "false");
167: descr.setDefault(Boolean.parseBoolean(defMsgSvcStatsEnabled));
168:
169: attributeInfos[3] = new ModelMBeanAttributeInfo(
170: // name type descr R W isIs Descriptor
171: MSG_SVC_STATS_ENABLED, "boolean", attrDescr, true,
172: true, true, descr);
173:
174: return attributeInfos;
175: }
176:
177: /*--------------------------------------------------------------------------------*\
178: * private helpers *
179: \*--------------------------------------------------------------------------------*/
180:
181: /**
182: * @return the abosolute path to the JBI Home directory
183: */
184: private String getJbiHome() {
185: com.sun.jbi.EnvironmentContext envCtx = com.sun.jbi.util.EnvironmentAccess
186: .getContext();
187: return envCtx.getJbiInstallRoot();
188: }
189: }
|