Source Code Cross Referenced for JBIRuntimeLogLevelsPropertySheetAdaptor.java in  » ESB » open-esb » com » sun » jbi » jsf » util » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » ESB » open esb » com.sun.jbi.jsf.util 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003:         * 
004:         * Copyright 1997-2007 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:        package com.sun.jbi.jsf.util;
038:
039:        import com.sun.appserv.management.config.ConfigConfig;
040:        import com.sun.appserv.management.config.ModuleLogLevelsConfig;
041:        import com.sun.enterprise.tools.admingui.util.GuiUtil;
042:        import com.sun.jbi.jsf.util.BeanUtilities;
043:        import com.sun.jbi.jsf.util.SharedConstants;
044:        import com.sun.jbi.jsf.util.SystemLoggerUtilities;
045:        import com.sun.jbi.jsf.bean.LoggingBean;
046:        import com.sun.jbi.jsf.bean.AlertBean;
047:        import com.sun.jbi.jsf.factory.PropertySheetAdaptorBase;
048:        import com.sun.jbi.ui.common.JBIAdminCommands;
049:        import com.sun.jsftemplating.layout.descriptors.LayoutComponent;
050:        import com.sun.webui.jsf.component.Property;
051:        import com.sun.webui.jsf.component.StaticText;
052:        import com.sun.webui.jsf.component.DropDown;
053:        import com.sun.webui.jsf.component.HiddenField;
054:        import com.sun.webui.jsf.model.Option;
055:        import java.util.Properties;
056:        import java.util.HashMap;
057:        import java.util.TreeMap;
058:        import java.util.SortedMap;
059:        import java.util.logging.Logger;
060:        import java.util.logging.Level;
061:        import java.util.Map;
062:        import java.util.Set;
063:        import java.util.Iterator;
064:        import java.io.IOException;
065:        import java.io.File;
066:        import java.io.InputStream;
067:        import java.io.PrintStream;
068:        import javax.faces.component.UIComponent;
069:        import javax.faces.context.FacesContext;
070:
071:        /**
072:         *  <p> The <code>JBIRuntimeLogLevelsPropertySheetAdaptor</code> implementation must have a
073:         *	<code>public static JBIRuntimeLogLevelsPropertySheetAdaptor getInstance(FacesContext,
074:         *	LayoutComponent, UIComponent)</code> method in order to get access to
075:         *	an instance of the <code>JBIRuntimeLogLevelsPropertySheetAdaptor</code> instance.</p>
076:         *
077:         *  <p>	This class is used by <code>DynamicPropertySheetNodeFactory</code>.</p>
078:         *
079:         *
080:         */
081:        public class JBIRuntimeLogLevelsPropertySheetAdaptor extends
082:                PropertySheetAdaptorBase {
083:
084:            private static Logger sLog;
085:            private JBIAdminCommands mJac = BeanUtilities.getClient();
086:
087:            private static final Option[] mLogLevelOptions = {
088:                    new Option((Level.parse("FINEST")).getName(), GuiUtil
089:                            .getMessage(I18nUtilities
090:                                    .getResourceString("loglevel.FINEST"))),
091:                    new Option((Level.parse("FINER")).getName(), GuiUtil
092:                            .getMessage(I18nUtilities
093:                                    .getResourceString("loglevel.FINER"))),
094:                    new Option((Level.parse("FINE")).getName(), GuiUtil
095:                            .getMessage(I18nUtilities
096:                                    .getResourceString("loglevel.FINE"))),
097:                    new Option((Level.parse("CONFIG")).getName(), GuiUtil
098:                            .getMessage(I18nUtilities
099:                                    .getResourceString("loglevel.CONFIG"))),
100:                    new Option((Level.parse("INFO")).getName(), GuiUtil
101:                            .getMessage(I18nUtilities
102:                                    .getResourceString("loglevel.INFO"))),
103:                    new Option((Level.parse("WARNING")).getName(), GuiUtil
104:                            .getMessage(I18nUtilities
105:                                    .getResourceString("loglevel.WARNING"))),
106:                    new Option((Level.parse("SEVERE")).getName(), GuiUtil
107:                            .getMessage(I18nUtilities
108:                                    .getResourceString("loglevel.SEVERE"))),
109:                    new Option((Level.parse("OFF")).getName(), GuiUtil
110:                            .getMessage(I18nUtilities
111:                                    .getResourceString("loglevel.OFF"))),
112:                    new Option(GuiUtil.getMessage(I18nUtilities
113:                            .getResourceString("loglevel.DEFAULT")), GuiUtil
114:                            .getMessage(I18nUtilities
115:                                    .getResourceString("loglevel.DEFAULT"))), };
116:
117:            /**
118:             *	<p> This constructor is not used.</p>
119:             */
120:            private JBIRuntimeLogLevelsPropertySheetAdaptor() {
121:            }
122:
123:            /**
124:             *	<p> This constructor saves the <code>LayoutComponent</code> descriptor
125:             *	    and the <code>UIComponent</code> associated with this
126:             *	    <code>PropertySheetAdaptor</code>.  This constructor is used by the
127:             *	    getInstance() method.</p>
128:             */
129:            protected JBIRuntimeLogLevelsPropertySheetAdaptor(
130:                    LayoutComponent desc, UIComponent parent) {
131:                super (desc, parent);
132:            }
133:
134:            /**
135:             *	<p> This method provides access to an <code>JBIRuntimeLogLevelsPropertySheetAdaptor</code>
136:             *	    instance.  Each time it is invoked, it returns a new instance.</p>
137:             */
138:            public static JBIRuntimeLogLevelsPropertySheetAdaptor getInstance(
139:                    FacesContext ctx, LayoutComponent desc, UIComponent parent) {
140:                return new JBIRuntimeLogLevelsPropertySheetAdaptor(desc, parent);
141:            }
142:
143:            /**
144:             *	<p> Method that is called to initialize the PropertySheet component.</p>
145:             */
146:            public void init() {
147:                // Initialise the logger
148:                sLog = JBILogger.getInstance();
149:
150:                // The parent UIComponent
151:                UIComponent parent = getParentUIComponent();
152:
153:                // Retrieve the required option values
154:                mPropertySheetId = getRequiredOptionValue("propertySheetId",
155:                        parent);
156:                mPropertySheetSectionIdTag = getRequiredOptionValue(
157:                        "propertySheetSectionIdTag", parent);
158:                mPropertyIdTag = getRequiredOptionValue("propertyIdTag", parent);
159:                mStaticTextIdTag = getRequiredOptionValue("staticTextIdTag",
160:                        parent);
161:                mDropDownIdTag = getRequiredOptionValue("dropDownIdTag", parent);
162:                mHiddenFieldIdTag = getRequiredOptionValue("hiddenFieldIdTag",
163:                        parent);
164:            }
165:
166:            /**
167:             *	<p> Method that is called to retrieve the property sheet object.
168:             * 
169:             *	@param	parent - The parent component
170:             *  @return PropertySheet component
171:             */
172:            public UIComponent getPropertySheet(UIComponent parent) {
173:                constructPropertySheet(parent);
174:                return parent;
175:            }
176:
177:            /**
178:             * Helper class that will create the property sheet components.
179:             */
180:            private UIComponent constructPropertySheet(UIComponent parent) {
181:                // String componentName  = getRequiredOptionValue("componentName", parent);
182:                String instanceName = getRequiredOptionValue("instanceName",
183:                        parent);
184:                String targetName = (String) getOptionValue("targetName",
185:                        parent);
186:                String additionalFile = (String) getOptionValue(
187:                        "additionalLoggerFile", parent);
188:
189:                // Initialize the Save button to be enabled
190:                LoggingBean loggingBean = BeanUtilities.getLoggingBean();
191:                loggingBean.setSaveButtonDisabled(false);
192:
193:                // Retrieve any default value.  This would be used instead in the dropdown
194:                // instead of the level value read from the MBean.
195:                String defaultLevel = (String) getOptionValue(
196:                        "dropDownDefaultLevel", parent);
197:
198:                boolean PE_Flag = false;
199:                if (targetName == null) {
200:                    PE_Flag = true;
201:                    targetName = instanceName;
202:                }
203:
204:                TreeMap logLevels = SystemLoggerUtilities
205:                        .getJBIRuntimeLoggerLevels(targetName, instanceName);
206:                if (logLevels == null) {
207:                    logLevels = new TreeMap();
208:                }
209:
210:                UIComponent propertySheetSection = getPropertySheetSectionComponent(parent);
211:
212:                if (logLevels.size() == 0) {
213:                    UIComponent propertyComponent = getPropertyComponent(propertySheetSection);
214:                    String msg = "";
215:                    ((Property) propertyComponent).setLabel(msg);
216:                    loggingBean.setSaveButtonDisabled(true);
217:                    String alertType = "error";
218:                    String alertSummary = I18nUtilities
219:                            .getResourceString("jbi.internal.error.summary");
220:                    String alertDetails = I18nUtilities
221:                            .getResourceString("jbi.runtime.loggers.none.found");
222:                    AlertBean alertBean = BeanUtilities.getAlertBean();
223:                    alertBean.setAlertType(alertType);
224:                    alertBean.setAlertSummary(alertSummary);
225:                    alertBean.setAlertDetail(alertDetails);
226:                } else {
227:                    Set logLevelSet = null;
228:                    Level level = null;
229:                    String label = "";
230:                    logLevelSet = logLevels.keySet();
231:                    Iterator iter = logLevelSet.iterator();
232:                    while (iter.hasNext()) {
233:                        String name = (String) iter.next();
234:
235:                        label = SystemLoggerUtilities.getRuntimeDisplayName(
236:                                name, targetName, instanceName);
237:                        level = (Level) logLevels.get(name);
238:
239:                        String displayName = "(" + name + ")";
240:
241:                        // If a default value was given, then we want to use that as the level
242:                        if (defaultLevel != null) {
243:                            level = Level.parse(defaultLevel);
244:                        }
245:
246:                        UIComponent propertyComponent = getPropertyComponent(propertySheetSection);
247:                        UIComponent dropDownComponent = getDropDownComponent(propertyComponent);
248:                        UIComponent staticTextComponent = getStaticTextComponent(propertyComponent);
249:                        UIComponent hiddenFieldComponent = getHiddenFieldComponent(propertyComponent);
250:
251:                        ((Property) propertyComponent).setLabelAlign("left");
252:                        ((Property) propertyComponent).setNoWrap(true);
253:                        ((Property) propertyComponent).setOverlapLabel(false);
254:                        ((Property) propertyComponent).setLabel(label);
255:                        ((DropDown) dropDownComponent)
256:                                .setItems(mLogLevelOptions);
257:                        ((DropDown) dropDownComponent)
258:                                .setSelected(level == null ? GuiUtil
259:                                        .getMessage(I18nUtilities
260:                                                .getResourceString("loglevel.DEFAULT"))
261:                                        : level.getName());
262:                        ((StaticText) staticTextComponent).setText(displayName);
263:                        ((HiddenField) hiddenFieldComponent).setText(name);
264:                    }
265:                }
266:
267:                return parent;
268:            }
269:
270:            /**
271:             *	<p> This method returns the "options" that should be supplied to the
272:             *	    factory that creates the <code>PropertySheet</code>.</p>
273:             *
274:             *	<p> Some useful options for the standard <code>PropertySheet</code>
275:             *	    component include:<p>
276:             *
277:             * <ul><li>propertySheetId</li>
278:             * <li>propertySheetSectionIdTag</li>
279:             * <li>propertyIdTag</li>
280:             * <li>staticTextIdTag</li>
281:             * <li>dropDownIdTag</li>
282:             * <li>dropDownDefaultLevel</li>
283:             * <li>hiddenFieldIdTag</li>
284:             * <li>componentName</li>
285:             * <li>targetName</li>
286:             * <li>instanceName</li>
287:             * <li>propertySheetAdaptorClass</li></ul>
288:             *
289:             *	<p> See PropertySheet component documentation for more details.</p>
290:             */
291:            public Map<String, Object> getFactoryOptions() {
292:                Map<String, Object> result = null;
293:                LayoutComponent desc = getLayoutComponent();
294:                result = new HashMap<String, Object>();
295:                setProperty(result, "propertySheetId", desc
296:                        .getOption("propertySheetId"));
297:                setProperty(result, "propertySheetSectionIdTag", desc
298:                        .getOption("propertySheetSectionIdTag"));
299:                setProperty(result, "propertyIdTag", desc
300:                        .getOption("propertyIdTag"));
301:                setProperty(result, "staticTextIdTag", desc
302:                        .getOption("staticTextIdTag"));
303:                setProperty(result, "dropDownIdTag", desc
304:                        .getOption("dropDownIdTag"));
305:                setProperty(result, "dropDownDefaultLevel", desc
306:                        .getOption("dropDownDefaultLevel"));
307:                setProperty(result, "hiddenFieldIdTag", desc
308:                        .getOption("hiddenFieldIdTag"));
309:                setProperty(result, "componentName", desc
310:                        .getOption("componentName"));
311:                setProperty(result, "targetName", desc.getOption("targetName"));
312:                setProperty(result, "instanceName", desc
313:                        .getOption("instanceName"));
314:                setProperty(result, "propertySheetAdaptorClass", desc
315:                        .getOption("propertySheetAdaptorClass"));
316:                return result;
317:            }
318:
319:            /**
320:             *	<p> Helper method for setting Properties while avoiding NPE's.</p>
321:             */
322:            private void setProperty(Map props, String key, Object value) {
323:                if (value != null) {
324:                    props.put(key, value);
325:                }
326:            }
327:
328:            /**
329:             *	<p> This method returns any facets that should be applied to the
330:             *	    <code>PropertySheetNode (comp)</code>.  Useful facets for the sun
331:             *	    <code>PropertySheetNode</code> component are: "content" and "image".</p>
332:             *
333:             *	<p> Facets that already exist on <code>comp</code>, or facets that
334:             *	    are directly added to <code>comp</code> do not need to be returned
335:             *	    from this method.</p>
336:             *
337:             *	<p> This implementation directly adds a "content" facet and returns
338:             *	    <code>null</code> from this method.</p>
339:             *
340:             *	@param	comp	    The PropertySheet node <code>UIComponent</code>.
341:             *	@param	nodeObject  The (model) object representing the PropertySheet node.
342:             */
343:            public Map<String, UIComponent> getFacets(UIComponent comp,
344:                    Object nodeObject) {
345:                return null;
346:            }
347:
348:            /**
349:             *	<p> Advanced framework feature which provides better handling for
350:             *	    things such as expanding PropertySheetNodes, beforeEncode, and other
351:             *	    events.</p>
352:             *
353:             *	<p> This method should return a <code>Map</code> of <code>List</code>
354:             *	    of <code>Handler</code> objects.  Each <code>List</code> in the
355:             *	    <code>Map</code> should be registered under a key that cooresponds
356:             *	    to to the "event" in which the <code>Handler</code>s should be
357:             *	    invoked.</p>
358:             */
359:            public Map getHandlersByType(UIComponent comp, Object nodeObject) {
360:                return null;
361:            }
362:            /*
363:
364:             // ** TBD Dummuy methods to test the screens. 
365:             // ** Will replace with Common Client Call
366:             private TreeMap getLoggerLevels (String targetName,
367:             String instanceName)
368:             {
369:             TreeMap testMap = new TreeMap();
370:             testMap.put("com.sun.jbi.framework",                        Level.parse("FINEST"));
371:             testMap.put("com.sun.jbi.management.AdminService",          Level.parse("FINER"));
372:             testMap.put("com.sun.jbi.management.ConfigurationService",  Level.parse("FINE"));
373:             testMap.put("com.sun.jbi.management.DeploymentService",     Level.parse("CONFIG"));
374:             testMap.put("com.sun.jbi.management.FileTransferService",   Level.parse("INFO"));
375:             testMap.put("com.sun.jbi.management.InstallationService",   Level.parse("WARNING"));
376:             testMap.put("com.sun.jbi.messaging",                        Level.parse("SEVERE"));
377:             testMap.put("com.sun.jbi.messaging.util",                   Level.parse("OFF"));
378:             testMap.put("com.sun.jbi.wsdl2.logger",                     Level.parse("INFO"));
379:             return testMap;
380:             }
381:
382:
383:
384:             // ** TBD Dummuy methods to test the screens. 
385:             // ** Will replace with Common Client Call
386:             private TreeMap getLoggerLabels (String targetName,
387:             String instanceName)
388:             {
389:             TreeMap testMap = new TreeMap();
390:             testMap.put("com.sun.jbi.framework",                        "Framework");
391:             testMap.put("com.sun.jbi.management.AdminService",          "Administration Service");
392:             testMap.put("com.sun.jbi.management.ConfigurationService",  "Configuration Service");
393:             testMap.put("com.sun.jbi.management.DeploymentService",     "Deployment Service");
394:             testMap.put("com.sun.jbi.management.FileTransferService",   "File Transfer Service");
395:             testMap.put("com.sun.jbi.management.InstallationService",   "Installation Service");
396:             testMap.put("com.sun.jbi.messaging",                        "Messaging");
397:             testMap.put("com.sun.jbi.messaging.util",                   "Messaging Util");
398:             testMap.put("com.sun.jbi.wsdl2.logger",                     "WSDL");
399:             return testMap;
400:             }
401:             */
402:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.