Source Code Cross Referenced for JBIComponentNode.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) 


0001:        /*
0002:         * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
0003:         *
0004:         * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
0005:         *
0006:         * The contents of this file are subject to the terms of either the GNU
0007:         * General Public License Version 2 only ("GPL") or the Common
0008:         * Development and Distribution License("CDDL") (collectively, the
0009:         * "License"). You may not use this file except in compliance with the
0010:         * License. You can obtain a copy of the License at
0011:         * http://www.netbeans.org/cddl-gplv2.html
0012:         * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
0013:         * specific language governing permissions and limitations under the
0014:         * License.  When distributing the software, include this License Header
0015:         * Notice in each file and include the License file at
0016:         * nbbuild/licenses/CDDL-GPL-2-CP.  Sun designates this
0017:         * particular file as subject to the "Classpath" exception as provided
0018:         * by Sun in the GPL Version 2 section of the License file that
0019:         * accompanied this code. If applicable, add the following below the
0020:         * License Header, with the fields enclosed by brackets [] replaced by
0021:         * your own identifying information:
0022:         * "Portions Copyrighted [year] [name of copyright owner]"
0023:         *
0024:         * Contributor(s):
0025:         *
0026:         * The Original Software is NetBeans. The Initial Developer of the Original
0027:         * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
0028:         * Microsystems, Inc. All Rights Reserved.
0029:         *
0030:         * If you wish your version of this file to be governed by only the CDDL
0031:         * or only the GPL Version 2, indicate your decision by adding
0032:         * "[Contributor] elects to include this software in this distribution
0033:         * under the [CDDL or GPL Version 2] license." If you do not indicate a
0034:         * single choice of license, a recipient has the option to distribute
0035:         * your version of this file under either the CDDL, the GPL Version 2 or
0036:         * to extend the choice of license to its licensees as provided above.
0037:         * However, if you add GPL Version 2 code and therefore, elected the GPL
0038:         * Version 2 license, then the option applies only if the new code is
0039:         * made subject to such option by the copyright holder.
0040:         */
0041:        package org.netbeans.modules.sun.manager.jbi.nodes;
0042:
0043:        import com.sun.esb.management.api.administration.AdministrationService;
0044:        import com.sun.esb.management.api.configuration.ConfigurationService;
0045:        import com.sun.esb.management.api.installation.InstallationService;
0046:        import com.sun.esb.management.common.ManagementRemoteException;
0047:        import com.sun.esb.management.common.data.ComponentStatisticsData;
0048:        import com.sun.jbi.ui.common.JBIComponentInfo;
0049:        import com.sun.jbi.ui.common.ServiceAssemblyInfo;
0050:        import java.io.IOException;
0051:        import java.awt.Image;
0052:        import java.io.File;
0053:        import java.io.StringReader;
0054:        import java.util.ArrayList;
0055:        import java.util.Collections;
0056:        import java.util.HashMap;
0057:        import java.util.HashSet;
0058:        import java.util.LinkedHashMap;
0059:        import java.util.List;
0060:        import java.util.Map;
0061:        import java.util.ResourceBundle;
0062:        import java.util.Set;
0063:        import java.util.TreeMap;
0064:        import java.util.logging.Level;
0065:        import java.util.logging.Logger;
0066:        import javax.management.Attribute;
0067:        import javax.management.MBeanAttributeInfo;
0068:        import javax.management.openmbean.CompositeData;
0069:        import javax.management.openmbean.TabularData;
0070:        import javax.swing.Action;
0071:        import javax.swing.JFileChooser;
0072:        import javax.swing.SwingUtilities;
0073:        import javax.xml.parsers.DocumentBuilder;
0074:        import javax.xml.parsers.DocumentBuilderFactory;
0075:        import javax.xml.parsers.ParserConfigurationException;
0076:        import org.netbeans.modules.sun.manager.jbi.management.JBIMBeanTaskResultHandler;
0077:        import org.netbeans.modules.sun.manager.jbi.util.ProgressUI;
0078:        import org.netbeans.modules.sun.manager.jbi.GenericConstants;
0079:        import org.netbeans.modules.sun.manager.jbi.actions.AdvancedAction;
0080:        import org.netbeans.modules.sun.manager.jbi.actions.RefreshAction;
0081:        import org.netbeans.modules.sun.manager.jbi.actions.ShowComponentEndpointsStatisticsAction;
0082:        import org.netbeans.modules.sun.manager.jbi.actions.ShutdownAction;
0083:        import org.netbeans.modules.sun.manager.jbi.actions.StartAction;
0084:        import org.netbeans.modules.sun.manager.jbi.actions.StopAction;
0085:        import org.netbeans.modules.sun.manager.jbi.actions.UndeployAction;
0086:        import org.netbeans.modules.sun.manager.jbi.actions.UninstallAction;
0087:        import org.netbeans.modules.sun.manager.jbi.actions.UpgradeAction;
0088:        import org.netbeans.modules.sun.manager.jbi.management.AppserverJBIMgmtController;
0089:        import org.netbeans.modules.sun.manager.jbi.management.model.JBIComponentActionDescriptor;
0090:        import org.netbeans.modules.sun.manager.jbi.management.JBIComponentType;
0091:        import org.netbeans.modules.sun.manager.jbi.management.model.JBIComponentConfigurationDescriptor;
0092:        import org.netbeans.modules.sun.manager.jbi.management.model.JBIComponentConfigurationMBeanAttributeInfo;
0093:        import org.netbeans.modules.sun.manager.jbi.management.model.JBIComponentConfigurationParser;
0094:        import org.netbeans.modules.sun.manager.jbi.management.model.JBIComponentStatus;
0095:        import org.netbeans.modules.sun.manager.jbi.management.wrapper.api.PerformanceMeasurementServiceWrapper;
0096:        import org.netbeans.modules.sun.manager.jbi.management.wrapper.api.RuntimeManagementServiceWrapper;
0097:        import org.netbeans.modules.sun.manager.jbi.nodes.property.NewSchemaBasedConfigPropertySupportFactory;
0098:        import org.netbeans.modules.sun.manager.jbi.util.ComparableAttribute;
0099:        import org.netbeans.modules.sun.manager.jbi.util.DoNotShowAgainConfirmation;
0100:        import org.netbeans.modules.sun.manager.jbi.util.FileFilters;
0101:        import org.netbeans.modules.sun.manager.jbi.util.StackTraceUtil;
0102:        import org.netbeans.modules.sun.manager.jbi.util.Utils;
0103:        import org.openide.nodes.Sheet;
0104:        import org.openide.DialogDisplayer;
0105:        import org.openide.NotifyDescriptor;
0106:        import org.openide.actions.PropertiesAction;
0107:        import org.openide.nodes.Node;
0108:        import org.openide.nodes.PropertySupport;
0109:        import org.openide.util.NbBundle;
0110:        import org.openide.util.actions.SystemAction;
0111:        import org.w3c.dom.Document;
0112:        import org.w3c.dom.Element;
0113:        import org.w3c.dom.NodeList;
0114:        import org.xml.sax.InputSource;
0115:        import org.xml.sax.SAXException;
0116:
0117:        /**
0118:         * Abstract Node class for a JBI Component (Service Engine, Binding Component,
0119:         * or Shared Library).
0120:         *
0121:         * @author jqian
0122:         */
0123:        public abstract class JBIComponentNode extends AppserverJBIMgmtLeafNode
0124:                implements  Refreshable, Startable, Stoppable, Shutdownable,
0125:                Uninstallable, Undeployable, Upgradeable {
0126:
0127:            public static final String ENVIRONMENT_VARIABLES_NAME = "EnvironmentVariables"; // NOI18N
0128:            public static final String APPLICATION_VARIABLES_NAME = "ApplicationVariables"; // NOI18N
0129:            public static final String APPLICATION_CONFIGURATIONS_NAME = "ApplicationConfigurations"; // NOI18N
0130:            public static final String LAST_JBI_COMPONENT_INSTALLATION_DIRECTORY = "lastJBIComponentInstallationDir"; // NOI18N    
0131:            private static final String IDENTIFICATION_SHEET_SET_NAME = "IDENTIFICATION"; // NOI18N
0132:            private static final String LOGGERS_SHEET_SET_NAME = "LOGGERS"; // NOI18N
0133:            private static final String CONFIGURATION_SHEET_SET_NAME = "CONFIGURATION"; // NOI18N
0134:            private static final String COMPONENT_STATISTICS_SHEET_SET_NAME = "COMPONENT_STATISTICS"; // NOI18N
0135:            private static final String ACTIONABLE_MBEAN_NAME = "ManagementActions";
0136:            private static final String ACTIONABLE_MBEAN_GET_ACTIONS_OPERATION_NAME = "getActions";
0137:            private boolean busy;
0138:            private JBIComponentType compType;
0139:            private JBIComponentConfigurationDescriptor rootConfigDescriptor;
0140:            // Whether the component's jbi.xml has been checked or not. 
0141:            private boolean hasJbiXmlBeenChecked;
0142:            // This is not persistent across sessions.
0143:            private static boolean confirmComponentUninstallation = true;
0144:            // This is not persistent across sessions.
0145:            private static boolean confirmComponentShutdownDuringUpgrade = true;
0146:            // This is not persistent across sessions.
0147:            private static boolean confirmForServiceAssembliesUndeployment = true;
0148:            private static Logger logger = Logger
0149:                    .getLogger("org.netbeans.modules.sun.manager.jbi.nodes.JBIComponentNode"); // NOI18N
0150:
0151:            public JBIComponentNode(
0152:                    final AppserverJBIMgmtController controller,
0153:                    JBIComponentType compType, NodeType nodeType, String name,
0154:                    String description) {
0155:                super (controller, nodeType);
0156:
0157:                setName(name);
0158:
0159:                setDisplayName(name);
0160:
0161:                // Use HTML version for tooltip.
0162:                setShortDescription(Utils.getTooltip(description));
0163:                // Use non-HTML version in the property sheet's description area.
0164:                setValue("nodeDescription", description); // NOI18N 
0165:
0166:                this .compType = compType;
0167:            }
0168:
0169:            @Override
0170:            protected Sheet createSheet() {
0171:                Sheet sheet = new Sheet();
0172:
0173:                addSheetSet(sheet, GENERAL_SHEET_SET_NAME,
0174:                        "LBL_GENERAL_PROPERTIES", // NOI18N
0175:                        "DSC_GENERAL_PROPERTIES", // NOI18N
0176:                        getGeneralSheetSetProperties());
0177:
0178:                // 1. Augment the general property sheet by adding Identification sheet
0179:                try {
0180:                    String installationDescriptor = getInstallationDescriptor();
0181:                    Map<Attribute, MBeanAttributeInfo> identificationPropertyMap = getIdentificationSheetSetProperties(installationDescriptor);
0182:                    addSheetSet(sheet, IDENTIFICATION_SHEET_SET_NAME,
0183:                            "LBL_IDENTIFICATION_PROPERTIES", // NOI18N
0184:                            "DSC_IDENTIFICATION_PROPERTIES", // NOI18N
0185:                            identificationPropertyMap);
0186:                } catch (Exception e) {
0187:                    logger.warning(e.getMessage());
0188:                }
0189:
0190:                // 2. Augment the general property sheet by adding Configuration sheet
0191:                try {
0192:                    // #114173 The configuration schema is only available when  
0193:                    // the component is in started state.
0194:                    boolean isStarted = false;
0195:                    Sheet.Set generalSheetSet = sheet
0196:                            .get(GENERAL_SHEET_SET_NAME);
0197:                    if (generalSheetSet != null) {
0198:                        Property stateProperty = generalSheetSet.get("State"); // NOI18N
0199:                        if (stateProperty != null) {
0200:                            String state = (String) stateProperty.getValue();
0201:                            if (state != null
0202:                                    && state.equalsIgnoreCase("started")) { // NOI18N
0203:                                isStarted = true;
0204:                            }
0205:                        }
0206:                    }
0207:                    if (isStarted && !hasJbiXmlBeenChecked) {
0208:                        String compName = getName();
0209:                        AdministrationService adminService = getAdministrationService();
0210:                        String jbiXml = adminService
0211:                                .getComponentInstallationDescriptor(compName);
0212:                        rootConfigDescriptor = JBIComponentConfigurationParser
0213:                                .parse(jbiXml);
0214:                        hasJbiXmlBeenChecked = true;
0215:                    }
0216:
0217:                    Map<Attribute, ? extends MBeanAttributeInfo> configPropertyMap = getConfigurationSheetSetProperties();
0218:
0219:                    Sheet.Set sheetSet = null;
0220:                    if (rootConfigDescriptor != null) {
0221:                        PropertySupport[] propertySupports = createPropertySupportArrayWithSchema((Map<Attribute, JBIComponentConfigurationMBeanAttributeInfo>) configPropertyMap);
0222:                        sheetSet = createSheetSet(CONFIGURATION_SHEET_SET_NAME,
0223:                                "LBL_CONFIG_PROPERTIES", // NOI18N
0224:                                "DSC_CONFIG_PROPERTIES", // NOI18N
0225:                                propertySupports);
0226:                    } else {
0227:                        sheetSet = createSheetSet(CONFIGURATION_SHEET_SET_NAME,
0228:                                "LBL_CONFIG_PROPERTIES", // NOI18N
0229:                                "DSC_CONFIG_PROPERTIES", // NOI18N
0230:                                configPropertyMap);
0231:                    }
0232:
0233:                    if (sheetSet != null) {
0234:                        sheet.put(sheetSet);
0235:                    }
0236:                } catch (Exception e) {
0237:                    logger.warning(e.getMessage());
0238:                }
0239:
0240:                // 3. Augment the general property sheet by adding component 
0241:                // statistics sheet.
0242:                if (JBIComponentStatus.STARTED_STATE.equals(getState())) {
0243:                    try {
0244:                        addSheetSet(sheet, COMPONENT_STATISTICS_SHEET_SET_NAME,
0245:                                "LBL_COMPONENT_STATISTICS_PROPERTIES", // NOI18N
0246:                                "DSC_COMPONENT_STATISTICS_PROPERTIES", // NOI18N
0247:                                getComponentStatisticsSheetSetProperties());
0248:                    } catch (ManagementRemoteException e) {
0249:                        logger.warning(e.getMessage());
0250:                    }
0251:                }
0252:
0253:                return sheet;
0254:            }
0255:
0256:            private Map<Attribute, MBeanAttributeInfo> getComponentStatisticsSheetSetProperties()
0257:                    throws ManagementRemoteException {
0258:                AppserverJBIMgmtController controller = getAppserverJBIMgmtController();
0259:                PerformanceMeasurementServiceWrapper perfService = controller
0260:                        .getPerformanceMeasurementServiceWrapper();
0261:                ComponentStatisticsData statistics = perfService
0262:                        .getComponentStatistics(getName(), SERVER_TARGET);
0263:                return Utils.getIntrospectedPropertyMap(statistics, true);
0264:            }
0265:
0266:            protected PropertySupport[] createPropertySupportArrayWithSchema(
0267:                    final Map<Attribute, JBIComponentConfigurationMBeanAttributeInfo> attrMap) {
0268:
0269:                List<PropertySupport> supports = new ArrayList<PropertySupport>();
0270:
0271:                try {
0272:                    String compName = getName();
0273:
0274:                    for (Attribute attr : attrMap.keySet()) {
0275:                        JBIComponentConfigurationMBeanAttributeInfo info = attrMap
0276:                                .get(attr);
0277:
0278:                        PropertySupport support = NewSchemaBasedConfigPropertySupportFactory
0279:                                .getPropertySupport(this , attr, info);
0280:
0281:                        if (support == null) {
0282:
0283:                            //                    if (attr.getValue() instanceof TabularData) {
0284:                            //                        // There is no schema support for tabular data.
0285:                            //                        support = JBIPropertySupportFactory.getPropertySupport(
0286:                            //                                this, attr, info);
0287:                            //                        supports.add(support);
0288:                            //                        continue;
0289:                            //                    }
0290:
0291:                            String msg = "Failed to get property support for "
0292:                                    + compName
0293:                                    + ":"
0294:                                    + attr.getName()
0295:                                    + ". "
0296:                                    + "Missing definition in configuration schema.";
0297:                            NotifyDescriptor d = new NotifyDescriptor.Message(
0298:                                    msg, NotifyDescriptor.WARNING_MESSAGE);
0299:                            DialogDisplayer.getDefault().notify(d);
0300:                        } else {
0301:                            supports.add(support);
0302:                        }
0303:                    }
0304:
0305:                } catch (Exception e) {
0306:                    e.printStackTrace();
0307:                }
0308:
0309:                return supports.toArray(new PropertySupport[0]);
0310:            }
0311:
0312:            protected Map<Attribute, MBeanAttributeInfo> getGeneralSheetSetProperties() {
0313:                JBIComponentInfo componentInfo = getJBIComponentInfo();
0314:                return Utils.getIntrospectedPropertyMap(componentInfo, false,
0315:                        MODEL_BEAN_INFO_PACKAGE_NAME);
0316:            }
0317:
0318:            /**
0319:             * Gets the property map mapping from Attribute to MBeanAttributeInfo.
0320:             * 
0321:             * If there is no schema defined for the component configurations, then
0322:             * all the attributes will be sorted based on their names (not display names).
0323:             * 
0324:             * If there is a schema defined for the component configurations, then
0325:             * all the attributes will be sorted based on the sequence definition
0326:             * in the schema.
0327:             * 
0328:             * @return
0329:             */
0330:            private Map<Attribute, ? extends MBeanAttributeInfo> getConfigurationSheetSetProperties()
0331:                    throws ManagementRemoteException {
0332:
0333:                Map<Attribute, MBeanAttributeInfo> ret = new LinkedHashMap<Attribute, MBeanAttributeInfo>();
0334:
0335:                ConfigurationService configService = getConfigurationService();
0336:                String compName = getName();
0337:
0338:                Map<String, Object> configMap = configService
0339:                        .getComponentConfigurationAsMap(compName, SERVER_TARGET);
0340:
0341:                try {
0342:                    if (rootConfigDescriptor == null) {
0343:                        // Fallback on regular attributes if the component does not have 
0344:                        // configuration schema defined yet.
0345:                        List<String> keys = new ArrayList<String>();
0346:                        if (configMap != null) {
0347:                            keys.addAll(configMap.keySet());
0348:                        }
0349:                        Collections.sort(keys);
0350:
0351:                        for (String key : keys) {
0352:                            Object value = configMap.get(key);
0353:                            Attribute attr = new Attribute(key, value);
0354:                            MBeanAttributeInfo attrInfo = new MBeanAttributeInfo(
0355:                                    key, value.getClass().getName(), key, // need acess to MBeanAttributeInfo
0356:                                    true, true, false);
0357:                            ret.put(attr, attrInfo);
0358:                        }
0359:
0360:                        // App Var/Config is only available when component is started.
0361:                        if (JBIComponentStatus.STARTED_STATE.equals(getState())) {
0362:                            try {
0363:                                if (configService.isAppVarsSupported(compName,
0364:                                        SERVER_TARGET)) {
0365:                                    TabularData appVars = configService
0366:                                            .getApplicationVariablesAsTabularData(
0367:                                                    compName, SERVER_TARGET);
0368:                                    Attribute attr = new Attribute(
0369:                                            APPLICATION_VARIABLES_NAME, appVars);
0370:                                    MBeanAttributeInfo attrInfo = new MBeanAttributeInfo(
0371:                                            APPLICATION_VARIABLES_NAME,
0372:                                            "javax.management.openmbean.TabularData", // NOI18N
0373:                                            "Application variables", true,
0374:                                            true, false);
0375:                                    ret.put(attr, attrInfo);
0376:                                }
0377:                            } catch (Exception e) {
0378:                                e.printStackTrace();
0379:                            }
0380:
0381:                            try {
0382:                                if (configService.isAppConfigSupported(
0383:                                        compName, SERVER_TARGET)) {
0384:                                    TabularData appConfigs = configService
0385:                                            .getApplicationConfigurationsAsTabularData(
0386:                                                    compName, SERVER_TARGET);
0387:                                    Attribute attr = new Attribute(
0388:                                            APPLICATION_CONFIGURATIONS_NAME,
0389:                                            appConfigs);
0390:                                    MBeanAttributeInfo attrInfo = new MBeanAttributeInfo(
0391:                                            APPLICATION_CONFIGURATIONS_NAME,
0392:                                            "javax.management.openmbean.TabularData", // NOI18N
0393:                                            "Application configurations", true,
0394:                                            true, false);
0395:                                    ret.put(attr, attrInfo);
0396:                                }
0397:                            } catch (Exception e) {
0398:                                e.printStackTrace();
0399:                            }
0400:                        }
0401:
0402:                    } else {
0403:                        // Attributes are ordered based on schema definition.
0404:                        addProperty(ret, rootConfigDescriptor, configService,
0405:                                configMap);
0406:                    }
0407:                } catch (Exception e) {
0408:                    e.printStackTrace();
0409:                }
0410:
0411:                return ret;
0412:            }
0413:
0414:            private void addProperty(
0415:                    Map<Attribute, MBeanAttributeInfo> attrMap,
0416:                    JBIComponentConfigurationDescriptor configDescriptor,
0417:                    ConfigurationService configService,
0418:                    Map<String, Object> configMap)
0419:                    throws ManagementRemoteException {
0420:
0421:                String name = configDescriptor.getName();
0422:                Object value = null;
0423:
0424:                if (configDescriptor instanceof  JBIComponentConfigurationDescriptor.ApplicationConfiguration) {
0425:                    if (JBIComponentStatus.STARTED_STATE.equals(getState())) {
0426:                        value = configService
0427:                                .getApplicationConfigurationsAsTabularData(
0428:                                        getName(), SERVER_TARGET);
0429:                    }
0430:                } else if (configDescriptor instanceof  JBIComponentConfigurationDescriptor.ApplicationVariable) {
0431:                    if (JBIComponentStatus.STARTED_STATE.equals(getState())) {
0432:                        value = configService
0433:                                .getApplicationVariablesAsTabularData(
0434:                                        getName(), SERVER_TARGET);
0435:                    }
0436:                } else if (configDescriptor.isProperty()) {
0437:                    if (!configDescriptor.showDisplayAtRuntime()) {
0438:                        return;
0439:                    }
0440:                    value = configMap.get(name);
0441:                } else { // PropertyGroup or root descriptor
0442:                    for (JBIComponentConfigurationDescriptor childDescriptor : configDescriptor
0443:                            .getChildren()) {
0444:                        addProperty(attrMap, childDescriptor, configService,
0445:                                configMap);
0446:                    }
0447:                }
0448:
0449:                if (value != null) {
0450:                    Attribute attr = new Attribute(name, value);
0451:
0452:                    JBIComponentConfigurationMBeanAttributeInfo attrInfo = new JBIComponentConfigurationMBeanAttributeInfo(
0453:                            configDescriptor, value.getClass().getName(), true,
0454:                            true, false);
0455:
0456:                    attrMap.put(attr, attrInfo);
0457:                }
0458:            }
0459:
0460:            /**
0461:             * Sets the property as an attribute to the underlying AMX mbeans. It
0462:             * usually will delegate to the controller object which is responsible for
0463:             * finding the correct AMX mbean objectname in order to execute a
0464:             * JMX setAttribute.
0465:             *
0466:             * @param attrName The name of the property to be set.
0467:             * @param value The value retrieved from the property sheet to be set in the
0468:             *        backend.
0469:             * @returns the updated Attribute accessed from the Sheet.
0470:             */
0471:            public Attribute setSheetProperty(String attrName, Object value) {
0472:
0473:                if (StackTraceUtil
0474:                        .isCalledBy(
0475:                        //PropertyDialogManager.class.getCanonicalName(),
0476:                                "org.openide.explorer.propertysheet.PropertyDialogManager", // NOI18N
0477:                                "cancelValue")) { // NOI18N
0478:                    return new Attribute(attrName, value);
0479:                }
0480:                // Only configuration properties on the component's property sheet is editable.
0481:                try {
0482:                    ConfigurationService configService = getConfigurationService();
0483:                    String compName = getName();
0484:                    Map<String, Object> map = new HashMap<String, Object>();
0485:                    map.put(attrName, value);
0486:                    configService.setComponentConfiguration(compName, map,
0487:                            SERVER_TARGET);
0488:
0489:                    // Get the new value
0490:                    value = configService.getComponentConfigurationAsMap(
0491:                            compName, SERVER_TARGET).get(attrName);
0492:                } catch (ManagementRemoteException e) {
0493:                    NotifyDescriptor d = new NotifyDescriptor.Message(e
0494:                            .getMessage(), NotifyDescriptor.ERROR_MESSAGE);
0495:                    DialogDisplayer.getDefault().notify(d);
0496:                }
0497:
0498:                return new Attribute(attrName, value);
0499:            }
0500:
0501:            public Attribute setLoggerSheetProperty(String loggerName,
0502:                    Level value) {
0503:                try {
0504:                    ConfigurationService configService = getConfigurationService();
0505:                    String compName = getName();
0506:                    configService.setComponentLoggerLevel(compName, loggerName,
0507:                            value, SERVER_TARGET, null); // null?
0508:
0509:                    // changing top-level logger property has bigger impact
0510:                    updatePropertySheet();
0511:                } catch (Exception e) {
0512:                    NotifyDescriptor d = new NotifyDescriptor.Message(e
0513:                            .getMessage(), NotifyDescriptor.ERROR_MESSAGE);
0514:                    DialogDisplayer.getDefault().notify(d);
0515:                    value = null;
0516:                }
0517:
0518:                return new Attribute(loggerName, value);
0519:            }
0520:
0521:            /**
0522:             * Updates an existing application variable.
0523:             * 
0524:             * @param name      application variable name
0525:             * @param value     new value of the application variable
0526:             * @return  an XML management message if the operation is a complete 
0527:             *          or partial success
0528:             * @throw ManagementRemoteException if the operation is a complete failure
0529:             */
0530:            public String setApplicationVariable(String name,
0531:                    CompositeData value) throws ManagementRemoteException {
0532:                ConfigurationService configService = getConfigurationService();
0533:                String compName = getName();
0534:                return configService.setApplicationVariable(compName,
0535:                        SERVER_TARGET, name, value);
0536:            }
0537:
0538:            /**
0539:             * Adds a new application variable.
0540:             * 
0541:             * @param name      application variable name
0542:             * @param value     value of the application variable
0543:             * @return  an XML management message if the operation is a complete 
0544:             *          or partial success
0545:             * @throw ManagementRemoteException if the operation is a complete failure
0546:             */
0547:            public String addApplicationVariable(String name,
0548:                    CompositeData value) throws ManagementRemoteException {
0549:                ConfigurationService configService = getConfigurationService();
0550:                String compName = getName();
0551:                return configService.addApplicationVariable(compName,
0552:                        SERVER_TARGET, name, value);
0553:            }
0554:
0555:            /**
0556:             * Deletes an existing application variable.
0557:             * 
0558:             * @param name  an existing application variable name
0559:             * @return  an XML management message if the operation is a complete 
0560:             *          or partial success
0561:             * @throw ManagementRemoteException if the operation is a complete failure
0562:             */
0563:            public String deleteApplicationVariable(String name)
0564:                    throws ManagementRemoteException {
0565:                ConfigurationService configService = getConfigurationService();
0566:                String compName = getName();
0567:                return configService.deleteApplicationVariables(compName,
0568:                        SERVER_TARGET, new String[] { name }); // TODO: support mass-deletion
0569:            }
0570:
0571:            /**
0572:             * Updates an existing application configuration.
0573:             * 
0574:             * @param name      application configuration name
0575:             * @param value     new value of composite data
0576:             * @return  an XML management message if the operation is a complete 
0577:             *          or partial success
0578:             * @throw ManagementRemoteException if the operation is a complete failure
0579:             */
0580:            public String setApplicationConfiguration(String name,
0581:                    CompositeData value) throws ManagementRemoteException {
0582:                ConfigurationService configService = getConfigurationService();
0583:                String compName = getName();
0584:                return configService.setApplicationConfiguration(compName,
0585:                        SERVER_TARGET, name, value);
0586:            }
0587:
0588:            /**
0589:             * Adds a new application configuration.
0590:             * 
0591:             * @param name      application configuration name
0592:             * @param value     new value of composite data
0593:             * @return  an XML management message if the operation is a complete 
0594:             *          or partial success
0595:             * @throw ManagementRemoteException if the operation is a complete failure
0596:             */
0597:            public String addApplicationConfiguration(String name,
0598:                    CompositeData value) throws ManagementRemoteException {
0599:                ConfigurationService configService = getConfigurationService();
0600:                String compName = getName();
0601:                return configService.addApplicationConfiguration(compName,
0602:                        SERVER_TARGET, name, value);
0603:            }
0604:
0605:            /**
0606:             * Deletes an existing application configuration.
0607:             * 
0608:             * @param name  application configuration name
0609:             * @return  an XML management message if the operation is a complete 
0610:             *          or partial success
0611:             * @throw ManagementRemoteException if the operation is a complete failure
0612:             */
0613:            public String deleteApplicationConfiguration(String name)
0614:                    throws ManagementRemoteException {
0615:                ConfigurationService configService = getConfigurationService();
0616:                String compName = getName();
0617:                return configService.deleteApplicationConfiguration(compName,
0618:                        SERVER_TARGET, name);
0619:            }
0620:
0621:            public void refresh() {
0622:                // Explicitly reset the property sheet (since the property sheet in 
0623:                // AbstractNode is "sticky").
0624:                setSheet(createSheet());
0625:            }
0626:
0627:            /**
0628:             *
0629:             */
0630:            @Override
0631:            public Image getIcon(int type) {
0632:                String state = getState();
0633:                String iconName = getIconName(state);
0634:
0635:                String externalBadgeIconName = null;
0636:                if (busy) {
0637:                    externalBadgeIconName = IconConstants.BUSY_ICON;
0638:                } else {
0639:                    if (JBIComponentInfo.SHUTDOWN_STATE.equals(state)) {
0640:                        externalBadgeIconName = getInstalledIconBadgeName();
0641:                    } else if (JBIComponentInfo.STOPPED_STATE.equals(state)) {
0642:                        externalBadgeIconName = getStoppedIconBadgeName();
0643:                    } else if (!JBIComponentInfo.STARTED_STATE.equals(state)) {
0644:                        externalBadgeIconName = getUnknownIconBadgeName();
0645:                    }
0646:                }
0647:
0648:                return Utils.getBadgedIcon(getClass(), iconName, null,
0649:                        externalBadgeIconName);
0650:            }
0651:
0652:            protected String getInstalledIconBadgeName() {
0653:                return IconConstants.INSTALLED_ICON;
0654:            }
0655:
0656:            protected String getStoppedIconBadgeName() {
0657:                return IconConstants.STOPPED_ICON;
0658:            }
0659:
0660:            protected String getUnknownIconBadgeName() {
0661:                return IconConstants.UNKNOWN_ICON;
0662:            }
0663:
0664:            /**
0665:             *
0666:             * @param busy
0667:             */
0668:            private void setBusy(boolean busy) {
0669:                this .busy = busy;
0670:                fireIconChange();
0671:            }
0672:
0673:            /**
0674:             *
0675:             * @return
0676:             */
0677:            private JBIComponentInfo getJBIComponentInfo() {
0678:                RuntimeManagementServiceWrapper mgmtService = getRuntimeManagementServiceWrapper();
0679:
0680:                if (mgmtService != null) {
0681:                    try {
0682:                        return mgmtService.getJBIComponent(compType, getName(),
0683:                                SERVER_TARGET);
0684:                    } catch (ManagementRemoteException e) {
0685:                        NotifyDescriptor d = new NotifyDescriptor.Message(e
0686:                                .getMessage(), NotifyDescriptor.ERROR_MESSAGE);
0687:                        DialogDisplayer.getDefault().notify(d);
0688:                    }
0689:                }
0690:
0691:                return null;
0692:            }
0693:
0694:            private void clearJBIComponentStatusCache(JBIComponentType compType) {
0695:                getRuntimeManagementServiceWrapper()
0696:                        .clearJBIComponentStatusCache(compType);
0697:            }
0698:
0699:            /**
0700:             *
0701:             * @return
0702:             */
0703:            private String getState() {
0704:                JBIComponentInfo info = getJBIComponentInfo();
0705:                return info == null ? null : info.getState();
0706:            }
0707:
0708:            private void updatePropertySheet() {
0709:                Sheet sheet = createSheet();
0710:                setSheet(sheet);
0711:                firePropertySetsChange(null, null);
0712:            }
0713:
0714:            //========================== Startable =====================================
0715:            public boolean canStart() {
0716:                String state = getState();
0717:                return !busy
0718:                        && (JBIComponentInfo.STOPPED_STATE.equals(state) || JBIComponentInfo.SHUTDOWN_STATE
0719:                                .equals(state));
0720:            }
0721:
0722:            public void start() {
0723:                RuntimeManagementServiceWrapper mgmtService = getRuntimeManagementServiceWrapper();
0724:                if (mgmtService == null) {
0725:                    return;
0726:                }
0727:
0728:                String progressLabel = getStartProgressLabel();
0729:                final String componentName = getName();
0730:                String title = NbBundle.getMessage(JBIComponentNode.class,
0731:                        progressLabel, new Object[] { componentName });
0732:                final ProgressUI progressUI = new ProgressUI(title, false);
0733:
0734:                SwingUtilities.invokeLater(new Runnable() {
0735:
0736:                    public void run() {
0737:                        setBusy(true);
0738:                        progressUI.start();
0739:                    }
0740:                });
0741:
0742:                String result = null;
0743:                try {
0744:                    result = mgmtService.startComponent(componentName,
0745:                            SERVER_TARGET);
0746:                } catch (ManagementRemoteException e) {
0747:                    result = e.getMessage();
0748:                } finally {
0749:                    JBIMBeanTaskResultHandler.showRemoteInvokationResult(
0750:                            GenericConstants.START_COMPONENT_OPERATION_NAME,
0751:                            componentName, result);
0752:                }
0753:
0754:                SwingUtilities.invokeLater(new Runnable() {
0755:
0756:                    public void run() {
0757:                        clearJBIComponentStatusCache(compType);
0758:                        progressUI.finish();
0759:                        setBusy(false);
0760:                        updatePropertySheet();
0761:                    }
0762:                });
0763:            }
0764:
0765:            //========================== Stoppable =====================================
0766:            public boolean canStop() {
0767:                return !busy
0768:                        && JBIComponentInfo.STARTED_STATE.equals(getState());
0769:            }
0770:
0771:            public void stop() {
0772:                RuntimeManagementServiceWrapper mgmtService = getRuntimeManagementServiceWrapper();
0773:                if (mgmtService == null) {
0774:                    return;
0775:                }
0776:
0777:                String progressLabel = getStopProgressLabel();
0778:                final String componentName = getName();
0779:                String title = NbBundle.getMessage(JBIComponentNode.class,
0780:                        progressLabel, new Object[] { componentName });
0781:                final ProgressUI progressUI = new ProgressUI(title, false);
0782:
0783:                SwingUtilities.invokeLater(new Runnable() {
0784:
0785:                    public void run() {
0786:                        setBusy(true);
0787:                        progressUI.start();
0788:                    }
0789:                });
0790:
0791:                String result = null;
0792:                try {
0793:                    result = mgmtService.stopComponent(componentName,
0794:                            SERVER_TARGET);
0795:                } catch (ManagementRemoteException e) {
0796:                    result = e.getMessage();
0797:                } finally {
0798:                    JBIMBeanTaskResultHandler.showRemoteInvokationResult(
0799:                            GenericConstants.STOP_COMPONENT_OPERATION_NAME,
0800:                            componentName, result);
0801:                }
0802:
0803:                SwingUtilities.invokeLater(new Runnable() {
0804:
0805:                    public void run() {
0806:                        clearJBIComponentStatusCache(compType);
0807:                        progressUI.finish();
0808:                        setBusy(false);
0809:                        updatePropertySheet();
0810:                    }
0811:                });
0812:            }
0813:
0814:            //========================== Shutdownable ==================================
0815:            public boolean canShutdown() {
0816:                return canStop() || !busy
0817:                        && JBIComponentInfo.STOPPED_STATE.equals(getState());
0818:            }
0819:
0820:            public void shutdown(boolean force) {
0821:
0822:                RuntimeManagementServiceWrapper mgmtService = getRuntimeManagementServiceWrapper();
0823:                if (mgmtService == null) {
0824:                    return;
0825:                }
0826:
0827:                if (canStop()) {
0828:                    stop();
0829:                }
0830:
0831:                String progressLabel = getShutdownProgressLabel();
0832:                final String componentName = getName();
0833:                String title = NbBundle.getMessage(JBIComponentNode.class,
0834:                        progressLabel, new Object[] { componentName });
0835:                final ProgressUI progressUI = new ProgressUI(title, false);
0836:
0837:                SwingUtilities.invokeLater(new Runnable() {
0838:
0839:                    public void run() {
0840:                        setBusy(true);
0841:                        progressUI.start();
0842:                    }
0843:                });
0844:
0845:                String result = null;
0846:                try {
0847:                    result = mgmtService.shutdownComponent(componentName,
0848:                            force, SERVER_TARGET);
0849:                } catch (ManagementRemoteException e) {
0850:                    result = e.getMessage();
0851:                } finally {
0852:                    JBIMBeanTaskResultHandler.showRemoteInvokationResult(
0853:                            GenericConstants.SHUTDOWN_COMPONENT_OPERATION_NAME,
0854:                            componentName, result);
0855:                }
0856:
0857:                SwingUtilities.invokeLater(new Runnable() {
0858:
0859:                    public void run() {
0860:                        clearJBIComponentStatusCache(compType);
0861:                        progressUI.finish();
0862:                        setBusy(false);
0863:                        updatePropertySheet();
0864:                    }
0865:                });
0866:            }
0867:
0868:            //========================== Uninstallable =================================
0869:            public boolean canUninstall() {
0870:                return canShutdown() || !busy
0871:                        && JBIComponentInfo.SHUTDOWN_STATE.equals(getState());
0872:            }
0873:
0874:            public void uninstall(boolean force) {
0875:
0876:                final String componentName = getName();
0877:
0878:                if (confirmComponentUninstallation) {
0879:                    DoNotShowAgainConfirmation d = new DoNotShowAgainConfirmation(
0880:                            NbBundle
0881:                                    .getMessage(JBIComponentNode.class,
0882:                                            "MSG_UNINSTALL_CONFIRMATION",
0883:                                            componentName), // NOI18N
0884:                            NbBundle.getMessage(JBIComponentNode.class,
0885:                                    "TTL_UNINSTALL_CONFIRMATION"), // NOI18N
0886:                            NotifyDescriptor.YES_NO_OPTION);
0887:                    if (DialogDisplayer.getDefault().notify(d) != NotifyDescriptor.YES_OPTION) {
0888:                        return;
0889:                    }
0890:
0891:                    if (d.getDoNotShowAgain()) {
0892:                        confirmComponentUninstallation = false;
0893:                    }
0894:                }
0895:
0896:                // Make sure no service assembly is deployed before stop-shutdown-uninstall.
0897:                if (canUndeploy()) {
0898:                    if (!undeploy(force)) { // undeployment cancelled or failed
0899:                        return;
0900:                    }
0901:                }
0902:
0903:                InstallationService mgmtService = getInstallationService();
0904:                if (mgmtService == null) {
0905:                    return;
0906:                }
0907:
0908:                if (canShutdown()) {
0909:                    shutdown(force);
0910:                }
0911:
0912:                String progressLabel = getUninstallProgressLabel();
0913:                String title = NbBundle.getMessage(JBIComponentNode.class,
0914:                        progressLabel, new Object[] { componentName });
0915:                final ProgressUI progressUI = new ProgressUI(title, false);
0916:
0917:                SwingUtilities.invokeLater(new Runnable() {
0918:
0919:                    public void run() {
0920:                        progressUI.start();
0921:                    }
0922:                });
0923:
0924:                String result = null;
0925:                try {
0926:                    result = uninstallComponent(mgmtService, componentName,
0927:                            force);
0928:                } catch (ManagementRemoteException e) {
0929:                    result = e.getMessage();
0930:                } finally {
0931:                    JBIMBeanTaskResultHandler
0932:                            .showRemoteInvokationResult(
0933:                                    GenericConstants.UNINSTALL_COMPONENT_OPERATION_NAME,
0934:                                    componentName, result);
0935:                }
0936:
0937:                SwingUtilities.invokeLater(new Runnable() {
0938:
0939:                    public void run() {
0940:                        clearJBIComponentStatusCache(compType);
0941:                        progressUI.finish();
0942:                    }
0943:                });
0944:            }
0945:
0946:            //========================== Upgradeable =================================
0947:            public boolean canUpgrade() {
0948:                return !busy;
0949:            }
0950:
0951:            public void upgrade() {
0952:
0953:                InstallationService installationService = getInstallationService();
0954:                if (installationService == null) {
0955:                    return;
0956:                }
0957:
0958:                String componentName = getName();
0959:
0960:                JFileChooser chooser = getJFileChooser();
0961:                int returnValue = chooser.showDialog(null, NbBundle.getMessage(
0962:                        JBIComponentNode.class,
0963:                        "LBL_Upgrade_JBI_Component_Button")); //NOI18N
0964:
0965:                if (returnValue == JFileChooser.APPROVE_OPTION) {
0966:                    File[] selectedFiles = chooser.getSelectedFiles();
0967:                    if (selectedFiles.length > 0) {
0968:                        System.setProperty(
0969:                                LAST_JBI_COMPONENT_INSTALLATION_DIRECTORY,
0970:                                selectedFiles[0].getParent());
0971:                    }
0972:
0973:                    List<File> files = filterSelectedFiles(selectedFiles);
0974:                    if (files.size() == 0) {
0975:                        return;
0976:                    }
0977:
0978:                    // Automatic component shutdown before calling upgrade
0979:                    String oldState = getState();
0980:                    if (JBIComponentInfo.STOPPED_STATE.equals(oldState)
0981:                            || JBIComponentInfo.STARTED_STATE.equals(oldState)) {
0982:                        if (confirmComponentShutdownDuringUpgrade) {
0983:                            DoNotShowAgainConfirmation d = new DoNotShowAgainConfirmation(
0984:                                    NbBundle
0985:                                            .getMessage(
0986:                                                    JBIComponentNode.class,
0987:                                                    "MSG_AUTO_SHUTDOWN_COMPONENT_DURING_UPGRADE", // NOI18N
0988:                                                    componentName),
0989:                                    NbBundle
0990:                                            .getMessage(JBIComponentNode.class,
0991:                                                    "TTL_AUTO_SHUTDOWN_COMPONENT_DURING_UPGRADE"), // NOI18N
0992:                                    NotifyDescriptor.YES_NO_OPTION);
0993:                            if (DialogDisplayer.getDefault().notify(d) != NotifyDescriptor.YES_OPTION) {
0994:                                return;
0995:                            }
0996:
0997:                            if (d.getDoNotShowAgain()) {
0998:                                confirmComponentShutdownDuringUpgrade = false;
0999:                            }
1000:                        }
1001:
1002:                        shutdown(false);
1003:                    }
1004:
1005:                    // Make sure the component is really shutdown before calling upgrade
1006:                    clearJBIComponentStatusCache(compType);
1007:                    String state = getState();
1008:                    if (JBIComponentInfo.SHUTDOWN_STATE.equals(state)) {
1009:                        String progressLabel = getUpgradeProgressMessageLabel();
1010:                        String message = NbBundle.getMessage(
1011:                                JBIComponentContainerNode.class, progressLabel,
1012:                                componentName);
1013:                        final ProgressUI progressUI = new ProgressUI(message,
1014:                                false);
1015:
1016:                        SwingUtilities.invokeLater(new Runnable() {
1017:
1018:                            public void run() {
1019:                                setBusy(true);
1020:                                progressUI.start();
1021:                            }
1022:                        });
1023:
1024:                        String jarFilePath = files.get(0).getAbsolutePath();
1025:                        String result = null;
1026:                        try {
1027:                            result = installationService.upgradeComponent(
1028:                                    componentName, jarFilePath);
1029:                        } catch (ManagementRemoteException e) {
1030:                            result = e.getMessage();
1031:                            return;
1032:                        } finally {
1033:                            JBIMBeanTaskResultHandler
1034:                                    .showRemoteInvokationResult(
1035:                                            GenericConstants.UPGRADE_COMPONENT_OPERATION_NAME,
1036:                                            jarFilePath, result);
1037:                            SwingUtilities.invokeLater(new Runnable() {
1038:
1039:                                public void run() {
1040:                                    progressUI.finish();
1041:                                    setBusy(false);
1042:                                }
1043:                            });
1044:                        }
1045:                    }
1046:
1047:                    // Restore old state
1048:                    if (JBIComponentInfo.STARTED_STATE.equals(oldState)) {
1049:                        start();
1050:                    }
1051:                    if (JBIComponentInfo.STOPPED_STATE.equals(oldState)) {
1052:                        start();
1053:                        stop();
1054:                    }
1055:                }
1056:            }
1057:
1058:            private List<File> filterSelectedFiles(File[] files) {
1059:                List<File> ret = new ArrayList<File>();
1060:                DocumentBuilderFactory factory = DocumentBuilderFactory
1061:                        .newInstance();
1062:                DocumentBuilder docBuilder = null;
1063:                try {
1064:                    docBuilder = factory.newDocumentBuilder();
1065:                } catch (ParserConfigurationException ex) {
1066:                    ex.printStackTrace();
1067:                }
1068:
1069:                if (docBuilder != null) {
1070:                    for (File file : files) {
1071:                        if (getValidator().validate(file)) {
1072:                            ret.add(file);
1073:                        } else {
1074:                            String msg = NbBundle
1075:                                    .getMessage(
1076:                                            getClass(),
1077:                                            "MSG_INVALID_COMPONENT_SELECTION_FOR_UPGRADE", // NOI18N
1078:                                            file.getName(), getName());
1079:                            NotifyDescriptor d = new NotifyDescriptor.Message(
1080:                                    msg, NotifyDescriptor.ERROR_MESSAGE);
1081:                            DialogDisplayer.getDefault().notify(d);
1082:                        }
1083:                    }
1084:                }
1085:
1086:                return ret;
1087:            }
1088:
1089:            private JFileChooser getJFileChooser() {
1090:                JFileChooser chooser = new JFileChooser();
1091:
1092:                ResourceBundle bundle = NbBundle
1093:                        .getBundle(JBIComponentNode.class);
1094:
1095:                String title = NbBundle.getMessage(JBIComponentNode.class,
1096:                        "LBL_Upgrade_Chooser_Name", getName()); // NOI18N
1097:                chooser.setDialogTitle(title);
1098:                chooser.setDialogType(JFileChooser.CUSTOM_DIALOG);
1099:
1100:                chooser.setApproveButtonMnemonic(bundle.getString(
1101:                        "Upgrade_JBI_Component_Button_Mnemonic").charAt(0)); //NOI18N
1102:                chooser.setMultiSelectionEnabled(true);
1103:
1104:                chooser
1105:                        .addChoosableFileFilter(chooser
1106:                                .getAcceptAllFileFilter());
1107:                chooser.addChoosableFileFilter(FileFilters.JarFileFilter
1108:                        .getInstance());
1109:
1110:                chooser.setApproveButtonToolTipText(NbBundle.getMessage(
1111:                        JBIComponentNode.class,
1112:                        "LBL_Upgrade_JBI_Component_Button")); //NOI18N
1113:
1114:                chooser.getAccessibleContext().setAccessibleName(title);
1115:                chooser.getAccessibleContext().setAccessibleDescription(title);
1116:
1117:                String lastInstallDir = System
1118:                        .getProperty(LAST_JBI_COMPONENT_INSTALLATION_DIRECTORY);
1119:                if (lastInstallDir != null) {
1120:                    chooser.setCurrentDirectory(new File(lastInstallDir));
1121:                }
1122:
1123:                return chooser;
1124:            }
1125:
1126:            /**
1127:             * Gets the identification properties of a JBI component or a shared library.
1128:             */
1129:            private static Map<Attribute, MBeanAttributeInfo> getIdentificationSheetSetProperties(
1130:                    String descriptor) throws ParserConfigurationException,
1131:                    SAXException, IOException {
1132:
1133:                Map<Attribute, MBeanAttributeInfo> map = new HashMap<Attribute, MBeanAttributeInfo>();
1134:
1135:                if (descriptor != null && descriptor.startsWith("<?xml")) { // NOI18N
1136:                    DocumentBuilderFactory factory = DocumentBuilderFactory
1137:                            .newInstance();
1138:                    factory.setNamespaceAware(true);
1139:                    DocumentBuilder builder = factory.newDocumentBuilder();
1140:                    Document doc = builder.parse(new InputSource(
1141:                            new StringReader(descriptor)));
1142:
1143:                    NodeList nodeList = doc.getElementsByTagNameNS(
1144:                            "http://www.sun.com/jbi/descriptor/identification", // NOI18N
1145:                            "VersionInfo"); // NOI18N
1146:                    if (nodeList.getLength() > 0) {
1147:                        Element element = (Element) nodeList.item(0);
1148:
1149:                        String buildNumberLabel = NbBundle.getMessage(
1150:                                AppserverJBIMgmtController.class,
1151:                                "LBL_BUILD_NUMBER"); // NOI18N
1152:                        String buildNumberDesc = NbBundle.getMessage(
1153:                                AppserverJBIMgmtController.class,
1154:                                "DSC_BUILD_NUMBER"); // NOI18N
1155:
1156:                        String buildNumber = element
1157:                                .getAttribute("build-number"); // NOI18N
1158:                        if (buildNumber != null) {
1159:                            Attribute attr = new Attribute(buildNumberLabel,
1160:                                    buildNumber);
1161:                            MBeanAttributeInfo info = new MBeanAttributeInfo(
1162:                                    buildNumberLabel, "java.lang.String", // NOI18N
1163:                                    buildNumberDesc, true, false, false);
1164:                            map.put(attr, info);
1165:                        }
1166:
1167:                        String specVersionLabel = NbBundle.getMessage(
1168:                                AppserverJBIMgmtController.class,
1169:                                "LBL_SPECIFICATION_VERSION"); // NOI18N
1170:                        String specVersionDesc = NbBundle.getMessage(
1171:                                AppserverJBIMgmtController.class,
1172:                                "DSC_SPECIFICATION_VERSION"); // NOI18N
1173:
1174:                        String specVersion = element
1175:                                .getAttribute("specification-version"); // NOI18N
1176:                        if (specVersion != null) {
1177:                            Attribute attr = new Attribute(specVersionLabel,
1178:                                    specVersion);
1179:                            MBeanAttributeInfo info = new MBeanAttributeInfo(
1180:                                    specVersionLabel, "java.lang.String", // NOI18N
1181:                                    specVersionDesc, true, false, false);
1182:                            map.put(attr, info);
1183:                        }
1184:                    }
1185:                }
1186:
1187:                return map;
1188:            }
1189:
1190:            //===================== Abstract Methods ===================================
1191:            protected abstract String getContainerType();
1192:
1193:            protected abstract String getIconName(String state);
1194:
1195:            protected abstract String getStartProgressLabel();
1196:
1197:            protected abstract String getStopProgressLabel();
1198:
1199:            protected abstract String getShutdownProgressLabel();
1200:
1201:            protected abstract String getUninstallProgressLabel();
1202:
1203:            protected abstract String getUpgradeProgressMessageLabel();
1204:
1205:            protected abstract String uninstallComponent(
1206:                    InstallationService installationService,
1207:                    String componentName, boolean force)
1208:                    throws ManagementRemoteException;
1209:
1210:            protected abstract JBIArtifactValidator getValidator();
1211:
1212:            protected abstract String getInstallationDescriptor()
1213:                    throws ManagementRemoteException;
1214:
1215:            //==========================================================================
1216:            /**
1217:             * Abstract node class for Service Engine or Binding Component.
1218:             */
1219:            abstract static class RealJBIComponentNode extends JBIComponentNode {
1220:
1221:                RealJBIComponentNode(
1222:                        final AppserverJBIMgmtController controller,
1223:                        JBIComponentType compType, NodeType nodeType,
1224:                        String name, String description) {
1225:                    super (controller, compType, nodeType, name, description);
1226:                }
1227:
1228:                @Override
1229:                public Action[] getActions(boolean flag) {
1230:                    List<Action> actions = new ArrayList<Action>();
1231:
1232:                    actions.add(SystemAction.get(StartAction.class));
1233:                    actions.add(SystemAction.get(StopAction.class));
1234:                    actions.add(SystemAction.get(ShutdownAction.Normal.class));
1235:                    actions.add(SystemAction.get(UninstallAction.Normal.class));
1236:                    actions.add(SystemAction.get(UpgradeAction.class));
1237:                    actions.add(null);
1238:                    actions.add(SystemAction.get(AdvancedAction.class));
1239:
1240:                    List<Action> extraActions = getExtraActions();
1241:                    if (extraActions != null && extraActions.size() > 0) {
1242:                        actions.add(null);
1243:                        actions.addAll(extraActions);
1244:                    }
1245:
1246:                    actions.add(null);
1247:                    actions.add(SystemAction.get(UndeployAction.Normal.class));
1248:                    actions.add(null);
1249:                    actions.add(SystemAction.get(PropertiesAction.class));
1250:                    actions.add(SystemAction.get(RefreshAction.class));
1251:                    actions.add(null);
1252:                    actions.add(SystemAction
1253:                            .get(ShowComponentEndpointsStatisticsAction.class));
1254:
1255:                    return actions.toArray(new Action[] {});
1256:                }
1257:
1258:                /**
1259:                 * Gets a non-null list of actions that are specific to this component.
1260:                 */
1261:                protected List<Action> getExtraActions() {
1262:                    return null;
1263:                }
1264:
1265:                @Override
1266:                protected Sheet createSheet() {
1267:
1268:                    Sheet sheet = super .createSheet();
1269:
1270:                    // Augment the property sheet by adding loggers sheet
1271:                    try {
1272:                        addSheetSet(sheet, LOGGERS_SHEET_SET_NAME,
1273:                                "LBL_LOGGERS_PROPERTIES", // NOI18N
1274:                                "DSC_LOGGERS_PROPERTIES", // NOI18N
1275:                                getLoggerSheetSetProperties());
1276:                    } catch (ManagementRemoteException e) {
1277:                        logger.warning(e.getMessage());
1278:                    }
1279:
1280:                    return sheet;
1281:                }
1282:
1283:                /**
1284:                 * Gets the logger properties to be displayed for this JBI Component.
1285:                 *
1286:                 * @return A java.util.Map containing all logger properties.
1287:                 */
1288:                private Map<Attribute, MBeanAttributeInfo> getLoggerSheetSetProperties()
1289:                        throws ManagementRemoteException {
1290:
1291:                    // Sorted by the fully qualified logger name (loggerCustomName).
1292:                    // Only display the short name in the property sheet.
1293:                    Map<Attribute, MBeanAttributeInfo> ret = new TreeMap<Attribute, MBeanAttributeInfo>();
1294:
1295:                    ConfigurationService configService = getConfigurationService();
1296:                    Map<String, Level> loggerMap = configService
1297:                            .getComponentLoggerLevels(getName(), SERVER_TARGET,
1298:                                    null); // NULL?    
1299:
1300:                    for (String loggerCustomName : loggerMap.keySet()) {
1301:                        Level logLevel = loggerMap.get(loggerCustomName);
1302:                        int lastDotIndex = loggerCustomName.lastIndexOf("."); // NOI18N
1303:                        String shortName = lastDotIndex == -1 ? loggerCustomName
1304:                                : loggerCustomName.substring(lastDotIndex + 1);
1305:
1306:                        Attribute attr = new Attribute(loggerCustomName,
1307:                                logLevel);
1308:                        MBeanAttributeInfo info = new MBeanAttributeInfo(
1309:                                shortName, "java.util.logging.Level", // NOI18N
1310:                                loggerCustomName, true, true, false);
1311:                        ret.put(new ComparableAttribute(attr), info);
1312:                    }
1313:
1314:                    return ret;
1315:                }
1316:
1317:                protected String uninstallComponent(
1318:                        InstallationService installationService,
1319:                        String componentName, boolean force)
1320:                        throws ManagementRemoteException {
1321:                    return installationService.uninstallComponent(
1322:                            componentName, force, SERVER_TARGET);
1323:                }
1324:
1325:                protected String getInstallationDescriptor()
1326:                        throws ManagementRemoteException {
1327:                    AdministrationService adminService = getAdministrationService();
1328:                    return adminService
1329:                            .getComponentInstallationDescriptor(getName());
1330:                }
1331:
1332:                //========================== Undeployable =================================
1333:                public boolean canUndeploy() {
1334:                    RuntimeManagementServiceWrapper mgmtService = getRuntimeManagementServiceWrapper();
1335:                    if (mgmtService == null) {
1336:                        return false;
1337:                    }
1338:
1339:                    String componentName = getName();
1340:
1341:                    try {
1342:                        List<ServiceAssemblyInfo> saInfos = mgmtService
1343:                                .listServiceAssemblies(componentName,
1344:                                        SERVER_TARGET);
1345:
1346:                        return saInfos.size() > 0;
1347:                    } catch (ManagementRemoteException e) {
1348:                        NotifyDescriptor d = new NotifyDescriptor.Message(e
1349:                                .getMessage(), NotifyDescriptor.ERROR_MESSAGE);
1350:                        DialogDisplayer.getDefault().notify(d);
1351:                    }
1352:
1353:                    return true;
1354:                }
1355:
1356:                public boolean undeploy(boolean force) {
1357:                    RuntimeManagementServiceWrapper mgmtService = getRuntimeManagementServiceWrapper();
1358:
1359:                    if (mgmtService == null) {
1360:                        return false;
1361:                    }
1362:
1363:                    String componentName = getName();
1364:                    List<String> saNames = null;
1365:                    try {
1366:                        saNames = mgmtService.getServiceAssemblyNames(
1367:                                componentName, SERVER_TARGET);
1368:                    } catch (ManagementRemoteException e) {
1369:                        NotifyDescriptor d = new NotifyDescriptor.Message(e
1370:                                .getMessage(), NotifyDescriptor.ERROR_MESSAGE);
1371:                        DialogDisplayer.getDefault().notify(d);
1372:                        return false;
1373:                    }
1374:
1375:                    boolean success = true;
1376:
1377:                    if (saNames.size() > 0) {
1378:
1379:                        JBINode jbiNode = (JBINode) getParentNode()
1380:                                .getParentNode();
1381:
1382:                        JBIComponentContainerNode sesNode = (JBIComponentContainerNode.ServiceEngines) jbiNode
1383:                                .getChildren().getNodes()[0];
1384:                        // Can't do refresh: NPE while invoking undeployment on multiple components.
1385:                        sesNode.refresh();
1386:
1387:                        JBIComponentContainerNode bcsNode = (JBIComponentContainerNode.BindingComponents) jbiNode
1388:                                .getChildren().getNodes()[1];
1389:                        bcsNode.refresh();
1390:
1391:                        JBIServiceAssembliesNode sasNode = (JBIServiceAssembliesNode) jbiNode
1392:                                .getChildren().getNodes()[3];
1393:                        sasNode.refresh();
1394:
1395:                        try {
1396:                            List<String> componentsNeedingStart = getNonStartedComponentsForServiceAssemblies(saNames);
1397:
1398:                            if (confirmForServiceAssembliesUndeployment) {
1399:                                String wordWrappedSANames = Utils
1400:                                        .wordWrapString(saNames.toString(), 80,
1401:                                                "<br>"); // NOI18N
1402:
1403:                                String msg;
1404:                                if (componentsNeedingStart.size() > 0) {
1405:                                    if (StackTraceUtil
1406:                                            .isCalledBy(
1407:                                                    "org.netbeans.modules.sun.manager.jbi.nodes.JBIComponentNode", // NOI18N
1408:                                                    //JBIComponentNode.this.getClass().getCanonicalName(),
1409:                                                    "uninstall")) { // NOI18N
1410:                                        msg = NbBundle
1411:                                                .getMessage(
1412:                                                        JBIComponentNode.class,
1413:                                                        "MSG_UNDEPLOY_WITH_AUTO_COMPONENT_START_DURING_UNINSTALL_CONFIRMATION", // NOI18N
1414:                                                        componentName,
1415:                                                        wordWrappedSANames,
1416:                                                        componentsNeedingStart);
1417:                                    } else {
1418:                                        msg = NbBundle
1419:                                                .getMessage(
1420:                                                        JBIComponentNode.class,
1421:                                                        "MSG_UNDEPLOY_WITH_AUTO_COMPONENT_START_CONFIRMATION", // NOI18N
1422:                                                        componentName,
1423:                                                        wordWrappedSANames,
1424:                                                        componentsNeedingStart);
1425:                                    }
1426:                                } else {
1427:                                    if (StackTraceUtil
1428:                                            .isCalledBy(
1429:                                                    "org.netbeans.modules.sun.manager.jbi.nodes.JBIComponentNode", // NOI18N
1430:                                                    //JBIComponentNode.this.getClass().getCanonicalName(),
1431:                                                    "uninstall")) { // NOI18N
1432:                                        msg = NbBundle
1433:                                                .getMessage(
1434:                                                        JBIComponentNode.class,
1435:                                                        "MSG_UNDEPLOY_DURING_UNINSTALL_CONFIRMATION", // NOI18N
1436:                                                        componentName,
1437:                                                        wordWrappedSANames);
1438:                                    } else {
1439:                                        msg = NbBundle.getMessage(
1440:                                                JBIComponentNode.class,
1441:                                                "MSG_UNDEPLOY_CONFIRMATION", // NOI18N
1442:                                                componentName,
1443:                                                wordWrappedSANames);
1444:                                    }
1445:                                }
1446:
1447:                                String title = NbBundle.getMessage(
1448:                                        JBIComponentNode.class,
1449:                                        "TTL_UNDEPLOY_CONFIRMATION"); // NOI18N
1450:                                DoNotShowAgainConfirmation d = new DoNotShowAgainConfirmation(
1451:                                        msg, title,
1452:                                        NotifyDescriptor.YES_NO_OPTION);
1453:
1454:                                if (DialogDisplayer.getDefault().notify(d) == NotifyDescriptor.NO_OPTION) {
1455:                                    return false;
1456:                                }
1457:
1458:                                if (d.getDoNotShowAgain()) {
1459:                                    confirmForServiceAssembliesUndeployment = false;
1460:                                }
1461:                            }
1462:
1463:                            // Start the required components
1464:                            List<JBIComponentInfo> bcInfoes = mgmtService
1465:                                    .listBindingComponents(SERVER_TARGET);
1466:
1467:                            for (String componentNeedingStart : componentsNeedingStart) {
1468:                                boolean isBC = false;
1469:                                for (JBIComponentInfo bcInfo : bcInfoes) {
1470:                                    if (bcInfo.getName().equals(
1471:                                            componentNeedingStart)) {
1472:                                        isBC = true;
1473:                                        break;
1474:                                    }
1475:                                }
1476:
1477:                                Node startableNode = isBC ? getChildNode(
1478:                                        bcsNode, componentNeedingStart)
1479:                                        : getChildNode(sesNode,
1480:                                                componentNeedingStart);
1481:                                ((Startable) startableNode).start();
1482:                            }
1483:                        } catch (ManagementRemoteException e) {
1484:                            NotifyDescriptor d = new NotifyDescriptor.Message(e
1485:                                    .getMessage(),
1486:                                    NotifyDescriptor.ERROR_MESSAGE);
1487:                            DialogDisplayer.getDefault().notify(d);
1488:                            return false;
1489:                        }
1490:
1491:                        // real work
1492:                        for (String saName : saNames) {
1493:                            Node saNode = getChildNode(sasNode, saName);
1494:                            if (saNode != null) {
1495:                                success = success
1496:                                        && ((Undeployable) saNode)
1497:                                                .undeploy(force);
1498:                            }
1499:                        }
1500:
1501:                        sasNode.refresh();
1502:                    }
1503:
1504:                    return success;
1505:                }
1506:
1507:                private Node getChildNode(Node parentNode, String childName) {
1508:                    Node[] childNodes = parentNode.getChildren().getNodes();
1509:                    for (Node childNode : childNodes) {
1510:                        if (childNode.getName().equals(childName)) {
1511:                            return childNode;
1512:                        }
1513:                    }
1514:
1515:                    return null;
1516:                }
1517:
1518:                /**
1519:                 * Gets the list of non-started components that the given list of
1520:                 * service assemblies are deployed on.
1521:                 * 
1522:                 * @param saNames   a list of service assembly names
1523:                 * @return          the list of target components
1524:                 */
1525:                private List<String> getNonStartedComponentsForServiceAssemblies(
1526:                        List<String> saNames) throws ManagementRemoteException {
1527:
1528:                    List<String> ret = new ArrayList<String>();
1529:
1530:                    RuntimeManagementServiceWrapper mgmtService = getRuntimeManagementServiceWrapper();
1531:                    assert mgmtService != null;
1532:
1533:                    AdministrationService adminService = getAdministrationService();
1534:                    assert adminService != null;
1535:
1536:                    Set<String> componentNames = new HashSet<String>();
1537:                    for (String saName : saNames) {
1538:                        componentNames.addAll(getComponentsForServiceAssembly(
1539:                                adminService, saName));
1540:                    }
1541:
1542:                    List<JBIComponentInfo> bcInfoes = mgmtService
1543:                            .listBindingComponents(SERVER_TARGET);
1544:                    List<JBIComponentInfo> seInfoes = mgmtService
1545:                            .listServiceEngines(SERVER_TARGET);
1546:
1547:                    for (String componentName : componentNames) {
1548:                        String state = null;
1549:                        for (JBIComponentInfo bcInfo : bcInfoes) {
1550:                            if (bcInfo.getName().equals(componentName)) {
1551:                                state = bcInfo.getState();
1552:                                break;
1553:                            }
1554:                        }
1555:                        if (state == null) {
1556:                            for (JBIComponentInfo seInfo : seInfoes) {
1557:                                if (seInfo.getName().equals(componentName)) {
1558:                                    state = seInfo.getState();
1559:                                    break;
1560:                                }
1561:                            }
1562:                        }
1563:
1564:                        if (!JBIComponentStatus.STARTED_STATE.equals(state)) {
1565:                            ret.add(componentName);
1566:                        }
1567:                    }
1568:
1569:                    return ret;
1570:                }
1571:
1572:                /**
1573:                 * Gets the list of components that the given service assembly is 
1574:                 * deployed on.
1575:                 * 
1576:                 * @param saName   a service assembly names
1577:                 * @return         the list of target components
1578:                 */
1579:                private static List<String> getComponentsForServiceAssembly(
1580:                        AdministrationService adminService, String saName) {
1581:                    List<String> ret = new ArrayList<String>();
1582:
1583:                    try {
1584:                        String saDD = adminService
1585:                                .getServiceAssemblyDeploymentDescriptor(saName);
1586:
1587:                        DocumentBuilderFactory factory = DocumentBuilderFactory
1588:                                .newInstance();
1589:                        factory.setNamespaceAware(true);
1590:                        DocumentBuilder builder = factory.newDocumentBuilder();
1591:
1592:                        // parse SA DD
1593:                        Document saDoc = builder.parse(new InputSource(
1594:                                new StringReader(saDD)));
1595:                        NodeList sus = saDoc
1596:                                .getElementsByTagName("service-unit"); // NOI18N
1597:                        for (int i = 0; i < sus.getLength(); i++) {
1598:                            Element su = (Element) sus.item(i);
1599:                            String componentName = ((Element) su
1600:                                    .getElementsByTagName("component-name")
1601:                                    .item(0)).getFirstChild().getNodeValue(); // target/component-name                    
1602:                            ret.add(componentName);
1603:                        }
1604:                    } catch (Exception ex) {
1605:                        ex.printStackTrace();
1606:                    }
1607:
1608:                    return ret;
1609:                }
1610:            }
1611:
1612:            //========================= Concrete Nodes =================================
1613:            /**
1614:             * Node class for a Service Engine.
1615:             */
1616:            static class ServiceEngine extends RealJBIComponentNode {
1617:
1618:                ServiceEngine(final AppserverJBIMgmtController controller,
1619:                        String name, String description) {
1620:                    super (controller, JBIComponentType.SERVICE_ENGINE,
1621:                            NodeType.SERVICE_ENGINE, name, description);
1622:                }
1623:
1624:                @Override
1625:                protected List<Action> getExtraActions() {
1626:                    List<Action> extraActions = new ArrayList<Action>();
1627:
1628:                    ConfigurationService configService = getConfigurationService();
1629:                    assert configService != null;
1630:
1631:                    String componentName = getName();
1632:
1633:                    String actionXML = null;
1634:
1635:                    try {
1636:                        actionXML = (String) configService
1637:                                .invokeExtensionMBeanOperation(
1638:                                        componentName,
1639:                                        ACTIONABLE_MBEAN_NAME,
1640:                                        ACTIONABLE_MBEAN_GET_ACTIONS_OPERATION_NAME,
1641:                                        new Object[] {}, new String[] {},
1642:                                        SERVER_TARGET, null);
1643:                    } catch (ManagementRemoteException e) {
1644:                        // This is OK. The component is not required to define 
1645:                        // its ActionableMBean.   
1646:                        e.printStackTrace();
1647:                    }
1648:
1649:                    if (actionXML != null) {
1650:                        extraActions.addAll(JBIComponentActionDescriptor
1651:                                .getActions(actionXML));
1652:                    }
1653:
1654:                    return extraActions;
1655:                }
1656:
1657:                protected JBIArtifactValidator getValidator() {
1658:                    return JBIArtifactValidator
1659:                            .getServiceEngineValidator(getName());
1660:                }
1661:
1662:                protected String getContainerType() {
1663:                    return GenericConstants.SERVICE_ENGINES_FOLDER_NAME;
1664:                }
1665:
1666:                protected String getIconName(String state) {
1667:                    return IconConstants.SERVICE_ENGINE_ICON;
1668:                }
1669:
1670:                protected String getStartProgressLabel() {
1671:                    return "LBL_Starting_Service_Engine"; // NOI18N
1672:                }
1673:
1674:                protected String getStopProgressLabel() {
1675:                    return "LBL_Stopping_Service_Engine"; // NOI18N
1676:                }
1677:
1678:                protected String getShutdownProgressLabel() {
1679:                    return "LBL_Shutting_Down_Service_Engine"; // NOI18N
1680:                }
1681:
1682:                protected String getUninstallProgressLabel() {
1683:                    return "LBL_Uninstalling_Service_Engine"; // NOI18N
1684:                }
1685:
1686:                protected String getUpgradeProgressMessageLabel() {
1687:                    return "LBL_Upgrading_Service_Engine"; // NOI18N
1688:                }
1689:            }
1690:
1691:            //==========================================================================
1692:            /**
1693:             * Node class for a Binding Component.
1694:             */
1695:            static class BindingComponent extends RealJBIComponentNode {
1696:
1697:                BindingComponent(final AppserverJBIMgmtController controller,
1698:                        String name, String description) {
1699:                    super (controller, JBIComponentType.BINDING_COMPONENT,
1700:                            NodeType.BINDING_COMPONENT, name, description);
1701:                }
1702:
1703:                protected JBIArtifactValidator getValidator() {
1704:                    return JBIArtifactValidator
1705:                            .getBindingComponentValidator(getName());
1706:                }
1707:
1708:                protected String getContainerType() {
1709:                    return GenericConstants.BINDING_COMPONENTS_FOLDER_NAME;
1710:                }
1711:
1712:                protected String getIconName(String state) {
1713:                    return IconConstants.BINDING_COMPONENT_ICON;
1714:                }
1715:
1716:                protected String getStartProgressLabel() {
1717:                    return "LBL_Starting_Binding_Component"; // NOI18N
1718:                }
1719:
1720:                protected String getStopProgressLabel() {
1721:                    return "LBL_Stopping_Binding_Component"; // NOI18N
1722:                }
1723:
1724:                protected String getShutdownProgressLabel() {
1725:                    return "LBL_Shutting_Down_Binding_Component"; // NOI18N
1726:                }
1727:
1728:                protected String getUninstallProgressLabel() {
1729:                    return "LBL_Uninstalling_Binding_Component"; // NOI18N
1730:                }
1731:
1732:                protected String getUpgradeProgressMessageLabel() {
1733:                    return "LBL_Upgrading_Binding_Component"; // NOI18N
1734:                }
1735:            }
1736:
1737:            //==========================================================================
1738:            /**
1739:             * Node class for a Shared Library.
1740:             */
1741:            static class SharedLibrary extends JBIComponentNode {
1742:
1743:                SharedLibrary(final AppserverJBIMgmtController controller,
1744:                        String name, String description) {
1745:                    super (controller, JBIComponentType.SHARED_LIBRARY,
1746:                            NodeType.SHARED_LIBRARY, name, description);
1747:                }
1748:
1749:                @Override
1750:                public Action[] getActions(boolean flag) {
1751:                    return new SystemAction[] {
1752:                            SystemAction.get(UninstallAction.Normal.class),
1753:                            null, SystemAction.get(PropertiesAction.class) };
1754:                }
1755:
1756:                protected String uninstallComponent(
1757:                        InstallationService installationService,
1758:                        String componentName, boolean force)
1759:                        throws ManagementRemoteException {
1760:                    return installationService.uninstallSharedLibrary(
1761:                            componentName, force, SERVER_TARGET);
1762:                }
1763:
1764:                protected JBIArtifactValidator getValidator() {
1765:                    return null;
1766:                }
1767:
1768:                protected String getContainerType() {
1769:                    return GenericConstants.SHARED_LIBRARIES_FOLDER_NAME;
1770:                }
1771:
1772:                protected String getIconName(String state) {
1773:                    return IconConstants.SHARED_LIBRARY_ICON;
1774:                }
1775:
1776:                protected String getStartProgressLabel() {
1777:                    return null;
1778:                }
1779:
1780:                protected String getStopProgressLabel() {
1781:                    return null;
1782:                }
1783:
1784:                protected String getShutdownProgressLabel() {
1785:                    return null;
1786:                }
1787:
1788:                protected String getUninstallProgressLabel() {
1789:                    return "LBL_Uninstalling_Shared_Library"; // NOI18N
1790:                }
1791:
1792:                protected String getUpgradeProgressMessageLabel() {
1793:                    return null;
1794:                }
1795:
1796:                @Override
1797:                protected String getInstalledIconBadgeName() {
1798:                    return null;
1799:                }
1800:
1801:                @Override
1802:                protected String getStoppedIconBadgeName() {
1803:                    return null;
1804:                }
1805:
1806:                @Override
1807:                protected String getUnknownIconBadgeName() {
1808:                    return null;
1809:                }
1810:
1811:                @Override
1812:                protected String getInstallationDescriptor()
1813:                        throws ManagementRemoteException {
1814:                    AdministrationService adminService = getAdministrationService();
1815:                    return adminService
1816:                            .getSharedLibraryInstallationDescriptor(getName());
1817:                }
1818:
1819:                //#125827 Remove the State property for Shared Library to reduce confusion.
1820:                @Override
1821:                protected Map<Attribute, MBeanAttributeInfo> getGeneralSheetSetProperties() {
1822:                    Map<Attribute, MBeanAttributeInfo> ret = super 
1823:                            .getGeneralSheetSetProperties();
1824:                    for (Attribute attr : ret.keySet()) {
1825:                        if (attr.getName().equals("State")) { // NOI18N
1826:                            ret.remove(attr);
1827:                            break;
1828:                        }
1829:                    }
1830:                    return ret;
1831:                }
1832:
1833:                //========================== Undeployable =================================
1834:                public boolean canUndeploy() {
1835:                    return false;
1836:                }
1837:
1838:                public boolean undeploy(boolean force) {
1839:                    throw new RuntimeException(
1840:                            "Cannot undeploy shared library."); // NOI18N
1841:                }
1842:            }
1843:        }
ww__w__.j_ava___2___s___.c_om | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.