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: * @(#)LoggerConfigurationFactory.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 java.util.logging.Logger;
040:
041: /**
042: * LoggerConfigurationFactory exposes the log levels for configuration.
043: * Addition of new runtime loggers would require updates to this class.
044: *
045: * @author Sun Microsystems, Inc.
046: */
047: public class LoggerConfigurationFactory extends ConfigurationFactory {
048: /** Runtime Logger Names */
049: public static final String FRAMEWORK_LOGGER = "com.sun.jbi.framework";
050: public static final String MESSAGING_LOGGER = "com.sun.jbi.messaging";
051: public static final String MANAGEMENT_LOGGER = "com.sun.jbi.management";
052: public static final String ADMIN_LOGGER = "com.sun.jbi.management.AdminService";
053: public static final String INSTALLATION_LOGGER = "com.sun.jbi.management.InstallationService";
054: public static final String DEPLOYMENT_LOGGER = "com.sun.jbi.management.DeploymentService";
055: public static final String CONFIGURATION_LOGGER = "com.sun.jbi.management.ConfigurationService";
056: public static final String LOGGING_LOGGER = "com.sun.jbi.management.LoggingService";
057:
058: private static final int sNumAttributes = 8;
059: private static final String LOGGER_VALUES = "{ALL, CONFIG, FINE, FINER, FINEST, INFO, OFF, SEVERE, WARNING}";
060:
061: /**
062: * Constructor
063: *
064: * @param defProps - default properties
065: */
066: public LoggerConfigurationFactory(Properties defProps) {
067: super (defProps, ConfigurationCategory.Logger);
068: }
069:
070: /**
071: *
072: */
073: public ModelMBeanAttributeInfo[] createMBeanAttributeInfo() {
074: ModelMBeanAttributeInfo[] attributeInfos = new ModelMBeanAttributeInfo[sNumAttributes];
075: DescriptorSupport descr;
076: String attrName;
077: String attrDescr;
078:
079: // -- Framework Logger
080: descr = new DescriptorSupport();
081: attrDescr = getString(LocalStringKeys.FRAMEWORK_LOGGER_DESCR);
082: descr.setAttributeName(FRAMEWORK_LOGGER);
083: descr
084: .setDisplayName(getString(LocalStringKeys.FRAMEWORK_LOGGER_DISPLAY_NAME));
085: descr
086: .setDisplayNameId(getToken(LocalStringKeys.FRAMEWORK_LOGGER_DISPLAY_NAME));
087: descr
088: .setDescriptionId(getToken(LocalStringKeys.FRAMEWORK_LOGGER_DESCR));
089: descr
090: .setToolTip(getString(LocalStringKeys.FRAMEWORK_LOGGER_TOOLTIP));
091: descr
092: .setToolTipId(getToken(LocalStringKeys.FRAMEWORK_LOGGER_TOOLTIP));
093: descr.setResourceBundleName("com.sun.jbi.management");
094: descr.setIsStatic(false);
095: descr.setIsPassword(false);
096: descr.setDefault(getDefaultLogLevel());
097: descr.setEnumValue(LOGGER_VALUES);
098:
099: attributeInfos[0] = new ModelMBeanAttributeInfo(
100: // name type descr R W isIs Descriptor
101: FRAMEWORK_LOGGER, "java.lang.String", attrDescr, true,
102: true, false, descr);
103:
104: // -- Messaging Logger
105: descr = new DescriptorSupport();
106: attrDescr = getString(LocalStringKeys.MESSAGING_LOGGER_DESCR);
107: descr.setAttributeName(MESSAGING_LOGGER);
108: descr
109: .setDisplayName(getString(LocalStringKeys.MESSAGING_LOGGER_DISPLAY_NAME));
110: descr
111: .setDisplayNameId(getToken(LocalStringKeys.MESSAGING_LOGGER_DISPLAY_NAME));
112: descr
113: .setDescriptionId(getToken(LocalStringKeys.MESSAGING_LOGGER_DESCR));
114: descr
115: .setToolTip(getString(LocalStringKeys.MESSAGING_LOGGER_TOOLTIP));
116: descr
117: .setToolTipId(getToken(LocalStringKeys.MESSAGING_LOGGER_TOOLTIP));
118: descr.setResourceBundleName("com.sun.jbi.management");
119: descr.setIsStatic(false);
120: descr.setIsPassword(false);
121: descr.setDefault(getDefaultLogLevel());
122: descr.setEnumValue(LOGGER_VALUES);
123:
124: attributeInfos[1] = new ModelMBeanAttributeInfo(
125: // name type descr R W isIs Descriptor
126: MESSAGING_LOGGER, "java.lang.String", attrDescr, true,
127: true, false, descr);
128:
129: // -- Management Logger
130: descr = new DescriptorSupport();
131: attrDescr = getString(LocalStringKeys.MANAGEMENT_LOGGER_DESCR);
132: descr.setAttributeName(MANAGEMENT_LOGGER);
133: descr
134: .setDisplayName(getString(LocalStringKeys.MANAGEMENT_LOGGER_DISPLAY_NAME));
135: descr
136: .setDisplayNameId(getToken(LocalStringKeys.MANAGEMENT_LOGGER_DISPLAY_NAME));
137: descr
138: .setDescriptionId(getToken(LocalStringKeys.MANAGEMENT_LOGGER_DESCR));
139: descr
140: .setToolTip(getString(LocalStringKeys.MANAGEMENT_LOGGER_TOOLTIP));
141: descr
142: .setToolTipId(getToken(LocalStringKeys.MANAGEMENT_LOGGER_TOOLTIP));
143: descr.setResourceBundleName("com.sun.jbi.management");
144: descr.setIsStatic(false);
145: descr.setIsPassword(false);
146: descr.setDefault(getDefaultLogLevel());
147: descr.setEnumValue(LOGGER_VALUES);
148:
149: attributeInfos[2] = new ModelMBeanAttributeInfo(
150: // name type descr R W isIs Descriptor
151: MANAGEMENT_LOGGER, "java.lang.String", attrDescr, true,
152: true, false, descr);
153:
154: // -- AdminService Logger
155: descr = new DescriptorSupport();
156: attrDescr = getString(LocalStringKeys.ADMIN_LOGGER_DESCR);
157: descr.setAttributeName(ADMIN_LOGGER);
158: descr
159: .setDisplayName(getString(LocalStringKeys.ADMIN_LOGGER_DISPLAY_NAME));
160: descr
161: .setDisplayNameId(getToken(LocalStringKeys.ADMIN_LOGGER_DISPLAY_NAME));
162: descr
163: .setDescriptionId(getToken(LocalStringKeys.ADMIN_LOGGER_DESCR));
164: descr
165: .setToolTip(getString(LocalStringKeys.ADMIN_LOGGER_TOOLTIP));
166: descr
167: .setToolTipId(getToken(LocalStringKeys.ADMIN_LOGGER_TOOLTIP));
168: descr.setResourceBundleName("com.sun.jbi.management");
169: descr.setIsStatic(false);
170: descr.setIsPassword(false);
171: descr.setDefault(getDefaultLogLevel());
172: descr.setEnumValue(LOGGER_VALUES);
173:
174: attributeInfos[3] = new ModelMBeanAttributeInfo(
175: // name type descr R W isIs Descriptor
176: ADMIN_LOGGER, "java.lang.String", attrDescr, true,
177: true, false, descr);
178:
179: // -- InstallationService Logger
180: descr = new DescriptorSupport();
181: attrDescr = getString(LocalStringKeys.INSTALLATION_LOGGER_DESCR);
182: descr.setAttributeName(INSTALLATION_LOGGER);
183: descr
184: .setDisplayName(getString(LocalStringKeys.INSTALLATION_LOGGER_DISPLAY_NAME));
185: descr
186: .setDisplayNameId(getToken(LocalStringKeys.INSTALLATION_LOGGER_DISPLAY_NAME));
187: descr
188: .setDescriptionId(getToken(LocalStringKeys.INSTALLATION_LOGGER_DESCR));
189: descr
190: .setToolTip(getString(LocalStringKeys.INSTALLATION_LOGGER_TOOLTIP));
191: descr
192: .setToolTipId(getToken(LocalStringKeys.INSTALLATION_LOGGER_TOOLTIP));
193: descr.setResourceBundleName("com.sun.jbi.management");
194: descr.setIsStatic(false);
195: descr.setIsPassword(false);
196: descr.setDefault(getDefaultLogLevel());
197: descr.setEnumValue(LOGGER_VALUES);
198:
199: attributeInfos[4] = new ModelMBeanAttributeInfo(
200: // name type descr R W isIs Descriptor
201: INSTALLATION_LOGGER, "java.lang.String", attrDescr,
202: true, true, false, descr);
203:
204: // -- DeploymentService Logger
205: descr = new DescriptorSupport();
206: attrDescr = getString(LocalStringKeys.DEPLOYMENT_LOGGER_DESCR);
207: descr.setAttributeName(DEPLOYMENT_LOGGER);
208: descr
209: .setDisplayName(getString(LocalStringKeys.DEPLOYMENT_LOGGER_DISPLAY_NAME));
210: descr
211: .setDisplayNameId(getToken(LocalStringKeys.DEPLOYMENT_LOGGER_DISPLAY_NAME));
212: descr
213: .setDescriptionId(getToken(LocalStringKeys.DEPLOYMENT_LOGGER_DESCR));
214: descr
215: .setToolTip(getString(LocalStringKeys.DEPLOYMENT_LOGGER_TOOLTIP));
216: descr
217: .setToolTipId(getToken(LocalStringKeys.DEPLOYMENT_LOGGER_TOOLTIP));
218: descr.setResourceBundleName("com.sun.jbi.management");
219: descr.setIsStatic(false);
220: descr.setIsPassword(false);
221: descr.setDefault(getDefaultLogLevel());
222: descr.setEnumValue(LOGGER_VALUES);
223:
224: attributeInfos[5] = new ModelMBeanAttributeInfo(
225: // name type descr R W isIs Descriptor
226: DEPLOYMENT_LOGGER, "java.lang.String", attrDescr, true,
227: true, false, descr);
228:
229: // -- ConfigurationService Logger
230: descr = new DescriptorSupport();
231: attrDescr = getString(LocalStringKeys.CONFIGURATION_LOGGER_DESCR);
232: descr.setAttributeName(CONFIGURATION_LOGGER);
233: descr
234: .setDisplayName(getString(LocalStringKeys.CONFIGURATION_LOGGER_DISPLAY_NAME));
235: descr
236: .setDisplayNameId(getToken(LocalStringKeys.CONFIGURATION_LOGGER_DISPLAY_NAME));
237: descr
238: .setDescriptionId(getToken(LocalStringKeys.CONFIGURATION_LOGGER_DESCR));
239: descr
240: .setToolTip(getString(LocalStringKeys.CONFIGURATION_LOGGER_TOOLTIP));
241: descr
242: .setToolTipId(getToken(LocalStringKeys.CONFIGURATION_LOGGER_TOOLTIP));
243: descr.setResourceBundleName("com.sun.jbi.management");
244: descr.setIsStatic(false);
245: descr.setIsPassword(false);
246: descr.setDefault(getDefaultLogLevel());
247: descr.setEnumValue(LOGGER_VALUES);
248:
249: attributeInfos[6] = new ModelMBeanAttributeInfo(
250: // name type descr R W isIs Descriptor
251: CONFIGURATION_LOGGER, "java.lang.String", attrDescr,
252: true, true, false, descr);
253:
254: // -- LoggingService Logger
255: descr = new DescriptorSupport();
256: attrDescr = getString(LocalStringKeys.LOGGING_LOGGER_DESCR);
257: descr.setAttributeName(LOGGING_LOGGER);
258: descr
259: .setDisplayName(getString(LocalStringKeys.LOGGING_LOGGER_DISPLAY_NAME));
260: descr
261: .setDisplayNameId(getToken(LocalStringKeys.LOGGING_LOGGER_DISPLAY_NAME));
262: descr
263: .setDescriptionId(getToken(LocalStringKeys.LOGGING_LOGGER_DESCR));
264: descr
265: .setToolTip(getString(LocalStringKeys.LOGGING_LOGGER_TOOLTIP));
266: descr
267: .setToolTipId(getToken(LocalStringKeys.LOGGING_LOGGER_TOOLTIP));
268: descr.setResourceBundleName("com.sun.jbi.management");
269: descr.setIsStatic(false);
270: descr.setIsPassword(false);
271: descr.setDefault(getDefaultLogLevel());
272: descr.setEnumValue(LOGGER_VALUES);
273:
274: attributeInfos[7] = new ModelMBeanAttributeInfo(
275: // name type descr R W isIs Descriptor
276: LOGGING_LOGGER, "java.lang.String", attrDescr, true,
277: true, false, descr);
278:
279: return attributeInfos;
280: }
281:
282: /*--------------------------------------------------------------------------------*\
283: * private helpers *
284: \*--------------------------------------------------------------------------------*/
285:
286: }
|