Source Code Cross Referenced for JBINode.java in  » IDE-Netbeans » compapp » org » netbeans » modules » sun » manager » jbi » nodes » 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 » IDE Netbeans » compapp » org.netbeans.modules.sun.manager.jbi.nodes 
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
008:         * Development and Distribution License("CDDL") (collectively, the
009:         * "License"). You may not use this file except in compliance with the
010:         * License. You can obtain a copy of the License at
011:         * http://www.netbeans.org/cddl-gplv2.html
012:         * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
013:         * specific language governing permissions and limitations under the
014:         * License.  When distributing the software, include this License Header
015:         * Notice in each file and include the License file at
016:         * nbbuild/licenses/CDDL-GPL-2-CP.  Sun designates this
017:         * particular file as subject to the "Classpath" exception as provided
018:         * by Sun in the GPL Version 2 section of the License file that
019:         * accompanied this code. If applicable, add the following below the
020:         * License Header, with the fields enclosed by brackets [] replaced by
021:         * your own identifying information:
022:         * "Portions Copyrighted [year] [name of copyright owner]"
023:         *
024:         * Contributor(s):
025:         *
026:         * The Original Software is NetBeans. The Initial Developer of the Original
027:         * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
028:         * Microsystems, Inc. All Rights Reserved.
029:         *
030:         * If you wish your version of this file to be governed by only the CDDL
031:         * or only the GPL Version 2, indicate your decision by adding
032:         * "[Contributor] elects to include this software in this distribution
033:         * under the [CDDL or GPL Version 2] license." If you do not indicate a
034:         * single choice of license, a recipient has the option to distribute
035:         * your version of this file under either the CDDL, the GPL Version 2 or
036:         * to extend the choice of license to its licensees as provided above.
037:         * However, if you add GPL Version 2 code and therefore, elected the GPL
038:         * Version 2 license, then the option applies only if the new code is
039:         * made subject to such option by the copyright holder.
040:         */
041:        package org.netbeans.modules.sun.manager.jbi.nodes;
042:
043:        import com.sun.esb.management.api.configuration.ConfigurationService;
044:        import com.sun.esb.management.common.ManagementRemoteException;
045:        import com.sun.esb.management.common.data.FrameworkStatisticsData;
046:        import com.sun.esb.management.common.data.NMRStatisticsData;
047:        import java.awt.Image;
048:        import java.util.ArrayList;
049:        import java.util.Collections;
050:        import java.util.HashMap;
051:        import java.util.List;
052:        import java.util.Map;
053:        import java.util.Properties;
054:        import java.util.TreeMap;
055:        import java.util.logging.Level;
056:        import java.util.logging.Logger;
057:        import javax.management.Attribute;
058:        import javax.management.MBeanAttributeInfo;
059:        import javax.swing.Action;
060:        import javax.swing.ImageIcon;
061:        import org.netbeans.modules.sun.manager.jbi.actions.RefreshAction;
062:        import org.netbeans.modules.sun.manager.jbi.management.AppserverJBIMgmtController;
063:        import org.netbeans.modules.sun.manager.jbi.management.JBIComponentType;
064:        import org.netbeans.modules.sun.manager.jbi.management.wrapper.api.PerformanceMeasurementServiceWrapper;
065:        import org.netbeans.modules.sun.manager.jbi.management.wrapper.api.RuntimeManagementServiceWrapper;
066:        import org.netbeans.modules.sun.manager.jbi.nodes.property.JBIPropertySupportFactory;
067:        import org.netbeans.modules.sun.manager.jbi.util.ComparableAttribute;
068:        import org.netbeans.modules.sun.manager.jbi.util.Utils;
069:        import org.openide.DialogDisplayer;
070:        import org.openide.NotifyDescriptor;
071:        import org.openide.actions.PropertiesAction;
072:        import org.openide.nodes.PropertySupport;
073:        import org.openide.nodes.Sheet;
074:        import org.openide.util.actions.SystemAction;
075:        import org.openide.util.HelpCtx;
076:
077:        /**
078:         * Top node for the JBI lifecycle module.
079:         *
080:         * @author jqian
081:         */
082:        public class JBINode extends AppserverJBIMgmtContainerNode {
083:
084:            private static final String FRAMEWORK_STATISTICS_SHEET_SET_NAME = "FRAMEWORK_STATISTICS"; // NOI18N
085:            private static final String NMR_STATISTICS_SHEET_SET_NAME = "NMR_STATISTICS"; // NOI18N
086:            private static final String LOGGERS_SHEET_SET_NAME = "LOGGERS"; // NOI18N
087:            private static Logger logger = Logger
088:                    .getLogger("org.netbeans.modules.sun.manager.jbi.nodes.JBINode"); // NOI18N   
089:
090:            // Runtime configuration meta data
091:            private static final String RUNTIME_CONFIG_DISPLAY_NAME = "displayName"; // NOI18N
092:            private static final String RUNTIME_CONFIG_TOOLTIP = "toolTip"; // NOI18N
093:            private static final String RUNTIME_CONFIG_IS_STATIC = "isStatic"; // NOI18N
094:            //    private static final String RUNTIME_CONFIG_IS_PASSWORD = "isPassword"; // NOI18N
095:            //    private static final String RUNTIME_CONFIG_MIN_VALUE = "minValue"; // NOI18N
096:            //    private static final String RUNTIME_CONFIG_MAX_VALUE = "maxValue"; // NOI18N
097:            //    private static final String RUNTIME_CONFIG_ENUM_VALUE = "enumValue"; // NOI18N
098:
099:            // A list of runtime configurations that are not very useful for IDE users.
100:            private static final List<String> hiddenRuntimeConfigNames;
101:
102:            static {
103:                hiddenRuntimeConfigNames = new ArrayList<String>();
104:                hiddenRuntimeConfigNames.add("jbiHome"); // NOI18N
105:                hiddenRuntimeConfigNames.add("autoInstallDir"); // NOI18N
106:                hiddenRuntimeConfigNames.add("autoDeployDir"); // NOI18N
107:            }
108:
109:            /** Creates a new instance of JBINode */
110:            public JBINode(final AppserverJBIMgmtController controller) {
111:                super (controller, NodeType.JBI);
112:            }
113:
114:            @Override
115:            public Action[] getActions(boolean flag) {
116:                return new SystemAction[] {
117:                        SystemAction.get(PropertiesAction.class),
118:                        SystemAction.get(RefreshAction.class) };
119:            }
120:
121:            @Override
122:            public Image getIcon(int type) {
123:                return new ImageIcon(getClass().getResource(
124:                        IconConstants.JBI_ICON)).getImage();
125:            }
126:
127:            @Override
128:            public Image getOpenedIcon(int type) {
129:                return getIcon(type);
130:            }
131:
132:            @Override
133:            public void refresh() {
134:                // clear the cache first
135:                RuntimeManagementServiceWrapper service = getRuntimeManagementServiceWrapper();
136:                service
137:                        .clearJBIComponentStatusCache(JBIComponentType.SERVICE_ENGINE);
138:                service
139:                        .clearJBIComponentStatusCache(JBIComponentType.BINDING_COMPONENT);
140:                service
141:                        .clearJBIComponentStatusCache(JBIComponentType.SHARED_LIBRARY);
142:                service.clearServiceAssemblyStatusCache();
143:
144:                super .refresh();
145:
146:                // Explicitly reset the property sheet (since the property sheet in 
147:                // AbstractNode is "sticky").
148:                setSheet(createSheet());
149:            }
150:
151:            @Override
152:            protected Sheet createSheet() {
153:                Sheet sheet = new Sheet();
154:
155:                // Add the general property sheet the non-standard way
156:                try {
157:                    PropertySupport[] generalPropertySupports = getGeneralSheetSetPropertySupports();
158:
159:                    Sheet.Set sheetSet = createSheetSet(GENERAL_SHEET_SET_NAME,
160:                            "LBL_GENERAL_PROPERTIES", // NOI18N
161:                            "DSC_GENERAL_PROPERTIES", // NOI18N
162:                            generalPropertySupports);
163:                    if (sheetSet != null) {
164:                        sheet.put(sheetSet);
165:                    }
166:                } catch (Exception e) {
167:                    logger.warning(e.getMessage());
168:                }
169:
170:                // Augment the general property sheet by adding loggers sheet
171:                try {
172:                    addSheetSet(sheet, LOGGERS_SHEET_SET_NAME,
173:                            "LBL_LOGGERS_PROPERTIES", // NOI18N
174:                            "DSC_LOGGERS_PROPERTIES", // NOI18N
175:                            getLoggerSheetSetProperties());
176:                } catch (ManagementRemoteException e) {
177:                    logger.warning(e.getMessage());
178:                }
179:
180:                // Augment the general property sheet by adding framework statistics sheet
181:                try {
182:                    addSheetSet(sheet, FRAMEWORK_STATISTICS_SHEET_SET_NAME,
183:                            "LBL_FRAMEWORK_STATISTICS_PROPERTIES", // NOI18N
184:                            "DSC_FRAMEWORK_STATISTICS_PROPERTIES", // NOI18N
185:                            getFrameworkStatisticsSheetSetProperties());
186:                } catch (ManagementRemoteException e) {
187:                    logger.warning(e.getMessage());
188:                }
189:
190:                // Augment the general property sheet by adding NMR statistics sheet
191:                try {
192:                    addSheetSet(sheet, NMR_STATISTICS_SHEET_SET_NAME,
193:                            "LBL_NMR_STATISTICS_PROPERTIES", // NOI18N
194:                            "DSC_NMR_STATISTICS_PROPERTIES", // NOI18N
195:                            getNMRStatisticsSheetSetProperties());
196:                } catch (ManagementRemoteException e) {
197:                    logger.warning(e.getMessage());
198:                }
199:
200:                return sheet;
201:            }
202:
203:            private PropertySupport[] getGeneralSheetSetPropertySupports()
204:                    throws ManagementRemoteException {
205:
206:                List<PropertySupport> properties = new ArrayList<PropertySupport>();
207:
208:                AppserverJBIMgmtController controller = getAppserverJBIMgmtController();
209:                ConfigurationService configService = controller
210:                        .getConfigurationService();
211:                Map<String, Object> configMap = configService
212:                        .getRuntimeConfigurationAsMap(SERVER_TARGET);
213:
214:                List<String> keys = new ArrayList<String>();
215:                keys.addAll(configMap.keySet());
216:                Collections.sort(keys);
217:
218:                for (String key : keys) {
219:                    if (hiddenRuntimeConfigNames.contains(key)) {
220:                        continue;
221:                    }
222:
223:                    Object value = configMap.get(key);
224:                    Attribute attr = new Attribute(key, value);
225:
226:                    Properties metaData = configService
227:                            .getRuntimeConfigurationMetaData(key);
228:                    String displayName = metaData
229:                            .getProperty(RUNTIME_CONFIG_DISPLAY_NAME);
230:                    String toolTip = metaData
231:                            .getProperty(RUNTIME_CONFIG_TOOLTIP);
232:                    String isStatic = metaData.getProperty(
233:                            RUNTIME_CONFIG_IS_STATIC, "false"); // NOI18N
234:                    //            String isPassword = metaData.getProperty(RUNTIME_CONFIG_IS_PASSWORD, "false"); // NOI18N
235:                    //            String minValue = metaData.getProperty(RUNTIME_CONFIG_MIN_VALUE);
236:                    //            String maxValue = metaData.getProperty(RUNTIME_CONFIG_MAX_VALUE);
237:                    //            String enumValue = metaData.getProperty(RUNTIME_CONFIG_ENUM_VALUE);
238:
239:                    MBeanAttributeInfo attrInfo = new MBeanAttributeInfo(
240:                            displayName, value.getClass().getName(), toolTip,
241:                            true, !Boolean.parseBoolean(isStatic), false);
242:
243:                    PropertySupport property = JBIPropertySupportFactory
244:                            .getPropertySupport(this , attr, attrInfo);
245:                    properties.add(property);
246:                }
247:
248:                return properties.toArray(new PropertySupport[0]);
249:            }
250:
251:            /**
252:             * Gets the logger properties to be displayed for the framework.
253:             *
254:             * @return A java.util.Map containing all logger properties.
255:             */
256:            private Map<Attribute, MBeanAttributeInfo> getLoggerSheetSetProperties()
257:                    throws ManagementRemoteException {
258:
259:                // Sorted by the fully qualified logger name (loggerCustomName).
260:                // Only display the short name in the property sheet.
261:                Map<Attribute, MBeanAttributeInfo> ret = new TreeMap<Attribute, MBeanAttributeInfo>();
262:
263:                ConfigurationService configService = getConfigurationService();
264:                Map<String, Level> loggerMap = configService
265:                        .getRuntimeLoggerLevels(SERVER_TARGET);
266:
267:                for (String loggerCustomName : loggerMap.keySet()) {
268:                    Level logLevel = loggerMap.get(loggerCustomName);
269:                    String displayName = configService
270:                            .getRuntimeLoggerDisplayName(loggerCustomName,
271:                                    SERVER_TARGET);
272:
273:                    Attribute attr = new Attribute(loggerCustomName, logLevel);
274:                    MBeanAttributeInfo info = new MBeanAttributeInfo(
275:                            displayName, "java.util.logging.Level", // NOI18N
276:                            displayName + " (" + loggerCustomName + ")", // NOI18N
277:                            true, true, false);
278:                    ret.put(new ComparableAttribute(attr), info);
279:                }
280:
281:                return ret;
282:            }
283:
284:            private Map<Attribute, MBeanAttributeInfo> getFrameworkStatisticsSheetSetProperties()
285:                    throws ManagementRemoteException {
286:                AppserverJBIMgmtController controller = getAppserverJBIMgmtController();
287:                PerformanceMeasurementServiceWrapper perfService = controller
288:                        .getPerformanceMeasurementServiceWrapper();
289:                FrameworkStatisticsData statistics = perfService
290:                        .getFrameworkStatistics(SERVER_TARGET);
291:                return Utils.getIntrospectedPropertyMap(statistics, true,
292:                        MODEL_BEAN_INFO_PACKAGE_NAME);
293:            }
294:
295:            private Map<Attribute, MBeanAttributeInfo> getNMRStatisticsSheetSetProperties()
296:                    throws ManagementRemoteException {
297:                AppserverJBIMgmtController controller = getAppserverJBIMgmtController();
298:                PerformanceMeasurementServiceWrapper perfService = controller
299:                        .getPerformanceMeasurementServiceWrapper();
300:                NMRStatisticsData statistics = perfService
301:                        .getNMRStatistics(SERVER_TARGET);
302:                return Utils.getIntrospectedPropertyMap(statistics, true);
303:            }
304:
305:            public Attribute setSheetProperty(String attrName, Object value) {
306:                try {
307:                    ConfigurationService configService = getConfigurationService();
308:                    Map<String, Object> map = new HashMap<String, Object>();
309:                    map.put(attrName, value);
310:                    configService.setRuntimeConfiguration(map, SERVER_TARGET);
311:
312:                    // Get the new value
313:                    value = configService.getRuntimeConfigurationAsMap(
314:                            SERVER_TARGET).get(attrName);
315:                } catch (ManagementRemoteException e) {
316:                    NotifyDescriptor d = new NotifyDescriptor.Message(e
317:                            .getMessage(), NotifyDescriptor.ERROR_MESSAGE);
318:                    DialogDisplayer.getDefault().notify(d);
319:                }
320:
321:                return new Attribute(attrName, value);
322:            }
323:
324:            /**
325:             * Sets the logger property of the framework.
326:             * 
327:             * @param loggerName
328:             * @param value
329:             * @return
330:             */
331:            public Attribute setLoggerSheetProperty(String loggerName,
332:                    Level value) {
333:                try {
334:                    ConfigurationService configService = getConfigurationService();
335:                    configService.setRuntimeLoggerLevel(loggerName, value,
336:                            SERVER_TARGET);
337:                } catch (Exception e) {
338:                    NotifyDescriptor d = new NotifyDescriptor.Message(e
339:                            .getMessage(), NotifyDescriptor.ERROR_MESSAGE);
340:                    DialogDisplayer.getDefault().notify(d);
341:                    value = null;
342:                }
343:
344:                return new Attribute(loggerName, value);
345:            }
346:
347:            @Override
348:            public HelpCtx getHelpCtx() {
349:                return new HelpCtx(JBINode.class);
350:            }
351:        }
ww_w.__j__a__v__a__2__s___.c_o__m__ | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.