Source Code Cross Referenced for ConfigurationServiceMBeanImpl.java in  » ESB » open-esb » com » sun » esb » management » impl » configuration » Java Source Code / Java DocumentationJava Source Code and Java Documentation

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


0001:        /*
0002:         * BEGIN_HEADER - DO NOT EDIT
0003:         *
0004:         * The contents of this file are subject to the terms
0005:         * of the Common Development and Distribution License
0006:         * (the "License").  You may not use this file except
0007:         * in compliance with the License.
0008:         *
0009:         * You can obtain a copy of the license at
0010:         * https://open-esb.dev.java.net/public/CDDLv1.0.html.
0011:         * See the License for the specific language governing
0012:         * permissions and limitations under the License.
0013:         *
0014:         * When distributing Covered Code, include this CDDL
0015:         * HEADER in each file and include the License file at
0016:         * https://open-esb.dev.java.net/public/CDDLv1.0.html.
0017:         * If applicable add the following below this CDDL HEADER,
0018:         * with the fields enclosed by brackets "[]" replaced with
0019:         * your own identifying information: Portions Copyright
0020:         * [year] [name of copyright owner]
0021:         */
0022:
0023:        /*
0024:         * @(#)ConfigurationServiceMBeanImpl.java
0025:         * Copyright 2004-2007 Sun Microsystems, Inc. All Rights Reserved.
0026:         *
0027:         * END_HEADER - DO NOT EDIT
0028:         */
0029:        package com.sun.esb.management.impl.configuration;
0030:
0031:        import java.io.Serializable;
0032:        import java.util.Collection;
0033:        import java.util.HashMap;
0034:        import java.util.Iterator;
0035:        import java.util.List;
0036:        import java.util.Map;
0037:        import java.util.Properties;
0038:        import java.util.Set;
0039:        import java.util.TreeMap;
0040:        import java.util.logging.Level;
0041:
0042:        import javax.management.Attribute;
0043:        import javax.management.AttributeList;
0044:        import javax.management.Descriptor;
0045:        import javax.management.InstanceNotFoundException;
0046:        import javax.management.IntrospectionException;
0047:        import javax.management.MBeanAttributeInfo;
0048:        import javax.management.MBeanInfo;
0049:        import javax.management.MBeanServer;
0050:        import javax.management.MalformedObjectNameException;
0051:        import javax.management.ObjectName;
0052:        import javax.management.ReflectionException;
0053:        import javax.management.modelmbean.ModelMBeanAttributeInfo;
0054:        import javax.management.openmbean.CompositeData;
0055:        import javax.management.openmbean.CompositeType;
0056:        import javax.management.openmbean.TabularData;
0057:        import javax.xml.parsers.ParserConfigurationException;
0058:        import javax.xml.transform.TransformerException;
0059:
0060:        import com.sun.esb.management.api.configuration.ConfigurationService;
0061:        import com.sun.esb.management.base.services.AbstractListStateServiceMBeansImpl;
0062:        import com.sun.esb.management.common.ManagementRemoteException;
0063:        import com.sun.esb.management.common.TargetType;
0064:        import com.sun.esb.management.common.data.ApplicationVerificationReport;
0065:        import com.sun.esb.management.common.data.helper.ApplicationVerificationReportWriter;
0066:        import com.sun.jbi.EnvironmentContext;
0067:        import com.sun.jbi.management.MBeanNames;
0068:        import com.sun.jbi.ui.common.JBIAdminCommands;
0069:        import com.sun.jbi.ui.common.JBIComponentInfo;
0070:        import com.sun.jbi.ui.common.JBIJMXObjectNames;
0071:        import com.sun.jbi.ui.common.JBIManagementMessage;
0072:        import com.sun.jbi.ui.common.Util;
0073:        import com.sun.jbi.ui.runtime.verifier.JBIApplicationVerifier;
0074:        import com.sun.jbi.util.Constants;
0075:
0076:        /**
0077:         * Defines operations for common configuration services across the JBI Runtime,
0078:         * component containers, configuring logger levels, etc.
0079:         * 
0080:         * @author graj
0081:         */
0082:        public class ConfigurationServiceMBeanImpl extends
0083:                AbstractListStateServiceMBeansImpl implements 
0084:                ConfigurationService, Serializable, Constants {
0085:
0086:            static final long serialVersionUID = -1L;
0087:
0088:            /**
0089:             * Constructor - Constructs a new instance of ConfigurationServiceMBeanImpl
0090:             * 
0091:             * @param anEnvContext
0092:             */
0093:            public ConfigurationServiceMBeanImpl(EnvironmentContext anEnvContext) {
0094:                super (anEnvContext);
0095:            }
0096:
0097:            /**
0098:             * Detect the components support for component configuration. This method
0099:             * returns true if the component has a configuration MBean with configurable
0100:             * attributes
0101:             *
0102:             * @param componentName 
0103:             *            component identification
0104:             * @param targetName 
0105:             *              identification of the target. Can be a standalone server,
0106:             *              cluster or clustered instance.
0107:             * @return true if the components configuration MBean has configuration 
0108:             *              attributes
0109:             * @throws ManagementRemoteException if the component is not installed or is not 
0110:             *         in the Started state.
0111:             * 
0112:             */
0113:            public boolean isComponentConfigSupported(String componentName,
0114:                    String targetName) throws ManagementRemoteException {
0115:                Boolean isComponentConfigSupported = false;
0116:                ObjectName configFacadeMBean = this 
0117:                        .getComponentConfigurationFacadeMBeanName(
0118:                                componentName, targetName);
0119:                logDebug("isComponentConfigSupported(" + componentName + ","
0120:                        + targetName + "): configMBean = " + configFacadeMBean);
0121:
0122:                if ((configFacadeMBean != null)
0123:                        && (true == this .isValidTarget(configFacadeMBean))) {
0124:                    try {
0125:                        isComponentConfigSupported = (Boolean) this 
0126:                                .invokeMBeanOperation(configFacadeMBean,
0127:                                        "isComponentConfigSupported",
0128:                                        new Object[] {}, new String[] {});
0129:
0130:                        logDebug("isComponentConfigSupported(): result = "
0131:                                + isComponentConfigSupported);
0132:
0133:                    } catch (ManagementRemoteException jbiRE) {
0134:                        logDebug("isComponentConfigSupported caught ManagementRemoteException:");
0135:                        logWarning(jbiRE);
0136:                        throw jbiRE;
0137:                    } catch (Exception ex) {
0138:                        logDebug("isComponentConfigSupported  caught non-ManagementRemoteException:");
0139:                        logWarning(ex);
0140:
0141:                        throw new ManagementRemoteException(ex);
0142:                    }
0143:                } else {
0144:
0145:                    // TODO
0146:                    // Component installed and no MBean - return false
0147:                    // Component not installed - 
0148:                    // -- Component Configuration Facade MBean not found -- error
0149:                    // component not installed on target or does not have a config MBean.
0150:                    String[] args = new String[] { componentName, targetName };
0151:                    Exception mgmtEx = this 
0152:                            .createManagementException(
0153:                                    "ui.mbean.component.configuration.mbean.not.found.error",
0154:                                    args, null);
0155:                    throw new ManagementRemoteException(mgmtEx);
0156:                }
0157:                return isComponentConfigSupported;
0158:            }
0159:
0160:            /**
0161:             * Detect the components support for application configuration. This method
0162:             * returns true if the component has a configuration MBean and implements 
0163:             * all the operations for application configuration management.
0164:             *
0165:             * @param componentName 
0166:             *            component identification
0167:             * @param targetName 
0168:             *              identification of the target. Can be a standalone server,
0169:             *              cluster or clustered instance.
0170:             * @return true if the components configuration MBean implements all the
0171:             *         operations for application configuration.
0172:             * @throws ManagementRemoteException if the component is not installed or is not 
0173:             *         in the Started state.
0174:             * 
0175:             */
0176:            public boolean isAppConfigSupported(String componentName,
0177:                    String targetName) throws ManagementRemoteException {
0178:                Boolean isAppConfigSupported = false;
0179:                ObjectName configFacadeMBean = this 
0180:                        .getComponentConfigurationFacadeMBeanName(
0181:                                componentName, targetName);
0182:                logDebug("isAppConfigSupported(" + componentName + ","
0183:                        + targetName + "): configMBean = " + configFacadeMBean);
0184:
0185:                if ((configFacadeMBean != null)
0186:                        && (true == this .isValidTarget(configFacadeMBean))) {
0187:                    try {
0188:                        isAppConfigSupported = (Boolean) this 
0189:                                .invokeMBeanOperation(configFacadeMBean,
0190:                                        "isAppConfigSupported",
0191:                                        new Object[] {}, new String[] {});
0192:
0193:                        logDebug("isAppConfigSupported(): result = "
0194:                                + isAppConfigSupported);
0195:
0196:                    } catch (ManagementRemoteException jbiRE) {
0197:                        logDebug("isAppConfigSupported caught ManagementRemoteException:");
0198:                        logWarning(jbiRE);
0199:                        throw jbiRE;
0200:                    } catch (Exception ex) {
0201:                        logDebug("isAppConfigSupported  caught non-ManagementRemoteException:");
0202:                        logWarning(ex);
0203:
0204:                        throw new ManagementRemoteException(ex);
0205:                    }
0206:                } else {
0207:
0208:                    // TODO
0209:                    // Component installed and no MBean - return false
0210:                    // Component not installed - 
0211:                    // -- Component Configuration Facade MBean not found -- error
0212:                    // component not installed on target or does not have a config MBean.
0213:                    String[] args = new String[] { componentName, targetName };
0214:                    Exception mgmtEx = this 
0215:                            .createManagementException(
0216:                                    "ui.mbean.component.configuration.mbean.not.found.error",
0217:                                    args, null);
0218:                    throw new ManagementRemoteException(mgmtEx);
0219:                }
0220:                return isAppConfigSupported;
0221:            }
0222:
0223:            /**
0224:             * Detect the components support for application variables. This method
0225:             * returns true if the component has a configuration MBean and implements 
0226:             * all the operations for application variable management.
0227:             *
0228:             * @param componentName 
0229:             *            component identification
0230:             * @param targetName 
0231:             *              identification of the target. Can be a standalone server,
0232:             *              cluster or clustered instance.
0233:             * @return true if the components configuration MBean implements all the
0234:             *         operations for application variables.
0235:             * @throws ManagementRemoteException if the component is not installed or is not 
0236:             *         in the Started state.
0237:             * 
0238:             */
0239:            public boolean isAppVarsSupported(String componentName,
0240:                    String targetName) throws ManagementRemoteException {
0241:                Boolean isAppVarsSupported = false;
0242:                ObjectName configFacadeMBean = this 
0243:                        .getComponentConfigurationFacadeMBeanName(
0244:                                componentName, targetName);
0245:                logDebug("isAppVarsSupported(" + componentName + ","
0246:                        + targetName + "): configMBean = " + configFacadeMBean);
0247:
0248:                if ((configFacadeMBean != null)
0249:                        && (true == this .isValidTarget(configFacadeMBean))) {
0250:                    try {
0251:                        isAppVarsSupported = (Boolean) this 
0252:                                .invokeMBeanOperation(configFacadeMBean,
0253:                                        "isAppVarsSupported", new Object[] {},
0254:                                        new String[] {});
0255:
0256:                        logDebug("isAppVarsSupported(): result = "
0257:                                + isAppVarsSupported);
0258:
0259:                    } catch (ManagementRemoteException jbiRE) {
0260:                        logDebug("isAppVarsSupported caught ManagementRemoteException:");
0261:                        logWarning(jbiRE);
0262:                        throw jbiRE;
0263:                    } catch (Exception ex) {
0264:                        logDebug("isAppVarsSupported  caught non-ManagementRemoteException:");
0265:                        logWarning(ex);
0266:
0267:                        throw new ManagementRemoteException(ex);
0268:                    }
0269:                } else {
0270:
0271:                    // TODO
0272:                    // Component installed and no MBean - return false
0273:                    // Component not installed - 
0274:                    // -- Component Configuration Facade MBean not found -- error
0275:                    // component not installed on target or does not have a config MBean.
0276:                    String[] args = new String[] { componentName, targetName };
0277:                    Exception mgmtEx = this 
0278:                            .createManagementException(
0279:                                    "ui.mbean.component.configuration.mbean.not.found.error",
0280:                                    args, null);
0281:                    throw new ManagementRemoteException(mgmtEx);
0282:                }
0283:                return isAppVarsSupported;
0284:            }
0285:
0286:            /**
0287:             * Get the CompositeType definition for the components application configuration 
0288:             * 
0289:             * @param componentName
0290:             *            component identification
0291:             * @param targetName
0292:             *            identification of the target. Can be a standalone server,
0293:             *            cluster or clustered instance.
0294:             * @return the CompositeType for the components application configuration.
0295:             */
0296:            public CompositeType queryApplicationConfigurationType(
0297:                    String componentName, String targetName)
0298:                    throws ManagementRemoteException {
0299:
0300:                domainTargetCheck(targetName);
0301:
0302:                CompositeType appCfgType = null;
0303:                ObjectName configFacadeMBean = this 
0304:                        .getComponentConfigurationFacadeMBeanName(
0305:                                componentName, targetName);
0306:                logDebug("queryApplicationConfigurationType(" + componentName
0307:                        + "," + targetName + "): configMBean = "
0308:                        + configFacadeMBean);
0309:
0310:                if ((configFacadeMBean != null)
0311:                        && (true == this .isValidTarget(configFacadeMBean))) {
0312:                    try {
0313:                        appCfgType = (CompositeType) this .invokeMBeanOperation(
0314:                                configFacadeMBean,
0315:                                "queryApplicationConfigurationType",
0316:                                new Object[] {}, new String[] {});
0317:
0318:                        return appCfgType;
0319:                    } catch (ManagementRemoteException jbiRE) {
0320:                        logDebug("queryApplicationConfigurationType caught ManagementRemoteException:");
0321:                        logDebug(jbiRE);
0322:                        throw jbiRE;
0323:                    } catch (Exception ex) {
0324:                        logDebug("queryApplicationConfigurationType  caught non-ManagementRemoteException:");
0325:                        logDebug(ex);
0326:
0327:                        throw new ManagementRemoteException(ex);
0328:                    }
0329:                } else {
0330:                    // -- Component Configuration Facade MBean not found -- error
0331:                    // component not installed on target
0332:                    String[] args = new String[] { componentName, targetName };
0333:                    Exception mgmtEx = this 
0334:                            .createManagementException(
0335:                                    "ui.mbean.component.configuration.mbean.not.found.error",
0336:                                    args, null);
0337:                    throw new ManagementRemoteException(mgmtEx);
0338:                }
0339:            }
0340:
0341:            /**
0342:             * Add a named application configuration to a component installed on a given
0343:             * target.
0344:             * 
0345:             * @param componentName
0346:             *            component identification
0347:             * @param targetName
0348:             *            identification of the target. Can be a standalone server,
0349:             *            cluster or clustered instance.
0350:             * @param name
0351:             *            application configuration name
0352:             * @param config
0353:             *            application configuration represented as a set of properties.
0354:             * @return a JBI Management message indicating the status of the operation.
0355:             * @throws ManagementRemoteException
0356:             *             if there is a jmx error accessing the instance
0357:             * 
0358:             * @see com.sun.esb.management.api.configuration.ConfigurationService#addApplicationConfiguration(java.lang.String,
0359:             *      java.lang.String, java.lang.String, java.util.Properties)
0360:             */
0361:            public String addApplicationConfiguration(String componentName,
0362:                    String targetName, String name, Properties config)
0363:                    throws ManagementRemoteException {
0364:                domainTargetCheck(targetName);
0365:
0366:                String jbiMgmtMsgResult = null;
0367:                ObjectName configFacadeMBean = this 
0368:                        .getComponentConfigurationFacadeMBeanName(
0369:                                componentName, targetName);
0370:                logDebug("addApplicationConfiguration(" + componentName + ","
0371:                        + targetName + "): configMBean = " + configFacadeMBean);
0372:
0373:                if ((configFacadeMBean != null)
0374:                        && (true == this .isValidTarget(configFacadeMBean))) {
0375:                    try {
0376:                        jbiMgmtMsgResult = (String) this .invokeMBeanOperation(
0377:                                configFacadeMBean,
0378:                                "addApplicationConfiguration", new Object[] {
0379:                                        name, config }, new String[] {
0380:                                        "java.lang.String",
0381:                                        "java.util.Properties" });
0382:
0383:                        logDebug("addApplicationConfiguration(): result = "
0384:                                + jbiMgmtMsgResult);
0385:                        return jbiMgmtMsgResult;
0386:                    } catch (ManagementRemoteException jbiRE) {
0387:                        logDebug("addApplicationConfiguration caught ManagementRemoteException:");
0388:                        logWarning(jbiRE);
0389:                        throw jbiRE;
0390:                    } catch (Exception ex) {
0391:                        logDebug("addApplicationConfiguration  caught non-ManagementRemoteException:");
0392:                        logWarning(ex);
0393:                        String[] args = new String[] { name, componentName,
0394:                                targetName };
0395:                        Exception mgmtEx = this .createManagementException(
0396:                                "ui.mbean.component.add.app.config.error",
0397:                                args, ex);
0398:                        throw new ManagementRemoteException(mgmtEx);
0399:                    }
0400:                } else {
0401:                    // -- Component Configuration Facade MBean not found -- error
0402:                    // component not
0403:                    // installed on target
0404:                    String[] args = new String[] { componentName, targetName };
0405:                    Exception mgmtEx = this 
0406:                            .createManagementException(
0407:                                    "ui.mbean.component.configuration.mbean.not.found.error",
0408:                                    args, null);
0409:                    throw new ManagementRemoteException(mgmtEx);
0410:                }
0411:            }
0412:
0413:            /**
0414:             * Add application variables to a component installed on a given target. If
0415:             * even a variable from the set is already set on the component, this
0416:             * operation fails.
0417:             * 
0418:             * @param componentName
0419:             *            component identification
0420:             * @param targetName
0421:             *            identification of the target. Can be a standalone server,
0422:             *            cluster or clustered instance.
0423:             * @param appVariables -
0424:             *            set of application variables to add. The values of the
0425:             *            application variables have the application variable type and
0426:             *            value and the format is "[type]value"
0427:             * @return a JBI Management message indicating the status of the operation.
0428:             *         In case a variable is not added the management message has a
0429:             *         ERROR task status message giving the details of the failure.
0430:             * @throws ManagementRemoteException
0431:             *             if there is a jmx error accessing the instance
0432:             * 
0433:             * @see com.sun.esb.management.api.configuration.ConfigurationService#addApplicationVariables(java.lang.String,
0434:             *      java.lang.String, java.util.Properties)
0435:             */
0436:            @SuppressWarnings("unchecked")
0437:            public String addApplicationVariables(String componentName,
0438:                    String targetName, Properties appVariables)
0439:                    throws ManagementRemoteException {
0440:                domainTargetCheck(targetName);
0441:
0442:                ObjectName configFacadeMBean = this 
0443:                        .getComponentConfigurationFacadeMBeanName(
0444:                                componentName, targetName);
0445:                logDebug("addApplicationVariables(" + componentName + ","
0446:                        + targetName + "): configMBean = " + configFacadeMBean);
0447:
0448:                Map<String/* appVarName */, String /* JBI MgmtMsg result */> results = new HashMap<String/* appVarName */, String /** JBI MgmtMsg result*/
0449:                >();
0450:                if ((configFacadeMBean != null)
0451:                        && (true == this .isValidTarget(configFacadeMBean))) {
0452:
0453:                    componentStartedOnTargetCheck(componentName, targetName);
0454:
0455:                    // For each application variable invoke addApplicationVariable() on
0456:                    // the facade MBean. If the operation is not successful, get the
0457:                    // instance details : the error task status msg and the exception
0458:                    // info.
0459:                    // 
0460:                    // Build a composite message which has all the details re. which
0461:                    // attribute failed to be added and why ( in case of cluster need
0462:                    // the instance details )
0463:                    Set appVarNames = appVariables.keySet();
0464:
0465:                    for (Iterator itr = appVarNames.iterator(); itr.hasNext();) {
0466:                        String name = (String) itr.next();
0467:                        String typeAndValueStr = (String) appVariables
0468:                                .get(name);
0469:                        String result = null;
0470:                        try {
0471:                            CompositeData appVarCD = componentConfigurationHelper
0472:                                    .createApplicationVariableComposite(name,
0473:                                            typeAndValueStr);
0474:                            result = (String) this 
0475:                                    .invokeMBeanOperation(
0476:                                            configFacadeMBean,
0477:                                            "addApplicationVariable",
0478:                                            new Object[] { name, appVarCD },
0479:                                            new String[] { "java.lang.String",
0480:                                                    "javax.management.openmbean.CompositeData" });
0481:
0482:                            logDebug("addApplicationVariable(): result = "
0483:                                    + result);
0484:                        } catch (ManagementRemoteException jbiRE) {
0485:                            // exception msg is a management message already; just keep
0486:                            // it as it is
0487:                            logDebug("caught ManagementRemoteException:");
0488:                            logDebug(jbiRE);
0489:                            result = jbiRE.getMessage();
0490:
0491:                        } catch (Exception ex) {
0492:                            logDebug("caught non-ManagementRemoteException:");
0493:                            logDebug(ex);
0494:                            result = ex.getMessage();
0495:                        }
0496:                        results.put(name, result);
0497:                    }
0498:
0499:                } else {
0500:                    // -- Component Configuration Facade MBean not found -- error component not
0501:                    // installed on target
0502:                    String[] args = new String[] { componentName, targetName };
0503:                    Exception mgmtEx = this 
0504:                            .createManagementException(
0505:                                    "ui.mbean.component.configuration.mbean.not.found.error",
0506:                                    args, null);
0507:                    throw new ManagementRemoteException(mgmtEx);
0508:                }
0509:
0510:                JBIManagementMessage msg = JBIManagementMessage
0511:                        .createJBIManagementMessage("addApplicationVariables",
0512:                                results, false);
0513:                return com.sun.jbi.ui.common.JBIResultXmlBuilder.getInstance()
0514:                        .createJbiResultXml(msg);
0515:            }
0516:
0517:            /**
0518:             * Delete a named application configuration in a component installed on a
0519:             * given target.
0520:             * 
0521:             * @param componentName
0522:             *            component identification
0523:             * @param targetName
0524:             *            identification of the target. Can be a standalone server,
0525:             *            cluster or clustered instance.
0526:             * @param name
0527:             *            name of application configuration to be deleted
0528:             * @return a JBI Management message indicating the status of the operation.
0529:             * @throws ManagementRemoteException
0530:             *             if there is a jmx error accessing the instance
0531:             * 
0532:             * @see com.sun.esb.management.api.configuration.ConfigurationService#deleteApplicationConfiguration(java.lang.String,
0533:             *      java.lang.String, java.lang.String)
0534:             */
0535:            public String deleteApplicationConfiguration(String componentName,
0536:                    String targetName, String name)
0537:                    throws ManagementRemoteException {
0538:                domainTargetCheck(targetName);
0539:
0540:                String jbiMgmtMsgResult = null;
0541:                ObjectName configFacadeMBean = this 
0542:                        .getComponentConfigurationFacadeMBeanName(
0543:                                componentName, targetName);
0544:                logDebug("deleteApplicationConfiguration(" + componentName
0545:                        + "," + targetName + "): configMBean = "
0546:                        + configFacadeMBean);
0547:
0548:                if ((configFacadeMBean != null)
0549:                        && (true == this .isValidTarget(configFacadeMBean))) {
0550:                    try {
0551:                        jbiMgmtMsgResult = (String) this .invokeMBeanOperation(
0552:                                configFacadeMBean,
0553:                                "deleteApplicationConfiguration",
0554:                                new Object[] { name },
0555:                                new String[] { "java.lang.String" });
0556:
0557:                        logDebug("deleteApplicationConfiguration(): result = "
0558:                                + jbiMgmtMsgResult);
0559:                        return jbiMgmtMsgResult;
0560:                    } catch (ManagementRemoteException jbiRE) {
0561:                        logDebug("deleteApplicationConfiguration caught ManagementRemoteException:");
0562:                        logWarning(jbiRE);
0563:                        throw jbiRE;
0564:                    } catch (Exception ex) {
0565:                        logDebug("deleteApplicationConfiguration  caught non-ManagementRemoteException:");
0566:                        logWarning(ex);
0567:                        String[] args = new String[] { name, componentName,
0568:                                targetName };
0569:                        Exception mgmtEx = this .createManagementException(
0570:                                "ui.mbean.component.delete.app.config.error",
0571:                                args, ex);
0572:                        throw new ManagementRemoteException(mgmtEx);
0573:                    }
0574:                } else {
0575:                    // -- Component Configuration Facade MBean not found -- error
0576:                    // component not
0577:                    // installed on target
0578:                    String[] args = new String[] { componentName, targetName };
0579:                    Exception mgmtEx = this 
0580:                            .createManagementException(
0581:                                    "ui.mbean.component.configuration.mbean.not.found.error",
0582:                                    args, null);
0583:                    throw new ManagementRemoteException(mgmtEx);
0584:                }
0585:            }
0586:
0587:            /**
0588:             * Delete application variables from a component installed on a given
0589:             * target. If even a variable from the set has not been added to the
0590:             * component, this operation fails.
0591:             * 
0592:             * @param componentName
0593:             *            component identification
0594:             * @param targetName
0595:             *            identification of the target. Can be a standalone server,
0596:             *            cluster or clustered instance.
0597:             * @param appVariableNames -
0598:             *            names of application variables to delete.
0599:             * @return a JBI Management message indicating the status of the operation.
0600:             *         In case a variable is not deleted the management message has a
0601:             *         ERROR task status message giving the details of the failure.
0602:             * @throws ManagementRemoteException
0603:             *             if there is a jmx error accessing the instance *
0604:             * @see com.sun.esb.management.api.configuration.ConfigurationService#deleteApplicationVariables(java.lang.String,
0605:             *      java.lang.String, java.lang.String[])
0606:             */
0607:            @SuppressWarnings("unchecked")
0608:            public String deleteApplicationVariables(String componentName,
0609:                    String targetName, String[] appVariableNames)
0610:                    throws ManagementRemoteException {
0611:                domainTargetCheck(targetName);
0612:
0613:                ObjectName configFacadeMBean = this 
0614:                        .getComponentConfigurationFacadeMBeanName(
0615:                                componentName, targetName);
0616:                logDebug("deleteApplicationVariables(" + componentName + ","
0617:                        + targetName + "): configMBean = " + configFacadeMBean);
0618:
0619:                Map<String/* appVarName */, String /* JBI MgmtMsg result */> results = new HashMap();
0620:                if ((configFacadeMBean != null)
0621:                        && (true == this .isValidTarget(configFacadeMBean))) {
0622:
0623:                    componentStartedOnTargetCheck(componentName, targetName);
0624:
0625:                    // For each application variable invoke setApplicationVariable() on
0626:                    // the
0627:                    // facade MBean. If the operation is not successful, get the
0628:                    // instance
0629:                    // details : the error task status msg and the exception info.
0630:                    // 
0631:                    // Build a composite message which has all the details re. which
0632:                    // attribute failed to be set and why ( in case of cluster need the
0633:                    // instance details )
0634:                    if (appVariableNames != null) {
0635:                        for (String appVarName : appVariableNames) {
0636:                            String result = null;
0637:                            try {
0638:                                result = (String) this .invokeMBeanOperation(
0639:                                        configFacadeMBean,
0640:                                        "deleteApplicationVariable",
0641:                                        new Object[] { appVarName },
0642:                                        new String[] { "java.lang.String" });
0643:
0644:                                logDebug("deleteApplicationVariable(): result = "
0645:                                        + result);
0646:                            } catch (ManagementRemoteException jbiRE) {
0647:                                // exception msg is a management message already; just keep
0648:                                // it
0649:                                // as it is
0650:                                logDebug("caught ManagementRemoteException:");
0651:                                logDebug(jbiRE);
0652:                                result = jbiRE.getMessage();
0653:
0654:                            } catch (Exception ex) {
0655:                                logDebug("caught non-ManagementRemoteException:");
0656:                                logDebug(ex);
0657:                                result = ex.getMessage();
0658:                            }
0659:                            results.put(appVarName, result);
0660:                        }
0661:                    }
0662:
0663:                } else {
0664:                    // -- Component Configuration Facade MBean not found -- error component not
0665:                    // installed on target
0666:                    String[] args = new String[] { componentName, targetName };
0667:                    Exception mgmtEx = this 
0668:                            .createManagementException(
0669:                                    "ui.mbean.component.configuration.mbean.not.found.error",
0670:                                    args, null);
0671:                    throw new ManagementRemoteException(mgmtEx);
0672:                }
0673:                JBIManagementMessage msg = JBIManagementMessage
0674:                        .createJBIManagementMessage(
0675:                                "deleteApplicationVariables", results, true);
0676:                return com.sun.jbi.ui.common.JBIResultXmlBuilder.getInstance()
0677:                        .createJbiResultXml(msg);
0678:            }
0679:
0680:            /**
0681:             * This method is used to export the application variables and application
0682:             * configuration objects used by the given application in the specified
0683:             * target.
0684:             * 
0685:             * @param applicationName
0686:             *            the name of the application
0687:             * @param targetName
0688:             *            the target whose configuration has to be exported
0689:             * @param configDir
0690:             *            the dir to store the configurations
0691:             * @returns String the id for the zip file with exported configurations
0692:             * 
0693:             * @throws ManagementRemoteException
0694:             *             if the application configuration could not be exported
0695:             * 
0696:             * Note: param configDir is used between ant/cli and common client client.
0697:             * The return value is used between common client server and common client
0698:             * client.
0699:             * 
0700:             * @see com.sun.esb.management.api.configuration.ConfigurationService#exportApplicationConfiguration(java.lang.String,
0701:             *      java.lang.String, java.lang.String)
0702:             */
0703:            public String exportApplicationConfiguration(
0704:                    String applicationName, String targetName, String configDir)
0705:                    throws ManagementRemoteException {
0706:                String result = null;
0707:                JBIApplicationVerifier verifier = new JBIApplicationVerifier(
0708:                        this .environmentContext);
0709:                try {
0710:                    result = verifier.exportApplicationConfiguration(
0711:                            applicationName, targetName, configDir);
0712:                } catch (Exception ManagementRemoteException) {
0713:                    throw new ManagementRemoteException(
0714:                            ManagementRemoteException);
0715:                }
0716:                return result;
0717:
0718:            }
0719:
0720:            /**
0721:             * Get a specific named configuration. If the named configuration does not
0722:             * exist in the component the returned properties is an empty set.
0723:             * 
0724:             * @param componentName
0725:             *            component identification
0726:             * @param targetName
0727:             *            identification of the target. Can be a standalone server,
0728:             *            cluster or clustered instance.
0729:             * @return the application configuration represented as a set of properties.
0730:             * @throws ManagementRemoteException
0731:             *             if there is a jmx error accessing the instance
0732:             * 
0733:             * @see com.sun.esb.management.api.configuration.ConfigurationService#getApplicationConfiguration(java.lang.String,
0734:             *      java.lang.String, java.lang.String)
0735:             */
0736:            public Properties getApplicationConfiguration(String componentName,
0737:                    String name, String targetName)
0738:                    throws ManagementRemoteException {
0739:                domainTargetCheck(targetName);
0740:
0741:                Map<String, Properties> configMap = getApplicationConfigurations(
0742:                        componentName, targetName);
0743:                return configMap.get(name);
0744:            }
0745:
0746:            /**
0747:             * Get all the application configurations set on a component.
0748:             * 
0749:             * @param componentName
0750:             *            component identification
0751:             * @param targetName
0752:             *            identification of the target. Can be a standalone server,
0753:             *            cluster or clustered instance.
0754:             * @return a map of all the application configurations keyed by the
0755:             *         configuration name.
0756:             * @throws ManagementRemoteException
0757:             *             if there is a jmx error accessing the instance
0758:             * 
0759:             * @see com.sun.esb.management.api.configuration.ConfigurationService#getApplicationConfigurations(java.lang.String,
0760:             *      java.lang.String)
0761:             */
0762:            public Map<String, Properties> getApplicationConfigurations(
0763:                    String componentName, String targetName)
0764:                    throws ManagementRemoteException {
0765:                domainTargetCheck(targetName);
0766:
0767:                TabularData td = null;
0768:                Map<String, Properties> appConfigMap = new HashMap<String, Properties>();
0769:                ObjectName configFacadeMBean = this 
0770:                        .getComponentConfigurationFacadeMBeanName(
0771:                                componentName, targetName);
0772:                logDebug("getApplicationConfigurations(" + componentName + ","
0773:                        + targetName + "): configMBean = " + configFacadeMBean);
0774:
0775:                if ((configFacadeMBean != null)
0776:                        && (true == this .isValidTarget(configFacadeMBean))) {
0777:                    try {
0778:                        Object result = this .getAttributeValue(
0779:                                configFacadeMBean, "ApplicationConfigurations");
0780:                        if (result != null) {
0781:                            td = (TabularData) result;
0782:
0783:                            // Convert the application configuration Tabular Data to a
0784:                            // Map
0785:                            appConfigMap = getApplicationConfigurationsMap(td);
0786:                        }
0787:                        return appConfigMap;
0788:                    } catch (ManagementRemoteException jbiRE) {
0789:                        logDebug("getApplicationConfigurations caught ManagementRemoteException:");
0790:                        logWarning(jbiRE);
0791:                        throw jbiRE;
0792:                    } catch (Exception ex) {
0793:                        logDebug("getApplicationConfigurations  caught non-ManagementRemoteException:");
0794:                        logWarning(ex);
0795:                        String[] args = new String[] { componentName,
0796:                                targetName };
0797:                        Exception mgmtEx = this .createManagementException(
0798:                                "ui.mbean.component.get.app.config.error",
0799:                                args, ex);
0800:                        throw new ManagementRemoteException(mgmtEx);
0801:                    }
0802:                } else {
0803:                    // -- Component Configuration Facade MBean not found -- error
0804:                    // component not
0805:                    // installed on target
0806:                    String[] args = new String[] { componentName, targetName };
0807:                    Exception mgmtEx = this 
0808:                            .createManagementException(
0809:                                    "ui.mbean.component.configuration.mbean.not.found.error",
0810:                                    args, null);
0811:                    throw new ManagementRemoteException(mgmtEx);
0812:                }
0813:
0814:            }
0815:
0816:            /**
0817:             * Get all the application variables set on a component.
0818:             * 
0819:             * @return all the application variables et on the component. The return
0820:             *         proerties set has the name="[type]value" pairs for the
0821:             *         application variables.
0822:             * @return a JBI Management message indicating the status of the operation.
0823:             * @throws ManagementRemoteException
0824:             *             if there is a jmx error accessing the instance
0825:             * 
0826:             * @see com.sun.esb.management.api.configuration.ConfigurationService#getApplicationVariables(java.lang.String,
0827:             *      java.lang.String)
0828:             */
0829:            public Properties getApplicationVariables(String componentName,
0830:                    String targetName) throws ManagementRemoteException {
0831:                domainTargetCheck(targetName);
0832:
0833:                Properties appVarProps = new Properties();
0834:                ObjectName configFacadeMBean = this 
0835:                        .getComponentConfigurationFacadeMBeanName(
0836:                                componentName, targetName);
0837:                logDebug("getApplicationVariables(" + componentName + ","
0838:                        + targetName + "): configMBean = " + configFacadeMBean);
0839:
0840:                if ((configFacadeMBean != null)
0841:                        && (true == this .isValidTarget(configFacadeMBean))) {
0842:                    try {
0843:                        TabularData appVarTable = (TabularData) this 
0844:                                .getAttributeValue(configFacadeMBean,
0845:                                        "ApplicationVariables");
0846:
0847:                        appVarProps = this .componentConfigurationHelper
0848:                                .convertToApplicationVariablesProperties(appVarTable);
0849:                        logDebug("getApplicationVariables(): result = "
0850:                                + appVarProps);
0851:                    } catch (ManagementRemoteException jbiRE) {
0852:                        // exception msg is a management message already; just keep it
0853:                        // as it is
0854:                        logDebug("caught ManagementRemoteException:");
0855:                        logDebug(jbiRE);
0856:                        throw jbiRE;
0857:                    } catch (Exception ex) {
0858:                        logDebug("caught non-ManagementRemoteException:");
0859:                        logDebug(ex);
0860:                        Exception exception = this 
0861:                                .createManagementException(
0862:                                        "ui.mbean.install.config.mbean.error.set.attrs.error",
0863:                                        null, ex);
0864:                        ManagementRemoteException remoteException = new ManagementRemoteException(
0865:                                exception);
0866:                        throw remoteException;
0867:                    }
0868:                } else {
0869:                    // -- Component Configuration Facade MBean not found -- error component not
0870:                    // installed on target
0871:                    String[] args = new String[] { componentName, targetName };
0872:                    Exception mgmtEx = this 
0873:                            .createManagementException(
0874:                                    "ui.mbean.component.configuration.mbean.not.found.error",
0875:                                    args, null);
0876:                    throw new ManagementRemoteException(mgmtEx);
0877:                }
0878:                return appVarProps;
0879:            }
0880:
0881:            /**
0882:             * Retrieve component configuration
0883:             * 
0884:             * @param componentName
0885:             * @param targetName
0886:             * @return the targetName as key and the name/value pairs as properties
0887:             * @throws ManagementRemoteException
0888:             *             if there is a jmx error accessing the instance
0889:             * 
0890:             * @see com.sun.esb.management.api.configuration.ConfigurationService#getComponentConfiguration(java.lang.String,
0891:             *      java.lang.String)
0892:             */
0893:            public Properties getComponentConfiguration(String componentName,
0894:                    String targetName) throws ManagementRemoteException {
0895:                Properties result = null;
0896:                TargetType targetType = checkTargetType(targetName);
0897:                Exception exception = null;
0898:                String[] args = { targetName };
0899:
0900:                switch (targetType) {
0901:                case STANDALONE_SERVER:
0902:                case CLUSTER:
0903:                case CLUSTERED_SERVER:
0904:                    // use facade mbean code below
0905:                    break;
0906:
0907:                case DOMAIN:
0908:                case INVALID_TARGET:
0909:                default:
0910:                    logDebug("getComponentConfiguration(): target "
0911:                            + targetName + " type not supported.");
0912:                    exception = this .createManagementException(
0913:                            "ui.mbean.system.config.target.type.not.supported",
0914:                            args, null);
0915:                    throw new ManagementRemoteException(exception);
0916:                }
0917:
0918:                ObjectName configFacadeMBean = this 
0919:                        .getComponentConfigurationFacadeMBeanName(
0920:                                componentName, targetName);
0921:
0922:                logDebug("getComponentConfiguration(" + componentName + ","
0923:                        + targetName + "): configMBean = " + configFacadeMBean);
0924:                if ((configFacadeMBean != null)
0925:                        && (true == this .isValidTarget(configFacadeMBean))) {
0926:                    try {
0927:                        result = this 
0928:                                .getConfigurationAttributeValues(configFacadeMBean);
0929:                        logDebug("getComponentConfiguration: result properties = "
0930:                                + result);
0931:                    } catch (ManagementRemoteException jbiRE) {
0932:                        // exception msg is a management message already; just keep it
0933:                        // as it is
0934:                        logDebug("caught ManagementRemoteException:");
0935:                        logDebug(jbiRE);
0936:                        throw jbiRE;
0937:                    } catch (Exception ex) {
0938:                        logDebug("caught non-ManagementRemoteException:");
0939:                        logDebug(ex);
0940:                        exception = this 
0941:                                .createManagementException(
0942:                                        "ui.mbean.install.config.mbean.error.get.attrs.error",
0943:                                        null, ex);
0944:                        ManagementRemoteException remoteException = new ManagementRemoteException(
0945:                                exception);
0946:                        throw remoteException;
0947:                    }
0948:
0949:                }
0950:                return result;
0951:            }
0952:
0953:            /**
0954:             * Gets the extension MBean object names
0955:             * 
0956:             * @param componentName
0957:             *            name of the component
0958:             * @param extensionName
0959:             *            the name of the extension (e.g., Configuration, Logger, etc.)
0960:             * @param targetName
0961:             *            name of the target (e.g., cluster1, server, etc.)
0962:             * @return
0963:             * @throws ManagementRemoteException
0964:             *             on error
0965:             * 
0966:             * @see com.sun.esb.management.api.configuration.ConfigurationService#getComponentExtensionMBeanObjectNames(java.lang.String,
0967:             *      java.lang.String, java.lang.String)
0968:             */
0969:            @SuppressWarnings("unchecked")
0970:            public Map<String, ObjectName[]> getComponentExtensionMBeanObjectNames(
0971:                    String componentName, String extensionName,
0972:                    String targetName) throws ManagementRemoteException {
0973:                return super .getComponentExtensionMBeanObjectNames(
0974:                        componentName, extensionName, targetName);
0975:            }
0976:
0977:            /**
0978:             * Gets the extension MBean object names
0979:             * 
0980:             * @param componentName
0981:             *            name of the component
0982:             * @param extensionName
0983:             *            the name of the extension (e.g., Configuration, Logger, etc.)
0984:             * @param targetName
0985:             *            name of the target (e.g., cluster1, server, etc.)
0986:             * @param targetInstanceName
0987:             *            name of the target instance (e.g., cluster1-instance1, etc.)
0988:             * @return an array of ObjectName(s)
0989:             * @throws ManagementRemoteException
0990:             *             on error
0991:             * 
0992:             * @see com.sun.esb.management.api.configuration.ConfigurationService#getComponentExtensionMBeanObjectNames(java.lang.String,
0993:             *      java.lang.String, java.lang.String, java.lang.String)
0994:             */
0995:            @SuppressWarnings("unchecked")
0996:            public ObjectName[] getComponentExtensionMBeanObjectNames(
0997:                    String componentName, String extensionName,
0998:                    String targetName, String targetInstanceName)
0999:                    throws ManagementRemoteException {
1000:                return super .getComponentExtensionMBeanObjectNames(
1001:                        componentName, extensionName, targetName,
1002:                        targetInstanceName);
1003:            }
1004:
1005:            /**
1006:             * Gets the component custom loggers and their levels
1007:             * 
1008:             * @param componentName
1009:             *            name of the component
1010:             * @param targetName
1011:             *            name of the target (e.g., cluster1, server, etc.)
1012:             * @param targetInstanceName
1013:             *            name of the target instance (e.g., cluster1-instance1, etc.)
1014:             * @return a Map of loggerName to their log levels
1015:             * @throws ManagementRemoteException
1016:             *             on error
1017:             * 
1018:             * @see com.sun.esb.management.api.configuration.ConfigurationService#getComponentLoggerLevels(java.lang.String,
1019:             *      java.lang.String, java.lang.String)
1020:             */
1021:            @SuppressWarnings("unchecked")
1022:            public Map<String, Level> getComponentLoggerLevels(
1023:                    String componentName, String targetName,
1024:                    String targetInstanceName) throws ManagementRemoteException {
1025:                Map<String, Level> resultObject = new TreeMap<String, Level>();
1026:
1027:                logDebug("Get Component Logger Levels ");
1028:
1029:                ObjectName extensionMBeanObjectName = this 
1030:                        .getExtensionMBeanObjectName(componentName,
1031:                                JBIAdminCommands.DOMAIN_TARGET_KEY);
1032:
1033:                this .checkForValidTarget(extensionMBeanObjectName,
1034:                        JBIAdminCommands.DOMAIN_TARGET_KEY);
1035:
1036:                logDebug("Calling getLoggerMBeanNames on extensionMBeanObjectName = "
1037:                        + extensionMBeanObjectName);
1038:
1039:                // The following returns the Logger MBean registered by the Component on
1040:                // the Target. This is the MBean which matches the ObjectName pattern :
1041:                // com.sun.jbi:ComponentName=<component-name>,ControlType=Logger
1042:                // 
1043:                // getLoggerMBeanNames() : Map[String, ObjectName[]]
1044:                // 
1045:                Map<String, ObjectName[]> loggerMBeansMap = (Map<String, ObjectName[]>) this 
1046:                        .invokeMBeanOperation(extensionMBeanObjectName,
1047:                                "getLoggerMBeanNames");
1048:
1049:                if ((loggerMBeansMap != null)
1050:                        && ((targetName != null) || (targetInstanceName != null))) {
1051:                    // You now have the map of targetInstances to logger MBean names
1052:                    // For each of these get the log levels
1053:                    ObjectName[] filteredLoggerObjectNames = null;
1054:                    if (targetInstanceName != null) {
1055:                        filteredLoggerObjectNames = loggerMBeansMap
1056:                                .get(targetInstanceName);
1057:                    } else {
1058:                        filteredLoggerObjectNames = loggerMBeansMap
1059:                                .get(targetName);
1060:                    }
1061:
1062:                    // for each logger object name, get the loggers for that component
1063:                    if ((filteredLoggerObjectNames != null)
1064:                            && (filteredLoggerObjectNames.length > 0)) {
1065:
1066:                        for (int index = 0; index < filteredLoggerObjectNames.length; index++) {
1067:                            try {
1068:                                this .checkForValidTarget(
1069:                                        filteredLoggerObjectNames[index],
1070:                                        JBIAdminCommands.DOMAIN_TARGET_KEY);
1071:                                String[] loggerNames;
1072:                                String logLevel;
1073:                                loggerNames = (String[]) this 
1074:                                        .invokeMBeanOperation(
1075:                                                filteredLoggerObjectNames[index],
1076:                                                "getLoggerNames");
1077:                                for (int i = 0; i < loggerNames.length; i++) {
1078:                                    try {
1079:                                        Object[] args = new Object[1];
1080:                                        args[0] = loggerNames[i];
1081:                                        String[] signature = new String[1];
1082:                                        signature[0] = "java.lang.String";
1083:                                        logLevel = (String) this 
1084:                                                .invokeMBeanOperation(
1085:                                                        filteredLoggerObjectNames[index],
1086:                                                        "getLevel", args,
1087:                                                        signature);
1088:                                        resultObject.put(loggerNames[i], Level
1089:                                                .parse(logLevel));
1090:                                    } catch (ManagementRemoteException exception) {
1091:                                        logDebug(exception);
1092:                                    } catch (RuntimeException exception) {
1093:                                        logDebug(exception);
1094:                                    }
1095:                                }
1096:                            } catch (ManagementRemoteException exception) {
1097:                                logDebug(exception);
1098:                            } catch (RuntimeException exception) {
1099:                                logDebug(exception);
1100:                            }
1101:                        }
1102:                    }
1103:                } else {
1104:                    Exception exception = this 
1105:                            .createManagementException(
1106:                                    "ui.mbean.extension.getComponentLoggerLevels.error",
1107:                                    null, null);
1108:                    throw new ManagementRemoteException(exception);
1109:                }
1110:
1111:                return resultObject;
1112:            }
1113:
1114:            /**
1115:             * Gets the component custom loggers and their display names.
1116:             * 
1117:             * @param componentName
1118:             *            name of the component
1119:             * @param targetName
1120:             *            name of the target (e.g., cluster1, server, etc.)
1121:             * @param targetInstanceName
1122:             *            name of the target instance (e.g., cluster1-instance1, etc.)
1123:             * @return a Map of loggerName to their display names
1124:             * @throws ManagementRemoteException
1125:             *             on error
1126:             * 
1127:             * @see com.sun.esb.management.api.configuration.ConfigurationService#getComponentLoggerDisplayNames(java.lang.String,
1128:             *      java.lang.String, java.lang.String)
1129:             */
1130:            @SuppressWarnings("unchecked")
1131:            public Map<String, String> getComponentLoggerDisplayNames(
1132:                    String componentName, String targetName,
1133:                    String targetInstanceName) throws ManagementRemoteException {
1134:                Map<String, String> resultObject = new TreeMap<String, String>();
1135:
1136:                logDebug("Get Component Logger Display Names ");
1137:
1138:                ObjectName extensionMBeanObjectName = this 
1139:                        .getExtensionMBeanObjectName(componentName,
1140:                                JBIAdminCommands.DOMAIN_TARGET_KEY);
1141:
1142:                this .checkForValidTarget(extensionMBeanObjectName,
1143:                        JBIAdminCommands.DOMAIN_TARGET_KEY);
1144:
1145:                logDebug("Calling getLoggerMBeanNames on extensionMBeanObjectName = "
1146:                        + extensionMBeanObjectName);
1147:
1148:                // The following returns the Logger MBean registered by the Component on
1149:                // the Target. This is the MBean which matches the ObjectName pattern :
1150:                // com.sun.jbi:ComponentName=<component-name>,ControlType=Logger
1151:                // 
1152:                // getLoggerMBeanNames() : Map[String, ObjectName[]]
1153:                // 
1154:                Map<String, ObjectName[]> loggerMBeansMap = (Map<String, ObjectName[]>) this 
1155:                        .invokeMBeanOperation(extensionMBeanObjectName,
1156:                                "getLoggerMBeanNames");
1157:
1158:                if ((loggerMBeansMap != null)
1159:                        && ((targetName != null) || (targetInstanceName != null))) {
1160:                    // You now have the map of targetInstances to logger MBean names
1161:                    // For each of these get the display names
1162:                    ObjectName[] filteredLoggerObjectNames = null;
1163:                    if (targetInstanceName != null) {
1164:                        filteredLoggerObjectNames = loggerMBeansMap
1165:                                .get(targetInstanceName);
1166:                    } else {
1167:                        filteredLoggerObjectNames = loggerMBeansMap
1168:                                .get(targetName);
1169:                    }
1170:
1171:                    // for each logger object name, get the loggers for that component
1172:                    if ((filteredLoggerObjectNames != null)
1173:                            && (filteredLoggerObjectNames.length > 0)) {
1174:
1175:                        for (int index = 0; index < filteredLoggerObjectNames.length; index++) {
1176:                            try {
1177:                                this .checkForValidTarget(
1178:                                        filteredLoggerObjectNames[index],
1179:                                        JBIAdminCommands.DOMAIN_TARGET_KEY);
1180:                                String[] loggerNames;
1181:                                String displayName;
1182:                                loggerNames = (String[]) this 
1183:                                        .invokeMBeanOperation(
1184:                                                filteredLoggerObjectNames[index],
1185:                                                "getLoggerNames");
1186:                                for (int i = 0; i < loggerNames.length; i++) {
1187:                                    try {
1188:                                        Object[] args = new Object[1];
1189:                                        args[0] = loggerNames[i];
1190:                                        String[] signature = new String[1];
1191:                                        signature[0] = "java.lang.String";
1192:                                        displayName = (String) this 
1193:                                                .invokeMBeanOperation(
1194:                                                        filteredLoggerObjectNames[index],
1195:                                                        "getDisplayName", args,
1196:                                                        signature);
1197:                                        resultObject.put(loggerNames[i],
1198:                                                displayName);
1199:                                    } catch (ManagementRemoteException exception) {
1200:                                        logDebug(exception);
1201:                                    } catch (RuntimeException exception) {
1202:                                        logDebug(exception);
1203:                                    }
1204:                                }
1205:                            } catch (ManagementRemoteException exception) {
1206:                                logDebug(exception);
1207:                            } catch (RuntimeException exception) {
1208:                                logDebug(exception);
1209:                            }
1210:                        }
1211:                    }
1212:                } else {
1213:                    Exception exception = this 
1214:                            .createManagementException(
1215:                                    "ui.mbean.extension.getComponentLoggerDisplayNames.error",
1216:                                    null, null);
1217:                    throw new ManagementRemoteException(exception);
1218:                }
1219:
1220:                return resultObject;
1221:            }
1222:
1223:            /**
1224:             * This method returns a tabular data of a complex open data objects that
1225:             * represent the runtime configuration parameter descriptor. The parameter
1226:             * descriptor should contain the following data that represents the
1227:             * parameter.
1228:             * 
1229:             * name : name of the parameter value : value of the parameter as a String
1230:             * type. type : type of the parameter. Basic data types only. description:
1231:             * (optional) description of the parameter. displayName: (optional) display
1232:             * name of the parameter readOnly : true/false validValues : (optional) list
1233:             * of string values with ',' as delimiter. or a range value with - with a
1234:             * '-' as delimiter. min and max strings will be converted to the parameter
1235:             * type and then used to validate the value of the parameter.
1236:             * 
1237:             * @param targetName
1238:             *            cluster or instance name ( e.g. cluster1, instance1 ) on which
1239:             *            configuration parameters will be set. null to represent the
1240:             *            default instance which is admin server
1241:             * 
1242:             * @return Properties that represents the list of configuration parameter
1243:             *         descriptors.
1244:             * 
1245:             * @throws ManagementRemoteException
1246:             *             if there is a jmx error accessing the instance
1247:             * 
1248:             * @see com.sun.esb.management.api.configuration.ConfigurationService#getDefaultRuntimeConfiguration()
1249:             */
1250:            public Properties getDefaultRuntimeConfiguration()
1251:                    throws ManagementRemoteException {
1252:                return getDefaultRuntimeConfigurationInternal(JBIAdminCommands.DOMAIN_TARGET_KEY);
1253:            }
1254:
1255:            /**
1256:             * This method returns a tabular data of a complex open data objects that
1257:             * represent the runtime configuration parameter descriptor. The parameter
1258:             * descriptor should contain the following data that represents the
1259:             * parameter.
1260:             * 
1261:             * name : name of the parameter value : value of the parameter as a String
1262:             * type. type : type of the parameter. Basic data types only. description:
1263:             * (optional) description of the parameter. displayName: (optional) display
1264:             * name of the parameter readOnly : true/false validValues : (optional) list
1265:             * of string values with ',' as delimiter. or a range value with - with a
1266:             * '-' as delimiter. min and max strings will be converted to the parameter
1267:             * type and then used to validate the value of the parameter.
1268:             * 
1269:             * @param targetName
1270:             *            cluster or instance name ( e.g. cluster1, instance1 ) on which
1271:             *            configuration parameters will be set. null to represent the
1272:             *            default instance which is admin server
1273:             * 
1274:             * @return Properties that represents the list of configuration parameter
1275:             *         descriptors.
1276:             * 
1277:             * @throws ManagementRemoteException
1278:             *             if there is a jmx error accessing the instance
1279:             * 
1280:             * @see com.sun.esb.management.api.configuration.ConfigurationService#getRuntimeConfiguration(java.lang.String)
1281:             */
1282:            public Properties getRuntimeConfiguration(String targetName)
1283:                    throws ManagementRemoteException {
1284:                return getRuntimeConfigurationInternal(targetName);
1285:            }
1286:
1287:            /**
1288:             * This method returns the runtime configuration metadata associated with
1289:             * the specified property. The metadata contain name-value pairs like:
1290:             * default, descriptionID, descriptorType, displayName, displayNameId,
1291:             * isStatic, name, resourceBundleName, tooltip, tooltipId, etc.
1292:             * 
1293:             * @param propertyKeyName
1294:             * @return Properties that represent runtime configuration metadata
1295:             * @throws ManagementRemoteException
1296:             * 
1297:             * @see com.sun.esb.management.api.configuration.ConfigurationService#getRuntimeConfigurationMetaData(java.lang.String)
1298:             */
1299:            public Properties getRuntimeConfigurationMetaData(
1300:                    String propertyKeyName) throws ManagementRemoteException {
1301:                Map<String /* propertyKeyName */, Properties> metadata = null;
1302:                metadata = getRuntimeConfigurationMetadataInternal(JBIAdminCommands.DOMAIN_TARGET_KEY);
1303:                return metadata.get(propertyKeyName);
1304:            }
1305:
1306:            /**
1307:             * Lookup the level of one runtime logger
1308:             * 
1309:             * @param runtimeLoggerName
1310:             *            name of the runtime logger (e.g. com.sun.jbi.framework
1311:             * @param targetName
1312:             *            name of the target (e.g., cluster1, server, etc.)
1313:             * @param targetInstanceName
1314:             *            name of the target instance (e.g., cluster1-instance1, etc.)
1315:             * @return the matching Log Level.
1316:             * @throws ManagementRemoteException
1317:             * 
1318:             * @see com.sun.esb.management.api.configuration.ConfigurationService#getRuntimeLoggerLevel(java.lang.String,
1319:             *      java.lang.String, java.lang.String)
1320:             */
1321:            public Level getRuntimeLoggerLevel(String runtimeLoggerName,
1322:                    String targetName, String targetInstanceName)
1323:                    throws ManagementRemoteException {
1324:                return getRuntimeLoggerLevel(runtimeLoggerName, targetName);
1325:            }
1326:
1327:            /**
1328:             * Gets all the runtime loggers and their levels
1329:             * 
1330:             * @param targetName
1331:             *            name of the target (e.g., cluster1, server, etc.)
1332:             * @param targetInstanceName
1333:             *            name of the target instance (e.g., cluster1-instance1, etc.)
1334:             * @return a Map of runtimeLoggerName to their log levels
1335:             * @throws ManagementRemoteException
1336:             *             on error
1337:             * 
1338:             * @see com.sun.esb.management.api.configuration.ConfigurationService#getRuntimeLoggerLevels(java.lang.String,
1339:             *      java.lang.String)
1340:             */
1341:            public Map<String /* runtimeLoggerName */, Level /* logLevel */> getRuntimeLoggerLevels(
1342:                    String targetName, String targetInstanceName)
1343:                    throws ManagementRemoteException {
1344:                return getRuntimeLoggerLevels(targetName);
1345:            }
1346:
1347:            /**
1348:             * Gets all the runtime loggers and their display names
1349:             * 
1350:             * @param targetName
1351:             *            name of the target (e.g., cluster1, server, etc.)
1352:             * @param targetInstanceName
1353:             *            name of the target instance (e.g., cluster1-instance1, etc.)
1354:             * @return a Map of display names to their logger MBeans
1355:             * @throws ManagementRemoteException
1356:             *             on error
1357:             */
1358:            public Map<String /* display name */, String /* logger name */> getRuntimeLoggerNames(
1359:                    String targetName, String targetInstanceName)
1360:                    throws ManagementRemoteException {
1361:                return getRuntimeLoggerNames(targetName);
1362:            }
1363:
1364:            /**
1365:             * Gets all the runtime loggers and their levels.
1366:             * 
1367:             * @param targetName
1368:             *            name of the target (e.g., cluster1, server, etc.)
1369:             * @return a Map of runtimeLoggerName to their log levels
1370:             * @throws ManagementRemoteException
1371:             *             on error
1372:             */
1373:            @SuppressWarnings("unchecked")
1374:            public Map<String /* runtimeLoggerName */, Level /* logLevel */> getRuntimeLoggerLevels(
1375:                    String targetName) throws ManagementRemoteException {
1376:                Map<String, Level> resultObject = new TreeMap<String, Level>();
1377:
1378:                logDebug("getRuntimeLoggerLevels: targetName: " + targetName);
1379:
1380:                TargetType type = checkTargetType(targetName);
1381:                String[] args = { targetName };
1382:
1383:                switch (type) {
1384:                case CLUSTERED_SERVER:
1385:                case STANDALONE_SERVER:
1386:                    try {
1387:                        if (!this .getPlatformContext().isInstanceUp(targetName)) {
1388:                            Exception exception = this 
1389:                                    .createManagementException(
1390:                                            "ui.mbean.list.rt.logger.levels.instance.down.error",
1391:                                            args, null);
1392:                            throw new ManagementRemoteException(exception);
1393:                        }
1394:
1395:                        // call getSystemLoggerMBeans to get list of all system loggers
1396:                        ObjectName[] loggers = getSystemLoggerMBeans(targetName);
1397:
1398:                        logDebug("found the following " + loggers.length
1399:                                + " loggers: " + loggers);
1400:                        for (int index = 0; index < loggers.length; index++) {
1401:                            String loggerName = null;
1402:                            String logLevelString = null;
1403:                            try {
1404:                                logDebug("loggers[" + index
1405:                                        + "]: ObjectName = " + loggers[index]);
1406:                                loggerName = (String) this 
1407:                                        .invokeMBeanOperation(loggers[index],
1408:                                                "getLoggerName");
1409:                                logDebug("loggers[" + index + "]: name = "
1410:                                        + loggerName);
1411:
1412:                                logLevelString = (String) this 
1413:                                        .invokeMBeanOperation(loggers[index],
1414:                                                "getLogLevel");
1415:                                logDebug("level = " + logLevelString);
1416:                                this .checkForValidTarget(loggers[index],
1417:                                        JBIAdminCommands.DOMAIN_TARGET_KEY);
1418:                                resultObject.put(loggerName, Level
1419:                                        .parse(logLevelString));
1420:                            } catch (ManagementRemoteException exception) {
1421:                                logDebug("ManagementRemoteException");
1422:                                logDebug(exception);
1423:                            } catch (RuntimeException exception) {
1424:                                logDebug("RuntimeException");
1425:                                logDebug(exception);
1426:                            }
1427:                        }
1428:                    } catch (Exception ex) {
1429:                        throw ManagementRemoteException.filterJmxExceptions(ex);
1430:                    }
1431:
1432:                    break;
1433:
1434:                case INVALID_TARGET:
1435:
1436:                    logDebug("getRuntimeLoggerLevels(): target " + targetName
1437:                            + " type not supported.");
1438:                    Exception exception = this .createManagementException(
1439:                            "ui.mbean.invalid.target.error", args, null);
1440:                    throw new ManagementRemoteException(exception);
1441:
1442:                default:
1443:                    // Get all the attributes on the config facade MBean
1444:                    ObjectName loggerCfgFacade = getRuntimeLoggerConfigFacadeMBeanName(targetName);
1445:
1446:                    Properties attribs = getConfigurationAttributeValues(loggerCfgFacade);
1447:
1448:                    for (java.util.Iterator itr = attribs.keySet().iterator(); itr
1449:                            .hasNext();) {
1450:                        String loggerName = (String) itr.next();
1451:                        String level = (String) attribs.get(loggerName);
1452:                        Level loggerValue = null;
1453:                        if (level == null || "null".equalsIgnoreCase(level)
1454:                                || LOG_LEVEL_DEFAULT.equalsIgnoreCase(level)) {
1455:                            loggerValue = null;
1456:                        } else {
1457:                            loggerValue = Level.parse(level);
1458:                        }
1459:                        resultObject.put(loggerName, loggerValue);
1460:                    }
1461:                }
1462:
1463:                return resultObject;
1464:            }
1465:
1466:            /**
1467:             * Lookup the level of one runtime logger
1468:             * 
1469:             * @param runtimeLoggerName
1470:             *            name of the runtime logger (e.g. com.sun.jbi.framework
1471:             * @param targetName
1472:             *            name of the target (e.g., cluster1, server, etc.)
1473:             * @param targetInstanceName
1474:             *            name of the target instance (e.g., cluster1-instance1, etc.)
1475:             * @return the matching Log Level.
1476:             * @throws ManagementRemoteException
1477:             *             on error
1478:             */
1479:            public Level getRuntimeLoggerLevel(String runtimeLoggerName,
1480:                    String targetName) throws ManagementRemoteException {
1481:
1482:                Map<String, Level> loggers = this 
1483:                        .getRuntimeLoggerLevels(targetName);
1484:
1485:                if (loggers.containsKey(runtimeLoggerName)) {
1486:                    Level returnLevel = (Level) loggers.get(runtimeLoggerName);
1487:                    return returnLevel;
1488:                }
1489:                Exception exception = this .createManagementException(
1490:                        "ui.mbean.logger.id.does.not.exist",
1491:                        new String[] { runtimeLoggerName }, null);
1492:                throw new ManagementRemoteException(exception);
1493:            }
1494:
1495:            /**
1496:             * Gets all the runtime loggers and their display names
1497:             * 
1498:             * @param targetName
1499:             *            name of the target (e.g., cluster1, server, etc.)
1500:             * @param targetInstanceName
1501:             *            name of the target instance (e.g., cluster1-instance1, etc.)
1502:             * @return a Map of display names to their logger MBeans
1503:             * @throws ManagementRemoteException
1504:             *             on error
1505:             */
1506:            @SuppressWarnings("unchecked")
1507:            public Map<String /* display name */, String /* logger name */> getRuntimeLoggerNames(
1508:                    String targetName) throws ManagementRemoteException {
1509:                Map<String, String> resultObject = new TreeMap<String, String>();
1510:                logDebug("getRuntimeLoggerNames: targetName: " + targetName);
1511:
1512:                TargetType type = checkTargetType(targetName);
1513:                String[] args = { targetName };
1514:
1515:                switch (type) {
1516:                case CLUSTERED_SERVER:
1517:                    try {
1518:                        if (!this .getPlatformContext().isInstanceUp(targetName)) {
1519:                            Exception exception = this 
1520:                                    .createManagementException(
1521:                                            "ui.mbean.target.down", args, null);
1522:                            throw new ManagementRemoteException(exception);
1523:                        }
1524:
1525:                        // call getSystemLoggerMBeans to get list of all system loggers
1526:                        ObjectName[] loggers = getSystemLoggerMBeans(targetName);
1527:
1528:                        logDebug("found the following " + loggers.length
1529:                                + " loggers: " + loggers);
1530:                        for (int index = 0; index < loggers.length; index++) {
1531:                            String loggerDisplayName = null;
1532:                            String loggerName = null;
1533:                            try {
1534:                                logDebug("loggers[" + index
1535:                                        + "]: ObjectName = " + loggers[index]);
1536:                                loggerDisplayName = (String) this 
1537:                                        .invokeMBeanOperation(loggers[index],
1538:                                                "getDisplayName");
1539:                                loggerName = (String) this 
1540:                                        .invokeMBeanOperation(loggers[index],
1541:                                                "getLoggerName");
1542:                                logDebug("loggers[" + index + "]: name = "
1543:                                        + loggerName + ", display name = "
1544:                                        + loggerDisplayName);
1545:                                this .checkForValidTarget(loggers[index],
1546:                                        JBIAdminCommands.DOMAIN_TARGET_KEY);
1547:                                resultObject.put(loggerDisplayName, loggerName);
1548:                            } catch (ManagementRemoteException exception) {
1549:                                logDebug("ManagementRemoteException");
1550:                                logDebug(exception);
1551:                            } catch (RuntimeException exception) {
1552:                                logDebug("RuntimeException");
1553:                                logDebug(exception);
1554:                            }
1555:                        }
1556:                    } catch (Exception ex) {
1557:                        throw ManagementRemoteException.filterJmxExceptions(ex);
1558:                    }
1559:                    break;
1560:
1561:                case INVALID_TARGET:
1562:                    logDebug("getRuntimeLoggerNames(): target " + targetName
1563:                            + " type not supported.");
1564:                    Exception exception = this .createManagementException(
1565:                            "ui.mbean.invalid.target.error", args, null);
1566:                    throw new ManagementRemoteException(exception);
1567:
1568:                default:
1569:                    // Get all the attributes on the config facade MBean
1570:                    ObjectName loggerCfgFacade = getRuntimeLoggerConfigFacadeMBeanName(targetName);
1571:
1572:                    Map<String, Descriptor> descrMap = getConfigurationDescriptors(loggerCfgFacade);
1573:
1574:                    for (java.util.Iterator itr = descrMap.keySet().iterator(); itr
1575:                            .hasNext();) {
1576:                        String loggerName = (String) itr.next();
1577:                        Descriptor descr = descrMap.get(loggerName);
1578:                        String loggerDisplayName = (String) descr
1579:                                .getFieldValue("displayName");
1580:                        resultObject.put(loggerDisplayName, loggerName);
1581:                    }
1582:                }
1583:
1584:                return resultObject;
1585:            }
1586:
1587:            /**
1588:             * Return the display name for a runtime logger
1589:             * 
1590:             * @param runtimeLoggerName
1591:             *            name of the logger (e.g. com.sun.jbi.framework)
1592:             * @param targetName
1593:             *            name of the target (e.g., cluster1, server, etc.)
1594:             * @return the display name for the given logger
1595:             * @throws ManagementRemoteException
1596:             *             on error
1597:             */
1598:            @SuppressWarnings("unchecked")
1599:            public String getRuntimeLoggerDisplayName(String runtimeLoggerName,
1600:                    String targetName) throws ManagementRemoteException {
1601:                String resultString = null;
1602:                logDebug("getRuntimeLoggerDisplayName: loggerName: "
1603:                        + runtimeLoggerName + " , targetName: " + targetName);
1604:
1605:                TargetType type = checkTargetType(targetName);
1606:                String[] args = { targetName };
1607:
1608:                switch (type) {
1609:                case CLUSTERED_SERVER:
1610:                    try {
1611:                        if (!this .getPlatformContext().isInstanceUp(targetName)) {
1612:                            Exception exception = this 
1613:                                    .createManagementException(
1614:                                            "ui.mbean.target.down", args, null);
1615:                            throw new ManagementRemoteException(exception);
1616:                        }
1617:
1618:                        // call getSystemLoggerMBeans to get list of all system loggers
1619:                        ObjectName[] loggers = getSystemLoggerMBeans(targetName);
1620:
1621:                        for (int index = 0; index < loggers.length; index++) {
1622:                            String loggerName = null;
1623:                            String loggerDisplayName = null;
1624:                            try {
1625:                                logDebug("loggers[" + index
1626:                                        + "]: ObjectName = " + loggers[index]);
1627:                                loggerDisplayName = (String) this 
1628:                                        .invokeMBeanOperation(loggers[index],
1629:                                                "getDisplayName");
1630:                                loggerName = (String) this 
1631:                                        .invokeMBeanOperation(loggers[index],
1632:                                                "getLoggerName");
1633:                                logDebug("loggers[" + index + "]: "
1634:                                        + loggerName + ", " + loggerDisplayName);
1635:                                if (loggerName.equals(runtimeLoggerName)) {
1636:                                    logDebug("Found the matching logger.");
1637:                                    resultString = loggerDisplayName;
1638:                                }
1639:                            } catch (ManagementRemoteException exception) {
1640:                                logDebug("ManagementRemoteException");
1641:                                logDebug(exception);
1642:                            } catch (RuntimeException exception) {
1643:                                logDebug("RuntimeException");
1644:                                logDebug(exception);
1645:                            }
1646:                        }
1647:
1648:                    } catch (Exception ex) {
1649:                        throw ManagementRemoteException.filterJmxExceptions(ex);
1650:                    }
1651:                    break;
1652:
1653:                case INVALID_TARGET:
1654:                    logDebug("getRuntimeLoggerName(): target " + targetName
1655:                            + " type not supported.");
1656:                    Exception exception = this .createManagementException(
1657:                            "ui.mbean.invalid.target.error", args, null);
1658:                    throw new ManagementRemoteException(exception);
1659:
1660:                default:
1661:                    // Get all the attributes on the config facade MBean
1662:                    ObjectName loggerCfgFacade = getRuntimeLoggerConfigFacadeMBeanName(targetName);
1663:
1664:                    Map<String, Descriptor> descrMap = getConfigurationDescriptors(loggerCfgFacade);
1665:
1666:                    for (java.util.Iterator itr = descrMap.keySet().iterator(); itr
1667:                            .hasNext();) {
1668:
1669:                        String loggerName = (String) itr.next();
1670:                        if (loggerName.equals(runtimeLoggerName)) {
1671:                            Descriptor descr = descrMap.get(loggerName);
1672:                            resultString = (String) descr
1673:                                    .getFieldValue("displayName");
1674:                        }
1675:                    }
1676:                }
1677:
1678:                if (resultString == null) {
1679:                    Exception exception = this .createManagementException(
1680:                            "ui.mbean.logger.id.does.not.exist",
1681:                            new String[] { runtimeLoggerName }, null);
1682:                    throw new ManagementRemoteException(exception);
1683:                }
1684:                return resultString;
1685:
1686:            }
1687:
1688:            /**
1689:             * checks if the server need to be restarted to apply the changes made to
1690:             * some of the configuration parameters.
1691:             * 
1692:             * @return true if server need to be restarted for updated configuration to
1693:             *         take effect. false if no server restart is needed.
1694:             * 
1695:             * @see com.sun.esb.management.api.configuration.ConfigurationService#isServerRestartRequired()
1696:             */
1697:            public boolean isServerRestartRequired()
1698:                    throws ManagementRemoteException {
1699:                return false;
1700:            }
1701:
1702:            /**
1703:             * List all the application configurations in a component.
1704:             * 
1705:             * @param componentName
1706:             *            component identification
1707:             * @param targetName
1708:             *            identification of the target. Can be a standalone server,
1709:             *            cluster or clustered instance.
1710:             * @return an array of names of all the application configurations.
1711:             * @throws ManagementRemoteException
1712:             *             if there is a jmx error accessing the instance
1713:             * 
1714:             * @see com.sun.esb.management.api.configuration.ConfigurationService#listApplicationConfigurationNames(java.lang.String,
1715:             *      java.lang.String)
1716:             */
1717:            @SuppressWarnings("unchecked")
1718:            public String[] listApplicationConfigurationNames(
1719:                    String componentName, String targetName)
1720:                    throws ManagementRemoteException {
1721:                domainTargetCheck(targetName);
1722:
1723:                Map<String, Properties> configMap = getApplicationConfigurations(
1724:                        componentName, targetName);
1725:
1726:                Set configNamesSet = configMap.keySet();
1727:                String[] configNames = new String[configNamesSet.size()];
1728:                configNames = (String[]) configNamesSet.toArray(configNames);
1729:
1730:                return configNames;
1731:            }
1732:
1733:            /**
1734:             * Update a named application configuration in a component installed on a
1735:             * given target.
1736:             * 
1737:             * @param componentName
1738:             *            component identification
1739:             * @param targetName
1740:             *            identification of the target. Can be a standalone server,
1741:             *            cluster or clustered instance.
1742:             * @param name
1743:             *            application configuration name
1744:             * @param config
1745:             *            application configuration represented as a set of properties.
1746:             * @return a JBI Management message indicating the status of the operation.
1747:             * @throws ManagementRemoteException
1748:             *             if there is a jmx error accessing the instance
1749:             * 
1750:             * @see com.sun.esb.management.api.configuration.ConfigurationService#setApplicationConfiguration(java.lang.String,
1751:             *      java.lang.String, java.util.Properties, java.lang.String)
1752:             */
1753:            public String setApplicationConfiguration(String componentName,
1754:                    String name, Properties config, String targetName)
1755:                    throws ManagementRemoteException {
1756:                domainTargetCheck(targetName);
1757:
1758:                String jbiMgmtMsgResult = null;
1759:                ObjectName configFacadeMBean = this 
1760:                        .getComponentConfigurationFacadeMBeanName(
1761:                                componentName, targetName);
1762:                logDebug("setApplicationConfiguration(" + componentName + ","
1763:                        + targetName + "): configMBean = " + configFacadeMBean);
1764:
1765:                if ((configFacadeMBean != null)
1766:                        && (true == this .isValidTarget(configFacadeMBean))) {
1767:                    try {
1768:                        jbiMgmtMsgResult = (String) this .invokeMBeanOperation(
1769:                                configFacadeMBean,
1770:                                "setApplicationConfiguration", new Object[] {
1771:                                        name, config }, new String[] {
1772:                                        "java.lang.String",
1773:                                        "java.util.Properties" });
1774:
1775:                        logDebug("setApplicationConfiguration(): result = "
1776:                                + jbiMgmtMsgResult);
1777:                        return jbiMgmtMsgResult;
1778:                    } catch (ManagementRemoteException jbiRE) {
1779:                        logDebug("setApplicationConfiguration caught ManagementRemoteException:");
1780:                        logWarning(jbiRE);
1781:                        throw jbiRE;
1782:                    } catch (Exception ex) {
1783:                        logDebug("setApplicationConfiguration  caught non-ManagementRemoteException:");
1784:                        logWarning(ex);
1785:                        String[] args = new String[] { name, componentName,
1786:                                targetName };
1787:                        Exception mgmtEx = this .createManagementException(
1788:                                "ui.mbean.component.set.app.config.error",
1789:                                args, ex);
1790:                        throw new ManagementRemoteException(mgmtEx);
1791:                    }
1792:                } else {
1793:                    // -- Component Configuration Facade MBean not found -- error
1794:                    // component not
1795:                    // installed on target
1796:                    String[] args = new String[] { componentName, targetName };
1797:                    Exception mgmtEx = this 
1798:                            .createManagementException(
1799:                                    "ui.mbean.component.configuration.mbean.not.found.error",
1800:                                    args, null);
1801:                    throw new ManagementRemoteException(mgmtEx);
1802:                }
1803:            }
1804:
1805:            /**
1806:             * Set application variables on a component installed on a given target. If
1807:             * even a variable from the set has not been added to the component, this
1808:             * operation fails.
1809:             * 
1810:             * @param componentName
1811:             *            component identification
1812:             * @param targetName
1813:             *            identification of the target. Can be a standalone server,
1814:             *            cluster or clustered instance.
1815:             * @param appVariables -
1816:             *            set of application variables to update. The values of the
1817:             *            application variables have the application variable type and
1818:             *            value and the format is "[type]value"
1819:             * @return a JBI Management message indicating the status of the operation.
1820:             *         In case a variable is not set the management message has a ERROR
1821:             *         task status message giving the details of the failure.
1822:             * @throws ManagementRemoteException
1823:             *             if there is a jmx error accessing the instance
1824:             * 
1825:             * @see com.sun.esb.management.api.configuration.ConfigurationService#setApplicationVariables(java.lang.String,
1826:             *      java.lang.String, java.util.Properties)
1827:             */
1828:            @SuppressWarnings("unchecked")
1829:            public String setApplicationVariables(String componentName,
1830:                    Properties appVariables, String targetName)
1831:                    throws ManagementRemoteException {
1832:                domainTargetCheck(targetName);
1833:
1834:                ObjectName configFacadeMBean = this 
1835:                        .getComponentConfigurationFacadeMBeanName(
1836:                                componentName, targetName);
1837:                logDebug("setApplicationVariables(" + componentName + ","
1838:                        + targetName + "): configMBean = " + configFacadeMBean);
1839:
1840:                Map<String/* appVarName */, String /* JBI MgmtMsg result */> results = new HashMap<String/* appVarName */, String /*
1841:                 * JBI
1842:                 * MgmtMsg
1843:                 * result
1844:                 */>();
1845:                if ((configFacadeMBean != null)
1846:                        && (true == this .isValidTarget(configFacadeMBean))) {
1847:
1848:                    componentStartedOnTargetCheck(componentName, targetName);
1849:
1850:                    // For each application variable invoke setApplicationVariable() on
1851:                    // the
1852:                    // facade MBean. If the operation is not successful, get the
1853:                    // instance
1854:                    // details : the error task status msg and the exception info.
1855:                    //
1856:                    // Build a composite message which has all the details re. which
1857:                    // attribute failed to be set and why ( in case of cluster need the
1858:                    // instance details )
1859:                    Set appVarNames = appVariables.keySet();
1860:
1861:                    for (Iterator itr = appVarNames.iterator(); itr.hasNext();) {
1862:                        String name = (String) itr.next();
1863:                        String typeAndValueStr = (String) appVariables
1864:                                .get(name);
1865:                        String result = null;
1866:                        try {
1867:
1868:                            String type = this .componentConfigurationHelper
1869:                                    .getAppVarType(typeAndValueStr, null);
1870:                            String value = this .componentConfigurationHelper
1871:                                    .getAppVarValue(typeAndValueStr);
1872:                            if (type == null) {
1873:                                type = getExistingAppVarType(componentName,
1874:                                        targetName, name);
1875:                            }
1876:
1877:                            CompositeData appVarCD = this .componentConfigurationHelper
1878:                                    .createApplicationVariableComposite(name,
1879:                                            value, type);
1880:                            result = (String) this 
1881:                                    .invokeMBeanOperation(
1882:                                            configFacadeMBean,
1883:                                            "setApplicationVariable",
1884:                                            new Object[] { name, appVarCD },
1885:                                            new String[] { "java.lang.String",
1886:                                                    "javax.management.openmbean.CompositeData" });
1887:
1888:                            logDebug("setApplicationVariable(): result = "
1889:                                    + result);
1890:                        } catch (ManagementRemoteException jbiRE) {
1891:                            // exception msg is a management message already; just keep
1892:                            // it as it is
1893:                            logDebug("caught ManagementRemoteException:");
1894:                            logDebug(jbiRE);
1895:                            result = jbiRE.getMessage();
1896:
1897:                        } catch (Exception ex) {
1898:                            logDebug("caught non-ManagementRemoteException:");
1899:                            logDebug(ex);
1900:                            result = ex.getMessage();
1901:                        }
1902:                        results.put(name, result);
1903:                    }
1904:
1905:                } else {
1906:                    // -- Component Configuration Facade MBean not found -- error
1907:                    // component not
1908:                    // installed on target
1909:                    String[] args = new String[] { componentName, targetName };
1910:                    Exception mgmtEx = this 
1911:                            .createManagementException(
1912:                                    "ui.mbean.component.configuration.mbean.not.found.error",
1913:                                    args, null);
1914:                    throw new ManagementRemoteException(mgmtEx);
1915:                }
1916:                JBIManagementMessage msg = JBIManagementMessage
1917:                        .createJBIManagementMessage("setApplicationVariables",
1918:                                results, false);
1919:
1920:                String strMsg = com.sun.jbi.ui.common.JBIResultXmlBuilder
1921:                        .getInstance().createJbiResultXml(msg);
1922:
1923:                return com.sun.jbi.ui.common.JBIResultXmlBuilder.getInstance()
1924:                        .createJbiResultXml(msg);
1925:            }
1926:
1927:            /**
1928:             * Set the component static configuration. This operation uses the facade
1929:             * component configuration MBean to set the component properties.
1930:             * 
1931:             * @param componentName
1932:             * @param targetName
1933:             * @param configurationValues
1934:             * @return a management message indicating the status of the operation. If
1935:             *         the operation fails a JBIException ( encapsulated in the
1936:             *         ManagementRemoteException ) is thrown, the exception message is a
1937:             *         management XML message and gives the failure details.
1938:             * 
1939:             * @see com.sun.esb.management.api.configuration.ConfigurationService#setComponentConfiguration(java.lang.String,
1940:             *      java.util.Properties, java.lang.String)
1941:             */
1942:            public String setComponentConfiguration(String componentName,
1943:                    Properties configurationValues, String targetName)
1944:                    throws ManagementRemoteException {
1945:                String result = null;
1946:                AttributeList list = null;
1947:                TargetType targetType = checkTargetType(targetName);
1948:                Exception exception = null;
1949:                String[] args = { targetName };
1950:
1951:                switch (targetType) {
1952:                case STANDALONE_SERVER:
1953:                case CLUSTER:
1954:                case CLUSTERED_SERVER:
1955:                    // use facade mbean code below
1956:                    break;
1957:                case DOMAIN:
1958:                case INVALID_TARGET:
1959:                default:
1960:                    logDebug("setComponentConfiguration(): target "
1961:                            + targetName + " type not supported.");
1962:                    exception = this .createManagementException(
1963:                            "ui.mbean.system.config.target.type.not.supported",
1964:                            args, null);
1965:                    throw new ManagementRemoteException(exception);
1966:                }
1967:
1968:                ObjectName configFacadeMBean = this 
1969:                        .getComponentConfigurationFacadeMBeanName(
1970:                                componentName, targetName);
1971:                logDebug("setComponentConfiguration(" + componentName + ","
1972:                        + targetName + "): configMBean = " + configFacadeMBean);
1973:
1974:                if ((configFacadeMBean != null)
1975:                        && (true == this .isValidTarget(configFacadeMBean))) {
1976:                    try {
1977:                        list = this .constructMBeanAttributes(configFacadeMBean,
1978:                                configurationValues);
1979:                        result = this .setMBeanConfigAttributes(
1980:                                configFacadeMBean, list);
1981:                        logDebug("setComponentConfiguration(): result = "
1982:                                + result);
1983:                    } catch (ManagementRemoteException jbiRE) {
1984:                        // exception msg is a management message already; just keep it
1985:                        // as it is
1986:                        logDebug("caught ManagementRemoteException:");
1987:                        logDebug(jbiRE);
1988:                        throw jbiRE;
1989:                    } catch (Exception ex) {
1990:                        logDebug("caught non-ManagementRemoteException:");
1991:                        logDebug(ex);
1992:                        exception = this 
1993:                                .createManagementException(
1994:                                        "ui.mbean.install.config.mbean.error.set.attrs.error",
1995:                                        null, ex);
1996:                        ManagementRemoteException remoteException = new ManagementRemoteException(
1997:                                exception);
1998:                        throw remoteException;
1999:                    }
2000:
2001:                }
2002:                return result;
2003:            }
2004:
2005:            /**
2006:             * Sets the component log level for a given logger
2007:             * 
2008:             * @param componentName
2009:             *            name of the component
2010:             * @param loggerName
2011:             *            the component logger name
2012:             * @param logLevel
2013:             *            the level to set the logger; when null, reverts the logger to
2014:             *            inherit its level from its parent logger
2015:             * @param targetName
2016:             *            name of the target (e.g., cluster1, server, etc.)
2017:             * @param targetInstanceName
2018:             *            name of the target instance (e.g., cluster1-instance1, etc.)
2019:             * @throws ManagementRemoteException
2020:             *             on error
2021:             * 
2022:             * @see com.sun.esb.management.api.configuration.ConfigurationService#setComponentLoggerLevel(java.lang.String,
2023:             *      java.lang.String, java.util.logging.Level, java.lang.String,
2024:             *      java.lang.String)
2025:             */
2026:            @SuppressWarnings("unchecked")
2027:            public void setComponentLoggerLevel(String componentName,
2028:                    String loggerCustomName, Level logLevel, String targetName,
2029:                    String targetInstanceName) throws ManagementRemoteException {
2030:                logDebug("Set Component Logger Level");
2031:
2032:                ObjectName extensionMBeanObjectName = this 
2033:                        .getExtensionMBeanObjectName(componentName,
2034:                                JBIAdminCommands.DOMAIN_TARGET_KEY);
2035:
2036:                this .checkForValidTarget(extensionMBeanObjectName,
2037:                        JBIAdminCommands.DOMAIN_TARGET_KEY);
2038:
2039:                logDebug("Calling getLoggerMBeanNames on extensionMBeanObjectName = "
2040:                        + extensionMBeanObjectName);
2041:
2042:                // The following filters the Logger MBeans registered by the Component
2043:                // on the target based on the log name. These are the MBeans which match
2044:                // the ObjectName pattern:
2045:                // com.sun.jbi:ComponentName=<component-name>,ControlType=Logger
2046:                Map<String, ObjectName[]> loggerMBeansMap = (Map<String, ObjectName[]>) this 
2047:                        .invokeMBeanOperation(extensionMBeanObjectName,
2048:                                "getLoggerMBeanNames");
2049:
2050:                if ((loggerMBeansMap != null)
2051:                        && ((targetName != null) || (targetInstanceName != null))) {
2052:                    // You now have the map of targetInstances to logger MBean names
2053:                    // For each of these get the log level for the logger
2054:                    ObjectName[] filteredLoggerObjectNames = null;
2055:                    if (targetInstanceName != null) {
2056:                        filteredLoggerObjectNames = loggerMBeansMap
2057:                                .get(targetInstanceName);
2058:                    } else {
2059:                        filteredLoggerObjectNames = loggerMBeansMap
2060:                                .get(targetName);
2061:                    }
2062:                    // for each logger name, set the log level
2063:                    if ((filteredLoggerObjectNames != null)
2064:                            && (filteredLoggerObjectNames.length > 0)) {
2065:                        for (int index = 0; index < filteredLoggerObjectNames.length; index++) {
2066:                            try {
2067:                                this .checkForValidTarget(
2068:                                        filteredLoggerObjectNames[index],
2069:                                        JBIAdminCommands.DOMAIN_TARGET_KEY);
2070:                                Object[] args = new Object[1];
2071:                                args[0] = loggerCustomName;
2072:                                String[] signature = new String[1];
2073:                                signature[0] = "java.lang.String";
2074:                                this .invokeMBeanOperation(
2075:                                        filteredLoggerObjectNames[index],
2076:                                        setLevel(logLevel), args, signature);
2077:                            } catch (ManagementRemoteException exception) {
2078:                                logDebug(exception);
2079:                            } catch (RuntimeException exception) {
2080:                                logDebug(exception);
2081:                            }
2082:                        }
2083:                    }
2084:                } else {
2085:                    Exception exception = this .createManagementException(
2086:                            "ui.mbean.extension.setComponentLoggerLevel.error",
2087:                            null, null);
2088:                    throw new ManagementRemoteException(exception);
2089:                }
2090:            }
2091:
2092:            /**
2093:             * This method sets one or more configuration parameters on the runtime with
2094:             * a list of name/value pairs passed as a properties object. The property
2095:             * name in the properties object should be an existing configuration
2096:             * parameter name. If user try to set the parameter that is not in the
2097:             * configuration parameters list, this method will throw an exception.
2098:             * 
2099:             * The value of the property can be any object. If the value is non string
2100:             * object, its string value (Object.toString()) will be used as a value that
2101:             * will be set on the configuration.
2102:             * 
2103:             * This method first validates whether all the paramters passed in
2104:             * properties object exist in the runtime configuration or not. If any one
2105:             * the parameters passed is not existing, it will return an error without
2106:             * settings the parameters that are passed in the properties including a
2107:             * valid parameters.
2108:             * 
2109:             * If there is an error in setting a paramter, this method throws an
2110:             * exception with the list of parameters that were not set.
2111:             * 
2112:             * @param Properties
2113:             *            params Properties object that contains name/value pairs
2114:             *            corresponding to the configuration parameters to be set on the
2115:             *            runtime.
2116:             * 
2117:             * @param targetName
2118:             *            cluster or instance name ( e.g. cluster1, instance1 ) on which
2119:             *            configuration parameters will be set. null to represent the
2120:             *            default instance which is admin server
2121:             * 
2122:             * @return true if server restart is required, false if not
2123:             * 
2124:             * @throws ManagementRemoteException
2125:             *             if there is a jmx error or a invalid parameter is passed in
2126:             *             the params properties object. In case of an error setting the
2127:             *             a particular parameter, the error message should list the
2128:             *             invalid parameters.
2129:             * 
2130:             * @see com.sun.esb.management.api.configuration.ConfigurationService#setRuntimeConfiguration(java.util.Properties,
2131:             *      java.lang.String)
2132:             */
2133:            public boolean setRuntimeConfiguration(Properties parameters,
2134:                    String targetName) throws ManagementRemoteException {
2135:                return setRuntimeConfigurationInternal(parameters, targetName);
2136:            }
2137:
2138:            /**
2139:             * Sets the log level for a given runtime logger
2140:             * 
2141:             * @param runtimeLoggerName
2142:             *            name of the runtime logger
2143:             * @param logLevel
2144:             *            the level to set the logger
2145:             * @param targetName
2146:             *            name of the target (e.g., cluster1, server, etc.)
2147:             * @param targetInstanceName
2148:             *            name of the target instance (e.g., cluster1-instance1, etc.)
2149:             * @throws ManagementRemoteException
2150:             *             on error
2151:             * 
2152:             * @see com.sun.esb.management.api.configuration.ConfigurationService#setRuntimeLoggerLevel(java.lang.String,
2153:             *      java.util.logging.Level, java.lang.String, java.lang.String)
2154:             */
2155:            public void setRuntimeLoggerLevel(String runtimeLoggerName,
2156:                    Level logLevel, String targetName, String targetInstanceName)
2157:                    throws ManagementRemoteException {
2158:                setRuntimeLoggerLevel(runtimeLoggerName, logLevel, targetName);
2159:            }
2160:
2161:            /**
2162:             * Sets the log level for a given runtime logger
2163:             * 
2164:             * @param runtimeLoggerName
2165:             *            name of the runtime logger
2166:             * @param logLevel
2167:             *            the level to set the logger
2168:             * @param targetName
2169:             *            name of the target (e.g., cluster1, server, etc.)
2170:             * @throws ManagementRemoteException
2171:             *             on error
2172:             */
2173:            @SuppressWarnings("unchecked")
2174:            public void setRuntimeLoggerLevel(String runtimeLoggerName,
2175:                    Level logLevel, String targetName)
2176:                    throws ManagementRemoteException {
2177:
2178:                logDebug("setRuntimeLoggerLevel(" + runtimeLoggerName + ")");
2179:                TargetType type = checkTargetType(targetName);
2180:                String[] args = { targetName };
2181:                boolean updated = false;
2182:
2183:                switch (type) {
2184:                case CLUSTERED_SERVER:
2185:                    try {
2186:                        if (!this .getPlatformContext().isInstanceUp(targetName)) {
2187:                            Exception exception = this 
2188:                                    .createManagementException(
2189:                                            "ui.mbean.target.down", args, null);
2190:                        }
2191:
2192:                        // call getSystemLoggerMBeans to get list of all system loggers
2193:                        ObjectName[] loggers = getSystemLoggerMBeans(targetName);
2194:
2195:                        for (int index = 0; index < loggers.length; index++) {
2196:                            String loggerName = null;
2197:                            try {
2198:                                this .checkForValidTarget(loggers[index],
2199:                                        JBIAdminCommands.DOMAIN_TARGET_KEY);
2200:                                loggerName = (String) this 
2201:                                        .invokeMBeanOperation(loggers[index],
2202:                                                "getLoggerName");
2203:                                logDebug("loggers[" + index + "]: name = "
2204:                                        + loggerName);
2205:                                if (loggerName.equals(runtimeLoggerName)) {
2206:                                    logDebug("Found the matching logger.");
2207:                                    this .invokeMBeanOperation(loggers[index],
2208:                                            setLevel(logLevel));
2209:                                    updated = true;
2210:                                }
2211:                            } catch (ManagementRemoteException exception) {
2212:                                logDebug("ManagementRemoteException");
2213:                                logDebug(exception);
2214:                            } catch (RuntimeException exception) {
2215:                                logDebug("RuntimeException");
2216:                                logDebug(exception);
2217:                            }
2218:                        }
2219:
2220:                    } catch (Exception ex) {
2221:                        throw ManagementRemoteException.filterJmxExceptions(ex);
2222:                    }
2223:                    break;
2224:
2225:                case INVALID_TARGET:
2226:                    logDebug("setRuntimeLoggerLevels(): target " + targetName
2227:                            + " type not supported.");
2228:                    Exception exception = this .createManagementException(
2229:                            "ui.mbean.invalid.target.error", args, null);
2230:                    throw new ManagementRemoteException(exception);
2231:
2232:                default:
2233:
2234:                    ObjectName loggerCfgFacade = getRuntimeLoggerConfigFacadeMBeanName(targetName);
2235:
2236:                    AttributeList attribList = new AttributeList();
2237:                    Attribute attrib = new Attribute(runtimeLoggerName,
2238:                            (null == logLevel ? "DEFAULT" : logLevel.getName()));
2239:                    attribList.add(attrib);
2240:                    AttributeList updatedAttribs = (AttributeList) setMBeanAttributes(
2241:                            environmentContext.getMBeanServer(),
2242:                            loggerCfgFacade, attribList);
2243:                    if (updatedAttribs != null) {
2244:                        for (Object updatedObj : updatedAttribs) {
2245:                            Attribute updatedAttrib = (Attribute) updatedObj;
2246:                            if (updatedAttrib.getName()
2247:                                    .equals(attrib.getName())) {
2248:                                updated = true;
2249:                            }
2250:                        }
2251:                    }
2252:
2253:                }
2254:                if (!updated) {
2255:                    Exception exception = this .createManagementException(
2256:                            "ui.mbean.logger.id.does.not.exist",
2257:                            new String[] { runtimeLoggerName }, null);
2258:                    throw new ManagementRemoteException(exception);
2259:                }
2260:
2261:            }
2262:
2263:            /**
2264:             * Return the display name for a runtime logger
2265:             * 
2266:             * @param runtimeLoggerName
2267:             *            name of the logger (e.g. com.sun.jbi.framework)
2268:             * @param targetName
2269:             *            name of the target (e.g., cluster1, server, etc.)
2270:             * @param targetInstanceName
2271:             *            name of the target instance (e.g., cluster1-instance1, etc.)
2272:             * @return the display name for the given logger
2273:             * @throws ManagementRemoteException
2274:             *             on error
2275:             */
2276:            public String getRuntimeLoggerDisplayName(String runtimeLoggerName,
2277:                    String targetName, String targetInstanceName)
2278:                    throws ManagementRemoteException {
2279:                return getRuntimeLoggerDisplayName(runtimeLoggerName,
2280:                        targetName);
2281:            }
2282:
2283:            /**
2284:             * This method is used to verify if the application variables and
2285:             * application configuration objects used in the given application are
2286:             * available in JBI runtime in the specified target. Also this method
2287:             * verifies if all necessary components are installed. If generateTemplates
2288:             * is true templates for missing application variables and application
2289:             * configurations are generated. A command script that uses the template
2290:             * files to set configuration objects is generated.
2291:             * 
2292:             * @param applicationURL
2293:             *            the URL for the application zip file
2294:             * @param generateTemplates
2295:             *            true if templates have to be generated
2296:             * @param templateDir
2297:             *            the dir to store the generated templates
2298:             * @param includeDeployCommand
2299:             *            true if the generated script should include deploy command
2300:             * @param targetName
2301:             *            the target on which the application has to be verified
2302:             * 
2303:             * @returns XML string corresponding to the verification report
2304:             * 
2305:             * CompositeType of verification report String - "ServiceAssemblyName",
2306:             * String - "ServiceAssemblyDescription", Integer - "NumServiceUnits",
2307:             * Boolean - "AllComponentsInstalled", String[] - "MissingComponentsList",
2308:             * CompositeData[] - "EndpointInfo", String - "TemplateZIPID"
2309:             * 
2310:             * CompositeType of each EndpointInfo String - "EndpointName", String -
2311:             * "ServiceUnitName", String - "ComponentName", String - "Status"
2312:             * 
2313:             * @throws ManagementRemoteException
2314:             *             if the application could not be verified
2315:             * 
2316:             * Note: param templateDir is used between ant/cli and common client client
2317:             * TemplateZIPID is used between common client server and common client
2318:             * client
2319:             * 
2320:             * @see com.sun.esb.management.api.configuration.ConfigurationService#verifyApplication(java.lang.String,
2321:             *      java.lang.String, boolean, java.lang.String, boolean)
2322:             */
2323:            public String verifyApplication(String applicationURL,
2324:                    boolean generateTemplates, String templateDir,
2325:                    boolean includeDeployCommand, String targetName)
2326:                    throws ManagementRemoteException {
2327:                String result = null;
2328:                JBIApplicationVerifier verifier = new JBIApplicationVerifier(
2329:                        this .environmentContext);
2330:                CompositeData data = null;
2331:                try {
2332:                    data = verifier.verifyApplication(applicationURL,
2333:                            targetName, generateTemplates, templateDir,
2334:                            includeDeployCommand);
2335:                } catch (Exception ManagementRemoteException) {
2336:                    throw new ManagementRemoteException(
2337:                            ManagementRemoteException);
2338:                }
2339:                if (data != null) {
2340:                    ApplicationVerificationReport report = null;
2341:                    report = new ApplicationVerificationReport(data);
2342:                    try {
2343:                        result = ApplicationVerificationReportWriter
2344:                                .serialize(report);
2345:                    } catch (ParserConfigurationException e) {
2346:                        throw new ManagementRemoteException(e);
2347:                    } catch (TransformerException e) {
2348:                        throw new ManagementRemoteException(e);
2349:                    }
2350:                }
2351:                return result;
2352:            }
2353:
2354:            /**
2355:             * Get the component configuration facade MBean name for the target. If the
2356:             * component is not installed on the target, this returns a null.
2357:             * 
2358:             * @param componentName -
2359:             *            component id
2360:             * @param targetName -
2361:             *            target name
2362:             * @return the ObjectName of the components facade Configuration MBean for a
2363:             *         target.
2364:             */
2365:            protected ObjectName getComponentConfigurationFacadeMBeanName(
2366:                    String componentName, String targetName)
2367:                    throws ManagementRemoteException {
2368:                domainTargetCheck(targetName);
2369:                ObjectName objName = null;
2370:
2371:                // if the target is a cluster instance get the Component Extension
2372:                // MBean for the cluster and then get the config MBean for the clustered
2373:                // instance
2374:                boolean isTargetCluserInstance = getEnvironmentContext()
2375:                        .getPlatformContext().isClusteredServer(targetName);
2376:
2377:                logDebug("Get Component Configuration MBean Name for component "
2378:                        + componentName);
2379:
2380:                ObjectName extensionMBeanObjectName = null;
2381:
2382:                if (isTargetCluserInstance) {
2383:                    String cluster = getEnvironmentContext()
2384:                            .getPlatformContext().getTargetName(targetName);
2385:                    extensionMBeanObjectName = this 
2386:                            .getExtensionMBeanObjectName(componentName, cluster);
2387:                } else {
2388:                    extensionMBeanObjectName = this 
2389:                            .getExtensionMBeanObjectName(componentName,
2390:                                    targetName);
2391:                }
2392:
2393:                if (!(isMBeanRegistered(extensionMBeanObjectName))) {
2394:                    return objName;
2395:                }
2396:
2397:                logDebug("Calling getComponentConfigurationFacadeMBeanName on extensionMBeanObjectName = "
2398:                        + extensionMBeanObjectName);
2399:
2400:                objName = (ObjectName) this .invokeMBeanOperation(
2401:                        extensionMBeanObjectName,
2402:                        "getComponentConfigurationFacadeMBeanName", targetName);
2403:
2404:                return objName;
2405:            }
2406:
2407:            /**
2408:             * Retrieve component configuration for a clustered server (that is up)
2409:             * 
2410:             * @param componentName
2411:             * @param targetName
2412:             * @return the targetName as key and the name/value pairs as properties
2413:             */
2414:            protected Properties getComponentConfigurationForClusteredServer(
2415:                    String componentName, String targetName)
2416:                    throws ManagementRemoteException {
2417:                Properties result = null;
2418:
2419:                logDebug("Entering getComponentConfigurationForClusteredServer("
2420:                        + componentName + ", " + targetName + ")...");
2421:
2422:                try {
2423:                    ObjectName configMBeanName = this .getConfigMBeanName(
2424:                            componentName, targetName);
2425:
2426:                    javax.management.MBeanServerConnection mbns = this 
2427:                            .getPlatformContext().getMBeanServerConnection(
2428:                                    targetName);
2429:
2430:                    result = this 
2431:                            .getMBeanAttributeValues(mbns, configMBeanName);
2432:                    logDebug("getComponentConfigurationForClusteredServer: result properties = "
2433:                            + result);
2434:                } catch (ManagementRemoteException jbiRE) {
2435:                    // exception msg is a management message already; just keep it
2436:                    // as it is
2437:                    logDebug("caught ManagementRemoteException:");
2438:                    logDebug(jbiRE);
2439:                    throw jbiRE;
2440:                } catch (Exception ex) {
2441:                    Exception exception = this 
2442:                            .createManagementException(
2443:                                    "ui.mbean.install.config.mbean.error.get.attrs.error",
2444:                                    null, ex);
2445:                    ManagementRemoteException remoteException = new ManagementRemoteException(
2446:                            exception);
2447:                    throw remoteException;
2448:                }
2449:                return result;
2450:            }
2451:
2452:            /**
2453:             * Find the actual object config MBean Name -- used by both g/setting
2454:             * component configuations for clustered servers
2455:             * 
2456:             * @param componentName
2457:             * @param targetName
2458:             * @return the actual component's config MBean name
2459:             */
2460:            @SuppressWarnings("unchecked")
2461:            protected ObjectName getConfigMBeanName(String componentName,
2462:                    String targetName) throws ManagementRemoteException {
2463:
2464:                logDebug("getConfigMBeanName(" + componentName + ", "
2465:                        + targetName + ")...");
2466:
2467:                String clusterName = this .getPlatformContext().getTargetName(
2468:                        targetName);
2469:                ObjectName result = null;
2470:
2471:                // Check if the component is installed on the cluster, if not then
2472:                // its an error.
2473:                if (false == this .isExistingComponent(componentName,
2474:                        clusterName)) {
2475:                    String[] args = { componentName };
2476:                    Exception exception = this .createManagementException(
2477:                            "ui.mbean.component.id.does.not.exist", args, null);
2478:                    logDebug(exception);
2479:                    throw new ManagementRemoteException(exception);
2480:                }
2481:
2482:                // Check if the component is in the Started state on the cluster,
2483:                // if not then you cannot configure it.
2484:                String state = JBIComponentInfo.UNKNOWN_STATE;
2485:                try {
2486:                    ObjectName lifeCycleMBeanObjectName = null;
2487:                    lifeCycleMBeanObjectName = this 
2488:                            .getComponentLifeCycleMBeanObjectName(
2489:                                    componentName, clusterName);
2490:                    state = (String) this .getMBeanAttribute(
2491:                            lifeCycleMBeanObjectName, "CurrentState");
2492:                } catch (ManagementRemoteException exception) {
2493:                    // do not rethrow it. The state is already defaulted to
2494:                    // JBIComponentInfo.UNKNOWN_STATE
2495:                    state = JBIComponentInfo.UNKNOWN_STATE;
2496:                }
2497:                if (true == RUNNING_STATE.equals(state)) {
2498:                    state = JBIComponentInfo.STARTED_STATE;
2499:                }
2500:                logDebug("state of component " + componentName + " on target "
2501:                        + targetName + " = " + state);
2502:                if (!JBIComponentInfo.STARTED_STATE.equals(state)) {
2503:                    String[] args = { componentName };
2504:                    Exception exception = this .createManagementException(
2505:                            "ui.mbean.component.id.not.started.state", args,
2506:                            null);
2507:                    logDebug(exception);
2508:                    throw new ManagementRemoteException(exception);
2509:                }
2510:
2511:                try {
2512:                    javax.management.MBeanServerConnection mbns = this 
2513:                            .getPlatformContext().getMBeanServerConnection(
2514:                                    targetName);
2515:
2516:                    // first, look for "standard naming convention" MBean
2517:                    // com.sun.jbi:ControlType=Configuration,ComponentName=___
2518:                    Map<String, ObjectName[]> clusterMBeans = new HashMap<String, ObjectName[]>();
2519:                    try {
2520:                        String target = this .getPlatformContext()
2521:                                .getTargetName(targetName);
2522:                        clusterMBeans = getComponentExtensionMBeanObjectNames(
2523:                                componentName, "Configuration", target);
2524:
2525:                    } catch (Exception ex) {
2526:                        logDebug(ex);
2527:                    }
2528:
2529:                    ObjectName[] clusteredInstanceMBeans = clusterMBeans
2530:                            .get(targetName);
2531:
2532:                    if (clusteredInstanceMBeans.length > 0) {
2533:                        if (clusteredInstanceMBeans.length > 1) {
2534:                            logDebug("More than one component configuration MBean registered for component "
2535:                                    + componentName);
2536:                        }
2537:                        result = clusteredInstanceMBeans[0];
2538:                    } else {
2539:                        // search for the ebi name (existing jbi components) MBean
2540:                        // com.sun.ebi:ServiceType=Configuration,IdentificationName=___
2541:                        ObjectName ebiPattern = null;
2542:                        try {
2543:                            ebiPattern = new ObjectName(
2544:                                    "com.sun.ebi:ServiceType=Configuration,IdentificationName="
2545:                                            + componentName + ",*");
2546:                        } catch (Exception ex) {
2547:                            logDebug(ex);
2548:                        }
2549:
2550:                        Set<ObjectName> ebiNames = mbns.queryNames(ebiPattern,
2551:                                null);
2552:
2553:                        if (!ebiNames.isEmpty()) {
2554:                            if (ebiNames.size() > 1) {
2555:                                logDebug("More than one MBean matches ebi pattern "
2556:                                        + ebiPattern
2557:                                        + ": "
2558:                                        + convertToString(ebiNames));
2559:                            }
2560:                            result = (ObjectName) ebiNames.iterator().next();
2561:                        }
2562:                    }
2563:                    if (result == null) {
2564:                        String[] args = { componentName, targetName };
2565:                        Exception exception = this .createManagementException(
2566:                                "ui.mbean.component.cannot.find.config.mbean",
2567:                                args, null);
2568:                        logDebug(exception);
2569:                        throw new ManagementRemoteException(exception);
2570:                    }
2571:                } catch (ManagementRemoteException jbiRE) {
2572:                    // exception msg is a management message already; just keep it
2573:                    // as it is
2574:                    logDebug("caught ManagementRemoteException:");
2575:                    logDebug(jbiRE);
2576:                    throw jbiRE;
2577:                } catch (Exception ex) {
2578:                    Exception exception = this 
2579:                            .createManagementException(
2580:                                    "ui.mbean.install.config.mbean.error.get.attrs.error",
2581:                                    null, ex);
2582:                    ManagementRemoteException remoteException = new ManagementRemoteException(
2583:                            exception);
2584:                    throw remoteException;
2585:                }
2586:                logDebug("getConfigMBeanName() returning " + result);
2587:                return result;
2588:            }
2589:
2590:            /**
2591:             * Convert the objects in the collection to a printable string.
2592:             * 
2593:             * @param set
2594:             *            a non-empty set
2595:             */
2596:            @SuppressWarnings("unchecked")
2597:            protected String convertToString(Collection colxn) {
2598:                StringBuffer strBuf = new StringBuffer("[ ");
2599:                if (!colxn.isEmpty()) {
2600:                    java.util.Iterator itr = colxn.iterator();
2601:                    while (itr.hasNext()) {
2602:                        strBuf.append(itr.next().toString());
2603:                        if (itr.hasNext()) {
2604:                            strBuf.append(",  ");
2605:                        } else {
2606:                            strBuf.append("  ");
2607:                        }
2608:                    }
2609:                }
2610:                strBuf.append(" ]");
2611:                return strBuf.toString();
2612:            }
2613:
2614:            /**
2615:             * returns the ObjectName for the Extension Mbean of this component.
2616:             * 
2617:             * @param componentName
2618:             * @param targetName
2619:             * 
2620:             * @return the ObjectName of the Extension MBean or null.
2621:             */
2622:            @SuppressWarnings("unchecked")
2623:            protected ObjectName getExtensionMBeanObjectName(
2624:                    String componentName, String targetName)
2625:                    throws ManagementRemoteException {
2626:                return super .getExtensionMBeanObjectName(componentName,
2627:                        targetName);
2628:            }
2629:
2630:            /**
2631:             * Get the config extension MBean attribute values
2632:             * 
2633:             * @param objectName
2634:             * @return
2635:             * @throws ManagementRemoteException
2636:             */
2637:            protected Properties getConfigurationAttributeValues(
2638:                    ObjectName objectName) throws ManagementRemoteException {
2639:                Properties properties = new Properties();
2640:                MBeanServer mbeanServer = this .environmentContext
2641:                        .getMBeanServer();
2642:                try {
2643:                    properties = this .getMBeanAttributeValues(mbeanServer,
2644:                            objectName);
2645:                } catch (ManagementRemoteException exception) {
2646:                    properties = new Properties();
2647:                    JBIManagementMessage mgmtMsg = null;
2648:                    mgmtMsg = exception.extractJBIManagementMessage();
2649:                    properties.setProperty(COMPONENT_CONFIG_INSTANCE_ERROR_KEY,
2650:                            mgmtMsg.getMessage());
2651:
2652:                }
2653:
2654:                return properties;
2655:            }
2656:
2657:            /**
2658:             * Get the config extension MBean attribute values
2659:             * 
2660:             * @param objectName
2661:             * @return
2662:             * @throws ManagementRemoteException
2663:             */
2664:            protected Map<String /*attributeName*/, Object /*attributeValue*/> getConfigurationAttributeValuesAsMap(
2665:                    ObjectName objectName) throws ManagementRemoteException {
2666:                Map<String /*attributeName*/, Object /*attributeValue*/> properties = null;
2667:                properties = new HashMap<String /*attributeName*/, Object /*attributeValue*/>();
2668:                MBeanServer mbeanServer = this .environmentContext
2669:                        .getMBeanServer();
2670:                try {
2671:                    properties = this .getMBeanAttributeValuesAsMap(mbeanServer,
2672:                            objectName);
2673:                } catch (ManagementRemoteException exception) {
2674:                    properties = new HashMap<String /*attributeName*/, Object /*attributeValue*/>();
2675:                    JBIManagementMessage mgmtMsg = null;
2676:                    mgmtMsg = exception.extractJBIManagementMessage();
2677:                    properties.put(COMPONENT_CONFIG_INSTANCE_ERROR_KEY, mgmtMsg
2678:                            .getMessage());
2679:
2680:                }
2681:
2682:                return properties;
2683:            }
2684:
2685:            /**
2686:             * Get the default JBI runtime configuration
2687:             * 
2688:             * @param targetName
2689:             * @return
2690:             * @throws ManagementRemoteException
2691:             */
2692:            protected Properties getDefaultRuntimeConfigurationInternal(
2693:                    String targetName) throws ManagementRemoteException {
2694:                final String DEFAULT_VALUE_KEY = "default";
2695:                Properties properties = new Properties();
2696:                ObjectName systemObjectName = null;
2697:                ObjectName installationObjectName = null;
2698:                ObjectName deploymentObjectName = null;
2699:
2700:                String SYSTEM_TYPE = "System";
2701:                String INSTALLATION_TYPE = "Installation";
2702:                String DEPLOYMENT_TYPE = "Deployment";
2703:
2704:                systemObjectName = this .getConfigurationMBeanObjectName(
2705:                        targetName, SYSTEM_TYPE);
2706:                installationObjectName = this .getConfigurationMBeanObjectName(
2707:                        targetName, INSTALLATION_TYPE);
2708:                deploymentObjectName = this .getConfigurationMBeanObjectName(
2709:                        targetName, DEPLOYMENT_TYPE);
2710:
2711:                MBeanServer mbeanServer = this .environmentContext
2712:                        .getMBeanServer();
2713:
2714:                MBeanInfo mbeanSystemInfo = null;
2715:                MBeanInfo mbeanInstallationInfo = null;
2716:                MBeanInfo mbeanDeploymentInfo = null;
2717:
2718:                try {
2719:                    mbeanSystemInfo = mbeanServer
2720:                            .getMBeanInfo(systemObjectName);
2721:                } catch (InstanceNotFoundException exception) {
2722:                    throw new ManagementRemoteException(exception);
2723:                } catch (IntrospectionException exception) {
2724:                    throw new ManagementRemoteException(exception);
2725:                } catch (ReflectionException exception) {
2726:                    throw new ManagementRemoteException(exception);
2727:                }
2728:
2729:                try {
2730:                    mbeanInstallationInfo = mbeanServer
2731:                            .getMBeanInfo(installationObjectName);
2732:                } catch (InstanceNotFoundException exception) {
2733:                    throw new ManagementRemoteException(exception);
2734:                } catch (IntrospectionException exception) {
2735:                    throw new ManagementRemoteException(exception);
2736:                } catch (ReflectionException exception) {
2737:                    throw new ManagementRemoteException(exception);
2738:                }
2739:
2740:                try {
2741:                    mbeanDeploymentInfo = mbeanServer
2742:                            .getMBeanInfo(deploymentObjectName);
2743:                } catch (InstanceNotFoundException exception) {
2744:                    throw new ManagementRemoteException(exception);
2745:                } catch (IntrospectionException exception) {
2746:                    throw new ManagementRemoteException(exception);
2747:                } catch (ReflectionException exception) {
2748:                    throw new ManagementRemoteException(exception);
2749:                }
2750:
2751:                MBeanAttributeInfo[] systemAttributes = mbeanSystemInfo
2752:                        .getAttributes();
2753:                if (systemAttributes != null) {
2754:                    for (MBeanAttributeInfo attributeInfo : systemAttributes) {
2755:                        String attributeName = attributeInfo.getName();
2756:                        if (attributeInfo instanceof  ModelMBeanAttributeInfo) {
2757:                            Descriptor descriptor = ((ModelMBeanAttributeInfo) attributeInfo)
2758:                                    .getDescriptor();
2759:                            String[] fields = descriptor.getFieldNames();
2760:                            if (fields != null) {
2761:                                for (String fieldName : fields) {
2762:                                    Object value = descriptor
2763:                                            .getFieldValue(fieldName);
2764:                                    if ((DEFAULT_VALUE_KEY.equals(fieldName) == true)
2765:                                            && (value != null)) {
2766:                                        properties.setProperty(attributeName,
2767:                                                value + "");
2768:                                    }
2769:                                }
2770:                            }
2771:                        }
2772:                    }
2773:                }
2774:
2775:                MBeanAttributeInfo[] installationAttributes = mbeanInstallationInfo
2776:                        .getAttributes();
2777:                if (installationAttributes != null) {
2778:                    for (MBeanAttributeInfo attributeInfo : installationAttributes) {
2779:                        String attributeName = attributeInfo.getName();
2780:                        if (attributeInfo instanceof  ModelMBeanAttributeInfo) {
2781:                            Descriptor descriptor = ((ModelMBeanAttributeInfo) attributeInfo)
2782:                                    .getDescriptor();
2783:                            String[] fields = descriptor.getFieldNames();
2784:                            if (fields != null) {
2785:                                for (String fieldName : fields) {
2786:                                    Object value = descriptor
2787:                                            .getFieldValue(fieldName);
2788:                                    if ((DEFAULT_VALUE_KEY.equals(fieldName) == true)
2789:                                            && (value != null)) {
2790:                                        properties.setProperty(attributeName,
2791:                                                value + "");
2792:                                    }
2793:                                }
2794:                            }
2795:                        }
2796:                    }
2797:                }
2798:
2799:                MBeanAttributeInfo[] deploymentAttributes = mbeanDeploymentInfo
2800:                        .getAttributes();
2801:                if (deploymentAttributes != null) {
2802:                    for (MBeanAttributeInfo attributeInfo : deploymentAttributes) {
2803:                        String attributeName = attributeInfo.getName();
2804:                        if (attributeInfo instanceof  ModelMBeanAttributeInfo) {
2805:                            Descriptor descriptor = ((ModelMBeanAttributeInfo) attributeInfo)
2806:                                    .getDescriptor();
2807:                            String[] fields = descriptor.getFieldNames();
2808:                            if (fields != null) {
2809:                                for (String fieldName : fields) {
2810:                                    Object value = descriptor
2811:                                            .getFieldValue(fieldName);
2812:                                    if ((DEFAULT_VALUE_KEY.equals(fieldName) == true)
2813:                                            && (value != null)) {
2814:                                        properties.setProperty(attributeName,
2815:                                                value + "");
2816:                                    }
2817:                                }
2818:                            }
2819:                        }
2820:                    }
2821:                }
2822:
2823:                return properties;
2824:            }
2825:
2826:            /**
2827:             * Get the JBI Runtime Configuration Service MBean Object Name
2828:             * 
2829:             * @param targetName
2830:             * @param configurationType
2831:             * @return
2832:             * @throws ManagementRemoteException
2833:             */
2834:            public ObjectName getConfigurationMBeanObjectName(
2835:                    String targetName, String configurationType)
2836:                    throws ManagementRemoteException {
2837:                ObjectName configurationMBeanObjectName = null;
2838:                String objectNameString = JBIJMXObjectNames.JMX_JBI_DOMAIN
2839:                        + COLON + JBIJMXObjectNames.TARGET_KEY + EQUAL
2840:                        + targetName + COMMA
2841:                        + JBIJMXObjectNames.SERVICE_NAME_KEY + EQUAL
2842:                        + JBIJMXObjectNames.CONFIGURATION_SERVICE + COMMA
2843:                        + JBIJMXObjectNames.SERVICE_TYPE_KEY + EQUAL
2844:                        + configurationType;
2845:
2846:                try {
2847:                    configurationMBeanObjectName = new ObjectName(
2848:                            objectNameString);
2849:                } catch (MalformedObjectNameException exception) {
2850:                    throw new ManagementRemoteException(exception);
2851:                } catch (NullPointerException exception) {
2852:                    throw new ManagementRemoteException(exception);
2853:                }
2854:                return configurationMBeanObjectName;
2855:            }
2856:
2857:            /**
2858:             * Get the JBI Runtime Configuration
2859:             * 
2860:             * @param targetName
2861:             * @return
2862:             * @throws ManagementRemoteException
2863:             */
2864:            Properties getRuntimeConfigurationInternal(String targetName)
2865:                    throws ManagementRemoteException {
2866:                Properties properties = new Properties();
2867:                ObjectName systemObjectName = null;
2868:                ObjectName installationObjectName = null;
2869:                ObjectName deploymentObjectName = null;
2870:
2871:                String SYSTEM_TYPE = "System";
2872:                String INSTALLATION_TYPE = "Installation";
2873:                String DEPLOYMENT_TYPE = "Deployment";
2874:
2875:                if (((TargetType) checkTargetType(targetName)) == TargetType.INVALID_TARGET) {
2876:                    logDebug("getRuntimeConfigurationInternal(): target "
2877:                            + targetName + " type not supported.");
2878:                    String[] args = { targetName };
2879:                    Exception exception = this .createManagementException(
2880:                            "ui.mbean.system.config.target.type.not.supported",
2881:                            args, null);
2882:                    throw new ManagementRemoteException(exception);
2883:                }
2884:
2885:                systemObjectName = this .getConfigurationMBeanObjectName(
2886:                        targetName, SYSTEM_TYPE);
2887:                installationObjectName = this .getConfigurationMBeanObjectName(
2888:                        targetName, INSTALLATION_TYPE);
2889:                deploymentObjectName = this .getConfigurationMBeanObjectName(
2890:                        targetName, DEPLOYMENT_TYPE);
2891:
2892:                MBeanServer mbeanServer = this .environmentContext
2893:                        .getMBeanServer();
2894:
2895:                MBeanInfo mbeanSystemInfo = null;
2896:                MBeanInfo mbeanInstallationInfo = null;
2897:                MBeanInfo mbeanDeploymentInfo = null;
2898:
2899:                try {
2900:                    mbeanSystemInfo = mbeanServer
2901:                            .getMBeanInfo(systemObjectName);
2902:                } catch (InstanceNotFoundException exception) {
2903:                    throw new ManagementRemoteException(exception);
2904:                } catch (IntrospectionException exception) {
2905:                    throw new ManagementRemoteException(exception);
2906:                } catch (ReflectionException exception) {
2907:                    throw new ManagementRemoteException(exception);
2908:                }
2909:
2910:                try {
2911:                    mbeanInstallationInfo = mbeanServer
2912:                            .getMBeanInfo(installationObjectName);
2913:                } catch (InstanceNotFoundException exception) {
2914:                    throw new ManagementRemoteException(exception);
2915:                } catch (IntrospectionException exception) {
2916:                    throw new ManagementRemoteException(exception);
2917:                } catch (ReflectionException exception) {
2918:                    throw new ManagementRemoteException(exception);
2919:                }
2920:
2921:                try {
2922:                    mbeanDeploymentInfo = mbeanServer
2923:                            .getMBeanInfo(deploymentObjectName);
2924:                } catch (InstanceNotFoundException exception) {
2925:                    throw new ManagementRemoteException(exception);
2926:                } catch (IntrospectionException exception) {
2927:                    throw new ManagementRemoteException(exception);
2928:                } catch (ReflectionException exception) {
2929:                    throw new ManagementRemoteException(exception);
2930:                }
2931:
2932:                MBeanAttributeInfo[] systemAttributes = mbeanSystemInfo
2933:                        .getAttributes();
2934:                if (systemAttributes != null) {
2935:                    for (MBeanAttributeInfo attributeInfo : systemAttributes) {
2936:                        String attributeName = attributeInfo.getName();
2937:                        Object attributeValue = getAttributeValue(
2938:                                systemObjectName, attributeName);
2939:                        properties.setProperty(attributeName, attributeValue
2940:                                + "");
2941:                    }
2942:                }
2943:
2944:                MBeanAttributeInfo[] installationAttributes = mbeanInstallationInfo
2945:                        .getAttributes();
2946:                if (installationAttributes != null) {
2947:                    for (MBeanAttributeInfo attributeInfo : installationAttributes) {
2948:                        String attributeName = attributeInfo.getName();
2949:                        Object attributeValue = getAttributeValue(
2950:                                installationObjectName, attributeName);
2951:                        properties.setProperty(attributeName, attributeValue
2952:                                + "");
2953:                    }
2954:                }
2955:
2956:                MBeanAttributeInfo[] deploymentAttributes = mbeanDeploymentInfo
2957:                        .getAttributes();
2958:                if (deploymentAttributes != null) {
2959:                    for (MBeanAttributeInfo attributeInfo : deploymentAttributes) {
2960:                        String attributeName = attributeInfo.getName();
2961:                        Object attributeValue = getAttributeValue(
2962:                                deploymentObjectName, attributeName);
2963:                        properties.setProperty(attributeName, attributeValue
2964:                                + "");
2965:                    }
2966:                }
2967:
2968:                return properties;
2969:            }
2970:
2971:            /**
2972:             * Get JBI Runtime Configuration Metadata
2973:             * 
2974:             * @param targetName
2975:             * @return
2976:             * @throws ManagementRemoteException
2977:             */
2978:            Map<String /* propertyKeyName */, Properties> getRuntimeConfigurationMetadataInternal(
2979:                    String targetName) throws ManagementRemoteException {
2980:                Properties properties = null;
2981:                Map<String /* propertyKeyName */, Properties> result = null;
2982:                result = new HashMap<String /* propertyKeyName */, Properties>();
2983:
2984:                ObjectName systemObjectName = null;
2985:                ObjectName installationObjectName = null;
2986:                ObjectName deploymentObjectName = null;
2987:
2988:                String SYSTEM_TYPE = "System";
2989:                String INSTALLATION_TYPE = "Installation";
2990:                String DEPLOYMENT_TYPE = "Deployment";
2991:
2992:                systemObjectName = this .getConfigurationMBeanObjectName(
2993:                        targetName, SYSTEM_TYPE);
2994:                installationObjectName = this .getConfigurationMBeanObjectName(
2995:                        targetName, INSTALLATION_TYPE);
2996:                deploymentObjectName = this .getConfigurationMBeanObjectName(
2997:                        targetName, DEPLOYMENT_TYPE);
2998:
2999:                MBeanServer mbeanServer = this .environmentContext
3000:                        .getMBeanServer();
3001:
3002:                MBeanInfo mbeanSystemInfo = null;
3003:                MBeanInfo mbeanInstallationInfo = null;
3004:                MBeanInfo mbeanDeploymentInfo = null;
3005:
3006:                try {
3007:                    mbeanSystemInfo = mbeanServer
3008:                            .getMBeanInfo(systemObjectName);
3009:                } catch (InstanceNotFoundException exception) {
3010:                    throw new ManagementRemoteException(exception);
3011:                } catch (IntrospectionException exception) {
3012:                    throw new ManagementRemoteException(exception);
3013:                } catch (ReflectionException exception) {
3014:                    throw new ManagementRemoteException(exception);
3015:                }
3016:
3017:                try {
3018:                    mbeanInstallationInfo = mbeanServer
3019:                            .getMBeanInfo(installationObjectName);
3020:                } catch (InstanceNotFoundException exception) {
3021:                    throw new ManagementRemoteException(exception);
3022:                } catch (IntrospectionException exception) {
3023:                    throw new ManagementRemoteException(exception);
3024:                } catch (ReflectionException exception) {
3025:                    throw new ManagementRemoteException(exception);
3026:                }
3027:
3028:                try {
3029:                    mbeanDeploymentInfo = mbeanServer
3030:                            .getMBeanInfo(deploymentObjectName);
3031:                } catch (InstanceNotFoundException exception) {
3032:                    throw new ManagementRemoteException(exception);
3033:                } catch (IntrospectionException exception) {
3034:                    throw new ManagementRemoteException(exception);
3035:                } catch (ReflectionException exception) {
3036:                    throw new ManagementRemoteException(exception);
3037:                }
3038:
3039:                MBeanAttributeInfo[] systemAttributes = mbeanSystemInfo
3040:                        .getAttributes();
3041:                MBeanAttributeInfo[] installationAttributes = mbeanInstallationInfo
3042:                        .getAttributes();
3043:                MBeanAttributeInfo[] deploymentAttributes = mbeanDeploymentInfo
3044:                        .getAttributes();
3045:
3046:                if (systemAttributes != null) {
3047:                    for (MBeanAttributeInfo attributeInfo : systemAttributes) {
3048:                        String attributeName = attributeInfo.getName();
3049:                        if (attributeName != null) {
3050:                            properties = new Properties();
3051:                            if (attributeInfo instanceof  ModelMBeanAttributeInfo) {
3052:                                Descriptor descriptor = ((ModelMBeanAttributeInfo) attributeInfo)
3053:                                        .getDescriptor();
3054:                                String[] fields = descriptor.getFieldNames();
3055:                                if (fields != null) {
3056:                                    for (String fieldName : fields) {
3057:                                        Object value = descriptor
3058:                                                .getFieldValue(fieldName);
3059:                                        if ((fieldName != null)
3060:                                                && (value != null)) {
3061:                                            properties.setProperty(fieldName,
3062:                                                    value + "");
3063:                                        }
3064:                                    }
3065:                                }
3066:                            }
3067:                            result.put(attributeName, properties);
3068:                        }
3069:                    }
3070:                }
3071:
3072:                if (installationAttributes != null) {
3073:                    for (MBeanAttributeInfo attributeInfo : installationAttributes) {
3074:                        String attributeName = attributeInfo.getName();
3075:                        if (attributeName != null) {
3076:                            properties = new Properties();
3077:                            if (attributeInfo instanceof  ModelMBeanAttributeInfo) {
3078:                                Descriptor descriptor = ((ModelMBeanAttributeInfo) attributeInfo)
3079:                                        .getDescriptor();
3080:                                String[] fields = descriptor.getFieldNames();
3081:                                if (fields != null) {
3082:                                    for (String fieldName : fields) {
3083:                                        Object value = descriptor
3084:                                                .getFieldValue(fieldName);
3085:                                        if ((fieldName != null)
3086:                                                && (value != null)) {
3087:                                            properties.setProperty(fieldName,
3088:                                                    value + "");
3089:                                        }
3090:                                    }
3091:                                }
3092:                            }
3093:                            result.put(attributeName, properties);
3094:                        }
3095:                    }
3096:                }
3097:
3098:                if (deploymentAttributes != null) {
3099:                    for (MBeanAttributeInfo attributeInfo : deploymentAttributes) {
3100:                        String attributeName = attributeInfo.getName();
3101:                        if (attributeName != null) {
3102:                            properties = new Properties();
3103:                            if (attributeInfo instanceof  ModelMBeanAttributeInfo) {
3104:                                Descriptor descriptor = ((ModelMBeanAttributeInfo) attributeInfo)
3105:                                        .getDescriptor();
3106:                                String[] fields = descriptor.getFieldNames();
3107:                                if (fields != null) {
3108:                                    for (String fieldName : fields) {
3109:                                        Object value = descriptor
3110:                                                .getFieldValue(fieldName);
3111:                                        if ((fieldName != null)
3112:                                                && (value != null)) {
3113:                                            properties.setProperty(fieldName,
3114:                                                    value + "");
3115:                                        }
3116:                                    }
3117:                                }
3118:                            }
3119:                            result.put(attributeName, properties);
3120:                        }
3121:                    }
3122:                }
3123:
3124:                return result;
3125:            }
3126:
3127:            /**
3128:             * returns the ObjectName for the LoggingService Mbean of this target.
3129:             * 
3130:             * @param targetName
3131:             * 
3132:             * @return the ObjectName of the LoggingService MBean or null.
3133:             */
3134:            public ObjectName getLoggingServiceMBeanObjectName(String targetName) {
3135:                ObjectName loggingMBeanObjectName = null;
3136:                String loggingString = JBIJMXObjectNames.JMX_JBI_DOMAIN + COLON
3137:                        + MBeanNames.INSTANCE_NAME_KEY + EQUAL + targetName
3138:                        + COMMA + JBIJMXObjectNames.SERVICE_NAME_KEY + EQUAL
3139:                        + MBeanNames.SERVICE_NAME_LOGGING_SERVICE + COMMA
3140:                        + JBIJMXObjectNames.CONTROL_TYPE_KEY + EQUAL
3141:                        + MBeanNames.CONTROL_TYPE_LOGGING_SERVICE + COMMA
3142:                        + JBIJMXObjectNames.COMPONENT_TYPE_KEY + EQUAL
3143:                        + JBIJMXObjectNames.SYSTEM_COMPONENT_TYPE_VALUE;
3144:
3145:                try {
3146:                    loggingMBeanObjectName = new ObjectName(loggingString);
3147:                } catch (Exception exception) {
3148:                    logDebug(exception);
3149:                }
3150:                return loggingMBeanObjectName;
3151:            }
3152:
3153:            /**
3154:             * Set component configuration for a clustered server (that is up)
3155:             * 
3156:             * @param componentName
3157:             * @param targetName
3158:             * @param configurationValues
3159:             * @return a management message indicating the status of the operation. If
3160:             *         the operation fails a JBIException ( encapsulated in the
3161:             *         ManagementRemoteException ) is thrown, the exception message is a
3162:             *         management XML message and gives the failure details.
3163:             */
3164:            String setComponentConfigurationForClusteredServer(
3165:                    String componentName, String targetName,
3166:                    Properties configurationValues)
3167:                    throws ManagementRemoteException {
3168:                String result = null;
3169:                AttributeList list = null;
3170:
3171:                logDebug("Entering setComponentConfigurationForClusteredServer("
3172:                        + componentName + ", " + targetName + ")...");
3173:
3174:                try {
3175:                    ObjectName configMBeanName = this .getConfigMBeanName(
3176:                            componentName, targetName);
3177:
3178:                    javax.management.MBeanServerConnection mbns = this 
3179:                            .getPlatformContext().getMBeanServerConnection(
3180:                                    targetName);
3181:
3182:                    list = this .constructMBeanAttributes(mbns, configMBeanName,
3183:                            configurationValues);
3184:                    this .setMBeanAttributes(mbns, configMBeanName, list);
3185:
3186:                    // create success management message
3187:                    result = createManagementMessage(
3188:                            "setComponentConfiguration", true, "INFO",
3189:                            "ui.mbean.component.set.attribute.success",
3190:                            new Object[] { componentName });
3191:                    logDebug("setComponentConfigurationForClusteredServer(): result = "
3192:                            + result);
3193:                } catch (ManagementRemoteException jbiRE) {
3194:                    logDebug("caught ManagementRemoteException:");
3195:                    logDebug(jbiRE);
3196:                    Exception jbiMgmtEx = createManagementException(
3197:                            "ui.mbean.component.set.attribute.error",
3198:                            new String[] { componentName, jbiRE.toString() },
3199:                            jbiRE);
3200:
3201:                    throw new ManagementRemoteException(jbiMgmtEx);
3202:                } catch (Exception ex) {
3203:                    Exception exception = this .createManagementException(
3204:                            "ui.mbean.component.set.attribute.error", null, ex);
3205:                    ManagementRemoteException remoteException = new ManagementRemoteException(
3206:                            exception);
3207:                    throw remoteException;
3208:                }
3209:                return result;
3210:            }
3211:
3212:            /**
3213:             * Return the "verb" (the setXXX MBean operation) for the given log level
3214:             * 
3215:             * @param logLevel
3216:             *            log level to set logger to
3217:             * @return a MBean operation to set the logger to that level
3218:             */
3219:            protected String setLevel(Level logLevel) {
3220:                if (null == logLevel) {
3221:                    return "setDefault";
3222:                }
3223:                if (Level.OFF.equals(logLevel)) {
3224:                    return "setOff";
3225:                }
3226:                if (Level.SEVERE.equals(logLevel)) {
3227:                    return "setSevere";
3228:                }
3229:                if (Level.WARNING.equals(logLevel)) {
3230:                    return "setWarning";
3231:                }
3232:                if (Level.INFO.equals(logLevel)) {
3233:                    return "setInfo";
3234:                }
3235:                if (Level.CONFIG.equals(logLevel)) {
3236:                    return "setConfig";
3237:                }
3238:                if (Level.FINE.equals(logLevel)) {
3239:                    return "setFine";
3240:                }
3241:                if (Level.FINER.equals(logLevel)) {
3242:                    return "setFiner";
3243:                }
3244:                if (Level.FINEST.equals(logLevel)) {
3245:                    return "setFinest";
3246:                }
3247:                if (Level.ALL.equals(logLevel)) {
3248:                    return "setAll";
3249:                }
3250:                // should never reach this statement
3251:                return "setDefault";
3252:            }
3253:
3254:            /**
3255:             * Set JBI Runtime Configuration
3256:             * 
3257:             * @param properties
3258:             * @param targetName
3259:             * @return
3260:             * @throws ManagementRemoteException
3261:             */
3262:            @SuppressWarnings("unchecked")
3263:            protected boolean setRuntimeConfigurationInternal(
3264:                    Properties properties, String targetName)
3265:                    throws ManagementRemoteException {
3266:                ObjectName systemObjectName = null;
3267:                ObjectName installationObjectName = null;
3268:                ObjectName deploymentObjectName = null;
3269:
3270:                final String SYSTEM_TYPE = "System";
3271:                final String INSTALLATION_TYPE = "Installation";
3272:                final String DEPLOYMENT_TYPE = "Deployment";
3273:
3274:                if (((TargetType) checkTargetType(targetName)) == TargetType.INVALID_TARGET) {
3275:                    logDebug("setRuntimeConfigurationInternal(): target "
3276:                            + targetName + " type not supported.");
3277:                    String[] args = { targetName };
3278:                    Exception exception = this .createManagementException(
3279:                            "ui.mbean.system.config.target.type.not.supported",
3280:                            args, null);
3281:                    throw new ManagementRemoteException(exception);
3282:                }
3283:
3284:                systemObjectName = this .getConfigurationMBeanObjectName(
3285:                        targetName, SYSTEM_TYPE);
3286:                installationObjectName = this .getConfigurationMBeanObjectName(
3287:                        targetName, INSTALLATION_TYPE);
3288:                deploymentObjectName = this .getConfigurationMBeanObjectName(
3289:                        targetName, DEPLOYMENT_TYPE);
3290:
3291:                MBeanServer mbeanServer = this .environmentContext
3292:                        .getMBeanServer();
3293:
3294:                MBeanInfo mbeanSystemInfo = null;
3295:                MBeanInfo mbeanInstallationInfo = null;
3296:                MBeanInfo mbeanDeploymentInfo = null;
3297:
3298:                try {
3299:                    mbeanSystemInfo = mbeanServer
3300:                            .getMBeanInfo(systemObjectName);
3301:                } catch (InstanceNotFoundException exception) {
3302:                    throw new ManagementRemoteException(exception);
3303:                } catch (IntrospectionException exception) {
3304:                    throw new ManagementRemoteException(exception);
3305:                } catch (ReflectionException exception) {
3306:                    throw new ManagementRemoteException(exception);
3307:                }
3308:
3309:                try {
3310:                    mbeanInstallationInfo = mbeanServer
3311:                            .getMBeanInfo(installationObjectName);
3312:                } catch (InstanceNotFoundException exception) {
3313:                    throw new ManagementRemoteException(exception);
3314:                } catch (IntrospectionException exception) {
3315:                    throw new ManagementRemoteException(exception);
3316:                } catch (ReflectionException exception) {
3317:                    throw new ManagementRemoteException(exception);
3318:                }
3319:
3320:                try {
3321:                    mbeanDeploymentInfo = mbeanServer
3322:                            .getMBeanInfo(deploymentObjectName);
3323:                } catch (InstanceNotFoundException exception) {
3324:                    throw new ManagementRemoteException(exception);
3325:                } catch (IntrospectionException exception) {
3326:                    throw new ManagementRemoteException(exception);
3327:                } catch (ReflectionException exception) {
3328:                    throw new ManagementRemoteException(exception);
3329:                }
3330:
3331:                Object attributeValueObject = null;
3332:                MBeanAttributeInfo[] systemAttributes = mbeanSystemInfo
3333:                        .getAttributes();
3334:                MBeanAttributeInfo[] installationAttributes = mbeanInstallationInfo
3335:                        .getAttributes();
3336:                MBeanAttributeInfo[] deploymentAttributes = mbeanDeploymentInfo
3337:                        .getAttributes();
3338:
3339:                Map<String /* Name */, Object /* Type */> attributeNameTypeMap = new HashMap<String /* Name */, Object /* Type */>();
3340:
3341:                Properties metaDataProperties = null;
3342:                // Validate to ensure there is no poison data
3343:                if (systemAttributes != null) {
3344:                    for (MBeanAttributeInfo attributeInfo : systemAttributes) {
3345:                        String attributeName = attributeInfo.getName();
3346:                        String stringValue = properties
3347:                                .getProperty(attributeName);
3348:                        if (stringValue != null) {
3349:                            String type = attributeInfo.getType();
3350:                            try {
3351:                                // construct the value object using reflection.
3352:                                attributeValueObject = Util.newInstance(type,
3353:                                        stringValue);
3354:                                attributeNameTypeMap.put(attributeName,
3355:                                        attributeValueObject);
3356:                            } catch (Exception ex) {
3357:                                String[] args = { stringValue, type,
3358:                                        attributeName };
3359:                                Exception exception = this 
3360:                                        .createManagementException(
3361:                                                "ui.mbean.install.config.mbean.attrib.type.convertion.error",
3362:                                                args, ex);
3363:                                throw new ManagementRemoteException(exception);
3364:
3365:                            }
3366:                        }
3367:                    }
3368:                }
3369:
3370:                if (installationAttributes != null) {
3371:                    for (MBeanAttributeInfo attributeInfo : installationAttributes) {
3372:                        String attributeName = attributeInfo.getName();
3373:                        String stringValue = properties
3374:                                .getProperty(attributeName);
3375:                        if (stringValue != null) {
3376:                            String type = attributeInfo.getType();
3377:                            try {
3378:                                // construct the value object using reflection.
3379:                                attributeValueObject = Util.newInstance(type,
3380:                                        stringValue);
3381:                                attributeNameTypeMap.put(attributeName,
3382:                                        attributeValueObject);
3383:                            } catch (Exception ex) {
3384:                                String[] args = { stringValue, type,
3385:                                        attributeName };
3386:                                Exception exception = this 
3387:                                        .createManagementException(
3388:                                                "ui.mbean.install.config.mbean.attrib.type.convertion.error",
3389:                                                args, ex);
3390:                                throw new ManagementRemoteException(exception);
3391:
3392:                            }
3393:                        }
3394:                    }
3395:                }
3396:
3397:                if (deploymentAttributes != null) {
3398:                    for (MBeanAttributeInfo attributeInfo : deploymentAttributes) {
3399:                        String attributeName = attributeInfo.getName();
3400:                        String stringValue = properties
3401:                                .getProperty(attributeName);
3402:                        if (stringValue != null) {
3403:                            String type = attributeInfo.getType();
3404:                            try {
3405:                                // construct the value object using reflection.
3406:                                attributeValueObject = Util.newInstance(type,
3407:                                        stringValue);
3408:                                attributeNameTypeMap.put(attributeName,
3409:                                        attributeValueObject);
3410:                            } catch (Exception ex) {
3411:                                String[] args = { stringValue, type,
3412:                                        attributeName };
3413:                                Exception exception = this 
3414:                                        .createManagementException(
3415:                                                "ui.mbean.install.config.mbean.attrib.type.convertion.error",
3416:                                                args, ex);
3417:                                throw new ManagementRemoteException(exception);
3418:
3419:                            }
3420:                        }
3421:                    }
3422:                }
3423:
3424:                // Make sure the properties does not have bogus key values
3425:                // passed in.
3426:                Set keySet = properties.keySet();
3427:                Set attributeSet = attributeNameTypeMap.keySet();
3428:
3429:                if (keySet != null) {
3430:                    for (Object keyObject : keySet) {
3431:                        String key = (String) keyObject;
3432:                        if (attributeSet.contains(key) == false) {
3433:                            // throw an exception
3434:                            String[] args = { key };
3435:                            Exception exception = this 
3436:                                    .createManagementException(
3437:                                            "ui.mbean.runtime.config.mbean.attrib.key.invalid.error",
3438:                                            args, null);
3439:                            throw new ManagementRemoteException(exception);
3440:                        }
3441:                    }
3442:                }
3443:
3444:                // Retrieve runtime configuration metadata
3445:                final String IS_STATIC_KEY = "isStatic";
3446:                boolean isRestartRequired = false;
3447:                Map<String /* propertyKeyName */, Properties> metadata = null;
3448:                metadata = getRuntimeConfigurationMetadataInternal(targetName);
3449:
3450:                // Set Values
3451:                if (systemAttributes != null) {
3452:                    for (MBeanAttributeInfo attributeInfo : systemAttributes) {
3453:                        String attributeName = attributeInfo.getName();
3454:                        String stringValue = properties
3455:                                .getProperty(attributeName);
3456:                        if (stringValue != null) {
3457:                            String type = attributeInfo.getType();
3458:                            try {
3459:                                // construct the value object using reflection.
3460:                                attributeValueObject = Util.newInstance(type,
3461:                                        stringValue);
3462:                            } catch (Exception ex) {
3463:                                String[] args = { stringValue, type,
3464:                                        attributeName };
3465:                                Exception exception = this 
3466:                                        .createManagementException(
3467:                                                "ui.mbean.install.config.mbean.attrib.type.convertion.error",
3468:                                                args, ex);
3469:                                throw new ManagementRemoteException(exception);
3470:
3471:                            }
3472:                            this .setAttributeValue(systemObjectName,
3473:                                    attributeName, attributeValueObject);
3474:
3475:                            metaDataProperties = metadata.get(attributeName);
3476:                            if (true == Boolean.valueOf(metaDataProperties
3477:                                    .getProperty(IS_STATIC_KEY))) {
3478:                                isRestartRequired = true;
3479:                            }
3480:
3481:                        }
3482:                    }
3483:                }
3484:
3485:                if (installationAttributes != null) {
3486:                    for (MBeanAttributeInfo attributeInfo : installationAttributes) {
3487:                        String attributeName = attributeInfo.getName();
3488:                        String stringValue = properties
3489:                                .getProperty(attributeName);
3490:                        if (stringValue != null) {
3491:                            String type = attributeInfo.getType();
3492:                            try {
3493:                                // construct the value object using reflection.
3494:                                attributeValueObject = Util.newInstance(type,
3495:                                        stringValue);
3496:                            } catch (Exception ex) {
3497:                                String[] args = { stringValue, type,
3498:                                        attributeName };
3499:                                Exception exception = this 
3500:                                        .createManagementException(
3501:                                                "ui.mbean.install.config.mbean.attrib.type.convertion.error",
3502:                                                args, ex);
3503:                                throw new ManagementRemoteException(exception);
3504:
3505:                            }
3506:                            this .setAttributeValue(installationObjectName,
3507:                                    attributeName, attributeValueObject);
3508:
3509:                            metaDataProperties = metadata.get(attributeName);
3510:                            if (true == Boolean.valueOf(metaDataProperties
3511:                                    .getProperty(IS_STATIC_KEY))) {
3512:                                isRestartRequired = true;
3513:                            }
3514:
3515:                        }
3516:                    }
3517:                }
3518:
3519:                if (deploymentAttributes != null) {
3520:                    for (MBeanAttributeInfo attributeInfo : deploymentAttributes) {
3521:                        String attributeName = attributeInfo.getName();
3522:                        String stringValue = properties
3523:                                .getProperty(attributeName);
3524:                        if (stringValue != null) {
3525:                            String type = attributeInfo.getType();
3526:                            try {
3527:                                // construct the value object using reflection.
3528:                                attributeValueObject = Util.newInstance(type,
3529:                                        stringValue);
3530:                            } catch (Exception ex) {
3531:                                String[] args = { stringValue, type,
3532:                                        attributeName };
3533:                                Exception exception = this 
3534:                                        .createManagementException(
3535:                                                "ui.mbean.install.config.mbean.attrib.type.convertion.error",
3536:                                                args, ex);
3537:                                throw new ManagementRemoteException(exception);
3538:
3539:                            }
3540:                            this .setAttributeValue(deploymentObjectName,
3541:                                    attributeName, attributeValueObject);
3542:
3543:                            metaDataProperties = metadata.get(attributeName);
3544:                            if (true == Boolean.valueOf(metaDataProperties
3545:                                    .getProperty(IS_STATIC_KEY))) {
3546:                                isRestartRequired = true;
3547:                            }
3548:
3549:                        }
3550:                    }
3551:                }
3552:
3553:                return isRestartRequired;
3554:            }
3555:
3556:            /**
3557:             * Convert a application configuration TabularData to a Map keyed by the
3558:             * "configurationName". The value is the application configuration
3559:             * represented as properties.
3560:             * 
3561:             * @return a Map of application configuration properties
3562:             */
3563:            @SuppressWarnings("unchecked")
3564:            protected Map<String, Properties> getApplicationConfigurationsMap(
3565:                    TabularData td) {
3566:                Map<String, Properties> configMap = new HashMap();
3567:                Set configKeys = td.keySet();
3568:
3569:                if (configKeys != null) {
3570:                    for (Object configKey : configKeys) {
3571:                        List keyList = (List) configKey;
3572:
3573:                        String[] index = new String[keyList.size()];
3574:                        index = (String[]) keyList.toArray(index);
3575:                        CompositeData cd = td.get(index);
3576:
3577:                        Properties configProps = this .componentConfigurationHelper
3578:                                .convertCompositeDataToProperties(cd);
3579:                        configMap.put(index[0], configProps);
3580:                    }
3581:                }
3582:                return configMap;
3583:            }
3584:
3585:            /**
3586:             * Retrieves the component specific configuration schema.
3587:             * 
3588:             * @param componentName
3589:             *            component identification
3590:             * @param targetName
3591:             *            identification of the target. Can be a standalone server,
3592:             *            cluster or clustered instance.
3593:             * @return a String containing the configuration schema.
3594:             * @throws ManagementRemoteException
3595:             *             on errors.
3596:             */
3597:            public String retrieveConfigurationDisplaySchema(
3598:                    String componentName, String targetName)
3599:                    throws ManagementRemoteException {
3600:                domainTargetCheck(targetName);
3601:
3602:                String schema = "";
3603:                ObjectName configFacadeMBean = this 
3604:                        .getComponentConfigurationFacadeMBeanName(
3605:                                componentName, targetName);
3606:                logDebug("retrieveConfigurationDisplaySchema(" + componentName
3607:                        + "," + targetName + "): configMBean = "
3608:                        + configFacadeMBean);
3609:
3610:                if ((configFacadeMBean != null)
3611:                        && (true == this .isValidTarget(configFacadeMBean))) {
3612:                    try {
3613:                        Object[] params = new Object[] { componentName,
3614:                                targetName };
3615:
3616:                        String[] signature = new String[] { "java.lang.String",
3617:                                "java.lang.String" };
3618:
3619:                        schema = (String) this .invokeMBeanOperation(
3620:                                configFacadeMBean,
3621:                                "retrieveConfigurationDisplaySchema", params,
3622:                                signature);
3623:                    } catch (ManagementRemoteException jbiRE) {
3624:                        logDebug("retrieveConfigurationDisplaySchema caught ManagementRemoteException:");
3625:                        throw jbiRE;
3626:                    } catch (Exception ex) {
3627:                        logDebug("retrieveConfigurationDisplaySchema caught non-ManagementRemoteException:");
3628:
3629:                        throw new ManagementRemoteException(ex);
3630:                    }
3631:                } else {
3632:                    // -- Component Configuration Facade MBean not found -- error
3633:                    // component not
3634:                    // installed on target
3635:                    String[] args = new String[] { componentName, targetName };
3636:                    Exception mgmtEx = this 
3637:                            .createManagementException(
3638:                                    "ui.mbean.component.configuration.mbean.not.found.error",
3639:                                    args, null);
3640:                    throw new ManagementRemoteException(mgmtEx);
3641:                }
3642:                return schema;
3643:            }
3644:
3645:            /**
3646:             * Retrieves the component configuration metadata. The XML data conforms to
3647:             * the component configuration schema.
3648:             * 
3649:             * @param componentName
3650:             *            component identification
3651:             * @param targetName
3652:             *            identification of the target. Can be a standalone server,
3653:             *            cluster or clustered instance.
3654:             * @return a String containing the configuration metadata.
3655:             * @throws ManagementRemoteException
3656:             *             on errors
3657:             */
3658:            public String retrieveConfigurationDisplayData(
3659:                    String componentName, String targetName)
3660:                    throws ManagementRemoteException {
3661:                domainTargetCheck(targetName);
3662:
3663:                String data = "";
3664:                ObjectName configFacadeMBean = this 
3665:                        .getComponentConfigurationFacadeMBeanName(
3666:                                componentName, targetName);
3667:                logDebug("retrieveConfigurationDisplayData(" + componentName
3668:                        + "," + targetName + "): configMBean = "
3669:                        + configFacadeMBean);
3670:
3671:                if ((configFacadeMBean != null)
3672:                        && (true == this .isValidTarget(configFacadeMBean))) {
3673:                    try {
3674:                        Object[] params = new Object[] { componentName,
3675:                                targetName };
3676:
3677:                        String[] signature = new String[] { "java.lang.String",
3678:                                "java.lang.String" };
3679:
3680:                        data = (String) this .invokeMBeanOperation(
3681:                                configFacadeMBean,
3682:                                "retrieveConfigurationDisplayData", params,
3683:                                signature);
3684:                    } catch (ManagementRemoteException jbiRE) {
3685:                        logDebug("retrieveConfigurationDisplayData caught ManagementRemoteException:");
3686:                        throw jbiRE;
3687:                    } catch (Exception ex) {
3688:                        logDebug("retrieveConfigurationDisplayData caught non-ManagementRemoteException:");
3689:
3690:                        throw new ManagementRemoteException(ex);
3691:                    }
3692:                } else {
3693:                    // -- Component Configuration Facade MBean not found -- error component not
3694:                    // installed on target
3695:                    String[] args = new String[] { componentName, targetName };
3696:                    Exception mgmtEx = this 
3697:                            .createManagementException(
3698:                                    "ui.mbean.component.configuration.mbean.not.found.error",
3699:                                    args, null);
3700:                    throw new ManagementRemoteException(mgmtEx);
3701:                }
3702:                return data;
3703:            }
3704:
3705:            /**
3706:             * Add an application configuration. The configuration name is a part of the
3707:             * CompositeData. The itemName for the configuration name is
3708:             * "configurationName" and the type is SimpleType.STRING
3709:             * 
3710:             * @param componentName
3711:             * @param targetName
3712:             * @param name -
3713:             *            configuration name, must match the value of the field "name"
3714:             *            in the namedConfig
3715:             * @param appConfig -
3716:             *            application configuration composite
3717:             * @return management message string which gives the status of the
3718:             *         operation. For target=cluster, instance specific details are
3719:             *         included.
3720:             * @throws ManagementRemoteException
3721:             *             if the application configuration cannot be added.
3722:             */
3723:            public String addApplicationConfiguration(String componentName,
3724:                    String targetName, String name, CompositeData appConfig)
3725:                    throws ManagementRemoteException {
3726:                domainTargetCheck(targetName);
3727:
3728:                String jbiMgmtMsgResult = null;
3729:                ObjectName configFacadeMBean = this 
3730:                        .getComponentConfigurationFacadeMBeanName(
3731:                                componentName, targetName);
3732:                logDebug("addApplicationConfiguration(" + componentName + ","
3733:                        + targetName + "): configMBean = " + configFacadeMBean);
3734:
3735:                if ((configFacadeMBean != null)
3736:                        && (true == this .isValidTarget(configFacadeMBean))) {
3737:                    try {
3738:                        jbiMgmtMsgResult = (String) this 
3739:                                .invokeMBeanOperation(
3740:                                        configFacadeMBean,
3741:                                        "addApplicationConfiguration",
3742:                                        new Object[] { name, appConfig },
3743:                                        new String[] { "java.lang.String",
3744:                                                "javax.management.openmbean.CompositeData" });
3745:
3746:                        logDebug("addApplicationConfiguration(): result = "
3747:                                + jbiMgmtMsgResult);
3748:                        return jbiMgmtMsgResult;
3749:                    } catch (ManagementRemoteException jbiRE) {
3750:                        logDebug("addApplicationConfiguration caught ManagementRemoteException:");
3751:                        logWarning(jbiRE);
3752:                        throw jbiRE;
3753:                    } catch (Exception ex) {
3754:                        logDebug("addApplicationConfiguration  caught non-ManagementRemoteException:");
3755:                        logWarning(ex);
3756:                        String[] args = new String[] { name, componentName,
3757:                                targetName };
3758:                        Exception mgmtEx = this .createManagementException(
3759:                                "ui.mbean.component.add.app.config.error",
3760:                                args, ex);
3761:                        throw new ManagementRemoteException(mgmtEx);
3762:                    }
3763:                } else {
3764:                    // -- Component Configuration Facade MBean not found -- error
3765:                    // component not
3766:                    // installed on target
3767:                    String[] args = new String[] { componentName, targetName };
3768:                    Exception mgmtEx = this 
3769:                            .createManagementException(
3770:                                    "ui.mbean.component.configuration.mbean.not.found.error",
3771:                                    args, null);
3772:                    throw new ManagementRemoteException(mgmtEx);
3773:                }
3774:            }
3775:
3776:            /**
3777:             * Update a application configuration. The configuration name is a part of
3778:             * the CompositeData. The itemName for the configuration name is
3779:             * "configurationName" and the type is SimpleType.STRING
3780:             * 
3781:             * @param componentName
3782:             * @param targetName
3783:             * @param name -
3784:             *            configuration name, must match the value of the field
3785:             *            "configurationName" in the appConfig
3786:             * @param appConfig -
3787:             *            application configuration composite
3788:             * @return management message string which gives the status of the
3789:             *         operation. For target=cluster, instance specific details are
3790:             *         included.
3791:             * @throws ManagementRemoteException
3792:             *             if there are errors encountered when updating the
3793:             *             configuration.
3794:             */
3795:            public String setApplicationConfiguration(String componentName,
3796:                    String targetName, String name, CompositeData appConfig)
3797:                    throws ManagementRemoteException {
3798:                domainTargetCheck(targetName);
3799:
3800:                String jbiMgmtMsgResult = null;
3801:                ObjectName configFacadeMBean = this 
3802:                        .getComponentConfigurationFacadeMBeanName(
3803:                                componentName, targetName);
3804:                logDebug("setApplicationConfiguration(" + componentName + ","
3805:                        + targetName + "): configMBean = " + configFacadeMBean);
3806:
3807:                if ((configFacadeMBean != null)
3808:                        && (true == this .isValidTarget(configFacadeMBean))) {
3809:                    try {
3810:                        jbiMgmtMsgResult = (String) this 
3811:                                .invokeMBeanOperation(
3812:                                        configFacadeMBean,
3813:                                        "setApplicationConfiguration",
3814:                                        new Object[] { name, appConfig },
3815:                                        new String[] { "java.lang.String",
3816:                                                "javax.management.openmbean.CompositeData" });
3817:
3818:                        logDebug("setApplicationConfiguration(): result = "
3819:                                + jbiMgmtMsgResult);
3820:                        return jbiMgmtMsgResult;
3821:                    } catch (ManagementRemoteException jbiRE) {
3822:                        logDebug("setApplicationConfiguration caught ManagementRemoteException:");
3823:                        logWarning(jbiRE);
3824:                        throw jbiRE;
3825:                    } catch (Exception ex) {
3826:                        logDebug("setApplicationConfiguration  caught non-ManagementRemoteException:");
3827:                        logWarning(ex);
3828:                        String[] args = new String[] { name, componentName,
3829:                                targetName };
3830:                        Exception mgmtEx = this .createManagementException(
3831:                                "ui.mbean.component.set.app.config.error",
3832:                                args, ex);
3833:                        throw new ManagementRemoteException(mgmtEx);
3834:                    }
3835:                } else {
3836:                    // -- Component Configuration Facade MBean not found -- error
3837:                    // component not
3838:                    // installed on target
3839:                    String[] args = new String[] { componentName, targetName };
3840:                    Exception mgmtEx = this 
3841:                            .createManagementException(
3842:                                    "ui.mbean.component.configuration.mbean.not.found.error",
3843:                                    args, null);
3844:                    throw new ManagementRemoteException(mgmtEx);
3845:                }
3846:            }
3847:
3848:            /**
3849:             * Get a Map of all application configurations for the component.
3850:             * 
3851:             * @param componentName
3852:             * @param targetName
3853:             * @return a TabularData of all the application configurations for a
3854:             *         component keyed by the configuration name.
3855:             * @throws ManagementRemoteException
3856:             *             if there are errors encountered when updating the
3857:             *             configuration.
3858:             */
3859:            public TabularData getApplicationConfigurationsAsTabularData(
3860:                    String componentName, String targetName)
3861:                    throws ManagementRemoteException {
3862:                domainTargetCheck(targetName);
3863:
3864:                TabularData td = null;
3865:                ObjectName configFacadeMBean = this 
3866:                        .getComponentConfigurationFacadeMBeanName(
3867:                                componentName, targetName);
3868:                logDebug("getApplicationConfigurations(" + componentName + ","
3869:                        + targetName + "): configMBean = " + configFacadeMBean);
3870:
3871:                if ((configFacadeMBean != null)
3872:                        && (true == this .isValidTarget(configFacadeMBean))) {
3873:                    try {
3874:                        Object result = this .getAttributeValue(
3875:                                configFacadeMBean, "ApplicationConfigurations");
3876:                        if (result != null) {
3877:                            td = (TabularData) result;
3878:                        }
3879:                        return td;
3880:                    } catch (ManagementRemoteException jbiRE) {
3881:                        logDebug("getApplicationConfigurations caught ManagementRemoteException:");
3882:                        logWarning(jbiRE);
3883:                        throw jbiRE;
3884:                    } catch (Exception ex) {
3885:                        logDebug("getApplicationConfigurations  caught non-ManagementRemoteException:");
3886:                        logWarning(ex);
3887:                        String[] args = new String[] { componentName,
3888:                                targetName };
3889:                        Exception mgmtEx = this .createManagementException(
3890:                                "ui.mbean.component.get.app.config.error",
3891:                                args, ex);
3892:                        throw new ManagementRemoteException(mgmtEx);
3893:                    }
3894:                } else {
3895:                    // -- Component Configuration Facade MBean not found -- error
3896:                    // component not installed on target
3897:                    String[] args = new String[] { componentName, targetName };
3898:                    Exception mgmtEx = this 
3899:                            .createManagementException(
3900:                                    "ui.mbean.component.configuration.mbean.not.found.error",
3901:                                    args, null);
3902:                    throw new ManagementRemoteException(mgmtEx);
3903:                }
3904:            }
3905:
3906:            /**
3907:             * Get the Application Variable set for a component.
3908:             * 
3909:             * @param componentName
3910:             * @param targetName
3911:             * @return a TabularData which has all the application variables set on the
3912:             *         component.
3913:             * @throws ManagementRemoteException
3914:             */
3915:            public TabularData getApplicationVariablesAsTabularData(
3916:                    String componentName, String targetName)
3917:                    throws ManagementRemoteException {
3918:                domainTargetCheck(targetName);
3919:                TabularData appVarTable = null;
3920:                ObjectName configFacadeMBean = this 
3921:                        .getComponentConfigurationFacadeMBeanName(
3922:                                componentName, targetName);
3923:                logDebug("getApplicationVariables(" + componentName + ","
3924:                        + targetName + "): configMBean = " + configFacadeMBean);
3925:
3926:                if ((configFacadeMBean != null)
3927:                        && (true == this .isValidTarget(configFacadeMBean))) {
3928:                    try {
3929:                        appVarTable = (TabularData) this .getAttributeValue(
3930:                                configFacadeMBean, "ApplicationVariables");
3931:
3932:                        logDebug("getApplicationVariables(): result = "
3933:                                + appVarTable);
3934:                    } catch (ManagementRemoteException jbiRE) {
3935:                        // exception msg is a management message already; just keep it
3936:                        // as it is
3937:                        logDebug("caught ManagementRemoteException:");
3938:                        logDebug(jbiRE);
3939:                        throw jbiRE;
3940:                    } catch (Exception ex) {
3941:                        logDebug("caught non-ManagementRemoteException:");
3942:                        logDebug(ex);
3943:                        Exception exception = this 
3944:                                .createManagementException(
3945:                                        "ui.mbean.install.config.mbean.error.set.attrs.error",
3946:                                        null, ex);
3947:                        ManagementRemoteException remoteException = new ManagementRemoteException(
3948:                                exception);
3949:                        throw remoteException;
3950:                    }
3951:                } else {
3952:                    // -- Component Configuration Facade MBean not found -- error
3953:                    // component not
3954:                    // installed on target
3955:                    String[] args = new String[] { componentName, targetName };
3956:                    Exception mgmtEx = this 
3957:                            .createManagementException(
3958:                                    "ui.mbean.component.configuration.mbean.not.found.error",
3959:                                    args, null);
3960:                    throw new ManagementRemoteException(mgmtEx);
3961:                }
3962:                return appVarTable;
3963:            }
3964:
3965:            /**
3966:             * This operation adds a new application variable. If a variable already
3967:             * exists with the same name as that specified then the operation fails.
3968:             * 
3969:             * @param componentName
3970:             * @param targetName
3971:             * @param name -
3972:             *            name of the application variable
3973:             * @param appVar -
3974:             *            this is the application variable composite
3975:             * @return management message string which gives the status of the
3976:             *         operation. For target=cluster, instance specific details are
3977:             *         included.
3978:             * @throws ManagementRemoteException
3979:             *             if an error occurs in adding the application variables to the
3980:             *             component.
3981:             */
3982:            public String addApplicationVariable(String componentName,
3983:                    String targetName, String name, CompositeData appVar)
3984:                    throws ManagementRemoteException {
3985:                domainTargetCheck(targetName);
3986:
3987:                String jbiMgmtMsgResult = null;
3988:                ObjectName configFacadeMBean = this 
3989:                        .getComponentConfigurationFacadeMBeanName(
3990:                                componentName, targetName);
3991:                logDebug("addApplicationVariable(" + componentName + ","
3992:                        + targetName + "): configMBean = " + configFacadeMBean);
3993:
3994:                if ((configFacadeMBean != null)
3995:                        && (true == this .isValidTarget(configFacadeMBean))) {
3996:                    try {
3997:                        jbiMgmtMsgResult = (String) this 
3998:                                .invokeMBeanOperation(
3999:                                        configFacadeMBean,
4000:                                        "addApplicationVariable",
4001:                                        new Object[] { name, appVar },
4002:                                        new String[] { "java.lang.String",
4003:                                                "javax.management.openmbean.CompositeData" });
4004:
4005:                        logDebug("addApplicationVariable(): result = "
4006:                                + jbiMgmtMsgResult);
4007:                        return jbiMgmtMsgResult;
4008:                    } catch (ManagementRemoteException jbiRE) {
4009:                        logDebug("addApplicationVariable caught ManagementRemoteException:");
4010:                        logWarning(jbiRE);
4011:                        throw jbiRE;
4012:                    } catch (Exception ex) {
4013:                        logDebug("addApplicationVariable  caught non-ManagementRemoteException:");
4014:                        logWarning(ex);
4015:                        String[] args = new String[] { name, componentName,
4016:                                targetName };
4017:                        Exception mgmtEx = this 
4018:                                .createManagementException(
4019:                                        "ui.mbean.install.config.mbean.error.set.attrs.error",
4020:                                        args, ex);
4021:                        throw new ManagementRemoteException(mgmtEx);
4022:                    }
4023:                } else {
4024:                    // -- Component Configuration Facade MBean not found -- error
4025:                    // component not
4026:                    // installed on target
4027:                    String[] args = new String[] { componentName, targetName };
4028:                    Exception mgmtEx = this 
4029:                            .createManagementException(
4030:                                    "ui.mbean.component.configuration.mbean.not.found.error",
4031:                                    args, null);
4032:                    throw new ManagementRemoteException(mgmtEx);
4033:                }
4034:            }
4035:
4036:            /**
4037:             * This operation sets an application variable. If a variable does not exist with 
4038:             * the same name, its an error.
4039:             * 
4040:             * @param componentName
4041:             * @param targetName
4042:             * @param name - name of the application variable
4043:             * @param appVar - this is the application variable composite to be updated.
4044:             * @return management message string which gives the status of the operation. For 
4045:             *         target=cluster, instance specific details are included. 
4046:             * @throws ManagementRemoteException if one or more application variables cannot be deleted
4047:             */
4048:            public String setApplicationVariable(String componentName,
4049:                    String targetName, String name, CompositeData appVar)
4050:                    throws ManagementRemoteException {
4051:                domainTargetCheck(targetName);
4052:
4053:                String jbiMgmtMsgResult = null;
4054:                ObjectName configFacadeMBean = this 
4055:                        .getComponentConfigurationFacadeMBeanName(
4056:                                componentName, targetName);
4057:                logDebug("setApplicationVariable(" + componentName + ","
4058:                        + targetName + "): configMBean = " + configFacadeMBean);
4059:
4060:                if ((configFacadeMBean != null)
4061:                        && (true == this .isValidTarget(configFacadeMBean))) {
4062:                    try {
4063:                        jbiMgmtMsgResult = (String) this 
4064:                                .invokeMBeanOperation(
4065:                                        configFacadeMBean,
4066:                                        "setApplicationVariable",
4067:                                        new Object[] { name, appVar },
4068:                                        new String[] { "java.lang.String",
4069:                                                "javax.management.openmbean.CompositeData" });
4070:
4071:                        logDebug("setApplicationVariable(): result = "
4072:                                + jbiMgmtMsgResult);
4073:                        return jbiMgmtMsgResult;
4074:                    } catch (ManagementRemoteException jbiRE) {
4075:                        logDebug("setApplicationVariable caught ManagementRemoteException:");
4076:                        logWarning(jbiRE);
4077:                        throw jbiRE;
4078:                    } catch (Exception ex) {
4079:                        logDebug("setApplicationVariable  caught non-ManagementRemoteException:");
4080:                        logWarning(ex);
4081:                        String[] args = new String[] { name, componentName,
4082:                                targetName };
4083:                        Exception mgmtEx = this 
4084:                                .createManagementException(
4085:                                        "ui.mbean.install.config.mbean.error.set.attrs.error",
4086:                                        args, ex);
4087:                        throw new ManagementRemoteException(mgmtEx);
4088:                    }
4089:                } else {
4090:                    // -- Component Configuration Facade MBean not found -- error
4091:                    // component not
4092:                    // installed on target
4093:                    String[] args = new String[] { componentName, targetName };
4094:                    Exception mgmtEx = this 
4095:                            .createManagementException(
4096:                                    "ui.mbean.component.configuration.mbean.not.found.error",
4097:                                    args, null);
4098:                    throw new ManagementRemoteException(mgmtEx);
4099:                }
4100:            }
4101:
4102:            /////////////////
4103:            /**
4104:             * This method returns a tabular data of a complex open data objects that
4105:             * represent the runtime configuration parameter descriptor. The parameter
4106:             * descriptor should contain the following data that represents the
4107:             * parameter.
4108:             * 
4109:             * name : name of the parameter value : value of the parameter as a String
4110:             * type. type : type of the parameter. Basic data types only. description:
4111:             * (optional) description of the parameter. displayName: (optional) display
4112:             * name of the parameter readOnly : true/false validValues : (optional) list
4113:             * of string values with ',' as delimiter. or a range value with - with a
4114:             * '-' as delimiter. min and max strings will be converted to the parameter
4115:             * type and then used to validate the value of the parameter.
4116:             * 
4117:             * @return Map that represents the list of configuration parameter
4118:             *         descriptors.
4119:             * 
4120:             * @throws ManagementRemoteException
4121:             *             if there is a jmx error accessing the instance
4122:             */
4123:            public Map<String /*attributeName*/, Object /*attributeValue*/> getDefaultRuntimeConfigurationAsMap()
4124:                    throws ManagementRemoteException {
4125:                return getDefaultRuntimeConfigurationAsMapInternal(JBIAdminCommands.DOMAIN_TARGET_KEY);
4126:            }
4127:
4128:            /**
4129:             * This method returns a tabular data of a complex open data objects that
4130:             * represent the runtime configuration parameter descriptor. The parameter
4131:             * descriptor should contain the following data that represents the
4132:             * parameter.
4133:             * 
4134:             * name : name of the parameter value : value of the parameter as a String
4135:             * type. type : type of the parameter. Basic data types only. description:
4136:             * (optional) description of the parameter. displayName: (optional) display
4137:             * name of the parameter readOnly : true/false validValues : (optional) list
4138:             * of string values with ',' as delimiter. or a range value with - with a
4139:             * '-' as delimiter. min and max strings will be converted to the parameter
4140:             * type and then used to validate the value of the parameter.
4141:             * 
4142:             * @param targetName
4143:             *            cluster or instance name ( e.g. cluster1, instance1 ) on which
4144:             *            configuration parameters will be set. null to represent the
4145:             *            default instance which is admin server
4146:             * 
4147:             * @return Map that represents the list of configuration parameter
4148:             *         descriptors.
4149:             * 
4150:             * @throws ManagementRemoteException
4151:             *             if there is a jmx error accessing the instance
4152:             */
4153:            public Map<String /*attributeName*/, Object /*attributeValue*/> getDefaultRuntimeConfigurationAsMapInternal(
4154:                    String targetName) throws ManagementRemoteException {
4155:                final String DEFAULT_VALUE_KEY = "default";
4156:                Map<String /*attributeName*/, Object /*attributeValue*/> properties = null;
4157:                properties = new HashMap<String /*attributeName*/, Object /*attributeValue*/>();
4158:                ObjectName systemObjectName = null;
4159:                ObjectName installationObjectName = null;
4160:                ObjectName deploymentObjectName = null;
4161:
4162:                String SYSTEM_TYPE = "System";
4163:                String INSTALLATION_TYPE = "Installation";
4164:                String DEPLOYMENT_TYPE = "Deployment";
4165:
4166:                systemObjectName = this .getConfigurationMBeanObjectName(
4167:                        targetName, SYSTEM_TYPE);
4168:                installationObjectName = this .getConfigurationMBeanObjectName(
4169:                        targetName, INSTALLATION_TYPE);
4170:                deploymentObjectName = this .getConfigurationMBeanObjectName(
4171:                        targetName, DEPLOYMENT_TYPE);
4172:
4173:                MBeanServer mbeanServer = this .environmentContext
4174:                        .getMBeanServer();
4175:
4176:                MBeanInfo mbeanSystemInfo = null;
4177:                MBeanInfo mbeanInstallationInfo = null;
4178:                MBeanInfo mbeanDeploymentInfo = null;
4179:
4180:                try {
4181:                    mbeanSystemInfo = mbeanServer
4182:                            .getMBeanInfo(systemObjectName);
4183:                } catch (InstanceNotFoundException exception) {
4184:                    throw new ManagementRemoteException(exception);
4185:                } catch (IntrospectionException exception) {
4186:                    throw new ManagementRemoteException(exception);
4187:                } catch (ReflectionException exception) {
4188:                    throw new ManagementRemoteException(exception);
4189:                }
4190:
4191:                try {
4192:                    mbeanInstallationInfo = mbeanServer
4193:                            .getMBeanInfo(installationObjectName);
4194:                } catch (InstanceNotFoundException exception) {
4195:                    throw new ManagementRemoteException(exception);
4196:                } catch (IntrospectionException exception) {
4197:                    throw new ManagementRemoteException(exception);
4198:                } catch (ReflectionException exception) {
4199:                    throw new ManagementRemoteException(exception);
4200:                }
4201:
4202:                try {
4203:                    mbeanDeploymentInfo = mbeanServer
4204:                            .getMBeanInfo(deploymentObjectName);
4205:                } catch (InstanceNotFoundException exception) {
4206:                    throw new ManagementRemoteException(exception);
4207:                } catch (IntrospectionException exception) {
4208:                    throw new ManagementRemoteException(exception);
4209:                } catch (ReflectionException exception) {
4210:                    throw new ManagementRemoteException(exception);
4211:                }
4212:
4213:                MBeanAttributeInfo[] systemAttributes = mbeanSystemInfo
4214:                        .getAttributes();
4215:                if (systemAttributes != null) {
4216:                    for (MBeanAttributeInfo attributeInfo : systemAttributes) {
4217:                        String attributeName = attributeInfo.getName();
4218:                        if (attributeInfo instanceof  ModelMBeanAttributeInfo) {
4219:                            Descriptor descriptor = ((ModelMBeanAttributeInfo) attributeInfo)
4220:                                    .getDescriptor();
4221:                            String[] fields = descriptor.getFieldNames();
4222:                            if (fields != null) {
4223:                                for (String fieldName : fields) {
4224:                                    Object value = descriptor
4225:                                            .getFieldValue(fieldName);
4226:                                    if ((DEFAULT_VALUE_KEY.equals(fieldName) == true)
4227:                                            && (value != null)) {
4228:                                        properties.put(attributeName, value);
4229:                                    }
4230:                                }
4231:                            }
4232:                        }
4233:                    }
4234:                }
4235:
4236:                MBeanAttributeInfo[] installationAttributes = mbeanInstallationInfo
4237:                        .getAttributes();
4238:                if (installationAttributes != null) {
4239:                    for (MBeanAttributeInfo attributeInfo : installationAttributes) {
4240:                        String attributeName = attributeInfo.getName();
4241:                        if (attributeInfo instanceof  ModelMBeanAttributeInfo) {
4242:                            Descriptor descriptor = ((ModelMBeanAttributeInfo) attributeInfo)
4243:                                    .getDescriptor();
4244:                            String[] fields = descriptor.getFieldNames();
4245:                            if (fields != null) {
4246:                                for (String fieldName : fields) {
4247:                                    Object value = descriptor
4248:                                            .getFieldValue(fieldName);
4249:                                    if ((DEFAULT_VALUE_KEY.equals(fieldName) == true)
4250:                                            && (value != null)) {
4251:                                        properties.put(attributeName, value);
4252:                                    }
4253:                                }
4254:                            }
4255:                        }
4256:                    }
4257:                }
4258:
4259:                MBeanAttributeInfo[] deploymentAttributes = mbeanDeploymentInfo
4260:                        .getAttributes();
4261:                if (deploymentAttributes != null) {
4262:                    for (MBeanAttributeInfo attributeInfo : deploymentAttributes) {
4263:                        String attributeName = attributeInfo.getName();
4264:                        if (attributeInfo instanceof  ModelMBeanAttributeInfo) {
4265:                            Descriptor descriptor = ((ModelMBeanAttributeInfo) attributeInfo)
4266:                                    .getDescriptor();
4267:                            String[] fields = descriptor.getFieldNames();
4268:                            if (fields != null) {
4269:                                for (String fieldName : fields) {
4270:                                    Object value = descriptor
4271:                                            .getFieldValue(fieldName);
4272:                                    if ((DEFAULT_VALUE_KEY.equals(fieldName) == true)
4273:                                            && (value != null)) {
4274:                                        properties.put(attributeName, value);
4275:                                    }
4276:                                }
4277:                            }
4278:                        }
4279:                    }
4280:                }
4281:
4282:                return properties;
4283:            }
4284:
4285:            /**
4286:             * This method returns a tabular data of a complex open data objects that
4287:             * represent the runtime configuration parameter descriptor. The parameter
4288:             * descriptor should contain the following data that represents the
4289:             * parameter.
4290:             * 
4291:             * name : name of the parameter value : value of the parameter as a String
4292:             * type. type : type of the parameter. Basic data types only. description:
4293:             * (optional) description of the parameter. displayName: (optional) display
4294:             * name of the parameter readOnly : true/false validValues : (optional) list
4295:             * of string values with ',' as delimiter. or a range value with - with a
4296:             * '-' as delimiter. min and max strings will be converted to the parameter
4297:             * type and then used to validate the value of the parameter.
4298:             * 
4299:             * @param targetName
4300:             *            cluster or instance name ( e.g. cluster1, instance1 ) on which
4301:             *            configuration parameters will be set. null to represent the
4302:             *            default instance which is admin server
4303:             * 
4304:             * @return Map that represents the list of configuration parameter
4305:             *         descriptors.
4306:             * 
4307:             * @throws ManagementRemoteException
4308:             *             if there is a jmx error accessing the instance
4309:             */
4310:            public Map<String /*attributeName*/, Object /*attributeValue*/> getRuntimeConfigurationAsMap(
4311:                    String targetName) throws ManagementRemoteException {
4312:                Map<String /*attributeName*/, Object /*attributeValue*/> properties = null;
4313:                properties = new HashMap<String /*attributeName*/, Object /*attributeValue*/>();
4314:                ObjectName systemObjectName = null;
4315:                ObjectName installationObjectName = null;
4316:                ObjectName deploymentObjectName = null;
4317:
4318:                String SYSTEM_TYPE = "System";
4319:                String INSTALLATION_TYPE = "Installation";
4320:                String DEPLOYMENT_TYPE = "Deployment";
4321:
4322:                systemObjectName = this .getConfigurationMBeanObjectName(
4323:                        targetName, SYSTEM_TYPE);
4324:                installationObjectName = this .getConfigurationMBeanObjectName(
4325:                        targetName, INSTALLATION_TYPE);
4326:                deploymentObjectName = this .getConfigurationMBeanObjectName(
4327:                        targetName, DEPLOYMENT_TYPE);
4328:
4329:                MBeanServer mbeanServer = this .environmentContext
4330:                        .getMBeanServer();
4331:
4332:                MBeanInfo mbeanSystemInfo = null;
4333:                MBeanInfo mbeanInstallationInfo = null;
4334:                MBeanInfo mbeanDeploymentInfo = null;
4335:
4336:                try {
4337:                    mbeanSystemInfo = mbeanServer
4338:                            .getMBeanInfo(systemObjectName);
4339:                } catch (InstanceNotFoundException exception) {
4340:                    throw new ManagementRemoteException(exception);
4341:                } catch (IntrospectionException exception) {
4342:                    throw new ManagementRemoteException(exception);
4343:                } catch (ReflectionException exception) {
4344:                    throw new ManagementRemoteException(exception);
4345:                }
4346:
4347:                try {
4348:                    mbeanInstallationInfo = mbeanServer
4349:                            .getMBeanInfo(installationObjectName);
4350:                } catch (InstanceNotFoundException exception) {
4351:                    throw new ManagementRemoteException(exception);
4352:                } catch (IntrospectionException exception) {
4353:                    throw new ManagementRemoteException(exception);
4354:                } catch (ReflectionException exception) {
4355:                    throw new ManagementRemoteException(exception);
4356:                }
4357:
4358:                try {
4359:                    mbeanDeploymentInfo = mbeanServer
4360:                            .getMBeanInfo(deploymentObjectName);
4361:                } catch (InstanceNotFoundException exception) {
4362:                    throw new ManagementRemoteException(exception);
4363:                } catch (IntrospectionException exception) {
4364:                    throw new ManagementRemoteException(exception);
4365:                } catch (ReflectionException exception) {
4366:                    throw new ManagementRemoteException(exception);
4367:                }
4368:
4369:                MBeanAttributeInfo[] systemAttributes = mbeanSystemInfo
4370:                        .getAttributes();
4371:                if (systemAttributes != null) {
4372:                    for (MBeanAttributeInfo attributeInfo : systemAttributes) {
4373:                        String attributeName = attributeInfo.getName();
4374:                        Object attributeValue = getAttributeValue(
4375:                                systemObjectName, attributeName);
4376:                        properties.put(attributeName, attributeValue);
4377:                    }
4378:                }
4379:
4380:                MBeanAttributeInfo[] installationAttributes = mbeanInstallationInfo
4381:                        .getAttributes();
4382:                if (installationAttributes != null) {
4383:                    for (MBeanAttributeInfo attributeInfo : installationAttributes) {
4384:                        String attributeName = attributeInfo.getName();
4385:                        Object attributeValue = getAttributeValue(
4386:                                installationObjectName, attributeName);
4387:                        properties.put(attributeName, attributeValue);
4388:                    }
4389:                }
4390:
4391:                MBeanAttributeInfo[] deploymentAttributes = mbeanDeploymentInfo
4392:                        .getAttributes();
4393:                if (deploymentAttributes != null) {
4394:                    for (MBeanAttributeInfo attributeInfo : deploymentAttributes) {
4395:                        String attributeName = attributeInfo.getName();
4396:                        Object attributeValue = getAttributeValue(
4397:                                deploymentObjectName, attributeName);
4398:                        properties.put(attributeName, attributeValue);
4399:                    }
4400:                }
4401:
4402:                return properties;
4403:            }
4404:
4405:            /**
4406:             * This method sets one or more configuration parameters on the runtime with
4407:             * a list of name/value pairs passed as a properties object. The property
4408:             * name in the properties object should be an existing configuration
4409:             * parameter name. If user try to set the parameter that is not in the
4410:             * configuration parameters list, this method will throw an exception.
4411:             * 
4412:             * The value of the property can be any object. If the value is non string
4413:             * object, its string value (Object.toString()) will be used as a value that
4414:             * will be set on the configuration.
4415:             * 
4416:             * This method first validates whether all the paramters passed in
4417:             * properties object exist in the runtime configuration or not. If any one
4418:             * the parameters passed is not existing, it will return an error without
4419:             * settings the parameters that are passed in the properties including a
4420:             * valid parameters.
4421:             * 
4422:             * If there is an error in setting a paramter, this method throws an
4423:             * exception with the list of parameters that were not set.
4424:             * 
4425:             * @param params
4426:             *            Map object that contains name/value pairs corresponding
4427:             *            to the configuration parameters to be set on the runtime.
4428:             * 
4429:             * @param targetName
4430:             *            cluster or instance name ( e.g. cluster1, instance1 ) on which
4431:             *            configuration parameters will be set. null to represent the
4432:             *            default instance which is admin server
4433:             * 
4434:             * @return true if server restart is required, false if not
4435:             * 
4436:             * @throws ManagementRemoteException
4437:             *             if there is a jmx error or a invalid parameter is passed in
4438:             *             the params properties object. In case of an error setting the
4439:             *             a particular parameter, the error message should list the
4440:             *             invalid parameters.
4441:             */
4442:            @SuppressWarnings("unchecked")
4443:            public boolean setRuntimeConfiguration(
4444:                    Map<String /*attributeName*/, Object /*attributeValue*/> properties,
4445:                    String targetName) throws ManagementRemoteException {
4446:                ObjectName systemObjectName = null;
4447:                ObjectName installationObjectName = null;
4448:                ObjectName deploymentObjectName = null;
4449:
4450:                final String SYSTEM_TYPE = "System";
4451:                final String INSTALLATION_TYPE = "Installation";
4452:                final String DEPLOYMENT_TYPE = "Deployment";
4453:
4454:                systemObjectName = this .getConfigurationMBeanObjectName(
4455:                        targetName, SYSTEM_TYPE);
4456:                installationObjectName = this .getConfigurationMBeanObjectName(
4457:                        targetName, INSTALLATION_TYPE);
4458:                deploymentObjectName = this .getConfigurationMBeanObjectName(
4459:                        targetName, DEPLOYMENT_TYPE);
4460:
4461:                MBeanServer mbeanServer = this .environmentContext
4462:                        .getMBeanServer();
4463:
4464:                MBeanInfo mbeanSystemInfo = null;
4465:                MBeanInfo mbeanInstallationInfo = null;
4466:                MBeanInfo mbeanDeploymentInfo = null;
4467:
4468:                try {
4469:                    mbeanSystemInfo = mbeanServer
4470:                            .getMBeanInfo(systemObjectName);
4471:                } catch (InstanceNotFoundException exception) {
4472:                    throw new ManagementRemoteException(exception);
4473:                } catch (IntrospectionException exception) {
4474:                    throw new ManagementRemoteException(exception);
4475:                } catch (ReflectionException exception) {
4476:                    throw new ManagementRemoteException(exception);
4477:                }
4478:
4479:                try {
4480:                    mbeanInstallationInfo = mbeanServer
4481:                            .getMBeanInfo(installationObjectName);
4482:                } catch (InstanceNotFoundException exception) {
4483:                    throw new ManagementRemoteException(exception);
4484:                } catch (IntrospectionException exception) {
4485:                    throw new ManagementRemoteException(exception);
4486:                } catch (ReflectionException exception) {
4487:                    throw new ManagementRemoteException(exception);
4488:                }
4489:
4490:                try {
4491:                    mbeanDeploymentInfo = mbeanServer
4492:                            .getMBeanInfo(deploymentObjectName);
4493:                } catch (InstanceNotFoundException exception) {
4494:                    throw new ManagementRemoteException(exception);
4495:                } catch (IntrospectionException exception) {
4496:                    throw new ManagementRemoteException(exception);
4497:                } catch (ReflectionException exception) {
4498:                    throw new ManagementRemoteException(exception);
4499:                }
4500:
4501:                Object attributeValueObject = null;
4502:                MBeanAttributeInfo[] systemAttributes = mbeanSystemInfo
4503:                        .getAttributes();
4504:                MBeanAttributeInfo[] installationAttributes = mbeanInstallationInfo
4505:                        .getAttributes();
4506:                MBeanAttributeInfo[] deploymentAttributes = mbeanDeploymentInfo
4507:                        .getAttributes();
4508:
4509:                Map<String /* Name */, Object /* Type */> attributeNameTypeMap = new HashMap<String /* Name */, Object /* Type */>();
4510:
4511:                Properties metaDataProperties = null;
4512:                // Validate to ensure there is no poison data
4513:                if (systemAttributes != null) {
4514:                    for (MBeanAttributeInfo attributeInfo : systemAttributes) {
4515:                        String attributeName = attributeInfo.getName();
4516:                        attributeValueObject = properties.get(attributeName);
4517:                        if (attributeValueObject != null) {
4518:                            String type = attributeInfo.getType();
4519:                            try {
4520:                                // construct the value object using reflection.
4521:                                attributeNameTypeMap.put(attributeName,
4522:                                        attributeValueObject);
4523:                            } catch (Exception ex) {
4524:                                String[] args = { attributeValueObject + "",
4525:                                        type, attributeName };
4526:                                Exception exception = this 
4527:                                        .createManagementException(
4528:                                                "ui.mbean.install.config.mbean.attrib.type.convertion.error",
4529:                                                args, ex);
4530:                                throw new ManagementRemoteException(exception);
4531:
4532:                            }
4533:                        }
4534:                    }
4535:                }
4536:
4537:                if (installationAttributes != null) {
4538:                    for (MBeanAttributeInfo attributeInfo : installationAttributes) {
4539:                        String attributeName = attributeInfo.getName();
4540:                        attributeValueObject = properties.get(attributeName);
4541:                        if (attributeValueObject != null) {
4542:                            String type = attributeInfo.getType();
4543:                            try {
4544:                                // construct the value object using reflection.
4545:                                attributeNameTypeMap.put(attributeName,
4546:                                        attributeValueObject);
4547:                            } catch (Exception ex) {
4548:                                String[] args = { attributeValueObject + "",
4549:                                        type, attributeName };
4550:                                Exception exception = this 
4551:                                        .createManagementException(
4552:                                                "ui.mbean.install.config.mbean.attrib.type.convertion.error",
4553:                                                args, ex);
4554:                                throw new ManagementRemoteException(exception);
4555:
4556:                            }
4557:                        }
4558:                    }
4559:                }
4560:
4561:                if (deploymentAttributes != null) {
4562:                    for (MBeanAttributeInfo attributeInfo : deploymentAttributes) {
4563:                        String attributeName = attributeInfo.getName();
4564:                        attributeValueObject = properties.get(attributeName);
4565:                        if (attributeValueObject != null) {
4566:                            String type = attributeInfo.getType();
4567:                            try {
4568:                                // construct the value object using reflection.
4569:                                attributeNameTypeMap.put(attributeName,
4570:                                        attributeValueObject);
4571:                            } catch (Exception ex) {
4572:                                String[] args = { attributeValueObject + "",
4573:                                        type, attributeName };
4574:                                Exception exception = this 
4575:                                        .createManagementException(
4576:                                                "ui.mbean.install.config.mbean.attrib.type.convertion.error",
4577:                                                args, ex);
4578:                                throw new ManagementRemoteException(exception);
4579:
4580:                            }
4581:                        }
4582:                    }
4583:                }
4584:
4585:                // Make sure the properties does not have bogus key values
4586:                // passed in.
4587:                Set keySet = properties.keySet();
4588:                Set attributeSet = attributeNameTypeMap.keySet();
4589:
4590:                if (keySet != null) {
4591:                    for (Object keyObject : keySet) {
4592:                        String key = (String) keyObject;
4593:                        if (attributeSet.contains(key) == false) {
4594:                            // throw an exception
4595:                            String[] args = { key };
4596:                            Exception exception = this 
4597:                                    .createManagementException(
4598:                                            "ui.mbean.runtime.config.mbean.attrib.key.invalid.error",
4599:                                            args, null);
4600:                            throw new ManagementRemoteException(exception);
4601:                        }
4602:                    }
4603:                }
4604:
4605:                // Retrieve runtime configuration metadata
4606:                final String IS_STATIC_KEY = "isStatic";
4607:                boolean isRestartRequired = false;
4608:                Map<String /* propertyKeyName */, Properties> metadata = null;
4609:                metadata = getRuntimeConfigurationMetadataInternal(targetName);
4610:
4611:                // Set Values
4612:                if (systemAttributes != null) {
4613:                    for (MBeanAttributeInfo attributeInfo : systemAttributes) {
4614:                        String attributeName = attributeInfo.getName();
4615:                        attributeValueObject = properties.get(attributeName);
4616:                        if (attributeValueObject != null) {
4617:                            this .setAttributeValue(systemObjectName,
4618:                                    attributeName, attributeValueObject);
4619:
4620:                            metaDataProperties = metadata.get(attributeName);
4621:                            if (true == Boolean.valueOf(metaDataProperties
4622:                                    .getProperty(IS_STATIC_KEY))) {
4623:                                isRestartRequired = true;
4624:                            }
4625:
4626:                        }
4627:                    }
4628:                }
4629:
4630:                if (installationAttributes != null) {
4631:                    for (MBeanAttributeInfo attributeInfo : installationAttributes) {
4632:                        String attributeName = attributeInfo.getName();
4633:                        attributeValueObject = properties.get(attributeName);
4634:                        if (attributeValueObject != null) {
4635:                            this .setAttributeValue(installationObjectName,
4636:                                    attributeName, attributeValueObject);
4637:
4638:                            metaDataProperties = metadata.get(attributeName);
4639:                            if (true == Boolean.valueOf(metaDataProperties
4640:                                    .getProperty(IS_STATIC_KEY))) {
4641:                                isRestartRequired = true;
4642:                            }
4643:
4644:                        }
4645:                    }
4646:                }
4647:
4648:                if (deploymentAttributes != null) {
4649:                    for (MBeanAttributeInfo attributeInfo : deploymentAttributes) {
4650:                        String attributeName = attributeInfo.getName();
4651:                        attributeValueObject = properties.get(attributeName);
4652:                        if (attributeValueObject != null) {
4653:                            this .setAttributeValue(deploymentObjectName,
4654:                                    attributeName, attributeValueObject);
4655:
4656:                            metaDataProperties = metadata.get(attributeName);
4657:                            if (true == Boolean.valueOf(metaDataProperties
4658:                                    .getProperty(IS_STATIC_KEY))) {
4659:                                isRestartRequired = true;
4660:                            }
4661:
4662:                        }
4663:                    }
4664:                }
4665:
4666:                return isRestartRequired;
4667:            }
4668:
4669:            /**
4670:             * Retrieve component configuration
4671:             * 
4672:             * @param componentName
4673:             * @param targetName
4674:             * @return the targetName as key and the name/value pairs as Map
4675:             * @throws ManagementRemoteException
4676:             *             on error
4677:             */
4678:            public Map<String /*attributeName*/, Object /*attributeValue*/> getComponentConfigurationAsMap(
4679:                    String componentName, String targetName)
4680:                    throws ManagementRemoteException {
4681:                Map<String /*attributeName*/, Object /*attributeValue*/> result = null;
4682:                TargetType targetType = checkTargetType(targetName);
4683:                Exception exception = null;
4684:                String[] args = { targetName };
4685:
4686:                switch (targetType) {
4687:                case STANDALONE_SERVER:
4688:                case CLUSTER:
4689:                case CLUSTERED_SERVER:
4690:                    // use facade mbean code below
4691:                    break;
4692:
4693:                case DOMAIN:
4694:                case INVALID_TARGET:
4695:                default:
4696:                    logDebug("getComponentConfiguration(): target "
4697:                            + targetName + " type not supported.");
4698:                    exception = this .createManagementException(
4699:                            "ui.mbean.system.config.target.type.not.supported",
4700:                            args, null);
4701:                    throw new ManagementRemoteException(exception);
4702:                }
4703:
4704:                ObjectName configFacadeMBean = this 
4705:                        .getComponentConfigurationFacadeMBeanName(
4706:                                componentName, targetName);
4707:
4708:                logDebug("getComponentConfiguration(" + componentName + ","
4709:                        + targetName + "): configMBean = " + configFacadeMBean);
4710:                if ((configFacadeMBean != null)
4711:                        && (true == this .isValidTarget(configFacadeMBean))) {
4712:                    try {
4713:                        result = this 
4714:                                .getConfigurationAttributeValuesAsMap(configFacadeMBean);
4715:                        logDebug("getComponentConfiguration: result properties = "
4716:                                + result);
4717:                    } catch (ManagementRemoteException jbiRE) {
4718:                        // exception msg is a management message already; just keep it
4719:                        // as it is
4720:                        logDebug("caught ManagementRemoteException:");
4721:                        logDebug(jbiRE);
4722:                        throw jbiRE;
4723:                    } catch (Exception ex) {
4724:                        logDebug("caught non-ManagementRemoteException:");
4725:                        logDebug(ex);
4726:                        exception = this 
4727:                                .createManagementException(
4728:                                        "ui.mbean.install.config.mbean.error.get.attrs.error",
4729:                                        null, ex);
4730:                        ManagementRemoteException remoteException = new ManagementRemoteException(
4731:                                exception);
4732:                        throw remoteException;
4733:                    }
4734:
4735:                }
4736:                return result;
4737:            }
4738:
4739:            /**
4740:             * Will return jbi mgmt message with success, failure, or partial success
4741:             * per instance. The entry per instance will have value as part of the
4742:             * management message (XML) String.
4743:             * 
4744:             * @param componentName
4745:             * @param configurationValues
4746:             * @param targetName
4747:             * @return value as part of the management message (XML) String.
4748:             * @throws ManagementRemoteException
4749:             *             on error
4750:             */
4751:            public String setComponentConfiguration(
4752:                    String componentName,
4753:                    Map<String /*attributeName*/, Object /*attributeValue*/> configurationValues,
4754:                    String targetName) throws ManagementRemoteException {
4755:                String result = null;
4756:                AttributeList list = null;
4757:                TargetType targetType = checkTargetType(targetName);
4758:                Exception exception = null;
4759:                String[] args = { targetName };
4760:
4761:                switch (targetType) {
4762:                case STANDALONE_SERVER:
4763:                case CLUSTER:
4764:                case CLUSTERED_SERVER:
4765:                    // use facade mbean code below
4766:                    break;
4767:                case DOMAIN:
4768:                case INVALID_TARGET:
4769:                default:
4770:                    logDebug("setComponentConfiguration(): target "
4771:                            + targetName + " type not supported.");
4772:                    exception = this .createManagementException(
4773:                            "ui.mbean.system.config.target.type.not.supported",
4774:                            args, null);
4775:                    throw new ManagementRemoteException(exception);
4776:                }
4777:
4778:                ObjectName configFacadeMBean = this 
4779:                        .getComponentConfigurationFacadeMBeanName(
4780:                                componentName, targetName);
4781:                logDebug("setComponentConfiguration(" + componentName + ","
4782:                        + targetName + "): configMBean = " + configFacadeMBean);
4783:
4784:                if ((configFacadeMBean != null)
4785:                        && (true == this .isValidTarget(configFacadeMBean))) {
4786:                    try {
4787:                        list = this .constructMBeanAttributes(configFacadeMBean,
4788:                                configurationValues);
4789:                        result = this .setMBeanConfigAttributes(
4790:                                configFacadeMBean, list);
4791:                        logDebug("setComponentConfiguration(): result = "
4792:                                + result);
4793:                    } catch (ManagementRemoteException jbiRE) {
4794:                        // exception msg is a management message already; just keep it
4795:                        // as it is
4796:                        logDebug("caught ManagementRemoteException:");
4797:                        logDebug(jbiRE);
4798:                        throw jbiRE;
4799:                    } catch (Exception ex) {
4800:                        logDebug("caught non-ManagementRemoteException:");
4801:                        logDebug(ex);
4802:                        exception = this 
4803:                                .createManagementException(
4804:                                        "ui.mbean.install.config.mbean.error.set.attrs.error",
4805:                                        null, ex);
4806:                        ManagementRemoteException remoteException = new ManagementRemoteException(
4807:                                exception);
4808:                        throw remoteException;
4809:                    }
4810:
4811:                }
4812:                return result;
4813:            }
4814:
4815:            /////////////////
4816:
4817:            /**
4818:             * Invokes an operation on an Extension MBean.
4819:             * @param componentName
4820:             * @param extensionName the name of the extension (e.g., Configuration, Logger, etc.)
4821:             * @param operationName The name of the operation to be invoked.
4822:             * @param parameters An array containing the parameters to be set when the operation is invoked
4823:             * @param signature An array containing the signature of the operation. The class objects will be loaded using the same class loader as the one used for loading the MBean on which the operation was invoked.
4824:             * @param targetName name of the target (e.g., server, Cluster1, StandloneServer2, etc.)
4825:             * @param targetInstanceName name of the target instance (e.g., Cluster1-Instance1, Cluster2-Instance10, etc.)
4826:             * @return The object returned by the operation, which represents the result of invoking the operation on the Extension MBean specified.
4827:             * @throws ManagementRemoteException
4828:             */
4829:            public Object invokeExtensionMBeanOperation(String componentName,
4830:                    String extensionName, String operationName,
4831:                    Object[] parameters, String[] signature, String targetName,
4832:                    String targetInstanceName) throws ManagementRemoteException {
4833:                Object result = null;
4834:                ObjectName[] objectNames = null;
4835:                boolean isClusteredServer = false;
4836:                objectNames = this .getComponentExtensionMBeanObjectNames(
4837:                        componentName, extensionName, targetName,
4838:                        targetInstanceName);
4839:                if (targetName != null) {
4840:                    isClusteredServer = this .getPlatformContext().isCluster(
4841:                            targetName);
4842:                }
4843:                if ((isClusteredServer == true) && (targetInstanceName == null)) {
4844:                    // perform operation on all target instances
4845:                    if (objectNames != null) {
4846:                        for (ObjectName objectName : objectNames) {
4847:                            result = this .invokeMBeanOperation(objectName,
4848:                                    operationName, parameters, signature);
4849:                        }
4850:                    }
4851:                } else {
4852:                    // perform operation on specified target or targetInstance
4853:                    String target = targetName;
4854:                    if (targetInstanceName != null) {
4855:                        target = targetInstanceName;
4856:                    }
4857:                    if (objectNames != null) {
4858:                        for (ObjectName objectName : objectNames) {
4859:                            String currentTarget = objectName
4860:                                    .getKeyProperty("JbiName");
4861:                            if ((currentTarget != null)
4862:                                    && (currentTarget.equals(target) == true)) {
4863:                                result = this .invokeMBeanOperation(objectName,
4864:                                        operationName, parameters, signature);
4865:                                break;
4866:                            }
4867:                        }
4868:                    }
4869:                }
4870:                return result;
4871:            }
4872:
4873:            /**
4874:             * @return the runtime logger configuration facade MBean Name for the 
4875:             *         specific target.
4876:             */
4877:            protected ObjectName getRuntimeLoggerConfigFacadeMBeanName(
4878:                    String target) {
4879:                return environmentContext.getMBeanNames()
4880:                        .getSystemServiceMBeanName(
4881:                                MBeanNames.ServiceName.ConfigurationService,
4882:                                MBeanNames.ServiceType.Logger, target);
4883:            }
4884:
4885:            /**
4886:             * @return the type of the actual application variable
4887:             *
4888:             */
4889:            protected String getExistingAppVarType(String compName,
4890:                    String targetName, String appVarName) {
4891:                String type = null;
4892:                try {
4893:                    Properties appVars = getApplicationVariables(compName,
4894:                            targetName);
4895:
4896:                    if (appVars.containsKey(appVarName)) {
4897:                        String typeAndValueStr = appVars
4898:                                .getProperty(appVarName);
4899:                        type = this .componentConfigurationHelper.getAppVarType(
4900:                                typeAndValueStr, null);
4901:                    }
4902:                } catch (Exception ex) {
4903:                }
4904:                return type;
4905:            }
4906:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.