Source Code Cross Referenced for AbstractServiceMBeansImpl.java in  » ESB » open-esb » com » sun » esb » management » base » services » 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.base.services 
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:         * @(#)AbstractServiceMBeansImpl.java
0025:         * Copyright 2004-2007 Sun Microsystems, Inc. All Rights Reserved.
0026:         *
0027:         * END_HEADER - DO NOT EDIT
0028:         */
0029:
0030:        package com.sun.esb.management.base.services;
0031:
0032:        import java.io.IOException;
0033:        import java.io.Serializable;
0034:        import java.util.ArrayList;
0035:        import java.util.HashMap;
0036:        import java.util.Iterator;
0037:        import java.util.List;
0038:        import java.util.Map;
0039:        import java.util.Properties;
0040:        import java.util.Set;
0041:        import java.util.logging.Level;
0042:
0043:        import javax.management.Attribute;
0044:        import javax.management.AttributeList;
0045:        import javax.management.AttributeNotFoundException;
0046:        import javax.management.InstanceNotFoundException;
0047:        import javax.management.IntrospectionException;
0048:        import javax.management.InvalidAttributeValueException;
0049:        import javax.management.MBeanAttributeInfo;
0050:        import javax.management.MBeanException;
0051:        import javax.management.MBeanInfo;
0052:        import javax.management.MBeanServer;
0053:        import javax.management.MBeanServerConnection;
0054:        import javax.management.MalformedObjectNameException;
0055:        import javax.management.ObjectName;
0056:        import javax.management.ReflectionException;
0057:        import javax.management.RuntimeMBeanException;
0058:        import javax.management.RuntimeOperationsException;
0059:
0060:        import com.sun.esb.management.common.ManagementRemoteException;
0061:        import com.sun.esb.management.common.TargetType;
0062:        import com.sun.jbi.EnvironmentContext;
0063:        import com.sun.jbi.management.MBeanNames;
0064:        import com.sun.jbi.management.MBeanNames.ServiceName;
0065:        import com.sun.jbi.management.MBeanNames.ServiceType;
0066:        import com.sun.jbi.platform.PlatformContext;
0067:        import com.sun.jbi.ui.common.I18NBundle;
0068:        import com.sun.jbi.ui.common.JBIAdminCommands;
0069:        import com.sun.jbi.ui.common.JBIManagementMessage;
0070:        import com.sun.jbi.ui.common.JBIRemoteException;
0071:        import com.sun.jbi.ui.common.JBIResultXmlBuilder;
0072:        import com.sun.jbi.ui.common.ToolsLogManager;
0073:        import com.sun.jbi.ui.common.Util;
0074:        import com.sun.jbi.ui.runtime.GenericsSupport;
0075:        import com.sun.jbi.util.ComponentConfigurationHelper;
0076:
0077:        /**
0078:         * @author graj
0079:         * 
0080:         */
0081:        public abstract class AbstractServiceMBeansImpl implements  Serializable {
0082:
0083:            static final long serialVersionUID = -1L;
0084:
0085:            /** i18n */
0086:            private static I18NBundle I18NBUNDLE = null;
0087:
0088:            /** Jbi Environment context. */
0089:            protected EnvironmentContext environmentContext;
0090:
0091:            /** Component Configuration helper */
0092:            protected ComponentConfigurationHelper componentConfigurationHelper;
0093:
0094:            protected static final String DOMAIN_TARGET_KEY = "domain";
0095:
0096:            protected static final String SERVER_TARGET_KEY = "server";
0097:
0098:            protected static final String CUSTOM_CONFIGURATION_NAME_KEY = "Configuration";
0099:
0100:            protected static final String CUSTOM_STATISTICS_NAME_KEY = "Statistics";
0101:
0102:            protected static final String CUSTOM_ADMINISTRATION_NAME_KEY = "Administration";
0103:
0104:            protected static final String CUSTOM_MANAGEMENT_ACTIONS_NAME_KEY = "ManagementActions";
0105:
0106:            protected static final String CUSTOM_LOGGER_NAME_KEY = "Logger";
0107:
0108:            protected static final String STARTED_STATE = "Started";
0109:
0110:            protected static final String RUNNING_STATE = "Running";
0111:
0112:            protected static final String EQUAL = "=";
0113:
0114:            protected static final String COLON = ":";
0115:
0116:            protected static final String COMMA = ",";
0117:
0118:            protected static final char PASSWORD_MASK_CHARACTER = '*';
0119:
0120:            protected static final String COMPONENT_CONFIG_INSTANCE_ERROR_KEY = "com.sun.jbi.cluster.instance.error";
0121:
0122:            /** JMX Domain name for the Enterprise Business Integration JMX MBeans */
0123:            protected static final String JMX_EBI_DOMAIN = "com.sun.ebi";
0124:
0125:            /** Enterprise Business Integration JMX domain */
0126:            protected static String EBIJMXDOMAIN = null;
0127:
0128:            protected static final String SERVICE_TYPE_KEY = "ServiceType";
0129:
0130:            protected static final String IDENTIFICATION_NAME_KEY = "IdentificationName";
0131:
0132:            /**
0133:             * 
0134:             */
0135:            public AbstractServiceMBeansImpl(EnvironmentContext anEnvContext) {
0136:                this .environmentContext = anEnvContext;
0137:                this .componentConfigurationHelper = new ComponentConfigurationHelper();
0138:            }
0139:
0140:            /**
0141:             * logs the message
0142:             * 
0143:             * @param aMsg
0144:             *            message string
0145:             */
0146:            protected static void log(String aMsg) {
0147:                ToolsLogManager.getRuntimeLogger().info(aMsg);
0148:            }
0149:
0150:            /**
0151:             * logs the message
0152:             * 
0153:             * @param aMsg
0154:             *            message string
0155:             */
0156:            protected static void logDebug(String aMsg) {
0157:                ToolsLogManager.getRuntimeLogger().fine(aMsg);
0158:            }
0159:
0160:            /**
0161:             * logs the message
0162:             * 
0163:             * @param ex
0164:             *            exception
0165:             */
0166:            protected static void logDebug(Exception ex) {
0167:                ToolsLogManager.getRuntimeLogger().log(Level.FINER,
0168:                        ex.getMessage(), ex);
0169:            }
0170:
0171:            /**
0172:             * logs errors
0173:             * 
0174:             * @param ex
0175:             *            exception
0176:             */
0177:            protected static void logError(Exception ex) {
0178:                ToolsLogManager.getRuntimeLogger().log(Level.SEVERE,
0179:                        ex.getMessage(), ex);
0180:            }
0181:
0182:            /**
0183:             * logs warnings
0184:             * 
0185:             * @param ex
0186:             *            exception
0187:             */
0188:            public static void logWarning(Exception ex) {
0189:                ToolsLogManager.getRuntimeLogger().log(Level.WARNING,
0190:                        ex.getMessage(), ex);
0191:            }
0192:
0193:            /**
0194:             * @return the platform context
0195:             */
0196:            protected PlatformContext getPlatformContext() {
0197:                PlatformContext platformContext = null;
0198:                EnvironmentContext context = getEnvironmentContext();
0199:                if (context != null) {
0200:                    platformContext = context.getPlatformContext();
0201:                }
0202:                return platformContext;
0203:            }
0204:
0205:            /**
0206:             * @return the EnvironmentContext
0207:             */
0208:            protected static EnvironmentContext getEnvironmentContext() {
0209:                return com.sun.jbi.util.EnvironmentAccess.getContext();
0210:            }
0211:
0212:            /**
0213:             * gives the I18N bundle
0214:             * 
0215:             * @return I18NBundle object
0216:             */
0217:            protected static I18NBundle getI18NBundle() {
0218:                // lazy initialize the JBI Client
0219:                if (I18NBUNDLE == null) {
0220:                    I18NBUNDLE = new I18NBundle("com.sun.jbi.ui.runtime.mbeans");
0221:                }
0222:                return I18NBUNDLE;
0223:            }
0224:
0225:            /**
0226:             * gives the I18N bundle
0227:             * 
0228:             * @param packageName
0229:             * @return I18NBundle object
0230:             */
0231:            protected static I18NBundle getI18NBundle(String packageName) {
0232:                // lazy initialize the JBI Client
0233:                if (I18NBUNDLE == null) {
0234:                    I18NBUNDLE = new I18NBundle(packageName);
0235:                }
0236:                return I18NBUNDLE;
0237:            }
0238:
0239:            /**
0240:             * Invokes the mbean and retrieves the attribute value
0241:             * 
0242:             * @param targetName
0243:             * @param objectName
0244:             *            object name
0245:             * @param attributeName
0246:             *            attribute name
0247:             * @return the value of the attribute
0248:             * @throws ManagementRemoteException
0249:             *             on error
0250:             */
0251:            protected Object getAttributeValue(String targetName,
0252:                    ObjectName objectName, String attributeName)
0253:                    throws ManagementRemoteException {
0254:
0255:                if ((DOMAIN_TARGET_KEY.equals(targetName) == true)
0256:                        || (SERVER_TARGET_KEY.equals(targetName) == true)) {
0257:                    return this .getAttributeValue(objectName, attributeName);
0258:                }
0259:                MBeanServerConnection connection = this 
0260:                        .getMBeanServerConnection(targetName);
0261:                return this .getAttributeValue(connection, objectName,
0262:                        attributeName);
0263:            }
0264:
0265:            /**
0266:             * Invokes the mbean and retrieves the attribute value
0267:             * 
0268:             * @param mbeanServer
0269:             *            connection to MBean Server
0270:             * @param objectName
0271:             *            object name
0272:             * @param attributeName
0273:             *            attribute name
0274:             * @return the value of the attribute
0275:             * @throws ManagementRemoteException
0276:             *             on error
0277:             */
0278:            protected Object getAttributeValue(MBeanServer mbeanServer,
0279:                    ObjectName objectName, String attributeName)
0280:                    throws ManagementRemoteException {
0281:
0282:                Object result = null;
0283:                try {
0284:                    result = mbeanServer
0285:                            .getAttribute(objectName, attributeName);
0286:                } catch (AttributeNotFoundException e) {
0287:                    throw new ManagementRemoteException(e);
0288:                } catch (InstanceNotFoundException e) {
0289:                    throw new ManagementRemoteException(e);
0290:                } catch (ReflectionException e) {
0291:                    throw new ManagementRemoteException(e);
0292:                } catch (MBeanException mbeanEx) {
0293:                    throw ManagementRemoteException
0294:                            .filterJmxExceptions(mbeanEx);
0295:                } catch (RuntimeMBeanException rtEx) {
0296:                    throw ManagementRemoteException.filterJmxExceptions(rtEx);
0297:                } catch (RuntimeOperationsException rtOpEx) {
0298:                    throw ManagementRemoteException.filterJmxExceptions(rtOpEx);
0299:                } catch (Exception ex) {
0300:                    throw ManagementRemoteException.filterJmxExceptions(ex);
0301:                }
0302:                return result;
0303:            }
0304:
0305:            /**
0306:             * Invokes the mbean and retrieves the attribute value
0307:             * 
0308:             * @param mbeanServer
0309:             *            connection to MBean Server
0310:             * @param objectName
0311:             *            object name
0312:             * @param attributeName
0313:             *            attribute name
0314:             * @return the value of the attribute
0315:             * @throws ManagementRemoteException
0316:             *             on error
0317:             */
0318:            protected Object getAttributeValue(
0319:                    MBeanServerConnection mbeanServer, ObjectName objectName,
0320:                    String attributeName) throws ManagementRemoteException {
0321:
0322:                Object result = null;
0323:                try {
0324:                    result = mbeanServer
0325:                            .getAttribute(objectName, attributeName);
0326:                } catch (AttributeNotFoundException e) {
0327:                    throw new ManagementRemoteException(e);
0328:                } catch (InstanceNotFoundException e) {
0329:                    throw new ManagementRemoteException(e);
0330:                } catch (MBeanException e) {
0331:                    throw new ManagementRemoteException(e);
0332:                } catch (ReflectionException e) {
0333:                    throw new ManagementRemoteException(e);
0334:                } catch (IOException e) {
0335:                    throw new ManagementRemoteException(e);
0336:                }
0337:                return result;
0338:            }
0339:
0340:            /**
0341:             * Invokes the mbean and retrieves the attribute value
0342:             * 
0343:             * @param objectName
0344:             *            object name
0345:             * @param attributeName
0346:             *            attribute name
0347:             * @return the value of the attribute
0348:             * @throws ManagementRemoteException
0349:             *             on error
0350:             */
0351:            protected Object getAttributeValue(ObjectName objectName,
0352:                    String attributeName) throws ManagementRemoteException {
0353:
0354:                MBeanServer mbeanServer = this .environmentContext
0355:                        .getMBeanServer();
0356:                Object result = null;
0357:                try {
0358:                    result = mbeanServer
0359:                            .getAttribute(objectName, attributeName);
0360:                } catch (AttributeNotFoundException e) {
0361:                    throw new ManagementRemoteException(e);
0362:                } catch (InstanceNotFoundException e) {
0363:                    throw new ManagementRemoteException(e);
0364:                } catch (ReflectionException e) {
0365:                    throw new ManagementRemoteException(e);
0366:                } catch (MBeanException mbeanEx) {
0367:                    throw ManagementRemoteException
0368:                            .filterJmxExceptions(mbeanEx);
0369:                } catch (RuntimeMBeanException rtEx) {
0370:                    throw ManagementRemoteException.filterJmxExceptions(rtEx);
0371:                } catch (RuntimeOperationsException rtOpEx) {
0372:                    throw ManagementRemoteException.filterJmxExceptions(rtOpEx);
0373:                } catch (Exception ex) {
0374:                    throw ManagementRemoteException.filterJmxExceptions(ex);
0375:                }
0376:                return result;
0377:            }
0378:
0379:            /**
0380:             * Invokes the mbean and retrieves the attribute value
0381:             * 
0382:             * @param targetName
0383:             * @param objectName
0384:             *            object name
0385:             * @param attributeName
0386:             *            attribute name
0387:             * @return the value of the attribute
0388:             * @throws ManagementRemoteException
0389:             *             on error
0390:             */
0391:            protected void setAttributeValue(String targetName,
0392:                    ObjectName objectName, String attributeName,
0393:                    Object attributeValue) throws ManagementRemoteException {
0394:                if ((DOMAIN_TARGET_KEY.equals(targetName) == true)
0395:                        || (SERVER_TARGET_KEY.equals(targetName) == true)) {
0396:                    this .setAttributeValue(objectName, attributeName,
0397:                            attributeValue);
0398:                } else {
0399:                    MBeanServerConnection connection = this 
0400:                            .getMBeanServerConnection(targetName);
0401:                    this .setAttributeValue(connection, objectName,
0402:                            attributeName, attributeValue);
0403:                }
0404:            }
0405:
0406:            /**
0407:             * Invokes the mbean and retrieves the attribute value
0408:             * 
0409:             * @param objectName
0410:             *            object name
0411:             * @param attributeName
0412:             *            attribute name
0413:             * @return the value of the attribute
0414:             * @throws ManagementRemoteException
0415:             *             on error
0416:             */
0417:            protected void setAttributeValue(ObjectName objectName,
0418:                    String attributeName, Object attributeValue)
0419:                    throws ManagementRemoteException {
0420:
0421:                MBeanServer mbeanServer = this .environmentContext
0422:                        .getMBeanServer();
0423:                Attribute attribute = null;
0424:                attribute = new Attribute(attributeName, attributeValue);
0425:
0426:                try {
0427:                    mbeanServer.setAttribute(objectName, attribute);
0428:                } catch (InstanceNotFoundException e) {
0429:                    throw new ManagementRemoteException(e);
0430:                } catch (AttributeNotFoundException e) {
0431:                    throw new ManagementRemoteException(e);
0432:                } catch (InvalidAttributeValueException e) {
0433:                    throw new ManagementRemoteException(e);
0434:                } catch (ReflectionException e) {
0435:                    throw new ManagementRemoteException(e);
0436:                } catch (MBeanException mbeanEx) {
0437:                    throw ManagementRemoteException
0438:                            .filterJmxExceptions(mbeanEx);
0439:                } catch (RuntimeMBeanException rtEx) {
0440:                    throw ManagementRemoteException.filterJmxExceptions(rtEx);
0441:                } catch (RuntimeOperationsException rtOpEx) {
0442:                    throw ManagementRemoteException.filterJmxExceptions(rtOpEx);
0443:                } catch (Exception ex) {
0444:                    throw ManagementRemoteException.filterJmxExceptions(ex);
0445:                }
0446:            }
0447:
0448:            /**
0449:             * Invokes the mbean and retrieves the attribute value
0450:             * 
0451:             * @param connection
0452:             * @param objectName
0453:             *            object name
0454:             * @param attributeName
0455:             *            attribute name
0456:             * @return the value of the attribute
0457:             * @throws ManagementRemoteException
0458:             *             on error
0459:             */
0460:            protected void setAttributeValue(MBeanServerConnection connection,
0461:                    ObjectName objectName, String attributeName,
0462:                    Object attributeValue) throws ManagementRemoteException {
0463:
0464:                Attribute attribute = null;
0465:                attribute = new Attribute(attributeName, attributeValue);
0466:
0467:                try {
0468:                    connection.setAttribute(objectName, attribute);
0469:                } catch (InstanceNotFoundException e) {
0470:                    throw new ManagementRemoteException(e);
0471:                } catch (AttributeNotFoundException e) {
0472:                    throw new ManagementRemoteException(e);
0473:                } catch (InvalidAttributeValueException e) {
0474:                    throw new ManagementRemoteException(e);
0475:                } catch (MBeanException e) {
0476:                    throw new ManagementRemoteException(e);
0477:                } catch (ReflectionException e) {
0478:                    throw new ManagementRemoteException(e);
0479:                } catch (IOException e) {
0480:                    throw new ManagementRemoteException(e);
0481:                }
0482:            }
0483:
0484:            /**
0485:             * invokes the operation on mbean
0486:             * 
0487:             * @param objectName
0488:             *            object name
0489:             * @param operationName
0490:             *            operation name
0491:             * @param params
0492:             *            parameters
0493:             * @param signature
0494:             *            signature of the parameters
0495:             * @return result object
0496:             * @throws ManagementRemoteException
0497:             *             on user error
0498:             */
0499:            protected Object invokeMBeanOperation(ObjectName objectName,
0500:                    String operationName, Object[] params, String[] signature)
0501:                    throws ManagementRemoteException {
0502:                // TODO: Add error code and message to each exception
0503:                MBeanServer mbeanServer = this .environmentContext
0504:                        .getMBeanServer();
0505:                Object result = null;
0506:
0507:                try {
0508:
0509:                    result = mbeanServer.invoke(objectName, operationName,
0510:                            params, signature);
0511:
0512:                } catch (InstanceNotFoundException notFoundEx) {
0513:                    throw new ManagementRemoteException(notFoundEx);
0514:                } catch (ReflectionException rEx) {
0515:                    throw new ManagementRemoteException(rEx);
0516:                } catch (MBeanException mbeanEx) {
0517:                    throw ManagementRemoteException
0518:                            .filterJmxExceptions(mbeanEx);
0519:                } catch (RuntimeMBeanException rtEx) {
0520:                    throw ManagementRemoteException.filterJmxExceptions(rtEx);
0521:                } catch (RuntimeOperationsException rtOpEx) {
0522:                    throw ManagementRemoteException.filterJmxExceptions(rtOpEx);
0523:                } catch (Exception ex) {
0524:                    throw ManagementRemoteException.filterJmxExceptions(ex);
0525:                }
0526:
0527:                return result;
0528:
0529:            }
0530:
0531:            /**
0532:             * invokes the operation on mbean
0533:             * 
0534:             * @param connection
0535:             * @param objectName
0536:             *            object name
0537:             * @param operationName
0538:             *            operation name
0539:             * @param params
0540:             *            parameters
0541:             * @param signature
0542:             *            signature of the parameters
0543:             * @return result object
0544:             * @throws ManagementRemoteException
0545:             *             on user error
0546:             */
0547:            protected Object invokeMBeanOperation(
0548:                    MBeanServerConnection connection, ObjectName objectName,
0549:                    String operationName, Object[] params, String[] signature)
0550:                    throws ManagementRemoteException {
0551:                // TODO: Add error code and message to each exception
0552:                Object result = null;
0553:
0554:                try {
0555:
0556:                    result = connection.invoke(objectName, operationName,
0557:                            params, signature);
0558:
0559:                } catch (InstanceNotFoundException notFoundEx) {
0560:                    throw new ManagementRemoteException(notFoundEx);
0561:                } catch (ReflectionException rEx) {
0562:                    throw new ManagementRemoteException(rEx);
0563:                } catch (MBeanException mbeanEx) {
0564:                    throw ManagementRemoteException
0565:                            .filterJmxExceptions(mbeanEx);
0566:                } catch (RuntimeMBeanException rtEx) {
0567:                    throw ManagementRemoteException.filterJmxExceptions(rtEx);
0568:                } catch (RuntimeOperationsException rtOpEx) {
0569:                    throw ManagementRemoteException.filterJmxExceptions(rtOpEx);
0570:                } catch (IOException rtOpEx) {
0571:                    throw ManagementRemoteException.filterJmxExceptions(rtOpEx);
0572:                } catch (Exception ex) {
0573:                    throw ManagementRemoteException.filterJmxExceptions(ex);
0574:                }
0575:
0576:                return result;
0577:
0578:            }
0579:
0580:            /**
0581:             * invokes the operation on mbean on appropriate target
0582:             * 
0583:             * @param targetName
0584:             * @param objectName
0585:             *            object name
0586:             * @param operationName
0587:             *            operation name
0588:             * @param params
0589:             *            parameters
0590:             * @param signature
0591:             *            signature of the parameters
0592:             * @return result object
0593:             * @throws ManagementRemoteException
0594:             *             on user error
0595:             */
0596:            protected Object invokeMBeanOperation(String targetName,
0597:                    ObjectName objectName, String operationName,
0598:                    Object[] params, String[] signature)
0599:                    throws ManagementRemoteException {
0600:                if ((DOMAIN_TARGET_KEY.equals(targetName) == true)
0601:                        || (SERVER_TARGET_KEY.equals(targetName) == true)) {
0602:                    return this .invokeMBeanOperation(objectName, operationName,
0603:                            params, signature);
0604:                }
0605:                MBeanServerConnection connection = this 
0606:                        .getMBeanServerConnection(targetName);
0607:                return this .invokeMBeanOperation(connection, objectName,
0608:                        operationName, params, signature);
0609:            }
0610:
0611:            /**
0612:             * invokes the operation on mbean
0613:             * 
0614:             * @return result object
0615:             * @param objectName
0616:             *            object name
0617:             * @param operationName
0618:             *            operation name
0619:             * @param param
0620:             *            operation param of type String
0621:             * @throws ManagementRemoteException
0622:             *             on user error
0623:             */
0624:            protected Object invokeMBeanOperation(ObjectName objectName,
0625:                    String operationName, String param)
0626:                    throws ManagementRemoteException {
0627:                Object[] params = new Object[1];
0628:                params[0] = param;
0629:
0630:                String[] signature = new String[1];
0631:                signature[0] = "java.lang.String";
0632:
0633:                return invokeMBeanOperation(objectName, operationName, params,
0634:                        signature);
0635:
0636:            }
0637:
0638:            /**
0639:             * invokes the operation on mbean
0640:             * 
0641:             * @return result object
0642:             * @param objectName
0643:             *            object name
0644:             * @param operationName
0645:             *            operation name
0646:             * @throws ManagementRemoteException
0647:             *             on user error
0648:             */
0649:            protected Object invokeMBeanOperation(ObjectName objectName,
0650:                    String operationName) throws ManagementRemoteException {
0651:                Object[] params = new Object[0];
0652:
0653:                String[] signature = new String[0];
0654:                return invokeMBeanOperation(objectName, operationName, params,
0655:                        signature);
0656:
0657:            }
0658:
0659:            /**
0660:             * invokes the operation on mbean
0661:             * 
0662:             * @return result object
0663:             * @param attributeName
0664:             *            attribute name
0665:             * @param objectName
0666:             *            object name
0667:             * @throws ManagementRemoteException
0668:             *             on user error
0669:             */
0670:            protected Object getMBeanAttribute(ObjectName objectName,
0671:                    String attributeName) throws ManagementRemoteException {
0672:                // TODO: Add error code and message to each exception
0673:                MBeanServer mbeanServer = this .environmentContext
0674:                        .getMBeanServer();
0675:                Object result = null;
0676:
0677:                try {
0678:
0679:                    result = mbeanServer
0680:                            .getAttribute(objectName, attributeName);
0681:
0682:                } catch (InstanceNotFoundException notFoundEx) {
0683:                    throw new ManagementRemoteException(notFoundEx);
0684:                } catch (ReflectionException rEx) {
0685:                    throw new ManagementRemoteException(rEx);
0686:                } catch (MBeanException mbeanEx) {
0687:                    throw ManagementRemoteException
0688:                            .filterJmxExceptions(mbeanEx);
0689:                } catch (RuntimeMBeanException rtEx) {
0690:                    throw ManagementRemoteException.filterJmxExceptions(rtEx);
0691:                } catch (RuntimeOperationsException rtOpEx) {
0692:                    throw ManagementRemoteException.filterJmxExceptions(rtOpEx);
0693:                } catch (Exception ex) {
0694:                    throw ManagementRemoteException.filterJmxExceptions(ex);
0695:                }
0696:
0697:                return result;
0698:
0699:            }
0700:
0701:            /**
0702:             * Test whether an mbean is registered.
0703:             * 
0704:             * @param objectName
0705:             * @return true when the mbean is registered, false otherwise
0706:             * @throws ManagementRemoteException
0707:             */
0708:            protected boolean isMBeanRegistered(ObjectName objectName)
0709:                    throws ManagementRemoteException {
0710:                boolean result = false;
0711:                MBeanServer mbeanServer = this .environmentContext
0712:                        .getMBeanServer();
0713:                try {
0714:                    result = mbeanServer.isRegistered(objectName);
0715:                } catch (RuntimeException exception) {
0716:                    throw ManagementRemoteException
0717:                            .filterJmxExceptions(exception);
0718:                }
0719:
0720:                return result;
0721:            }
0722:
0723:            /**
0724:             * Test whether it is a valid target.
0725:             * 
0726:             * @param objectName
0727:             * @return true when the mbean is registered, false otherwise
0728:             * @throws ManagementRemoteException
0729:             */
0730:            protected boolean isValidTarget(ObjectName objectName)
0731:                    throws ManagementRemoteException {
0732:
0733:                boolean result = false;
0734:                MBeanServer mbeanServer = getEnvironmentContext()
0735:                        .getMBeanServer();
0736:                try {
0737:                    result = mbeanServer.isRegistered(objectName);
0738:                } catch (RuntimeException exception) {
0739:                }
0740:
0741:                return result;
0742:                //        
0743:                //        return this.isValidTarget(objectName, DOMAIN_TARGET_KEY);
0744:            }
0745:
0746:            /**
0747:             * Test whether it is a valid target.
0748:             * 
0749:             * @param objectName
0750:             * @param targetName
0751:             * @return true when the mbean is registered, false otherwise
0752:             * @throws ManagementRemoteException
0753:             */
0754:            protected boolean isValidTarget(ObjectName objectName,
0755:                    String targetName) throws ManagementRemoteException {
0756:                boolean result = false;
0757:                if ((targetName.equals(DOMAIN_TARGET_KEY) == true)
0758:                        || (targetName.equals(SERVER_TARGET_KEY) == true)) {
0759:                    MBeanServer mbeanServer = this .environmentContext
0760:                            .getMBeanServer();
0761:                    try {
0762:                        result = mbeanServer.isRegistered(objectName);
0763:                    } catch (RuntimeException exception) {
0764:                        // Ignore Exception
0765:                        // Denotes MBean is not registered
0766:                    }
0767:                } else {
0768:                    MBeanServerConnection connection = this 
0769:                            .getMBeanServerConnection(targetName);
0770:                    try {
0771:                        result = connection.isRegistered(objectName);
0772:                    } catch (RuntimeException exception) {
0773:                        // Ignore Exception
0774:                        // Denotes MBean is not registered
0775:                    } catch (IOException exception) {
0776:                        // Ignore Exception
0777:                        // Denotes MBean is not registered
0778:                    }
0779:                }
0780:
0781:                return result;
0782:            }
0783:
0784:            /**
0785:             * invokes the operation on mbean
0786:             * 
0787:             * @param attributeValue
0788:             *            attrbute name
0789:             * @param attributeName
0790:             *            attribute value
0791:             * @param objectName
0792:             *            object name
0793:             * @throws ManagementRemoteException
0794:             *             on user error
0795:             */
0796:            protected void setMBeanAttribute(ObjectName objectName,
0797:                    String attributeName, Object attributeValue)
0798:                    throws ManagementRemoteException {
0799:                MBeanServer mbeanServer = this .environmentContext
0800:                        .getMBeanServer();
0801:
0802:                try {
0803:                    Attribute attr = new Attribute(attributeName,
0804:                            attributeValue);
0805:                    mbeanServer.setAttribute(objectName, attr);
0806:                } catch (InstanceNotFoundException notFoundEx) {
0807:                    throw new ManagementRemoteException(notFoundEx);
0808:                } catch (ReflectionException rEx) {
0809:                    throw new ManagementRemoteException(rEx);
0810:                } catch (MBeanException mbeanEx) {
0811:                    throw ManagementRemoteException
0812:                            .filterJmxExceptions(mbeanEx);
0813:                } catch (RuntimeMBeanException rtEx) {
0814:                    throw ManagementRemoteException.filterJmxExceptions(rtEx);
0815:                } catch (RuntimeOperationsException rtOpEx) {
0816:                    throw ManagementRemoteException.filterJmxExceptions(rtOpEx);
0817:                } catch (Exception ex) {
0818:                    throw ManagementRemoteException.filterJmxExceptions(ex);
0819:                }
0820:
0821:            }
0822:
0823:            /**
0824:             * set the specified attribute values on the mbean attributes
0825:             * 
0826:             * @param attrList
0827:             *            list of attributes
0828:             * @param objectName
0829:             *            object name
0830:             * @throws ManagementRemoteException
0831:             *             on user error
0832:             */
0833:            protected void setMBeanAttributes(ObjectName objectName,
0834:                    AttributeList attrList) throws ManagementRemoteException {
0835:                MBeanServer mbeanServer = this .environmentContext
0836:                        .getMBeanServer();
0837:
0838:                try {
0839:                    mbeanServer.setAttributes(objectName, attrList);
0840:                } catch (InstanceNotFoundException notFoundEx) {
0841:                    throw new ManagementRemoteException(notFoundEx);
0842:                } catch (ReflectionException rEx) {
0843:                    throw new ManagementRemoteException(rEx);
0844:                } catch (RuntimeMBeanException rtEx) {
0845:                    throw ManagementRemoteException.filterJmxExceptions(rtEx);
0846:                } catch (RuntimeOperationsException rtOpEx) {
0847:                    throw ManagementRemoteException.filterJmxExceptions(rtOpEx);
0848:                } catch (Exception ex) {
0849:                    throw ManagementRemoteException.filterJmxExceptions(ex);
0850:                }
0851:            }
0852:
0853:            /**
0854:             * set the specified attribute values on the mbean attributes
0855:             * 
0856:             * @param attrList
0857:             *            list of attributes
0858:             * @param objectName
0859:             *            object name
0860:             * @throws ManagementRemoteException
0861:             *             on user error
0862:             */
0863:            protected AttributeList setMBeanAttributes(
0864:                    MBeanServerConnection mbeanServer, ObjectName objectName,
0865:                    AttributeList attrList) throws ManagementRemoteException {
0866:
0867:                try {
0868:                    return mbeanServer.setAttributes(objectName, attrList);
0869:                } catch (InstanceNotFoundException notFoundEx) {
0870:                    throw new ManagementRemoteException(notFoundEx);
0871:                } catch (ReflectionException rEx) {
0872:                    throw new ManagementRemoteException(rEx);
0873:                } catch (RuntimeMBeanException rtEx) {
0874:                    throw ManagementRemoteException.filterJmxExceptions(rtEx);
0875:                } catch (RuntimeOperationsException rtOpEx) {
0876:                    throw ManagementRemoteException.filterJmxExceptions(rtOpEx);
0877:                } catch (Exception ex) {
0878:                    throw ManagementRemoteException.filterJmxExceptions(ex);
0879:                }
0880:
0881:            }
0882:
0883:            /**
0884:             * invokes the operation on mbean
0885:             * 
0886:             * @return Attribute List of the mbean to set
0887:             * @param objectName
0888:             *            mbean name
0889:             * @param params
0890:             *            a name value pair properties object contains the attribute
0891:             *            name and its value as string.
0892:             * @throws ManagementRemoteException
0893:             *             on user error
0894:             */
0895:            @SuppressWarnings("unchecked")
0896:            protected AttributeList constructMBeanAttributes(
0897:                    ObjectName objectName, Properties params)
0898:                    throws ManagementRemoteException {
0899:
0900:                MBeanServer mbeanServer = this .environmentContext
0901:                        .getMBeanServer();
0902:                AttributeList attrList = new AttributeList();
0903:                try {
0904:                    MBeanInfo mbeanInfo = mbeanServer.getMBeanInfo(objectName);
0905:                    MBeanAttributeInfo[] mbeanAttrInfoArray = mbeanInfo
0906:                            .getAttributes();
0907:                    Map attribInfoMap = new HashMap();
0908:                    for (int i = 0; i < mbeanAttrInfoArray.length; ++i) {
0909:                        MBeanAttributeInfo attrInfo = mbeanAttrInfoArray[i];
0910:                        attribInfoMap.put(attrInfo.getName(), attrInfo);
0911:                    }
0912:
0913:                    for (Iterator itr = params.keySet().iterator(); itr
0914:                            .hasNext();) {
0915:                        String attrName = (String) itr.next();
0916:                        String stringValue = params.getProperty(attrName);
0917:                        Object attrValueObj = null;
0918:
0919:                        // We can't validate properties if we don't have MBean attr info
0920:                        if (attribInfoMap.isEmpty()) {
0921:                            attrValueObj = stringValue;
0922:                        } else {
0923:                            MBeanAttributeInfo attrInfo = (MBeanAttributeInfo) attribInfoMap
0924:                                    .get(attrName);
0925:                            if (attrInfo == null) {
0926:                                String[] args = { attrName };
0927:                                Exception exception = this 
0928:                                        .createManagementException(
0929:                                                "ui.mbean.install.config.mbean.attrib.info.not.found",
0930:                                                args, null);
0931:                                throw new ManagementRemoteException(exception);
0932:
0933:                            }
0934:
0935:                            String type = attrInfo.getType();
0936:                            try {
0937:                                // construct the value object using reflection.
0938:                                attrValueObj = Util.newInstance(type,
0939:                                        stringValue);
0940:                            } catch (Exception ex) {
0941:                                String[] args = { stringValue, type, attrName };
0942:                                Exception exception = this 
0943:                                        .createManagementException(
0944:                                                "ui.mbean.install.config.mbean.attrib.type.convertion.error",
0945:                                                args, ex);
0946:                                throw new ManagementRemoteException(exception);
0947:
0948:                            }
0949:                        }
0950:
0951:                        Attribute attr = new Attribute(attrName, attrValueObj);
0952:                        attrList.add(attr);
0953:                    }
0954:                } catch (InstanceNotFoundException notFoundEx) {
0955:                    throw new ManagementRemoteException(notFoundEx);
0956:                } catch (ReflectionException rEx) {
0957:                    throw new ManagementRemoteException(rEx);
0958:                } catch (RuntimeMBeanException rtEx) {
0959:                    throw ManagementRemoteException.filterJmxExceptions(rtEx);
0960:                } catch (RuntimeOperationsException rtOpEx) {
0961:                    throw ManagementRemoteException.filterJmxExceptions(rtOpEx);
0962:                } catch (Exception ex) {
0963:                    throw ManagementRemoteException.filterJmxExceptions(ex);
0964:                }
0965:                return attrList;
0966:
0967:            }
0968:
0969:            /**
0970:             * invokes the operation on mbean
0971:             * 
0972:             * @return Attribute List of the mbean to set
0973:             * @param objectName
0974:             *            mbean name
0975:             * @param params
0976:             *            a name value pair Map object contains the attribute
0977:             *            name and its value.
0978:             * @throws ManagementRemoteException
0979:             *             on user error
0980:             */
0981:            @SuppressWarnings("unchecked")
0982:            protected AttributeList constructMBeanAttributes(
0983:                    ObjectName objectName,
0984:                    Map<String /*attributeName*/, Object /*attributeValue*/> params)
0985:                    throws ManagementRemoteException {
0986:
0987:                MBeanServer mbeanServer = this .environmentContext
0988:                        .getMBeanServer();
0989:                AttributeList attrList = new AttributeList();
0990:                try {
0991:                    MBeanInfo mbeanInfo = mbeanServer.getMBeanInfo(objectName);
0992:                    MBeanAttributeInfo[] mbeanAttrInfoArray = mbeanInfo
0993:                            .getAttributes();
0994:                    Map attribInfoMap = new HashMap();
0995:                    for (int i = 0; i < mbeanAttrInfoArray.length; ++i) {
0996:                        MBeanAttributeInfo attrInfo = mbeanAttrInfoArray[i];
0997:                        attribInfoMap.put(attrInfo.getName(), attrInfo);
0998:                    }
0999:
1000:                    for (Iterator itr = params.keySet().iterator(); itr
1001:                            .hasNext();) {
1002:                        String attrName = (String) itr.next();
1003:                        Object attrValueObj = params.get(attrName);
1004:                        Attribute attr = new Attribute(attrName, attrValueObj);
1005:                        attrList.add(attr);
1006:                    }
1007:                } catch (InstanceNotFoundException notFoundEx) {
1008:                    throw new ManagementRemoteException(notFoundEx);
1009:                } catch (ReflectionException rEx) {
1010:                    throw new ManagementRemoteException(rEx);
1011:                } catch (RuntimeMBeanException rtEx) {
1012:                    throw ManagementRemoteException.filterJmxExceptions(rtEx);
1013:                } catch (RuntimeOperationsException rtOpEx) {
1014:                    throw ManagementRemoteException.filterJmxExceptions(rtOpEx);
1015:                } catch (Exception ex) {
1016:                    throw ManagementRemoteException.filterJmxExceptions(ex);
1017:                }
1018:                return attrList;
1019:
1020:            }
1021:
1022:            /**
1023:             * invokes the operation on mbean
1024:             * 
1025:             * @return Attribute List of the mbean to set
1026:             * @param objectName
1027:             *            mbean name
1028:             * @param params
1029:             *            a name value pair properties object contains the attribute
1030:             *            name and its value as string.
1031:             * @throws ManagementRemoteException
1032:             *             on user error
1033:             */
1034:            @SuppressWarnings("unchecked")
1035:            protected AttributeList constructMBeanAttributes(
1036:                    MBeanServerConnection mbeanServer, ObjectName objectName,
1037:                    Properties params) throws ManagementRemoteException {
1038:
1039:                AttributeList attrList = new AttributeList();
1040:                try {
1041:                    MBeanInfo mbeanInfo = mbeanServer.getMBeanInfo(objectName);
1042:                    MBeanAttributeInfo[] mbeanAttrInfoArray = mbeanInfo
1043:                            .getAttributes();
1044:                    Map attribInfoMap = new HashMap();
1045:                    for (int i = 0; i < mbeanAttrInfoArray.length; ++i) {
1046:                        MBeanAttributeInfo attrInfo = mbeanAttrInfoArray[i];
1047:                        attribInfoMap.put(attrInfo.getName(), attrInfo);
1048:                    }
1049:
1050:                    for (Iterator itr = params.keySet().iterator(); itr
1051:                            .hasNext();) {
1052:                        String attrName = (String) itr.next();
1053:                        String stringValue = params.getProperty(attrName);
1054:                        Object attrValueObj = null;
1055:
1056:                        MBeanAttributeInfo attrInfo = (MBeanAttributeInfo) attribInfoMap
1057:                                .get(attrName);
1058:                        if (attrInfo == null) {
1059:                            String[] args = { attrName };
1060:                            Exception exception = this 
1061:                                    .createManagementException(
1062:                                            "ui.mbean.install.config.mbean.attrib.info.not.found",
1063:                                            args, null);
1064:                            throw new ManagementRemoteException(exception);
1065:
1066:                        }
1067:
1068:                        String type = attrInfo.getType();
1069:                        try {
1070:                            // construct the value object using reflection.
1071:                            attrValueObj = Util.newInstance(type, stringValue);
1072:                        } catch (Exception ex) {
1073:                            String[] args = { stringValue, type, attrName };
1074:                            Exception exception = this 
1075:                                    .createManagementException(
1076:                                            "ui.mbean.install.config.mbean.attrib.type.convertion.error",
1077:                                            args, ex);
1078:                            throw new ManagementRemoteException(exception);
1079:
1080:                        }
1081:
1082:                        Attribute attr = new Attribute(attrName, attrValueObj);
1083:                        attrList.add(attr);
1084:                    }
1085:
1086:                    return attrList;
1087:                } catch (InstanceNotFoundException notFoundEx) {
1088:                    throw new ManagementRemoteException(notFoundEx);
1089:                } catch (ReflectionException rEx) {
1090:                    throw new ManagementRemoteException(rEx);
1091:                } catch (RuntimeMBeanException rtEx) {
1092:                    throw ManagementRemoteException.filterJmxExceptions(rtEx);
1093:                } catch (RuntimeOperationsException rtOpEx) {
1094:                    throw ManagementRemoteException.filterJmxExceptions(rtOpEx);
1095:                } catch (Exception ex) {
1096:                    throw ManagementRemoteException.filterJmxExceptions(ex);
1097:                }
1098:
1099:            }
1100:
1101:            /**
1102:             * Creates a management message string and populates the exception
1103:             * 
1104:             * @param bundleKey
1105:             * @param args
1106:             *            of Strings
1107:             * @param sourceException -
1108:             *            the source exception to propagate
1109:             * @return Exception object created with a valid XML Management Message
1110:             */
1111:            protected Exception createManagementException(String bundleKey,
1112:                    String[] args, Exception sourceException) {
1113:                Exception exception = null;
1114:                String xmlManagementMessage = JBIResultXmlBuilder
1115:                        .createJbiResultXml(getI18NBundle(), bundleKey, args,
1116:                                sourceException);
1117:                exception = new Exception(xmlManagementMessage);
1118:                return exception;
1119:            }
1120:
1121:            /**
1122:             * Creates a management message.
1123:             * 
1124:             * @param taskId
1125:             * @param successResult
1126:             * @param msgType
1127:             * @param msgCode
1128:             * @param args
1129:             * @return
1130:             */
1131:            protected String createManagementMessage(String taskId,
1132:                    boolean successResult, String msgType, String msgCode,
1133:                    Object[] args) {
1134:                String msg = getI18NBundle().getMessage(msgCode, args);
1135:                String xmlManagementMessage = JBIResultXmlBuilder.getInstance()
1136:                        .createJbiResultXml(taskId, successResult, msgType,
1137:                                msgCode, msg, args);
1138:
1139:                return xmlManagementMessage;
1140:            }
1141:
1142:            /**
1143:             * returns the ObjectName for the DeploymentService Mbean of this component.
1144:             * 
1145:             * @param targetName
1146:             * 
1147:             * @return the ObjectName of the DeploymentService MBean or null.
1148:             */
1149:            protected ObjectName getDeploymentServiceMBeanObjectName(
1150:                    String targetName) {
1151:                MBeanNames mbeanNames = this .environmentContext.getMBeanNames();
1152:
1153:                return mbeanNames.getSystemServiceMBeanName(
1154:                        ServiceName.DeploymentService, ServiceType.Deployment,
1155:                        targetName);
1156:            }
1157:
1158:            /**
1159:             * returns the ObjectName for the AdminService Mbean of this component.
1160:             * 
1161:             * @return the ObjectName of the InstallationService MBean or null.
1162:             * @throws JBIRemoteException
1163:             *             on error.
1164:             */
1165:            protected ObjectName getAdminServiceMBeanObjectName()
1166:                    throws ManagementRemoteException {
1167:                try {
1168:                    MBeanNames mbeanNames = this .environmentContext
1169:                            .getMBeanNames();
1170:
1171:                    return mbeanNames.getSystemServiceMBeanName(
1172:                            MBeanNames.SERVICE_NAME_ADMIN_SERVICE,
1173:                            MBeanNames.CONTROL_TYPE_ADMIN_SERVICE);
1174:                } catch (Exception ex) {
1175:                    throw ManagementRemoteException.filterJmxExceptions(ex);
1176:                }
1177:
1178:            }
1179:
1180:            /**
1181:             * returns the ObjectName for the AdminService facade Mbean for a target
1182:             * 
1183:             * @param targetName
1184:             * 
1185:             * @return the ObjectName of the AdminService MBean or null.
1186:             */
1187:            protected ObjectName getAdminServiceMBeanObjectName(
1188:                    String targetName) {
1189:                MBeanNames mbeanNames = this .environmentContext.getMBeanNames();
1190:
1191:                return mbeanNames
1192:                        .getSystemServiceMBeanName(ServiceName.AdminService,
1193:                                ServiceType.Admin, targetName);
1194:            }
1195:
1196:            /**
1197:             * returns the ObjectName for the InstallationService Mbean of this
1198:             * component.
1199:             * 
1200:             * @param targetName
1201:             * @return the ObjectName of the InstallationService MBean or null.
1202:             */
1203:            protected ObjectName getInstallationServiceMBeanObjectName(
1204:                    String targetName) {
1205:                MBeanNames mbeanNames = this .environmentContext.getMBeanNames();
1206:                return mbeanNames.getSystemServiceMBeanName(
1207:                        ServiceName.InstallationService,
1208:                        ServiceType.Installation, targetName);
1209:            }
1210:
1211:            /**
1212:             * Check if a target is valid or not
1213:             * 
1214:             * @param objectName
1215:             * @param targetName
1216:             * @throws ManagementRemoteException
1217:             */
1218:            protected void checkForValidTarget(ObjectName objectName,
1219:                    String targetName) throws ManagementRemoteException {
1220:                boolean isRegistered = this .isValidTarget(objectName);
1221:                if (isRegistered == false) {
1222:                    String[] args = { targetName };
1223:                    Exception exception = this .createManagementException(
1224:                            "ui.mbean.invalid.target.error", args, null);
1225:                    throw new ManagementRemoteException(exception);
1226:
1227:                }
1228:            }
1229:
1230:            /**
1231:             * Check if a target is valid or not
1232:             * 
1233:             * @param objectName
1234:             * @param targetName
1235:             * @param useTargetNameFlag
1236:             * @throws ManagementRemoteException
1237:             */
1238:            protected void checkForValidTarget(ObjectName objectName,
1239:                    String targetName, boolean useTargetNameFlag)
1240:                    throws ManagementRemoteException {
1241:                boolean isRegistered = false;
1242:                if (useTargetNameFlag == true) {
1243:                    isRegistered = this .isValidTarget(objectName, targetName);
1244:                } else {
1245:                    isRegistered = this .isValidTarget(objectName);
1246:                }
1247:                if (isRegistered == false) {
1248:                    String[] args = { targetName };
1249:                    Exception exception = this .createManagementException(
1250:                            "ui.mbean.invalid.target.error", args, null);
1251:                    throw new ManagementRemoteException(exception);
1252:
1253:                }
1254:            }
1255:
1256:            /**
1257:             * Check the type of the specified target
1258:             * 
1259:             * @param targetName
1260:             * @return an enum representing the type of the target.
1261:             */
1262:            protected TargetType checkTargetType(String target) {
1263:                if (true == this .getPlatformContext()
1264:                        .isStandaloneServer(target)) {
1265:                    return TargetType.STANDALONE_SERVER;
1266:                }
1267:
1268:                if (true == this .getPlatformContext().isCluster(target)) {
1269:                    return TargetType.CLUSTER;
1270:                }
1271:
1272:                if (true == this .getPlatformContext().isClusteredServer(target)) {
1273:                    return TargetType.CLUSTERED_SERVER;
1274:                }
1275:
1276:                if (true == "domain".equals(target)) {
1277:                    return TargetType.DOMAIN;
1278:                }
1279:
1280:                return TargetType.INVALID_TARGET;
1281:            }
1282:
1283:            /**
1284:             * Retrieve MBeanServerConnection for targets other than server
1285:             * 
1286:             * @param targetName
1287:             * @return MBeanServerConnection
1288:             * @throws ManagementRemoteException
1289:             */
1290:            protected MBeanServerConnection getMBeanServerConnection(
1291:                    String targetName) throws ManagementRemoteException {
1292:                MBeanServerConnection connection = null;
1293:                try {
1294:                    connection = getPlatformContext().getMBeanServerConnection(
1295:                            targetName);
1296:                } catch (Exception e) {
1297:                    throw new ManagementRemoteException(e);
1298:                }
1299:                return connection;
1300:            }
1301:
1302:            /**
1303:             * gets the ebi jmx domain name
1304:             * 
1305:             * @return domain name
1306:             */
1307:            protected static String getEbiJmxDomain() {
1308:                if (EBIJMXDOMAIN == null) {
1309:                    EBIJMXDOMAIN = System.getProperty("ebi.jmx.domain",
1310:                            JMX_EBI_DOMAIN);
1311:                }
1312:                return EBIJMXDOMAIN;
1313:            }
1314:
1315:            /**
1316:             * Get the EBI Status MBean ObjectName
1317:             * 
1318:             * @param componentName
1319:             * @param targetName
1320:             * @return object name of ebi config MBean
1321:             * @throws ManagementRemoteException
1322:             */
1323:            @SuppressWarnings("unchecked")
1324:            protected ObjectName getEbiStatusMBeanObjectName(
1325:                    String componentName, String targetName)
1326:                    throws ManagementRemoteException {
1327:                ObjectName objectName = null;
1328:                Set<ObjectName> objectNameSet = null;
1329:                String name = null;
1330:                if ((targetName.equals(DOMAIN_TARGET_KEY) == true)
1331:                        || (targetName.equals(SERVER_TARGET_KEY) == true)) {
1332:                    MBeanServer server = this .environmentContext
1333:                            .getMBeanServer();
1334:
1335:                    name = getEbiJmxDomain() + ":" + SERVICE_TYPE_KEY
1336:                            + "=Status," + IDENTIFICATION_NAME_KEY + "="
1337:                            + componentName + ",*";
1338:                    try {
1339:                        ObjectName objectNameFilter = new ObjectName(name);
1340:                        if (server != null) {
1341:                            objectNameSet = server.queryNames(objectNameFilter,
1342:                                    null);
1343:                            for (ObjectName mBeanObjectName : objectNameSet) {
1344:                                if (mBeanObjectName != null) {
1345:                                    objectName = mBeanObjectName;
1346:                                    break;
1347:                                }
1348:                            }
1349:                        }
1350:                    } catch (MalformedObjectNameException e) {
1351:                        throw new ManagementRemoteException(e);
1352:                    } catch (NullPointerException e) {
1353:                        throw new ManagementRemoteException(e);
1354:                    }
1355:                } else {
1356:                    MBeanServerConnection connection = this 
1357:                            .getMBeanServerConnection(targetName);
1358:                    name = getEbiJmxDomain() + ":" + SERVICE_TYPE_KEY
1359:                            + "=Status," + IDENTIFICATION_NAME_KEY + "="
1360:                            + componentName + ",*";
1361:                    try {
1362:                        ObjectName objectNameFilter = new ObjectName(name);
1363:                        if (connection != null) {
1364:                            objectNameSet = connection.queryNames(
1365:                                    objectNameFilter, null);
1366:                            for (ObjectName mBeanObjectName : objectNameSet) {
1367:                                if (mBeanObjectName != null) {
1368:                                    objectName = mBeanObjectName;
1369:                                    break;
1370:                                }
1371:                            }
1372:                        }
1373:                    } catch (MalformedObjectNameException e) {
1374:                        throw new ManagementRemoteException(e);
1375:                    } catch (NullPointerException e) {
1376:                        throw new ManagementRemoteException(e);
1377:                    } catch (IOException e) {
1378:                        throw new ManagementRemoteException(e);
1379:                    }
1380:                }
1381:                return objectName;
1382:            }
1383:
1384:            /**
1385:             * Get the attributes on the MBean
1386:             * 
1387:             * @param connection
1388:             * @param objectName
1389:             * @return
1390:             * @throws ManagementRemoteException
1391:             */
1392:            protected Properties getMBeanAttributeValues(
1393:                    MBeanServerConnection connection, ObjectName objectName)
1394:                    throws ManagementRemoteException {
1395:                Properties properties = new Properties();
1396:                List<String> keyList = new ArrayList<String>();
1397:                MBeanInfo mbeanInfo = null;
1398:                try {
1399:                    mbeanInfo = connection.getMBeanInfo(objectName);
1400:                    MBeanAttributeInfo[] mbeanAttrInfoArray = mbeanInfo
1401:                            .getAttributes();
1402:                    for (MBeanAttributeInfo attributeInfo : mbeanAttrInfoArray) {
1403:                        String key = attributeInfo.getName();
1404:                        if (key != null) {
1405:                            Object value = null;
1406:                            try {
1407:                                value = connection
1408:                                        .getAttribute(objectName, key);
1409:                            } catch (AttributeNotFoundException e) {
1410:                                throw new ManagementRemoteException(e);
1411:                            } catch (InstanceNotFoundException e) {
1412:                                throw new ManagementRemoteException(e);
1413:                            } catch (MBeanException e) {
1414:                                throw new ManagementRemoteException(e);
1415:                            } catch (ReflectionException e) {
1416:                                throw new ManagementRemoteException(e);
1417:                            }
1418:                            if (value != null) {
1419:                                // Use getApplicationVariables to get application
1420:                                // variable values
1421:                                if (key.equals("ApplicationVariables")) {
1422:                                    // value = this
1423:                                    //     .convertToEnvironmentVariableString(value);
1424:                                    continue;
1425:                                }
1426:
1427:                                // Use getApplicationConfigurations to get application
1428:                                //             configuration values
1429:                                if (key.equals("ApplicationConfigurations")) {
1430:                                    //value = this
1431:                                    //         .convertToEnvironmentVariableString(value);
1432:                                    continue;
1433:                                }
1434:                                properties.put(key, value + "");
1435:                                keyList.add(key);
1436:                            }
1437:                        }
1438:                    }
1439:                } catch (InstanceNotFoundException e) {
1440:                    throw new ManagementRemoteException(e);
1441:                } catch (IntrospectionException e) {
1442:                    throw new ManagementRemoteException(e);
1443:                } catch (ReflectionException e) {
1444:                    throw new ManagementRemoteException(e);
1445:                } catch (IOException e) {
1446:                    throw new ManagementRemoteException(e);
1447:                }
1448:
1449:                // Mask Sensitive password Strings
1450:                /** TODO : With the facade layer we do not have the display data XML
1451:                 * When the common client is getting the attributes from the actual 
1452:                 * component MBean this path should be invoked
1453:                if (keyList.size() > 0) {
1454:                    String xmlDataString = this.getComponentConfigurationDisplayData(
1455:                            connection, objectName);
1456:                    keyList = this.getComponentConfigurationPasswordFields(
1457:                            xmlDataString, GenericsSupport.toArray(keyList,
1458:                                    String.class));
1459:                    for (String key : keyList) {
1460:                        String sensitiveString = properties.getProperty(key);
1461:                        sensitiveString = this
1462:                                .maskSensitiveString(sensitiveString, PASSWORD_MASK_CHARACTER);
1463:                        properties.setProperty(key, sensitiveString);
1464:                    }
1465:                }
1466:                 */
1467:
1468:                return properties;
1469:            }
1470:
1471:            /**
1472:             * Get the attributes on the MBean
1473:             * 
1474:             * @param connection
1475:             * @param objectName
1476:             * @return
1477:             * @throws ManagementRemoteException
1478:             */
1479:            protected Map<String /*attributeName*/, Object /*attributeValue*/> getMBeanAttributeValuesAsMap(
1480:                    MBeanServerConnection connection, ObjectName objectName)
1481:                    throws ManagementRemoteException {
1482:                Map<String /*attributeName*/, Object /*attributeValue*/> properties = null;
1483:                properties = new HashMap<String /*attributeName*/, Object /*attributeValue*/>();
1484:                List<String> keyList = new ArrayList<String>();
1485:                MBeanInfo mbeanInfo = null;
1486:                try {
1487:                    mbeanInfo = connection.getMBeanInfo(objectName);
1488:                    MBeanAttributeInfo[] mbeanAttrInfoArray = mbeanInfo
1489:                            .getAttributes();
1490:                    for (MBeanAttributeInfo attributeInfo : mbeanAttrInfoArray) {
1491:                        String key = attributeInfo.getName();
1492:                        if (key != null) {
1493:                            Object value = null;
1494:                            try {
1495:                                value = connection
1496:                                        .getAttribute(objectName, key);
1497:                            } catch (AttributeNotFoundException e) {
1498:                                throw new ManagementRemoteException(e);
1499:                            } catch (InstanceNotFoundException e) {
1500:                                throw new ManagementRemoteException(e);
1501:                            } catch (MBeanException e) {
1502:                                throw new ManagementRemoteException(e);
1503:                            } catch (ReflectionException e) {
1504:                                throw new ManagementRemoteException(e);
1505:                            }
1506:                            if (value != null) {
1507:                                // Use getApplicationVariables to get application
1508:                                // variable values
1509:                                if (key.equals("ApplicationVariables")) {
1510:                                    // value = this
1511:                                    //     .convertToEnvironmentVariableString(value);
1512:                                    continue;
1513:                                }
1514:
1515:                                // Use getApplicationConfigurations to get application
1516:                                //             configuration values
1517:                                if (key.equals("ApplicationConfigurations")) {
1518:                                    //value = this
1519:                                    //         .convertToEnvironmentVariableString(value);
1520:                                    continue;
1521:                                }
1522:                                properties.put(key, value);
1523:                                keyList.add(key);
1524:                            }
1525:                        }
1526:                    }
1527:                } catch (InstanceNotFoundException e) {
1528:                    throw new ManagementRemoteException(e);
1529:                } catch (IntrospectionException e) {
1530:                    throw new ManagementRemoteException(e);
1531:                } catch (ReflectionException e) {
1532:                    throw new ManagementRemoteException(e);
1533:                } catch (IOException e) {
1534:                    throw new ManagementRemoteException(e);
1535:                }
1536:
1537:                // Mask Sensitive password Strings
1538:                /** TODO : With the facade layer we do not have the display data XML
1539:                 * When the common client is getting the attributes from the actual 
1540:                 * component MBean this path should be invoked
1541:                if (keyList.size() > 0) {
1542:                    String xmlDataString = this.getComponentConfigurationDisplayData(
1543:                            connection, objectName);
1544:                    keyList = this.getComponentConfigurationPasswordFields(
1545:                            xmlDataString, GenericsSupport.toArray(keyList,
1546:                                    String.class));
1547:                    for (String key : keyList) {
1548:                        String sensitiveString = properties.getProperty(key);
1549:                        sensitiveString = this
1550:                                .maskSensitiveString(sensitiveString, PASSWORD_MASK_CHARACTER);
1551:                        properties.setProperty(key, sensitiveString);
1552:                    }
1553:                }
1554:                 */
1555:
1556:                return properties;
1557:            }
1558:
1559:            /**
1560:             * set the specified attribute values on the mbean attributes
1561:             * 
1562:             * @param attrList
1563:             *            list of attributes
1564:             * @param objectName
1565:             *            object name
1566:             * @return management message response from setConfigurationAttributes
1567:             * @throws ManagementRemoteException
1568:             *             on user error
1569:             */
1570:            protected String setMBeanConfigAttributes(ObjectName objectName,
1571:                    AttributeList attrList) throws ManagementRemoteException {
1572:                MBeanServer mbeanServer = this .environmentContext
1573:                        .getMBeanServer();
1574:
1575:                return this .setMBeanConfigAttributes(mbeanServer, objectName,
1576:                        attrList);
1577:            }
1578:
1579:            /**
1580:             * set the specified attribute values on the mbean attributes
1581:             * 
1582:             * @param MBeanServer
1583:             *            the MBean server to use
1584:             * @param attrList
1585:             *            list of attributes
1586:             * @param objectName
1587:             *            object name
1588:             * @return management message response from setConfigurationAttributes
1589:             * @throws ManagementRemoteException
1590:             *             on user error
1591:             */
1592:            protected String setMBeanConfigAttributes(
1593:                    MBeanServerConnection mbeanServer, ObjectName objectName,
1594:                    AttributeList attrList) throws ManagementRemoteException {
1595:                try {
1596:                    return ((String) mbeanServer.invoke(objectName,
1597:                            "setConfigurationAttributes",
1598:                            new Object[] { attrList },
1599:                            new String[] { "javax.management.AttributeList" }));
1600:                } catch (InstanceNotFoundException notFoundEx) {
1601:                    throw new ManagementRemoteException(notFoundEx);
1602:                } catch (ReflectionException rEx) {
1603:                    throw new ManagementRemoteException(rEx);
1604:                } catch (RuntimeMBeanException rtEx) {
1605:                    throw ManagementRemoteException.filterJmxExceptions(rtEx);
1606:                } catch (RuntimeOperationsException rtOpEx) {
1607:                    throw ManagementRemoteException.filterJmxExceptions(rtOpEx);
1608:                } catch (Exception ex) {
1609:                    throw ManagementRemoteException.filterJmxExceptions(ex);
1610:                }
1611:
1612:            }
1613:
1614:            /**
1615:             * Returns the stack-trace of the exception
1616:             * 
1617:             * @param exception
1618:             * @return stack traces as a string
1619:             */
1620:            protected String getStackTrace(JBIRemoteException exception) {
1621:                String buffer = "";
1622:                if (exception != null) {
1623:                    JBIManagementMessage message = exception
1624:                            .extractJBIManagementMessage();
1625:                    if (message != null) {
1626:                        buffer = message.getStackTrace();
1627:                    }
1628:                    if ((buffer == null) || (buffer.trim().length() == 0)) {
1629:                        buffer = "";
1630:                        StringBuffer cause = exception.getCauseStackTrace();
1631:                        if (cause != null) {
1632:                            buffer += getI18NBundle().getMessage(
1633:                                    "ui.mbean.stacktrace.caused.by.info")
1634:                                    + ":\n" + cause.toString();
1635:                            buffer += "\n";
1636:                        } else {
1637:                            String[] elements = exception
1638:                                    .getCauseMessageTrace();
1639:                            if (elements != null) {
1640:                                buffer += getI18NBundle().getMessage(
1641:                                        "ui.mbean.stacktrace.caused.by.info")
1642:                                        + ":\n";
1643:                                for (int index = 0; index < elements.length; index++) {
1644:                                    if (elements[index] != null) {
1645:                                        buffer += elements[index].toString();
1646:                                        buffer += "\n";
1647:                                    }
1648:                                }
1649:                            }
1650:                        }
1651:                        StackTraceElement[] elements = exception
1652:                                .getStackTrace();
1653:                        if (elements != null) {
1654:                            buffer += getI18NBundle().getMessage(
1655:                                    "ui.mbean.stacktrace.stack.trace.info")
1656:                                    + ":\n";
1657:                            for (int index = 0; index < elements.length; index++) {
1658:                                if (elements[index] != null) {
1659:                                    buffer += elements[index].toString();
1660:                                    buffer += "\n";
1661:                                }
1662:                            }
1663:                        }
1664:                    }
1665:                }
1666:                return buffer;
1667:            }
1668:
1669:            /**
1670:             * Check to ensure that the target is a domain target
1671:             * @throws ManagementRemoteException if target is domain
1672:             */
1673:            protected void domainTargetCheck(String target)
1674:                    throws ManagementRemoteException {
1675:                if ("domain".equals(target)) {
1676:                    Exception exception = this 
1677:                            .createManagementException(
1678:                                    "ui.mbean.component.configuration.domain.unsupported.error",
1679:                                    new String[0], null);
1680:                    throw new ManagementRemoteException(exception);
1681:                }
1682:            }
1683:
1684:            /**
1685:             * Returns a map of target names to an array of target instance names.
1686:             * In the case cluster targets, the key contains the cluster target name, 
1687:             * and the the value contains an array of the "target instance" names.
1688:             * If it is not a cluster target, the key contains the targetName, and 
1689:             * the value is null.
1690:             * 
1691:             * @return map of target names to array of target instance names
1692:             * @throws ManagementRemoteException
1693:             */
1694:            protected Map<String /*targetName*/, String[] /*targetInstanceNames*/> listTargetNames()
1695:                    throws ManagementRemoteException {
1696:                Map<String /*targetName*/, String[] /*targetInstanceNames*/> targetNameToTargetInstanceNameMap = null;
1697:                targetNameToTargetInstanceNameMap = new HashMap<String /*targetName*/, String[] /*targetInstanceNames*/>();
1698:                Set<String> clusters = this .getPlatformContext()
1699:                        .getClusterNames();
1700:                Set<String> servers = this .getPlatformContext()
1701:                        .getStandaloneServerNames();
1702:
1703:                // Add standalone targets
1704:                for (String serverTargetName : servers) {
1705:                    targetNameToTargetInstanceNameMap.put(serverTargetName,
1706:                            null);
1707:                }
1708:
1709:                // Add cluster targets
1710:                for (String clusterTargetName : clusters) {
1711:                    Set<String> serversInCluster = this .getPlatformContext()
1712:                            .getServersInCluster(clusterTargetName);
1713:                    List<String> serverNamesList = new ArrayList<String>();
1714:                    if (serversInCluster != null) {
1715:                        for (String instanceName : serversInCluster) {
1716:                            serverNamesList.add(instanceName);
1717:                        }
1718:                    }
1719:                    String[] serverNamesArray = GenericsSupport.toArray(
1720:                            serverNamesList, String.class);
1721:                    targetNameToTargetInstanceNameMap.put(clusterTargetName,
1722:                            serverNamesArray);
1723:                }
1724:
1725:                return targetNameToTargetInstanceNameMap;
1726:            }
1727:
1728:            /**
1729:             * Checks to see if the Target (server, cluster) is up or down.
1730:             * 
1731:             * @param targetName
1732:             *            name of the target (e.g., cluster1, server, etc.)
1733:             * @return true if Target is up, false if not
1734:             * @throws ManagementRemoteException
1735:             *             if error or exception occurs.
1736:             */
1737:            protected boolean isTargetUp(String targetName)
1738:                    throws ManagementRemoteException {
1739:                boolean isTargetUp = false;
1740:                Set<String> clusters = this .getPlatformContext()
1741:                        .getClusterNames();
1742:                Set<String> servers = this .getPlatformContext()
1743:                        .getStandaloneServerNames();
1744:
1745:                if (clusters.contains(targetName)) {
1746:                    Set<String> serversInCluster = this .getPlatformContext()
1747:                            .getServersInCluster(targetName);
1748:
1749:                    for (String instanceName : serversInCluster) {
1750:                        if (this .getPlatformContext()
1751:                                .isInstanceUp(instanceName)) {
1752:                            isTargetUp = true;
1753:                            break;
1754:                        }
1755:                    }
1756:                } else if (servers.contains(targetName)) {
1757:                    isTargetUp = this .getPlatformContext().isInstanceUp(
1758:                            targetName);
1759:                }
1760:
1761:                return isTargetUp;
1762:            }
1763:
1764:            /**
1765:             * Find Extension MBeans for targets that are up
1766:             * 
1767:             * @param componentName
1768:             * @param extensionName
1769:             * @param targetName
1770:             * @return map of instanceName to ObjectNames[] the contain live instances
1771:             * @throws ManagementRemoteException
1772:             */
1773:            protected Map<String /*instanceName*/, ObjectName[]> findLiveExtensionMBeanObjectNames(
1774:                    String componentName, String extensionName,
1775:                    String targetName) throws ManagementRemoteException {
1776:                Map<String /*instanceName*/, ObjectName[]> resultMap = new HashMap<String /*instanceName*/, ObjectName[]>();
1777:                Map<String /*instanceName*/, ObjectName[]> targetToObjectNamesMap = null;
1778:                Map<String /*targetName*/, String[] /*instanceNames*/> targetToInstanceNamesMap = null;
1779:                targetToInstanceNamesMap = listTargetNames();
1780:                targetToObjectNamesMap = getComponentExtensionMBeanObjectNames(
1781:                        componentName, extensionName, targetName);
1782:                if ((targetToInstanceNamesMap != null)
1783:                        && (targetToObjectNamesMap != null)) {
1784:                    String[] targetInstanceNames = targetToInstanceNamesMap
1785:                            .get(targetName);
1786:                    if (targetInstanceNames != null) {
1787:                        // This is a Cluster target
1788:                        for (String instanceName : targetInstanceNames) {
1789:                            if ((this .isPlatformContextInstanceUp(instanceName) == true)
1790:                                    && (this 
1791:                                            .isPlatformContextInstanceClustered(instanceName) == true)) {
1792:                                // the instance is live, and it is a clustered instance
1793:                                ObjectName[] objectName = targetToObjectNamesMap
1794:                                        .get(targetName);
1795:                                resultMap.put(instanceName, objectName);
1796:                            }
1797:                        }
1798:                    } else {
1799:                        // This is a NOT cluster target
1800:                        if (this .isTargetUp(targetName)
1801:                                && (this 
1802:                                        .isPlatformContextClusteredServer(targetName) == false)) {
1803:                            // The target is Live, and it is a stand-alone server
1804:                            ObjectName[] objectName = targetToObjectNamesMap
1805:                                    .get(targetName);
1806:                            resultMap.put(targetName, objectName);
1807:                        }
1808:                    }
1809:                }
1810:                return resultMap;
1811:            }
1812:
1813:            /**
1814:             * Gets the extension MBean object names
1815:             * 
1816:             * @param componentName
1817:             *            name of the component
1818:             * @param extensionName
1819:             *            the name of the extension (e.g., Configuration, Logger, etc.)
1820:             * @param targetName
1821:             *            name of the target (e.g., cluster1, server, etc.)
1822:             * @return
1823:             * @throws ManagementRemoteException
1824:             *             on error
1825:             */
1826:            @SuppressWarnings("unchecked")
1827:            protected Map<String, ObjectName[]> getComponentExtensionMBeanObjectNames(
1828:                    String componentName, String extensionName,
1829:                    String targetName) throws ManagementRemoteException {
1830:                Map<String, ObjectName[]> resultObject = null;
1831:                logDebug("Get Component Extension MBeans ");
1832:
1833:                ObjectName extensionMBeanObjectName = null;
1834:                try {
1835:                    extensionMBeanObjectName = this 
1836:                            .getExtensionMBeanObjectName(componentName,
1837:                                    JBIAdminCommands.DOMAIN_TARGET_KEY);
1838:                } catch (ManagementRemoteException exception) {
1839:                }
1840:
1841:                if (extensionMBeanObjectName == null) {
1842:                    return resultObject;
1843:                }
1844:
1845:                this .checkForValidTarget(extensionMBeanObjectName,
1846:                        JBIAdminCommands.DOMAIN_TARGET_KEY);
1847:
1848:                logDebug("Calling getCustomMBeanNames on extensionMBeanObjectName = "
1849:                        + extensionMBeanObjectName);
1850:
1851:                // return custom MBeans with CustomControlName=customName and
1852:                // ControlType=Custom
1853:                resultObject = (Map<String, ObjectName[]>) this 
1854:                        .invokeMBeanOperation(extensionMBeanObjectName,
1855:                                "getCustomMBeanNames", extensionName);
1856:
1857:                return resultObject;
1858:            }
1859:
1860:            /**
1861:             * Gets the extension MBean object names
1862:             * 
1863:             * @param componentName
1864:             *            name of the component
1865:             * @param extensionName
1866:             *            the name of the extension (e.g., Configuration, Logger, etc.)
1867:             * @param targetName
1868:             *            name of the target (e.g., cluster1, server, etc.)
1869:             * @param targetInstanceName
1870:             *            name of the target instance (e.g., cluster1-instance1, etc.)
1871:             * @return an array of ObjectName(s)
1872:             * @throws ManagementRemoteException
1873:             *             on error
1874:             */
1875:            @SuppressWarnings("unchecked")
1876:            protected ObjectName[] getComponentExtensionMBeanObjectNames(
1877:                    String componentName, String extensionName,
1878:                    String targetName, String targetInstanceName)
1879:                    throws ManagementRemoteException {
1880:                ObjectName[] resultObject = null;
1881:                Map<String, ObjectName[]> customMBeansMap = null;
1882:                logDebug("Get Component Extension MBeans ");
1883:
1884:                ObjectName extensionMBeanObjectName = this 
1885:                        .getExtensionMBeanObjectName(componentName,
1886:                                JBIAdminCommands.DOMAIN_TARGET_KEY);
1887:                if (extensionMBeanObjectName == null) {
1888:                    return resultObject;
1889:                }
1890:
1891:                this .checkForValidTarget(extensionMBeanObjectName,
1892:                        JBIAdminCommands.DOMAIN_TARGET_KEY);
1893:
1894:                logDebug("Calling getCustomMBeanNames on extensionMBeanObjectName = "
1895:                        + extensionMBeanObjectName);
1896:
1897:                // return custom MBeans with CustomControlName=customName and
1898:                // ControlType=Custom
1899:                customMBeansMap = (Map<String, ObjectName[]>) this 
1900:                        .invokeMBeanOperation(extensionMBeanObjectName,
1901:                                "getCustomMBeanNames", extensionName);
1902:                if ((customMBeansMap != null)
1903:                        && ((targetName != null) || (targetInstanceName != null))) {
1904:                    // You now have the map of targetInstances to extension MBean names
1905:                    if (targetInstanceName != null) {
1906:                        resultObject = customMBeansMap.get(targetInstanceName);
1907:                    } else {
1908:                        resultObject = customMBeansMap.get(targetName);
1909:                    }
1910:                }
1911:                return resultObject;
1912:            }
1913:
1914:            /**
1915:             * returns the ObjectName for the Extension Mbean of this component.
1916:             * 
1917:             * @param componentName
1918:             * @param targetName
1919:             * 
1920:             * @return the ObjectName of the Extension MBean or null.
1921:             */
1922:            @SuppressWarnings("unchecked")
1923:            protected ObjectName getExtensionMBeanObjectName(
1924:                    String componentName, String targetName)
1925:                    throws ManagementRemoteException {
1926:
1927:                ObjectName adminSvcMBeanObjectName = this 
1928:                        .getAdminServiceMBeanObjectName(targetName);
1929:
1930:                this .checkForValidTarget(adminSvcMBeanObjectName, targetName);
1931:
1932:                logDebug("Calling getComponentExtensionFacadeMBean on AdminService = "
1933:                        + adminSvcMBeanObjectName);
1934:
1935:                ObjectName extensionMBeanObjectName = (ObjectName) this 
1936:                        .invokeMBeanOperation(adminSvcMBeanObjectName,
1937:                                "getComponentExtensionFacadeMBean",
1938:                                componentName);
1939:
1940:                logDebug("getComponentExtensionFacadeMBean on AdminService returned = "
1941:                        + extensionMBeanObjectName);
1942:
1943:                return extensionMBeanObjectName;
1944:            }
1945:
1946:            /////////////////////////////
1947:            // Platform Context methods
1948:            /////////////////////////////
1949:
1950:            /**
1951:             * Get the instance name of the platform's administration server.  If the
1952:             * platform does not provide a separate administration server, then this 
1953:             * method returns the name of the local instance.
1954:             * @return instance name of the administration server
1955:             */
1956:            protected String getPlatformContextAdminServerName() {
1957:                return this .getPlatformContext().getAdminServerName();
1958:            }
1959:
1960:            /**
1961:             * Determine whether this instance is the administration server instance.
1962:             * @return <CODE>true</CODE> if this instance is the administration server,
1963:             * <CODE>false</CODE> if not.
1964:             */
1965:            protected boolean isPlatformContextAdminServer() {
1966:                return this .getPlatformContext().isAdminServer();
1967:            }
1968:
1969:            /**
1970:             * Get the name of this instance.
1971:             * @return the name of this server instance.
1972:             */
1973:            protected String getPlatformContextInstanceName() {
1974:                return this .getPlatformContext().getInstanceName();
1975:            }
1976:
1977:            /**
1978:             * Determine if the specified instance is up.
1979:             * @return true if the instance is up and running, false otherwise
1980:             */
1981:            protected boolean isPlatformContextInstanceUp(String instanceName) {
1982:                return this .getPlatformContext().isInstanceUp(instanceName);
1983:            }
1984:
1985:            /**
1986:             * Determine whether multiple servers are permitted within this AS
1987:             * installation.
1988:             * @return true if multiple servers are permitted.
1989:             */
1990:            protected boolean platformContextSupportsMultipleServers() {
1991:                return this .getPlatformContext().supportsMultipleServers();
1992:            }
1993:
1994:            /**
1995:             * Get the Target Name. If the instance is not a clustered instance then
1996:             * the target name is the instance name. If the instance is part of a
1997:             * cluster then the target name is the cluster name.
1998:             *
1999:             * @return the target name. 
2000:             */
2001:            protected String getPlatformContextTargetName() {
2002:                return this .getPlatformContext().getTargetName();
2003:            }
2004:
2005:            /**
2006:             * Get the Target Name for a specified instance. If the instance is not
2007:             * clustered the instance name is returned. This operation is invoked by
2008:             * the JBI instance MBeans only.
2009:             *
2010:             * @return the target name. 
2011:             */
2012:            protected String getPlatformContextTargetName(String instanceName) {
2013:                return this .getPlatformContext().getTargetName(instanceName);
2014:            }
2015:
2016:            /**
2017:             * Get a set of the names of all the standalone servers in the domain.
2018:             * @return a set of names of standalone servers in the domain.
2019:             */
2020:            protected Set<String> getPlatformContextStandaloneServerNames() {
2021:                return this .getPlatformContext().getStandaloneServerNames();
2022:            }
2023:
2024:            /**
2025:             * Get a set of the names of all the clustered servers in the domain.
2026:             * @return a set of names of clustered servers in the domain.
2027:             */
2028:            protected Set<String> getPlatformContextClusteredServerNames() {
2029:                return this .getPlatformContext().getClusteredServerNames();
2030:            }
2031:
2032:            /**
2033:             * Get a set of the names of all the clusters in the domain.
2034:             * @return a set of names of clusters in the domain.
2035:             */
2036:            protected Set<String> getPlatformContextClusterNames() {
2037:                return this .getPlatformContext().getClusterNames();
2038:            }
2039:
2040:            /**
2041:             * Get a set of the names of all the servers in the specified cluster.
2042:             * @return a set of names of servers in the cluster.
2043:             */
2044:            protected Set<String> getPlatformContextServersInCluster(
2045:                    String clusterName) {
2046:                return this .getPlatformContext().getServersInCluster(
2047:                        clusterName);
2048:            }
2049:
2050:            /**
2051:             * Determine whether a target is a valid server or cluster name.
2052:             * @return <CODE>true</CODE> if <CODE>targetName</CODE> is a valid
2053:             * standalone server name or cluster name, <CODE>false</CODE> if not.
2054:             */
2055:            protected boolean isPlatformContextValidTarget(String targetName) {
2056:                return this .getPlatformContext().isValidTarget(targetName);
2057:            }
2058:
2059:            /**
2060:             * Determine whether a target is a cluster.
2061:             * @return <CODE>true</CODE> if <CODE>targetName</CODE> is a cluster,
2062:             * <CODE>false</CODE> if not.
2063:             */
2064:            protected boolean isPlatformContextCluster(String targetName) {
2065:                return this .getPlatformContext().isCluster(targetName);
2066:            }
2067:
2068:            /**
2069:             * Determine whether a target is a standalone server.
2070:             * @return <CODE>true</CODE> if <CODE>targetName</CODE> is a standalone
2071:             * server, <CODE>false</CODE> if not.
2072:             */
2073:            protected boolean isPlatformContextStandaloneServer(
2074:                    String targetName) {
2075:                return this .getPlatformContext().isStandaloneServer(targetName);
2076:            }
2077:
2078:            /**
2079:             * Determine whether the target is a clustered server.
2080:             * @return <CODE>true</CODE> if <CODE>targetName</CODE> is a clustered
2081:             * server, <CODE>false</CODE> if not.
2082:             */
2083:            protected boolean isPlatformContextClusteredServer(String targetName) {
2084:                return this .getPlatformContext().isClusteredServer(targetName);
2085:            }
2086:
2087:            /**
2088:             * Determine whether or not an instance is clustered.
2089:             * @return <CODE>true</CODE> if the instance is clustered,
2090:             * <CODE>false</CODE> if not.
2091:             */
2092:            protected boolean isPlatformContextInstanceClustered(
2093:                    String instanceName) {
2094:                return this .getPlatformContext().isInstanceClustered(
2095:                        instanceName);
2096:            }
2097:
2098:            /**
2099:             * Get a string representation of the DAS JMX RMI connector port.
2100:             * @return the JMX RMI connector port as a (CODE>String</CODE>.
2101:             */
2102:            protected String getPlatformContextJmxRmiPort() {
2103:                return this .getPlatformContext().getJmxRmiPort();
2104:            }
2105:
2106:            /**
2107:             * Provides access to the platform's MBean server.
2108:             * @return platform MBean server.
2109:             */
2110:            protected MBeanServer getPlatformContextMBeanServer() {
2111:                return this .getPlatformContext().getMBeanServer();
2112:            }
2113:
2114:            /**
2115:             * Get the full path to the platform's instance root directory.
2116:             * @return platform instance root
2117:             */
2118:            protected String getPlatformContextInstanceRoot() {
2119:                return this .getPlatformContext().getInstanceRoot();
2120:            }
2121:
2122:            /**
2123:             * Get the full path to the platform's instaall root directory.
2124:             * @return platform install root
2125:             */
2126:            protected String getPlatformContextInstallRoot() {
2127:                return this.getPlatformContext().getInstallRoot();
2128:            }
2129:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.