Source Code Cross Referenced for JbiListRuntimeConfigurationTask.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:         * @(#)JbiListRuntimeConfigurationTask.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 JbiListRuntimeConfigurationTask extends JbiTargetTask {
058:            /** success msg key   */
059:            private static final String SUCCESS_STATUS_KEY = "jbi.ui.ant.list.configuration.successful";
060:            /** failure msg key   */
061:            private static final String FAILED_STATUS_KEY = "jbi.ui.ant.list.configuration.failed";
062:            /** logger success msg key   */
063:
064:            /** INSTANCE ERROR PROPERTY */
065:            private static final String INSTANCE_ERROR_PROP = "com.sun.jbi.cluster.instance.error";
066:
067:            /** Holds Param Nested elements */
068:            private List mParamList;
069:
070:            /**
071:             * Logic for listing runtime configuration
072:             */
073:
074:            private void executeListRuntimeConfiguration()
075:                    throws BuildException {
076:                this .logDebug("Executing List Runtime Configuration ....");
077:                try {
078:                    String target = getValidTarget();
079:                    List tmpParamList = this .getParamList();
080:                    List paramList = new ArrayList(tmpParamList);
081:
082:                    // Check the list, remove the entry with empty name value
083:                    Iterator iter = tmpParamList.iterator();
084:                    while (iter.hasNext()) {
085:                        Param param = (Param) iter.next();
086:                        if (param != null) {
087:                            String paramName = param.getName();
088:                            if ((paramName != null)
089:                                    && (paramName.trim().compareTo("") == 0)) {
090:                                paramList.remove(param);
091:                            }
092:                        }
093:                    }
094:
095:                    Properties returnProps = this .getJBIAdminCommands()
096:                            .getRuntimeConfiguration(target);
097:                    printRuntimeConfiguration(paramList, returnProps);
098:                } catch (Exception ex) {
099:                    processTaskException(ex);
100:                }
101:            }
102:
103:            /** executes the install task. Ant Task framework calls this method to
104:             * excute the task.
105:             * @throws BuildException if error or exception occurs.
106:             */
107:            public void executeTask() throws BuildException {
108:                this .logDebug("Executing List Configuration Task....");
109:
110:                executeListRuntimeConfiguration();
111:            }
112:
113:            /**
114:             * returns i18n key. tasks implement this method.
115:             * @return i18n key for the success status
116:             */
117:            protected String getTaskFailedStatusI18NKey() {
118:                return FAILED_STATUS_KEY;
119:            }
120:
121:            /**
122:             * returns i18n key. tasks implement this method.
123:             * @return i18n key for the failed status
124:             */
125:            protected String getTaskSuccessStatusI18NKey() {
126:                return SUCCESS_STATUS_KEY;
127:            }
128:
129:            /**
130:             * returns i18n key
131:             * @return the i18n key
132:             */
133:            protected String getEmptyQueryResultI18NKey(boolean isRuntime) {
134:                return isRuntime ? "jbi.ui.ant.print.jbi.config.info.empty"
135:                        : "jbi.ui.ant.print.jbi.comp.config.info.empty";
136:            }
137:
138:            /**
139:             * returns i18n key
140:             * @return the i18n key
141:             */
142:            protected String getQueryResultHeaderI18NKey(boolean isRuntime) {
143:                return isRuntime ? "jbi.ui.ant.print.jbi.config.info.header"
144:                        : "jbi.ui.ant.print.jbi.comp.config.info.header";
145:            }
146:
147:            /**
148:             * returns i18n key
149:             * @return the i18n key
150:             */
151:            protected String getQueryResultHeaderSeparatorI18NKey(
152:                    boolean isRuntime) {
153:                return isRuntime ? "jbi.ui.ant.print.jbi.config.info.header.separator"
154:                        : "jbi.ui.ant.print.jbi.comp.config.info.header.separator";
155:            }
156:
157:            /**
158:             * returns i18n key
159:             * @return the i18n key
160:             */
161:            protected String getQueryResultPageSeparatorI18NKey(
162:                    boolean isRuntime) {
163:                return isRuntime ? "jbi.ui.ant.print.jbi.config.info.separator"
164:                        : "jbi.ui.ant.print.jbi.comp.config.info.separator";
165:            }
166:
167:            /**
168:             * Printing runtime configuration
169:             * @param params the parameters to be printed
170:             */
171:            protected void printRuntimeConfiguration(List paramList,
172:                    Properties returnProps) {
173:                this .logDebug("Printing Rimtime Configuration ....");
174:                boolean isRuntime = true;
175:                String header = getI18NBundle().getMessage(
176:                        getQueryResultHeaderI18NKey(isRuntime),
177:                        getValidTarget());
178:                String headerSeparator = getI18NBundle().getMessage(
179:                        getQueryResultHeaderSeparatorI18NKey(isRuntime));
180:                String pageSeparator = getI18NBundle().getMessage(
181:                        getQueryResultPageSeparatorI18NKey(isRuntime));
182:                String emptyResult = getI18NBundle().getMessage(
183:                        getEmptyQueryResultI18NKey(isRuntime));
184:
185:                StringWriter stringWriter = new StringWriter();
186:                PrintWriter msgWriter = new PrintWriter(stringWriter);
187:
188:                msgWriter.println(headerSeparator);
189:                msgWriter.println(header);
190:                msgWriter.println(headerSeparator);
191:
192:                if ((returnProps == null) || (returnProps.size() <= 0)) {
193:                    msgWriter.println(emptyResult);
194:                    msgWriter.println(pageSeparator);
195:                } else if ((paramList == null) || (paramList.size() <= 0)) {
196:                    // sort the keys and display for deterministic output
197:                    SortedSet keys = new TreeSet(returnProps.keySet());
198:                    for (Object key : keys) {
199:                        String name = (String) key;
200:                        String value = returnProps.getProperty(name, "");
201:                        String param = getI18NBundle().getMessage(
202:                                "jbi.ui.ant.print.jbi.config.param", name,
203:                                value);
204:                        msgWriter.println(param);
205:                    }
206:                    msgWriter.println(pageSeparator);
207:                } else {
208:                    Iterator itr = paramList.iterator();
209:                    while (itr.hasNext()) {
210:                        String name = "" + ((Param) itr.next()).getName();
211:                        String value = returnProps.getProperty(name);
212:                        if (value != null) {
213:                            String msg = getI18NBundle().getMessage(
214:                                    "jbi.ui.ant.print.jbi.config.param", name,
215:                                    value);
216:                            msgWriter.println(msg);
217:                        } else {
218:                            String msg = getI18NBundle()
219:                                    .getMessage(
220:                                            "jbi.ui.ant.print.jbi.config.param.not.retrieved",
221:                                            name);
222:                            msgWriter.println(msg);
223:                        }
224:                    }
225:                    msgWriter.println(pageSeparator);
226:                }
227:
228:                msgWriter.close();
229:                printMessage(stringWriter.getBuffer().toString());
230:
231:            }
232:
233:            /**
234:             * returns param element list
235:             * @return param List
236:             */
237:            protected List getParamList() {
238:                if (this .mParamList == null) {
239:                    this .mParamList = new ArrayList();
240:                }
241:                return this .mParamList;
242:            }
243:
244:            /**
245:             * factory method for creating the nested element &lt;param>
246:             * @return Logger Object
247:             */
248:            public Param createParam() {
249:                Param param = new Param();
250:                this.getParamList().add(param);
251:                return param;
252:            }
253:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.