Source Code Cross Referenced for JbiListRuntimeLoggersTask.java in  » ESB » open-esb » com » sun » jbi » ui » ant » 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.ui.ant 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


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:         * @(#)JbiListRuntimeLoggersTask.java
025:         * Copyright 2004-2007 Sun Microsystems, Inc. All Rights Reserved.
026:         *
027:         * END_HEADER - DO NOT EDIT
028:         */
029:        package com.sun.jbi.ui.ant;
030:
031:        import com.sun.jbi.ui.common.JBIManagementMessage;
032:        import java.io.File;
033:        import java.io.FileInputStream;
034:        import java.io.IOException;
035:        import java.io.PrintWriter;
036:        import java.io.StringWriter;
037:        import java.util.ArrayList;
038:        import java.util.Enumeration;
039:        import java.util.Iterator;
040:        import java.util.List;
041:        import java.util.Map;
042:        import java.util.Properties;
043:        import java.util.Set;
044:        import java.util.SortedSet;
045:        import java.util.TreeSet;
046:        import java.util.TreeMap;
047:        import java.util.logging.Level;
048:        import java.util.StringTokenizer;
049:        import java.util.Vector;
050:        import org.apache.tools.ant.BuildException;
051:
052:        /** This class is an ant task for displaying the runtime configuration or component 
053:         * configuration.
054:         *
055:         * @author Sun Microsystems, Inc.
056:         */
057:        public class JbiListRuntimeLoggersTask extends JbiTargetTask {
058:            /** logger success msg key   */
059:            private static final String LOGGER_SUCCESS_STATUS_KEY = "jbi.ui.ant.list.logger.successful";
060:            /** logger failure msg key   */
061:            private static final String LOGGER_FAILED_STATUS_KEY = "jbi.ui.ant.list.logger.failed";
062:
063:            /** INSTANCE ERROR PROPERTY */
064:            private static final String INSTANCE_ERROR_PROP = "com.sun.jbi.cluster.instance.error";
065:
066:            /** Configuration Name Key */
067:            private static final String APP_CONFIG_NAME_KEY = "configurationName";
068:
069:            /** Holds Param Nested elements */
070:            private List mLoggerList;
071:
072:            /**
073:             * Logic for listing runtime configuration
074:             */
075:
076:            private void executeListRuntimeLoggers() throws BuildException {
077:                this .logDebug("Executing List Runtime Loggers ....");
078:                try {
079:                    String target = getValidTarget();
080:                    List tmpLoggerList = this .getLoggerList();
081:                    List loggerList = new ArrayList(tmpLoggerList);
082:
083:                    // Check the list, remove the entry with empty name value
084:                    Iterator iter = tmpLoggerList.iterator();
085:                    while (iter.hasNext()) {
086:                        Logger logger = (Logger) iter.next();
087:                        if (logger != null) {
088:                            String loggerName = logger.getName();
089:                            if ((loggerName != null)
090:                                    && (loggerName.trim().compareTo("") == 0)) {
091:                                loggerList.remove(logger);
092:                            }
093:                        }
094:                    }
095:
096:                    if (loggerList.size() == 0) {
097:                        Map<String, Level> resultLevels = this 
098:                                .getJBIAdminCommands().getRuntimeLoggerLevels(
099:                                        target);
100:                        if (resultLevels == null) {
101:                            String errMsg = createFailedFormattedJbiAdminResult(
102:                                    "jbi.ui.ant.task.error.no.logger.resolved",
103:                                    null);
104:                            throw new BuildException(errMsg);
105:                        }
106:
107:                        printRuntimeLoggerLevels(resultLevels);
108:                    } else {
109:                        // Go throught the logger elements
110:                        Iterator it = loggerList.iterator();
111:                        TreeMap<String, Level> resultLevels = new TreeMap<String, Level>();
112:                        while (it.hasNext()) {
113:                            Logger logger = (Logger) it.next();
114:                            String loggerName = logger.getName();
115:                            if ((loggerName != null)
116:                                    && (loggerName.compareTo("") != 0)) {
117:                                Level resultLevel = this .getJBIAdminCommands()
118:                                        .getRuntimeLoggerLevel(
119:                                                logger.getName(), target);
120:
121:                                if (resultLevel == null) {
122:                                    String errMsg = createFailedFormattedJbiAdminResult(
123:                                            "jbi.ui.ant.task.error.no.logger.resolved",
124:                                            null);
125:                                    throw new BuildException(errMsg);
126:                                }
127:
128:                                resultLevels.put(logger.getName(), resultLevel);
129:                            }
130:                        }
131:                        printRuntimeLoggerLevels(resultLevels);
132:                    }
133:                } catch (Exception ex) {
134:                    processTaskException(ex);
135:                }
136:            }
137:
138:            /** executes the install task. Ant Task framework calls this method to
139:             * excute the task.
140:             * @throws BuildException if error or exception occurs.
141:             */
142:            public void executeTask() throws BuildException {
143:                this .logDebug("Executing List Configuration Task....");
144:
145:                executeListRuntimeLoggers();
146:            }
147:
148:            /**
149:             * returns i18n key. tasks implement this method.
150:             * @return i18n key for the success status
151:             */
152:            protected String getTaskFailedStatusI18NKey() {
153:                return LOGGER_FAILED_STATUS_KEY;
154:            }
155:
156:            /**
157:             * returns i18n key. tasks implement this method.
158:             * @return i18n key for the failed status
159:             */
160:            protected String getTaskSuccessStatusI18NKey() {
161:                return LOGGER_SUCCESS_STATUS_KEY;
162:            }
163:
164:            /**
165:             * returns i18n key
166:             * @return the i18n key
167:             */
168:            protected String getLoggerEmptyQueryResultI18NKey(boolean isRuntime) {
169:                return isRuntime ? "jbi.ui.ant.print.jbi.logger.info.empty"
170:                        : "jbi.ui.ant.print.jbi.comp.logger.info.empty";
171:            }
172:
173:            /**
174:             * returns i18n key
175:             * @return the i18n key
176:             */
177:            protected String getQueryResultHeaderSeparatorI18NKey(
178:                    boolean isRuntime) {
179:                return isRuntime ? "jbi.ui.ant.print.jbi.config.info.header.separator"
180:                        : "jbi.ui.ant.print.jbi.comp.config.info.header.separator";
181:            }
182:
183:            /**
184:             * returns i18n key
185:             * @return the i18n key
186:             */
187:            protected String getLoggerQueryResultHeaderI18NKey(boolean isRuntime) {
188:                return isRuntime ? "jbi.ui.ant.print.jbi.logger.info.header"
189:                        : "jbi.ui.ant.print.jbi.comp.logger.info.header";
190:            }
191:
192:            /**
193:             * returns i18n key
194:             * @return the i18n key
195:             */
196:            protected String getQueryResultPageSeparatorI18NKey(
197:                    boolean isRuntime) {
198:                return isRuntime ? "jbi.ui.ant.print.jbi.config.info.separator"
199:                        : "jbi.ui.ant.print.jbi.comp.config.info.separator";
200:            }
201:
202:            protected void printRuntimeLoggerLevels(Map<String, Level> theMap) {
203:                this .logDebug("Printing Rimtime Logger Levels....");
204:                if (theMap == null) {
205:                    this .logDebug("List Runtime Logger Level map returns NULL");
206:                } else {
207:                    this .logDebug("Size of Runtime Logger Level map: "
208:                            + theMap.size());
209:                }
210:                boolean isRuntime = true;
211:                String header = getI18NBundle().getMessage(
212:                        getLoggerQueryResultHeaderI18NKey(isRuntime),
213:                        getValidTarget());
214:                String headerSeparator = getI18NBundle().getMessage(
215:                        getQueryResultHeaderSeparatorI18NKey(isRuntime));
216:                String pageSeparator = getI18NBundle().getMessage(
217:                        getQueryResultPageSeparatorI18NKey(isRuntime));
218:
219:                String emptyResult = getI18NBundle().getMessage(
220:                        getLoggerEmptyQueryResultI18NKey(isRuntime));
221:
222:                StringWriter stringWriter = new StringWriter();
223:                PrintWriter msgWriter = new PrintWriter(stringWriter);
224:
225:                msgWriter.println(headerSeparator);
226:                msgWriter.println(header);
227:                msgWriter.println(headerSeparator);
228:
229:                if (theMap == null || theMap.size() <= 0) {
230:                    msgWriter.println(emptyResult);
231:                    msgWriter.println(pageSeparator);
232:                } else {
233:                    // sort the keys and display for deterministic output
234:                    SortedSet keys = new TreeSet(theMap.keySet());
235:                    for (Object key : keys) {
236:                        String loggerName = (String) key;
237:                        Level level = (Level) theMap.get(loggerName);
238:                        String param = getI18NBundle().getMessage(
239:                                "jbi.ui.ant.print.jbi.config.param",
240:                                loggerName,
241:                                (level == null) ? "DEFAULT" : level
242:                                        .getLocalizedName());
243:                        msgWriter.println(param);
244:                    }
245:                    msgWriter.println(pageSeparator);
246:                }
247:
248:                msgWriter.close();
249:                printMessage(stringWriter.getBuffer().toString());
250:
251:            }
252:
253:            /**
254:             * returns nested element list of <logger>
255:             * @return Logger List
256:             */
257:            protected List getLoggerList() {
258:                if (this .mLoggerList == null) {
259:                    this .mLoggerList = new ArrayList();
260:                }
261:                return this .mLoggerList;
262:            }
263:
264:            /**
265:             * factory method for creating the nested element <logger>
266:             * @return Logger Object
267:             */
268:            public Logger createLogger() {
269:                Logger logger = new Logger();
270:                this.getLoggerList().add(logger);
271:                return logger;
272:            }
273:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.