Source Code Cross Referenced for AbstractUIMBeanImpl.java in  » ESB » open-esb » com » sun » jbi » ui » runtime » mbeans » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » ESB » open esb » com.sun.jbi.ui.runtime.mbeans 
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:         * @(#)AbstractUIMBeanImpl.java
0025:         * Copyright 2004-2007 Sun Microsystems, Inc. All Rights Reserved.
0026:         *
0027:         * END_HEADER - DO NOT EDIT
0028:         */
0029:        package com.sun.jbi.ui.runtime.mbeans;
0030:
0031:        import java.io.IOException;
0032:        import java.io.StringReader;
0033:        import java.net.MalformedURLException;
0034:        import java.net.URISyntaxException;
0035:        import java.util.ArrayList;
0036:        import java.util.Arrays;
0037:        import java.util.Collection;
0038:        import java.util.HashMap;
0039:        import java.util.HashSet;
0040:        import java.util.Iterator;
0041:        import java.util.List;
0042:        import java.util.ListIterator;
0043:        import java.util.Map;
0044:        import java.util.Properties;
0045:        import java.util.Set;
0046:        import java.util.Map.Entry;
0047:        import java.util.logging.Level;
0048:
0049:        import javax.jbi.management.DeploymentServiceMBean;
0050:        import javax.management.Attribute;
0051:        import javax.management.AttributeList;
0052:        import javax.management.AttributeNotFoundException;
0053:        import javax.management.Descriptor;
0054:        import javax.management.InstanceNotFoundException;
0055:        import javax.management.IntrospectionException;
0056:        import javax.management.InvalidAttributeValueException;
0057:        import javax.management.MBeanAttributeInfo;
0058:        import javax.management.MBeanException;
0059:        import javax.management.MBeanInfo;
0060:        import javax.management.MBeanServer;
0061:        import javax.management.MBeanServerConnection;
0062:        import javax.management.MalformedObjectNameException;
0063:        import javax.management.ObjectName;
0064:        import javax.management.ReflectionException;
0065:        import javax.management.RuntimeMBeanException;
0066:        import javax.management.RuntimeOperationsException;
0067:        import javax.management.modelmbean.ModelMBeanAttributeInfo;
0068:        import javax.management.openmbean.CompositeData;
0069:        import javax.management.openmbean.CompositeDataSupport;
0070:        import javax.management.openmbean.CompositeType;
0071:        import javax.management.openmbean.OpenDataException;
0072:        import javax.management.openmbean.OpenType;
0073:        import javax.management.openmbean.SimpleType;
0074:        import javax.management.openmbean.TabularData;
0075:        import javax.management.openmbean.TabularDataSupport;
0076:        import javax.management.openmbean.TabularType;
0077:        import javax.xml.parsers.ParserConfigurationException;
0078:
0079:        import org.xml.sax.SAXException;
0080:
0081:        import com.sun.esb.management.api.administration.AdministrationService;
0082:        import com.sun.esb.management.api.configuration.ConfigurationService;
0083:        import com.sun.esb.management.api.deployment.DeploymentService;
0084:        import com.sun.esb.management.api.installation.InstallationService;
0085:        import com.sun.esb.management.api.performance.PerformanceMeasurementService;
0086:        import com.sun.esb.management.api.runtime.RuntimeManagementService;
0087:        import com.sun.esb.management.impl.administration.AdministrationServiceImpl;
0088:        import com.sun.esb.management.impl.configuration.ConfigurationServiceImpl;
0089:        import com.sun.esb.management.impl.deployment.DeploymentServiceImpl;
0090:        import com.sun.esb.management.impl.installation.InstallationServiceImpl;
0091:        import com.sun.esb.management.impl.performance.PerformanceMeasurementServiceImpl;
0092:        import com.sun.esb.management.impl.runtime.RuntimeManagementServiceImpl;
0093:        import com.sun.jbi.ComponentInfo;
0094:        import com.sun.jbi.ComponentQuery;
0095:        import com.sun.jbi.ComponentState;
0096:        import com.sun.jbi.ComponentType;
0097:        import com.sun.jbi.EnvironmentContext;
0098:        import com.sun.jbi.management.MBeanNames;
0099:        import com.sun.jbi.management.MBeanNames.ComponentServiceType;
0100:        import com.sun.jbi.management.MBeanNames.ServiceName;
0101:        import com.sun.jbi.management.MBeanNames.ServiceType;
0102:        import com.sun.jbi.platform.PlatformContext;
0103:        import com.sun.jbi.ui.common.I18NBundle;
0104:        import com.sun.jbi.ui.common.JBIArchive;
0105:        import com.sun.jbi.ui.common.JBIComponentInfo;
0106:        import com.sun.jbi.ui.common.JBIJMXObjectNames;
0107:        import com.sun.jbi.ui.common.JBIManagementMessage;
0108:        import com.sun.jbi.ui.common.JBIRemoteException;
0109:        import com.sun.jbi.ui.common.JBIResultXmlBuilder;
0110:        import com.sun.jbi.ui.common.ServiceAssemblyInfo;
0111:        import com.sun.jbi.ui.common.ServiceUnitInfo;
0112:        import com.sun.jbi.ui.common.ToolsLogManager;
0113:        import com.sun.jbi.ui.common.Util;
0114:        import com.sun.jbi.ui.runtime.ComponentConfiguration;
0115:        import com.sun.jbi.ui.runtime.ComponentConfigurationParser;
0116:        import com.sun.jbi.ui.runtime.DisplayInformation;
0117:        import com.sun.jbi.ui.runtime.GenericsSupport;
0118:        import com.sun.jbi.util.ComponentConfigurationHelper;
0119:
0120:        /**
0121:         * Base class for Implementation of the UI MBean interface.
0122:         * 
0123:         * @author graj
0124:         */
0125:        public class AbstractUIMBeanImpl {
0126:
0127:            protected static final String STARTED_STATE = "Started";
0128:
0129:            protected static final String RUNNING_STATE = "Running";
0130:
0131:            private static final String EQUAL = "=";
0132:
0133:            private static final String COLON = ":";
0134:
0135:            private static final String COMMA = ",";
0136:
0137:            private static final char PASSWORD_MASK_CHARACTER = '*';
0138:
0139:            private static final String ENVIRONMENT_VARIABLES_KEY = "EnvironmentVariables";
0140:
0141:            protected static final String COMPONENT_CONFIG_INSTANCE_ERROR_KEY = "com.sun.jbi.cluster.instance.error";
0142:
0143:            /**
0144:             * any framework state
0145:             */
0146:            protected static final int ANY_FRAMEWORK_COMPONENT_STATE = -1;
0147:
0148:            /**
0149:             * sa started state
0150:             */
0151:            protected static final String FRAMEWORK_SA_STARTED_STATE = DeploymentServiceMBean.STARTED;
0152:
0153:            /**
0154:             * sa stopped state
0155:             */
0156:            protected static final String FRAMEWORK_SA_STOPPED_STATE = DeploymentServiceMBean.STOPPED;
0157:
0158:            /**
0159:             * sa shutdown state
0160:             */
0161:            protected static final String FRAMEWORK_SA_SHUTDOWN_STATE = DeploymentServiceMBean.SHUTDOWN;
0162:
0163:            /**
0164:             * any state
0165:             */
0166:            protected static final String FRAMEWORK_SA_ANY_STATE = "any";
0167:
0168:            /**
0169:             * state
0170:             */
0171:            protected static final String FRAMEWORK_SU_STARTED_STATE = "started";
0172:
0173:            /**
0174:             * state
0175:             */
0176:            protected static final String FRAMEWORK_SU_STOPPED_STATE = "stopped";
0177:
0178:            /**
0179:             * state
0180:             */
0181:            protected static final String FRAMEWORK_SU_SHUTDOWN_STATE = "shutdown";
0182:
0183:            /**
0184:             * state
0185:             */
0186:            protected static final String FRAMEWORK_SU_UNKNOWN_STATE = "unknown";
0187:
0188:            /** i18n */
0189:            private static I18NBundle sI18NBundle = null;
0190:
0191:            /** Jbi Environment context. */
0192:            protected EnvironmentContext mEnvContext;
0193:
0194:            /** Component Configuration helper */
0195:            protected ComponentConfigurationHelper mCfgHlpr;
0196:
0197:            protected transient AdministrationService administrationService;
0198:
0199:            protected transient ConfigurationService configurationService;
0200:
0201:            protected transient DeploymentService deploymentService;
0202:
0203:            protected transient InstallationService installationService;
0204:
0205:            protected transient RuntimeManagementService runtimeManagementService;
0206:
0207:            protected transient PerformanceMeasurementService performanceMeasurementService;
0208:
0209:            /**
0210:             * constructor
0211:             * 
0212:             * @param anEnvContext
0213:             *            context
0214:             */
0215:            public AbstractUIMBeanImpl(EnvironmentContext anEnvContext) {
0216:                this .mEnvContext = anEnvContext;
0217:                this .mCfgHlpr = new ComponentConfigurationHelper();
0218:            }
0219:
0220:            /**
0221:             * Get the Administration Service
0222:             * 
0223:             * @return administration Service
0224:             */
0225:            protected AdministrationService getAdministrationService() {
0226:                if (this .administrationService == null) {
0227:                    MBeanServer server = this .mEnvContext.getMBeanServer();
0228:                    boolean isRemoteConnection = false;
0229:                    this .administrationService = new AdministrationServiceImpl(
0230:                            server, isRemoteConnection);
0231:                }
0232:                return this .administrationService;
0233:            }
0234:
0235:            /**
0236:             * Get the Configuration Service
0237:             * 
0238:             * @return configuration Service
0239:             */
0240:            protected ConfigurationService getConfigurationService() {
0241:                if (this .configurationService == null) {
0242:                    boolean isRemoteConnection = false;
0243:                    MBeanServer server = this .mEnvContext.getMBeanServer();
0244:                    this .configurationService = new ConfigurationServiceImpl(
0245:                            server, isRemoteConnection);
0246:                }
0247:                return this .configurationService;
0248:            }
0249:
0250:            /**
0251:             * Get the Deployment Service
0252:             * 
0253:             * @return deployment Service
0254:             */
0255:            protected DeploymentService getDeploymentService() {
0256:                if (this .deploymentService == null) {
0257:                    MBeanServer server = this .mEnvContext.getMBeanServer();
0258:                    boolean isRemoteConnection = false;
0259:                    this .deploymentService = new DeploymentServiceImpl(server,
0260:                            isRemoteConnection);
0261:                }
0262:                return this .deploymentService;
0263:            }
0264:
0265:            /**
0266:             * Get the Installation Service
0267:             * 
0268:             * @return installation Service
0269:             */
0270:            protected InstallationService getInstallationService() {
0271:                if (this .installationService == null) {
0272:                    MBeanServer server = this .mEnvContext.getMBeanServer();
0273:                    boolean isRemoteConnection = false;
0274:                    this .installationService = new InstallationServiceImpl(
0275:                            server, isRemoteConnection);
0276:                }
0277:                return this .installationService;
0278:            }
0279:
0280:            /**
0281:             * Get the Runtime management Service
0282:             * 
0283:             * @return Runtime management Service
0284:             */
0285:            protected RuntimeManagementService getRuntimeManagementService() {
0286:                if (this .runtimeManagementService == null) {
0287:                    MBeanServer server = this .mEnvContext.getMBeanServer();
0288:                    boolean isRemoteConnection = false;
0289:                    this .runtimeManagementService = new RuntimeManagementServiceImpl(
0290:                            server, isRemoteConnection);
0291:                }
0292:                return this .runtimeManagementService;
0293:            }
0294:
0295:            /**
0296:             * Get the Performance Measurement Service
0297:             * 
0298:             * @return Performance Measurement Service
0299:             */
0300:            protected PerformanceMeasurementService getPerformanceMeasurementService() {
0301:                if (this .performanceMeasurementService == null) {
0302:                    MBeanServer server = this .mEnvContext.getMBeanServer();
0303:                    boolean isRemoteConnection = false;
0304:                    this .performanceMeasurementService = new PerformanceMeasurementServiceImpl(
0305:                            server, isRemoteConnection);
0306:                }
0307:                return this .performanceMeasurementService;
0308:            }
0309:
0310:            /**
0311:             * logs the message
0312:             * 
0313:             * @param aMsg
0314:             *            message string
0315:             */
0316:            public static void log(String aMsg) {
0317:
0318:                ToolsLogManager.getRuntimeLogger().info(aMsg);
0319:            }
0320:
0321:            /**
0322:             * logs the message
0323:             * 
0324:             * @param aMsg
0325:             *            message string
0326:             */
0327:            public static void logDebug(String aMsg) {
0328:                ToolsLogManager.getRuntimeLogger().fine(aMsg);
0329:            }
0330:
0331:            /**
0332:             * logs the message
0333:             * 
0334:             * @param ex
0335:             *            exception
0336:             */
0337:            public static void logDebug(Exception ex) {
0338:                ToolsLogManager.getRuntimeLogger().log(Level.FINER,
0339:                        ex.getMessage(), ex);
0340:            }
0341:
0342:            /**
0343:             * logs errors
0344:             * 
0345:             * @param ex
0346:             *            exception
0347:             */
0348:            public static void logError(Exception ex) {
0349:                ToolsLogManager.getRuntimeLogger().log(Level.SEVERE,
0350:                        ex.getMessage(), ex);
0351:            }
0352:
0353:            /**
0354:             * logs warnings
0355:             * 
0356:             * @param ex
0357:             *            exception
0358:             */
0359:            public static void logWarning(Exception ex) {
0360:                ToolsLogManager.getRuntimeLogger().log(Level.WARNING,
0361:                        ex.getMessage(), ex);
0362:            }
0363:
0364:            /**
0365:             * @return the platform context
0366:             */
0367:            protected PlatformContext getPlatformContext() {
0368:                PlatformContext platformContext = null;
0369:                EnvironmentContext context = getEnvironmentContext();
0370:                if (context != null) {
0371:                    platformContext = context.getPlatformContext();
0372:                }
0373:                return platformContext;
0374:            }
0375:
0376:            /**
0377:             * @return the EnvironmentContext
0378:             */
0379:            protected static EnvironmentContext getEnvironmentContext() {
0380:                return com.sun.jbi.util.EnvironmentAccess.getContext();
0381:            }
0382:
0383:            /**
0384:             * gives the I18N bundle
0385:             * 
0386:             * @return I18NBundle object
0387:             */
0388:            protected static I18NBundle getI18NBundle() {
0389:                // lazzy initialize the JBI Client
0390:                if (sI18NBundle == null) {
0391:                    sI18NBundle = new I18NBundle(
0392:                            "com.sun.jbi.ui.runtime.mbeans");
0393:                }
0394:                return sI18NBundle;
0395:            }
0396:
0397:            /**
0398:             * Invokes the mbean and retrieves the attribute value
0399:             * 
0400:             * @param mbeanServer
0401:             *            connection to MBean Server
0402:             * @param objectName
0403:             *            object name
0404:             * @param attributeName
0405:             *            attribute name
0406:             * @return the value of the attribute
0407:             * @throws JBIRemoteException
0408:             *             on error
0409:             */
0410:            protected Object getAttributeValue(MBeanServer mbeanServer,
0411:                    ObjectName objectName, String attributeName)
0412:                    throws JBIRemoteException {
0413:
0414:                Object result = null;
0415:                try {
0416:                    result = mbeanServer
0417:                            .getAttribute(objectName, attributeName);
0418:                } catch (AttributeNotFoundException e) {
0419:                    throw new JBIRemoteException(e);
0420:                } catch (InstanceNotFoundException e) {
0421:                    throw new JBIRemoteException(e);
0422:                } catch (ReflectionException e) {
0423:                    throw new JBIRemoteException(e);
0424:                } catch (MBeanException mbeanEx) {
0425:                    throw JBIRemoteException.filterJmxExceptions(mbeanEx);
0426:                } catch (RuntimeMBeanException rtEx) {
0427:                    throw JBIRemoteException.filterJmxExceptions(rtEx);
0428:                } catch (RuntimeOperationsException rtOpEx) {
0429:                    throw JBIRemoteException.filterJmxExceptions(rtOpEx);
0430:                } catch (Exception ex) {
0431:                    throw JBIRemoteException.filterJmxExceptions(ex);
0432:                }
0433:
0434:                return result;
0435:            }
0436:
0437:            /**
0438:             * Invokes the mbean and retrieves the attribute value
0439:             * 
0440:             * @param objectName
0441:             *            object name
0442:             * @param attributeName
0443:             *            attribute name
0444:             * @return the value of the attribute
0445:             * @throws JBIRemoteException
0446:             *             on error
0447:             */
0448:            protected Object getAttributeValue(ObjectName objectName,
0449:                    String attributeName) throws JBIRemoteException {
0450:
0451:                MBeanServer mbeanServer = this .mEnvContext.getMBeanServer();
0452:                Object result = null;
0453:                try {
0454:                    result = mbeanServer
0455:                            .getAttribute(objectName, attributeName);
0456:                } catch (AttributeNotFoundException e) {
0457:                    throw new JBIRemoteException(e);
0458:                } catch (InstanceNotFoundException e) {
0459:                    throw new JBIRemoteException(e);
0460:                } catch (ReflectionException e) {
0461:                    throw new JBIRemoteException(e);
0462:                } catch (MBeanException mbeanEx) {
0463:                    throw JBIRemoteException.filterJmxExceptions(mbeanEx);
0464:                } catch (RuntimeMBeanException rtEx) {
0465:                    throw JBIRemoteException.filterJmxExceptions(rtEx);
0466:                } catch (RuntimeOperationsException rtOpEx) {
0467:                    throw JBIRemoteException.filterJmxExceptions(rtOpEx);
0468:                } catch (Exception ex) {
0469:                    throw JBIRemoteException.filterJmxExceptions(ex);
0470:                }
0471:                return result;
0472:            }
0473:
0474:            /**
0475:             * Invokes the mbean and retrieves the attribute value
0476:             * 
0477:             * @param objectName
0478:             *            object name
0479:             * @param attributeName
0480:             *            attribute name
0481:             * @return the value of the attribute
0482:             * @throws JBIRemoteException
0483:             *             on error
0484:             */
0485:            protected void setAttributeValue(ObjectName objectName,
0486:                    String attributeName, Object attributeValue)
0487:                    throws JBIRemoteException {
0488:
0489:                MBeanServer mbeanServer = this .mEnvContext.getMBeanServer();
0490:                Attribute attribute = null;
0491:                attribute = new Attribute(attributeName, attributeValue);
0492:
0493:                try {
0494:                    mbeanServer.setAttribute(objectName, attribute);
0495:                } catch (InstanceNotFoundException e) {
0496:                    throw new JBIRemoteException(e);
0497:                } catch (AttributeNotFoundException e) {
0498:                    throw new JBIRemoteException(e);
0499:                } catch (InvalidAttributeValueException e) {
0500:                    throw new JBIRemoteException(e);
0501:                } catch (ReflectionException e) {
0502:                    throw new JBIRemoteException(e);
0503:                } catch (MBeanException mbeanEx) {
0504:                    throw JBIRemoteException.filterJmxExceptions(mbeanEx);
0505:                } catch (RuntimeMBeanException rtEx) {
0506:                    throw JBIRemoteException.filterJmxExceptions(rtEx);
0507:                } catch (RuntimeOperationsException rtOpEx) {
0508:                    throw JBIRemoteException.filterJmxExceptions(rtOpEx);
0509:                } catch (Exception ex) {
0510:                    throw JBIRemoteException.filterJmxExceptions(ex);
0511:                }
0512:            }
0513:
0514:            /**
0515:             * invokes the operation on mbean
0516:             * 
0517:             * @return result object
0518:             * @param objectName
0519:             *            object name
0520:             * @param operationName
0521:             *            operation name
0522:             * @param params
0523:             *            parameters
0524:             * @param signature
0525:             *            signature of the parameters
0526:             * @throws JBIRemoteException
0527:             *             on user error
0528:             */
0529:            protected Object invokeMBeanOperation(ObjectName objectName,
0530:                    String operationName, Object[] params, String[] signature)
0531:                    throws JBIRemoteException {
0532:                // TODO: Add error code and message to each exception
0533:                MBeanServer mbeanServer = this .mEnvContext.getMBeanServer();
0534:                Object result = null;
0535:
0536:                try {
0537:
0538:                    result = mbeanServer.invoke(objectName, operationName,
0539:                            params, signature);
0540:
0541:                } catch (InstanceNotFoundException notFoundEx) {
0542:                    throw new JBIRemoteException(notFoundEx);
0543:                } catch (ReflectionException rEx) {
0544:                    throw new JBIRemoteException(rEx);
0545:                } catch (MBeanException mbeanEx) {
0546:                    throw JBIRemoteException.filterJmxExceptions(mbeanEx);
0547:                } catch (RuntimeMBeanException rtEx) {
0548:                    throw JBIRemoteException.filterJmxExceptions(rtEx);
0549:                } catch (RuntimeOperationsException rtOpEx) {
0550:                    throw JBIRemoteException.filterJmxExceptions(rtOpEx);
0551:                } catch (Exception ex) {
0552:                    throw JBIRemoteException.filterJmxExceptions(ex);
0553:                }
0554:
0555:                return result;
0556:
0557:            }
0558:
0559:            /**
0560:             * invokes the operation on mbean
0561:             * 
0562:             * @return result object
0563:             * @param objectName
0564:             *            object name
0565:             * @param operationName
0566:             *            operation name
0567:             * @param param
0568:             *            operation param of type String
0569:             * @throws JBIRemoteException
0570:             *             on user error
0571:             */
0572:            protected Object invokeMBeanOperation(ObjectName objectName,
0573:                    String operationName, String param)
0574:                    throws JBIRemoteException {
0575:                Object[] params = new Object[1];
0576:                params[0] = param;
0577:
0578:                String[] signature = new String[1];
0579:                signature[0] = "java.lang.String";
0580:
0581:                return invokeMBeanOperation(objectName, operationName, params,
0582:                        signature);
0583:
0584:            }
0585:
0586:            /**
0587:             * invokes the operation on mbean
0588:             * 
0589:             * @return result object
0590:             * @param objectName
0591:             *            object name
0592:             * @param operationName
0593:             *            operation name
0594:             * @throws JBIRemoteException
0595:             *             on user error
0596:             */
0597:            protected Object invokeMBeanOperation(ObjectName objectName,
0598:                    String operationName) throws JBIRemoteException {
0599:                Object[] params = new Object[0];
0600:
0601:                String[] signature = new String[0];
0602:                return invokeMBeanOperation(objectName, operationName, params,
0603:                        signature);
0604:
0605:            }
0606:
0607:            /**
0608:             * invokes the operation on mbean
0609:             * 
0610:             * @return result object
0611:             * @param attributeName
0612:             *            attribute name
0613:             * @param objectName
0614:             *            object name
0615:             * @throws JBIRemoteException
0616:             *             on user error
0617:             */
0618:            protected Object getMBeanAttribute(ObjectName objectName,
0619:                    String attributeName) throws JBIRemoteException {
0620:                // TODO: Add error code and message to each exception
0621:                MBeanServer mbeanServer = this .mEnvContext.getMBeanServer();
0622:                Object result = null;
0623:
0624:                try {
0625:
0626:                    result = mbeanServer
0627:                            .getAttribute(objectName, attributeName);
0628:
0629:                } catch (InstanceNotFoundException notFoundEx) {
0630:                    throw new JBIRemoteException(notFoundEx);
0631:                } catch (ReflectionException rEx) {
0632:                    throw new JBIRemoteException(rEx);
0633:                } catch (MBeanException mbeanEx) {
0634:                    throw JBIRemoteException.filterJmxExceptions(mbeanEx);
0635:                } catch (RuntimeMBeanException rtEx) {
0636:                    throw JBIRemoteException.filterJmxExceptions(rtEx);
0637:                } catch (RuntimeOperationsException rtOpEx) {
0638:                    throw JBIRemoteException.filterJmxExceptions(rtOpEx);
0639:                } catch (Exception ex) {
0640:                    throw JBIRemoteException.filterJmxExceptions(ex);
0641:                }
0642:
0643:                return result;
0644:
0645:            }
0646:
0647:            /**
0648:             * This method is used to get MBeanInfo for the given mbean object
0649:             * @return MBeanInfo object
0650:             * @param mbeanName the objectname for the mbean
0651:             * @throws JBIRemoteException 
0652:             */
0653:            protected MBeanInfo getMBeanInfo(ObjectName mbeanName)
0654:                    throws JBIRemoteException {
0655:
0656:                MBeanServer mbeanServer = this .mEnvContext.getMBeanServer();
0657:
0658:                try {
0659:
0660:                    return (MBeanInfo) mbeanServer.getMBeanInfo(mbeanName);
0661:
0662:                } catch (InstanceNotFoundException notFoundEx) {
0663:                    throw new JBIRemoteException(notFoundEx);
0664:                } catch (ReflectionException rEx) {
0665:                    throw new JBIRemoteException(rEx);
0666:                } catch (RuntimeMBeanException rtEx) {
0667:                    throw JBIRemoteException.filterJmxExceptions(rtEx);
0668:                } catch (RuntimeOperationsException rtOpEx) {
0669:                    throw JBIRemoteException.filterJmxExceptions(rtOpEx);
0670:                } catch (Exception ex) {
0671:                    throw JBIRemoteException.filterJmxExceptions(ex);
0672:                }
0673:
0674:            }
0675:
0676:            /**
0677:             * Test whether an mbean is registered.
0678:             * 
0679:             * @param objectName
0680:             * @return true when the mbean is registered, false otherwise
0681:             * @throws JBIRemoteException
0682:             */
0683:            boolean isMBeanRegistered(ObjectName objectName)
0684:                    throws JBIRemoteException {
0685:                boolean result = false;
0686:                MBeanServer mbeanServer = this .mEnvContext.getMBeanServer();
0687:                try {
0688:                    result = mbeanServer.isRegistered(objectName);
0689:                } catch (RuntimeException exception) {
0690:                    throw JBIRemoteException.filterJmxExceptions(exception);
0691:                }
0692:
0693:                return result;
0694:            }
0695:
0696:            /**
0697:             * Test whether it is a valid target.
0698:             * 
0699:             * @param objectName
0700:             * @return true when the mbean is registered, false otherwise
0701:             * @throws JBIRemoteException
0702:             */
0703:            boolean isValidTarget(ObjectName objectName)
0704:                    throws JBIRemoteException {
0705:                boolean result = false;
0706:                MBeanServer mbeanServer = this .mEnvContext.getMBeanServer();
0707:                try {
0708:                    result = mbeanServer.isRegistered(objectName);
0709:                } catch (RuntimeException exception) {
0710:                }
0711:
0712:                return result;
0713:            }
0714:
0715:            /**
0716:             * invokes the operation on mbean
0717:             * 
0718:             * @param attributeValue
0719:             *            attrbute name
0720:             * @param attributeName
0721:             *            attribute value
0722:             * @param objectName
0723:             *            object name
0724:             * @throws JBIRemoteException
0725:             *             on user error
0726:             */
0727:            protected void setMBeanAttribute(ObjectName objectName,
0728:                    String attributeName, Object attributeValue)
0729:                    throws JBIRemoteException {
0730:                MBeanServer mbeanServer = this .mEnvContext.getMBeanServer();
0731:
0732:                try {
0733:                    Attribute attr = new Attribute(attributeName,
0734:                            attributeValue);
0735:                    mbeanServer.setAttribute(objectName, attr);
0736:                } catch (InstanceNotFoundException notFoundEx) {
0737:                    throw new JBIRemoteException(notFoundEx);
0738:                } catch (ReflectionException rEx) {
0739:                    throw new JBIRemoteException(rEx);
0740:                } catch (MBeanException mbeanEx) {
0741:                    throw JBIRemoteException.filterJmxExceptions(mbeanEx);
0742:                } catch (RuntimeMBeanException rtEx) {
0743:                    throw JBIRemoteException.filterJmxExceptions(rtEx);
0744:                } catch (RuntimeOperationsException rtOpEx) {
0745:                    throw JBIRemoteException.filterJmxExceptions(rtOpEx);
0746:                } catch (Exception ex) {
0747:                    throw JBIRemoteException.filterJmxExceptions(ex);
0748:                }
0749:
0750:            }
0751:
0752:            /**
0753:             * set the specified attribute values on the mbean attributes
0754:             * 
0755:             * @param attrList
0756:             *            list of attributes
0757:             * @param objectName
0758:             *            object name
0759:             * @throws JBIRemoteException
0760:             *             on user error
0761:             */
0762:            protected void setMBeanAttributes(ObjectName objectName,
0763:                    AttributeList attrList) throws JBIRemoteException {
0764:                MBeanServer mbeanServer = this .mEnvContext.getMBeanServer();
0765:
0766:                try {
0767:                    mbeanServer.setAttributes(objectName, attrList);
0768:                } catch (InstanceNotFoundException notFoundEx) {
0769:                    throw new JBIRemoteException(notFoundEx);
0770:                } catch (ReflectionException rEx) {
0771:                    throw new JBIRemoteException(rEx);
0772:                } catch (RuntimeMBeanException rtEx) {
0773:                    throw JBIRemoteException.filterJmxExceptions(rtEx);
0774:                } catch (RuntimeOperationsException rtOpEx) {
0775:                    throw JBIRemoteException.filterJmxExceptions(rtOpEx);
0776:                } catch (Exception ex) {
0777:                    throw JBIRemoteException.filterJmxExceptions(ex);
0778:                }
0779:
0780:            }
0781:
0782:            /**
0783:             * set the specified attribute values on the mbean attributes
0784:             * 
0785:             * @param attrList
0786:             *            list of attributes
0787:             * @param objectName
0788:             *            object name
0789:             * @return management message response from setConfigurationAttributes
0790:             * @throws JBIRemoteException
0791:             *             on user error
0792:             */
0793:            protected String setMBeanConfigAttributes(ObjectName objectName,
0794:                    AttributeList attrList) throws JBIRemoteException {
0795:                MBeanServer mbeanServer = this .mEnvContext.getMBeanServer();
0796:
0797:                return this .setMBeanConfigAttributes(mbeanServer, objectName,
0798:                        attrList);
0799:            }
0800:
0801:            /**
0802:             * set the specified attribute values on the mbean attributes
0803:             * 
0804:             * @param MBeanServer
0805:             *            the MBean server to use
0806:             * @param attrList
0807:             *            list of attributes
0808:             * @param objectName
0809:             *            object name
0810:             * @return management message response from setConfigurationAttributes
0811:             * @throws JBIRemoteException
0812:             *             on user error
0813:             */
0814:            protected String setMBeanConfigAttributes(
0815:                    MBeanServerConnection mbeanServer, ObjectName objectName,
0816:                    AttributeList attrList) throws JBIRemoteException {
0817:                try {
0818:                    return ((String) mbeanServer.invoke(objectName,
0819:                            "setConfigurationAttributes",
0820:                            new Object[] { attrList },
0821:                            new String[] { "javax.management.AttributeList" }));
0822:                } catch (InstanceNotFoundException notFoundEx) {
0823:                    throw new JBIRemoteException(notFoundEx);
0824:                } catch (ReflectionException rEx) {
0825:                    throw new JBIRemoteException(rEx);
0826:                } catch (RuntimeMBeanException rtEx) {
0827:                    throw JBIRemoteException.filterJmxExceptions(rtEx);
0828:                } catch (RuntimeOperationsException rtOpEx) {
0829:                    throw JBIRemoteException.filterJmxExceptions(rtOpEx);
0830:                } catch (Exception ex) {
0831:                    throw JBIRemoteException.filterJmxExceptions(ex);
0832:                }
0833:
0834:            }
0835:
0836:            /**
0837:             * set the specified attribute values on the mbean attributes
0838:             * 
0839:             * @param attrList
0840:             *            list of attributes
0841:             * @param objectName
0842:             *            object name
0843:             * @throws JBIRemoteException
0844:             *             on user error
0845:             */
0846:            protected AttributeList setMBeanAttributes(
0847:                    MBeanServerConnection mbeanServer, ObjectName objectName,
0848:                    AttributeList attrList) throws JBIRemoteException {
0849:
0850:                try {
0851:                    return mbeanServer.setAttributes(objectName, attrList);
0852:                } catch (InstanceNotFoundException notFoundEx) {
0853:                    throw new JBIRemoteException(notFoundEx);
0854:                } catch (ReflectionException rEx) {
0855:                    throw new JBIRemoteException(rEx);
0856:                } catch (RuntimeMBeanException rtEx) {
0857:                    throw JBIRemoteException.filterJmxExceptions(rtEx);
0858:                } catch (RuntimeOperationsException rtOpEx) {
0859:                    throw JBIRemoteException.filterJmxExceptions(rtOpEx);
0860:                } catch (Exception ex) {
0861:                    throw JBIRemoteException.filterJmxExceptions(ex);
0862:                }
0863:
0864:            }
0865:
0866:            /**
0867:             * Get the config extension MBean attribute values
0868:             * 
0869:             * @param objectName
0870:             * @return
0871:             * @throws JBIRemoteException
0872:             */
0873:            protected Properties getConfigurationAttributeValues(
0874:                    ObjectName objectName) throws JBIRemoteException {
0875:                Properties properties = new Properties();
0876:                MBeanServer mbeanServer = this .mEnvContext.getMBeanServer();
0877:                try {
0878:                    properties = this .getMBeanAttributeValues(mbeanServer,
0879:                            objectName);
0880:                } catch (JBIRemoteException exception) {
0881:                    properties = new Properties();
0882:                    JBIManagementMessage mgmtMsg = null;
0883:                    mgmtMsg = exception.extractJBIManagementMessage();
0884:                    properties.setProperty(COMPONENT_CONFIG_INSTANCE_ERROR_KEY,
0885:                            mgmtMsg.getMessage());
0886:
0887:                }
0888:
0889:                return properties;
0890:            }
0891:
0892:            /**
0893:             * Get the attributes on the MBean
0894:             * 
0895:             * @param mbeanServer
0896:             * @param objectName
0897:             * @return
0898:             * @throws JBIRemoteException
0899:             */
0900:            protected Properties getMBeanAttributeValues(
0901:                    MBeanServer mbeanServer, ObjectName objectName)
0902:                    throws JBIRemoteException {
0903:                Properties properties = new Properties();
0904:                List<String> keyList = new ArrayList<String>();
0905:                MBeanInfo mbeanInfo = null;
0906:                try {
0907:                    mbeanInfo = mbeanServer.getMBeanInfo(objectName);
0908:                    MBeanAttributeInfo[] mbeanAttrInfoArray = mbeanInfo
0909:                            .getAttributes();
0910:                    for (MBeanAttributeInfo attributeInfo : mbeanAttrInfoArray) {
0911:                        String key = attributeInfo.getName();
0912:                        if (key != null) {
0913:                            Object value = this .getAttributeValue(objectName,
0914:                                    key);
0915:                            if (value != null) {
0916:                                // -- Nikita : Use getApplicationVariables to get application
0917:                                //             variable values
0918:                                if (key.equals("ApplicationVariables")) {
0919:                                    //value = this
0920:                                    //         .convertToEnvironmentVariableString(value);
0921:                                    continue;
0922:                                }
0923:
0924:                                // -- Nikita : Use getApplicationConfigurations to get application
0925:                                //             configuration values
0926:                                if (key.equals("ApplicationConfigurations")) {
0927:                                    //value = this
0928:                                    //         .convertToEnvironmentVariableString(value);
0929:                                    continue;
0930:                                }
0931:                                properties.put(key, value + "");
0932:                                keyList.add(key);
0933:                            }
0934:                        }
0935:                    }
0936:                } catch (InstanceNotFoundException e) {
0937:                    throw new JBIRemoteException(e);
0938:                } catch (IntrospectionException e) {
0939:                    throw new JBIRemoteException(e);
0940:                } catch (ReflectionException e) {
0941:                    throw new JBIRemoteException(e);
0942:                }
0943:
0944:                return properties;
0945:            }
0946:
0947:            /**
0948:             * Get the attributes on the MBean
0949:             * 
0950:             * @param mbeanServer
0951:             * @param objectName
0952:             * @return
0953:             * @throws JBIRemoteException
0954:             */
0955:            protected Map<String, Descriptor> getConfigurationDescriptors(
0956:                    ObjectName objectName) throws JBIRemoteException {
0957:                Map<String, Descriptor> descrMap = new HashMap();
0958:                MBeanServer mbeanServer = mEnvContext.getMBeanServer();
0959:                MBeanInfo mbeanInfo = null;
0960:                try {
0961:                    mbeanInfo = mbeanServer.getMBeanInfo(objectName);
0962:                    MBeanAttributeInfo[] mbeanAttrInfoArray = mbeanInfo
0963:                            .getAttributes();
0964:
0965:                    for (MBeanAttributeInfo attributeInfo : mbeanAttrInfoArray) {
0966:                        if (attributeInfo instanceof  ModelMBeanAttributeInfo) {
0967:                            ModelMBeanAttributeInfo modelAttrInfo = (ModelMBeanAttributeInfo) attributeInfo;
0968:                            descrMap.put(modelAttrInfo.getName(), modelAttrInfo
0969:                                    .getDescriptor());
0970:                        }
0971:                    }
0972:                } catch (InstanceNotFoundException e) {
0973:                    throw new JBIRemoteException(e);
0974:                } catch (IntrospectionException e) {
0975:                    throw new JBIRemoteException(e);
0976:                } catch (ReflectionException e) {
0977:                    throw new JBIRemoteException(e);
0978:                }
0979:
0980:                return descrMap;
0981:            }
0982:
0983:            /**
0984:             * invokes the operation on mbean
0985:             * 
0986:             * @return Attribute List of the mbean to set
0987:             * @param objectName
0988:             *            mbean name
0989:             * @param params
0990:             *            a name value pair properties object contains the attribute
0991:             *            name and its value as string.
0992:             * @throws JBIRemoteException
0993:             *             on user error
0994:             */
0995:            protected AttributeList constructMBeanAttributes(
0996:                    ObjectName objectName, Properties params)
0997:                    throws JBIRemoteException {
0998:
0999:                MBeanServer mbeanServer = this .mEnvContext.getMBeanServer();
1000:                AttributeList attrList = new AttributeList();
1001:                try {
1002:                    MBeanInfo mbeanInfo = mbeanServer.getMBeanInfo(objectName);
1003:                    MBeanAttributeInfo[] mbeanAttrInfoArray = mbeanInfo
1004:                            .getAttributes();
1005:                    Map attribInfoMap = new HashMap();
1006:                    for (int i = 0; i < mbeanAttrInfoArray.length; ++i) {
1007:                        MBeanAttributeInfo attrInfo = mbeanAttrInfoArray[i];
1008:                        attribInfoMap.put(attrInfo.getName(), attrInfo);
1009:                    }
1010:
1011:                    for (Iterator itr = params.keySet().iterator(); itr
1012:                            .hasNext();) {
1013:                        String attrName = (String) itr.next();
1014:                        String stringValue = params.getProperty(attrName);
1015:                        Object attrValueObj = null;
1016:
1017:                        // We can't validate properties if we don't have MBean attr info
1018:                        if (attribInfoMap.isEmpty()) {
1019:                            attrValueObj = stringValue;
1020:                        } else {
1021:                            MBeanAttributeInfo attrInfo = (MBeanAttributeInfo) attribInfoMap
1022:                                    .get(attrName);
1023:                            if (attrInfo == null) {
1024:                                String[] args = { attrName };
1025:                                Exception exception = this 
1026:                                        .createManagementException(
1027:                                                "ui.mbean.install.config.mbean.attrib.info.not.found",
1028:                                                args, null);
1029:                                throw new JBIRemoteException(exception);
1030:
1031:                            }
1032:
1033:                            String type = attrInfo.getType();
1034:                            try {
1035:                                // construct the value object using reflection.
1036:                                attrValueObj = Util.newInstance(type,
1037:                                        stringValue);
1038:                            } catch (Exception ex) {
1039:                                String[] args = { stringValue, type, attrName };
1040:                                Exception exception = this 
1041:                                        .createManagementException(
1042:                                                "ui.mbean.install.config.mbean.attrib.type.convertion.error",
1043:                                                args, ex);
1044:                                throw new JBIRemoteException(exception);
1045:
1046:                            }
1047:                        }
1048:
1049:                        Attribute attr = new Attribute(attrName, attrValueObj);
1050:                        attrList.add(attr);
1051:                    }
1052:                } catch (InstanceNotFoundException notFoundEx) {
1053:                    throw new JBIRemoteException(notFoundEx);
1054:                } catch (ReflectionException rEx) {
1055:                    throw new JBIRemoteException(rEx);
1056:                } catch (RuntimeMBeanException rtEx) {
1057:                    throw JBIRemoteException.filterJmxExceptions(rtEx);
1058:                } catch (RuntimeOperationsException rtOpEx) {
1059:                    throw JBIRemoteException.filterJmxExceptions(rtOpEx);
1060:                } catch (Exception ex) {
1061:                    throw JBIRemoteException.filterJmxExceptions(ex);
1062:                }
1063:                return attrList;
1064:
1065:            }
1066:
1067:            /**
1068:             * invokes the operation on mbean
1069:             * 
1070:             * @return Attribute List of the mbean to set
1071:             * @param objectName
1072:             *            mbean name
1073:             * @param params
1074:             *            a name value pair properties object contains the attribute
1075:             *            name and its value as string.
1076:             * @throws JBIRemoteException
1077:             *             on user error
1078:             */
1079:            protected AttributeList constructMBeanAttributes(
1080:                    MBeanServerConnection mbeanServer, ObjectName objectName,
1081:                    Properties params) throws JBIRemoteException {
1082:
1083:                AttributeList attrList = new AttributeList();
1084:                try {
1085:                    MBeanInfo mbeanInfo = mbeanServer.getMBeanInfo(objectName);
1086:                    MBeanAttributeInfo[] mbeanAttrInfoArray = mbeanInfo
1087:                            .getAttributes();
1088:                    Map attribInfoMap = new HashMap();
1089:                    for (int i = 0; i < mbeanAttrInfoArray.length; ++i) {
1090:                        MBeanAttributeInfo attrInfo = mbeanAttrInfoArray[i];
1091:                        attribInfoMap.put(attrInfo.getName(), attrInfo);
1092:                    }
1093:
1094:                    for (Iterator itr = params.keySet().iterator(); itr
1095:                            .hasNext();) {
1096:                        String attrName = (String) itr.next();
1097:                        String stringValue = params.getProperty(attrName);
1098:                        Object attrValueObj = null;
1099:
1100:                        MBeanAttributeInfo attrInfo = (MBeanAttributeInfo) attribInfoMap
1101:                                .get(attrName);
1102:                        if (attrInfo == null) {
1103:                            String[] args = { attrName };
1104:                            Exception exception = this 
1105:                                    .createManagementException(
1106:                                            "ui.mbean.install.config.mbean.attrib.info.not.found",
1107:                                            args, null);
1108:                            throw new JBIRemoteException(exception);
1109:
1110:                        }
1111:
1112:                        String type = attrInfo.getType();
1113:                        try {
1114:                            // construct the value object using reflection.
1115:                            attrValueObj = Util.newInstance(type, stringValue);
1116:                        } catch (Exception ex) {
1117:                            String[] args = { stringValue, type, attrName };
1118:                            Exception exception = this 
1119:                                    .createManagementException(
1120:                                            "ui.mbean.install.config.mbean.attrib.type.convertion.error",
1121:                                            args, ex);
1122:                            throw new JBIRemoteException(exception);
1123:
1124:                        }
1125:
1126:                        Attribute attr = new Attribute(attrName, attrValueObj);
1127:                        attrList.add(attr);
1128:                    }
1129:
1130:                    return attrList;
1131:                } catch (InstanceNotFoundException notFoundEx) {
1132:                    throw new JBIRemoteException(notFoundEx);
1133:                } catch (ReflectionException rEx) {
1134:                    throw new JBIRemoteException(rEx);
1135:                } catch (RuntimeMBeanException rtEx) {
1136:                    throw JBIRemoteException.filterJmxExceptions(rtEx);
1137:                } catch (RuntimeOperationsException rtOpEx) {
1138:                    throw JBIRemoteException.filterJmxExceptions(rtOpEx);
1139:                } catch (Exception ex) {
1140:                    throw JBIRemoteException.filterJmxExceptions(ex);
1141:                }
1142:
1143:            }
1144:
1145:            /**
1146:             * Creates a management message string and populates the exception
1147:             * 
1148:             * @param bundleKey
1149:             * @param args
1150:             *            of Strings
1151:             * @param sourceException -
1152:             *            the source exception to propagate
1153:             * @return Exception object created with a valid XML Management Message
1154:             */
1155:            Exception createManagementException(String bundleKey,
1156:                    String[] args, Exception sourceException) {
1157:                Exception exception = null;
1158:                String xmlManagementMessage = JBIResultXmlBuilder
1159:                        .createJbiResultXml(
1160:                                AbstractUIMBeanImpl.getI18NBundle(), bundleKey,
1161:                                args, sourceException);
1162:                exception = new Exception(xmlManagementMessage);
1163:                return exception;
1164:            }
1165:
1166:            /**
1167:             * Creates a management message.
1168:             *
1169:             * @
1170:             *
1171:             */
1172:            String createManagementMessage(String taskId,
1173:                    boolean successResult, String msgType, String msgCode,
1174:                    Object[] args) {
1175:                String msg = AbstractUIMBeanImpl.getI18NBundle().getMessage(
1176:                        msgCode, args);
1177:                String xmlManagementMessage = JBIResultXmlBuilder.getInstance()
1178:                        .createJbiResultXml(taskId, successResult, msgType,
1179:                                msgCode, msg, args);
1180:
1181:                return xmlManagementMessage;
1182:            }
1183:
1184:            /**
1185:             * check for shared library
1186:             * 
1187:             * @return true if it is shared library else false.
1188:             * @param zipPath
1189:             *            file path
1190:             */
1191:            public boolean isSharedLibraryArchive(String zipPath) {
1192:                try {
1193:                    JBIArchive jbiZip = new JBIArchive(zipPath);
1194:                    return jbiZip.isSharedLibraryArchive();
1195:                } catch (Exception ex) {
1196:                    logDebug(ex);
1197:                    return false;
1198:                }
1199:            }
1200:
1201:            /**
1202:             * finds the component id property in the object name
1203:             * 
1204:             * @param jmxObjectName
1205:             *            jmx obj name
1206:             * @return componentId of the component if embbeded in object name else
1207:             *         null.
1208:             */
1209:            protected String getComponentNameFromJmxObjectName(
1210:                    ObjectName jmxObjectName) {
1211:                String componentName = null;
1212:                try {
1213:                    // TODO change COMPONENT_ID_KEY to Component Name when mgmt api
1214:                    // changes.
1215:                    componentName = ((ObjectName) jmxObjectName)
1216:                            .getKeyProperty(JBIJMXObjectNames.COMPONENT_ID_KEY);
1217:
1218:                } catch (NullPointerException nullEx) {
1219:                    componentName = null;
1220:                }
1221:                return componentName;
1222:            }
1223:
1224:            /**
1225:             * returns the ObjectName for the AdminService Mbean of this component.
1226:             * 
1227:             * @return the ObjectName of the InstallationService MBean or null.
1228:             * @throws JBIRemoteException
1229:             *             on error.
1230:             */
1231:            public ObjectName getAdminServiceMBeanObjectName()
1232:                    throws JBIRemoteException {
1233:                try {
1234:                    MBeanNames mbeanNames = this .mEnvContext.getMBeanNames();
1235:
1236:                    return mbeanNames.getSystemServiceMBeanName(
1237:                            MBeanNames.SERVICE_NAME_ADMIN_SERVICE,
1238:                            MBeanNames.CONTROL_TYPE_ADMIN_SERVICE);
1239:                } catch (Exception ex) {
1240:                    throw JBIRemoteException.filterJmxExceptions(ex);
1241:                }
1242:
1243:            }
1244:
1245:            /**
1246:             * returns the ObjectName for the InstallationService Mbean of this
1247:             * component.
1248:             * 
1249:             * @return the ObjectName of the InstallationService MBean or null.
1250:             */
1251:            public ObjectName getInstallationServiceMBeanObjectName() {
1252:                MBeanNames mbeanNames = this .mEnvContext.getMBeanNames();
1253:
1254:                return mbeanNames.getSystemServiceMBeanName(
1255:                        MBeanNames.SERVICE_NAME_INSTALL_SERVICE,
1256:                        MBeanNames.CONTROL_TYPE_INSTALL_SERVICE);
1257:            }
1258:
1259:            /**
1260:             * returns the ObjectName for the InstallationService Mbean of this
1261:             * component.
1262:             * 
1263:             * @param targetName
1264:             * @return the ObjectName of the InstallationService MBean or null.
1265:             */
1266:            public ObjectName getInstallationServiceMBeanObjectName(
1267:                    String targetName) {
1268:
1269:                MBeanNames mbeanNames = this .mEnvContext.getMBeanNames();
1270:                return mbeanNames.getSystemServiceMBeanName(
1271:                        ServiceName.InstallationService,
1272:                        ServiceType.Installation, targetName);
1273:            }
1274:
1275:            /**
1276:             * returns the ObjectName for the DeploymentService Mbean of this
1277:             * component.
1278:             * 
1279:             * @param targetName
1280:             * 
1281:             * @return the ObjectName of the DeploymentService MBean or null.
1282:             */
1283:            public ObjectName getDeploymentServiceMBeanObjectName(
1284:                    String targetName) {
1285:                MBeanNames mbeanNames = this .mEnvContext.getMBeanNames();
1286:
1287:                return mbeanNames.getSystemServiceMBeanName(
1288:                        ServiceName.DeploymentService, ServiceType.Deployment,
1289:                        targetName);
1290:            }
1291:
1292:            /**
1293:             * returns the ObjectName for the LoggingService Mbean of this target.
1294:             * 
1295:             * @param targetName
1296:             * 
1297:             * @return the ObjectName of the LoggingService MBean or null.
1298:             */
1299:            public ObjectName getLoggingServiceMBeanObjectName(String targetName) {
1300:                MBeanNames mbeanNames = this .mEnvContext.getMBeanNames();
1301:
1302:                ObjectName loggingMBeanObjectName = mbeanNames
1303:                        .getSystemServiceMBeanName(
1304:                                MBeanNames.ServiceName.ConfigurationService,
1305:                                MBeanNames.ServiceType.Logger, targetName);
1306:                /**
1307:                String loggingString = JBIJMXObjectNames.JMX_JBI_DOMAIN + COLON
1308:                       + MBeanNames.INSTANCE_NAME_KEY + EQUAL + targetName + COMMA
1309:                       + JBIJMXObjectNames.SERVICE_NAME_KEY + EQUAL
1310:                       + MBeanNames.SERVICE_NAME_LOGGING_SERVICE + COMMA
1311:                       + JBIJMXObjectNames.CONTROL_TYPE_KEY + EQUAL
1312:                       + MBeanNames.CONTROL_TYPE_LOGGING_SERVICE + COMMA
1313:                       + JBIJMXObjectNames.COMPONENT_TYPE_KEY + EQUAL
1314:                       + JBIJMXObjectNames.SYSTEM_COMPONENT_TYPE_VALUE;
1315:                
1316:                
1317:                try {
1318:                   loggingMBeanObjectName = new ObjectName(loggingString);
1319:                } catch (Exception exception) {
1320:                   logDebug(exception);
1321:                }*/
1322:                return loggingMBeanObjectName;
1323:            }
1324:
1325:            /**
1326:             * Looks up the cascaded LoggerMBeans for all JBI Framework
1327:             * System Services for a specific instance
1328:             * 
1329:             * @return array of object names for all system service LoggerMBeans.
1330:             */
1331:            public ObjectName[] getSystemLoggerMBeans(String instanceName) {
1332:                MBeanNames mbn = mEnvContext.getMBeanNames();
1333:                String tmp = mbn.getJmxDomainName();
1334:
1335:                tmp += ":" + mbn.INSTANCE_NAME_KEY + "=" + instanceName;
1336:                tmp += "," + mbn.COMPONENT_TYPE_KEY + "="
1337:                        + mbn.COMPONENT_TYPE_SYSTEM;
1338:                tmp += "," + mbn.CONTROL_TYPE_KEY + "="
1339:                        + mbn.CONTROL_TYPE_LOGGER;
1340:                //wildcard goes at the end:
1341:                tmp += ",*";
1342:
1343:                //exec the query:
1344:                ObjectName mbeanPattern = null;
1345:                try {
1346:                    mbeanPattern = new ObjectName(tmp);
1347:                } catch (javax.management.MalformedObjectNameException mex) {
1348:                    logDebug(mex.getMessage());
1349:                    return new ObjectName[0];
1350:                }
1351:
1352:                java.util.Set resultSet = mEnvContext.getMBeanServer()
1353:                        .queryNames(mbeanPattern, null);
1354:                ObjectName[] names = new ObjectName[0];
1355:
1356:                if (!resultSet.isEmpty()) {
1357:                    names = (ObjectName[]) resultSet.toArray(names);
1358:                } else {
1359:                    logDebug("Logger MBeans with ObjectName pattern " + tmp
1360:                            + " not found.");
1361:                }
1362:
1363:                return names;
1364:            }
1365:
1366:            /**
1367:             * 
1368:             * @param targetName
1369:             * @param configurationType
1370:             * @return
1371:             * @throws JBIRemoteException
1372:             */
1373:            public ObjectName getConfigurationMBeanObjectName(
1374:                    String targetName, String configurationType)
1375:                    throws JBIRemoteException {
1376:                ObjectName configurationMBeanObjectName = null;
1377:                String objectNameString = JBIJMXObjectNames.JMX_JBI_DOMAIN
1378:                        + COLON + JBIJMXObjectNames.TARGET_KEY + EQUAL
1379:                        + targetName + COMMA
1380:                        + JBIJMXObjectNames.SERVICE_NAME_KEY + EQUAL
1381:                        + JBIJMXObjectNames.CONFIGURATION_SERVICE + COMMA
1382:                        + JBIJMXObjectNames.SERVICE_TYPE_KEY + EQUAL
1383:                        + configurationType;
1384:
1385:                try {
1386:                    configurationMBeanObjectName = new ObjectName(
1387:                            objectNameString);
1388:                } catch (MalformedObjectNameException exception) {
1389:                    throw new JBIRemoteException(exception);
1390:                } catch (NullPointerException exception) {
1391:                    throw new JBIRemoteException(exception);
1392:                }
1393:                return configurationMBeanObjectName;
1394:            }
1395:
1396:            /**
1397:             * Retrieves the password fields in the given XML String
1398:             * 
1399:             * @param xmlDataString
1400:             * @param keys
1401:             * @return
1402:             */
1403:            List getComponentConfigurationPasswordFields(String xmlDataString,
1404:                    String[] keys) throws JBIRemoteException {
1405:                List<String> passwordFieldList = new ArrayList<String>();
1406:                ComponentConfiguration configuration = null;
1407:                ComponentConfigurationParser parser = null;
1408:                try {
1409:                    parser = ComponentConfigurationParser.parseFromString(
1410:                            xmlDataString, keys);
1411:                    configuration = parser.getComponentConfiguration();
1412:                    if (configuration != null) {
1413:                        Entry<String, DisplayInformation> entry = null;
1414:                        String key = null;
1415:                        DisplayInformation value = null;
1416:                        Set<Entry<String, DisplayInformation>> set = configuration
1417:                                .getDisplayDetailsMap().entrySet();
1418:                        Iterator<Entry<String, DisplayInformation>> iterator = set
1419:                                .iterator();
1420:                        while (iterator.hasNext() == true) {
1421:                            entry = iterator.next();
1422:                            if (entry != null) {
1423:                                key = entry.getKey();
1424:                                value = entry.getValue();
1425:                                if (value != null) {
1426:                                    if (value.isPasswordField() == true) {
1427:                                        passwordFieldList.add(key);
1428:                                    }
1429:                                }
1430:                            }
1431:                        }
1432:                    }
1433:                } catch (MalformedURLException e) {
1434:                    throw new JBIRemoteException(e);
1435:                } catch (ParserConfigurationException e) {
1436:                    throw new JBIRemoteException(e);
1437:                } catch (SAXException e) {
1438:                    throw new JBIRemoteException(e);
1439:                } catch (URISyntaxException e) {
1440:                    throw new JBIRemoteException(e);
1441:                } catch (IOException e) {
1442:                    throw new JBIRemoteException(e);
1443:                }
1444:
1445:                return passwordFieldList;
1446:            }
1447:
1448:            /**
1449:             * Retrieve component configuration display data as an XML String
1450:             * 
1451:             * @param server
1452:             * @param objectName
1453:             * @return
1454:             * @throws JBIRemoteException
1455:             */
1456:            String getComponentConfigurationDisplayData(MBeanServer server,
1457:                    ObjectName objectName) throws JBIRemoteException {
1458:                Object[] params = null;
1459:                String[] signature = null;
1460:                String xmlDataString = "";
1461:
1462:                try {
1463:                    xmlDataString = (String) server.invoke(objectName,
1464:                            "retrieveConfigurationDisplayData", params,
1465:                            signature);
1466:                } catch (InstanceNotFoundException e) {
1467:                    throw new JBIRemoteException(e);
1468:                } catch (MBeanException e) {
1469:                    throw new JBIRemoteException(e);
1470:                } catch (ReflectionException e) {
1471:                    throw new JBIRemoteException(e);
1472:                }
1473:                return xmlDataString;
1474:            }
1475:
1476:            /**
1477:             * Retrieve component configuration display schema as an XML String
1478:             * 
1479:             * @param server
1480:             * @param objectName
1481:             * @return
1482:             * @throws JBIRemoteException
1483:             */
1484:            String getComponentConfigurationDisplaySchema(MBeanServer server,
1485:                    ObjectName objectName) throws JBIRemoteException {
1486:                Object[] params = null;
1487:                String[] signature = null;
1488:                String xmlSchemaString = "";
1489:
1490:                try {
1491:                    xmlSchemaString = (String) server.invoke(objectName,
1492:                            "retrieveConfigurationDisplaySchema", params,
1493:                            signature);
1494:                } catch (InstanceNotFoundException e) {
1495:                    throw new JBIRemoteException(e);
1496:                } catch (MBeanException e) {
1497:                    throw new JBIRemoteException(e);
1498:                } catch (ReflectionException e) {
1499:                    throw new JBIRemoteException(e);
1500:                }
1501:
1502:                return xmlSchemaString;
1503:            }
1504:
1505:            /**
1506:             * Retrieve component configuration display data as an XML String
1507:             * 
1508:             * @param connection
1509:             * @param objectName
1510:             * @return
1511:             * @throws JBIRemoteException
1512:             */
1513:            String getComponentConfigurationDisplayData(
1514:                    MBeanServerConnection connection, ObjectName objectName)
1515:                    throws JBIRemoteException {
1516:                Object[] params = null;
1517:                String[] signature = null;
1518:                String xmlDataString = "";
1519:
1520:                try {
1521:                    xmlDataString = (String) connection.invoke(objectName,
1522:                            "retrieveConfigurationDisplayData", params,
1523:                            signature);
1524:                } catch (InstanceNotFoundException e) {
1525:                    throw new JBIRemoteException(e);
1526:                } catch (MBeanException e) {
1527:                    throw new JBIRemoteException(e);
1528:                } catch (ReflectionException e) {
1529:                    throw new JBIRemoteException(e);
1530:                } catch (IOException e) {
1531:                    throw new JBIRemoteException(e);
1532:                }
1533:                return xmlDataString;
1534:            }
1535:
1536:            /**
1537:             * Retrieve component configuration display schema as an XML String
1538:             * 
1539:             * @param connection
1540:             * @param objectName
1541:             * @return
1542:             * @throws JBIRemoteException
1543:             */
1544:            String getComponentConfigurationDisplaySchema(
1545:                    MBeanServerConnection connection, ObjectName objectName)
1546:                    throws JBIRemoteException {
1547:                Object[] params = null;
1548:                String[] signature = null;
1549:                String xmlSchemaString = "";
1550:
1551:                try {
1552:                    xmlSchemaString = (String) connection.invoke(objectName,
1553:                            "retrieveConfigurationDisplaySchema", params,
1554:                            signature);
1555:                } catch (InstanceNotFoundException e) {
1556:                    throw new JBIRemoteException(e);
1557:                } catch (MBeanException e) {
1558:                    throw new JBIRemoteException(e);
1559:                } catch (ReflectionException e) {
1560:                    throw new JBIRemoteException(e);
1561:                } catch (IOException e) {
1562:                    throw new JBIRemoteException(e);
1563:                }
1564:                return xmlSchemaString;
1565:            }
1566:
1567:            /**
1568:             * Get the attributes on the MBean
1569:             * 
1570:             * @param connection
1571:             * @param objectName
1572:             * @return
1573:             * @throws JBIRemoteException
1574:             */
1575:            protected Properties getMBeanAttributeValues(
1576:                    MBeanServerConnection connection, ObjectName objectName)
1577:                    throws JBIRemoteException {
1578:                Properties properties = new Properties();
1579:                List<String> keyList = new ArrayList<String>();
1580:                MBeanInfo mbeanInfo = null;
1581:                try {
1582:                    mbeanInfo = connection.getMBeanInfo(objectName);
1583:                    MBeanAttributeInfo[] mbeanAttrInfoArray = mbeanInfo
1584:                            .getAttributes();
1585:                    for (MBeanAttributeInfo attributeInfo : mbeanAttrInfoArray) {
1586:                        String key = attributeInfo.getName();
1587:                        if (key != null) {
1588:                            Object value = null;
1589:                            try {
1590:                                value = connection
1591:                                        .getAttribute(objectName, key);
1592:                            } catch (AttributeNotFoundException e) {
1593:                                throw new JBIRemoteException(e);
1594:                            } catch (InstanceNotFoundException e) {
1595:                                throw new JBIRemoteException(e);
1596:                            } catch (MBeanException e) {
1597:                                throw new JBIRemoteException(e);
1598:                            } catch (ReflectionException e) {
1599:                                throw new JBIRemoteException(e);
1600:                            }
1601:                            if (value != null) {
1602:                                if (key.equals("ApplicationVariables")) {
1603:                                    // Use getApplicationVariables to get app var data
1604:                                    // value = this
1605:                                    //     .convertToEnvironmentVariableString(value);
1606:                                    continue;
1607:                                }
1608:                                if (key.equals("ApplicationConfigurations")) {
1609:                                    // Use getApplicationConfigurations to get app config data
1610:                                    // value = this
1611:                                    //     .convertToEnvironmentVariableString(value);
1612:                                    continue;
1613:                                }
1614:                                properties.put(key, value + "");
1615:                                keyList.add(key);
1616:                            }
1617:                        }
1618:                    }
1619:                } catch (InstanceNotFoundException e) {
1620:                    throw new JBIRemoteException(e);
1621:                } catch (IntrospectionException e) {
1622:                    throw new JBIRemoteException(e);
1623:                } catch (ReflectionException e) {
1624:                    throw new JBIRemoteException(e);
1625:                } catch (IOException e) {
1626:                    throw new JBIRemoteException(e);
1627:                }
1628:
1629:                // Mask Sensitive password Strings
1630:                /** TODO : With the facade layer we do not have the display data XML
1631:                 * When the common client is getting the attributes from the actual 
1632:                 * component MBean this path should be invoked
1633:                if (keyList.size() > 0) {
1634:                    String xmlDataString = this.getComponentConfigurationDisplayData(
1635:                            connection, objectName);
1636:                    keyList = this.getComponentConfigurationPasswordFields(
1637:                            xmlDataString, GenericsSupport.toArray(keyList,
1638:                                    String.class));
1639:                    for (String key : keyList) {
1640:                        String sensitiveString = properties.getProperty(key);
1641:                        sensitiveString = this
1642:                                .maskSensitiveString(sensitiveString, PASSWORD_MASK_CHARACTER);
1643:                        properties.setProperty(key, sensitiveString);
1644:                    }
1645:                }
1646:                 */
1647:
1648:                return properties;
1649:            }
1650:
1651:            /**
1652:             * Sets environment variables as name=,type=, value=;
1653:             * 
1654:             * @param valueObject
1655:             * @return environment variable string
1656:             */
1657:            String convertToEnvironmentVariableString(Object valueObject) {
1658:                String result = "";
1659:                TabularData tabularData = null;
1660:                if (valueObject instanceof  TabularData) {
1661:                    tabularData = (TabularData) valueObject;
1662:
1663:                    for (Iterator dataIterator = tabularData.values()
1664:                            .iterator(); dataIterator.hasNext();) {
1665:                        CompositeData compositeData = (CompositeData) dataIterator
1666:                                .next();
1667:                        CompositeType compositeType = compositeData
1668:                                .getCompositeType();
1669:                        for (Iterator itemIterator = compositeType.keySet()
1670:                                .iterator(); itemIterator.hasNext();) {
1671:                            String keyName = (String) itemIterator.next();
1672:                            String keyType = (String) itemIterator.next();
1673:                            String keyValue = (String) itemIterator.next();
1674:
1675:                            String name = (String) compositeData.get(keyName);
1676:                            String type = (String) compositeData.get(keyType);
1677:                            String value = (String) compositeData.get(keyValue);
1678:                            result += ("Name=" + name + ", Type=" + type
1679:                                    + ", Value=" + value + "; ");
1680:                        }
1681:                    }
1682:                }
1683:
1684:                return result;
1685:            }
1686:
1687:            /**
1688:             * 
1689:             * @param environmentVariableMap
1690:             * @param environmentVariableRowType
1691:             * @return
1692:             * @throws OpenDataException
1693:             */
1694:            TabularData getEnvironmentVariables(
1695:                    Map<String, String[]> environmentVariableMap,
1696:                    CompositeType environmentVariableRowType)
1697:                    throws OpenDataException {
1698:                TabularData tabularData = createEnvironmentVariableTabularStructure();
1699:                for (Iterator iter = environmentVariableMap.keySet().iterator(); iter
1700:                        .hasNext();) {
1701:                    String name = (String) iter.next();
1702:                    String[] metadata = (String[]) environmentVariableMap
1703:                            .get(name);
1704:                    String value = metadata[0];
1705:                    String type = metadata[1];
1706:
1707:                    Object[] data = new Object[] { name, value, type };
1708:
1709:                    CompositeData rowData = new CompositeDataSupport(
1710:                            environmentVariableRowType, new String[] { "name",
1711:                                    "value", "type" }, data);
1712:                    tabularData.put(rowData);
1713:                }
1714:
1715:                return tabularData;
1716:            }
1717:
1718:            /**
1719:             * 
1720:             * @param tabularDataIn
1721:             * @return
1722:             * @throws InvalidAttributeValueException
1723:             * @throws OpenDataException
1724:             * @throws MBeanException
1725:             */
1726:            Map<String, String[]> setEnvironmentVariables(
1727:                    TabularData tabularDataIn)
1728:                    throws InvalidAttributeValueException, OpenDataException,
1729:                    MBeanException {
1730:                String attrName = ENVIRONMENT_VARIABLES_KEY;
1731:                Map<String, String[]> environmentVariableMap = new HashMap<String, String[]>();
1732:                String mapKey = null;
1733:                TabularData newTabularData = tabularDataIn;
1734:                List items = new ArrayList();
1735:                CompositeType rowType = tabularDataIn.getTabularType()
1736:                        .getRowType();
1737:
1738:                try {
1739:                    newTabularData = tabularDataIn;
1740:                } catch (Exception ex) {
1741:                    throw new InvalidAttributeValueException(
1742:                            "Invalid arguments");
1743:                }
1744:
1745:                for (Iterator rowTypeItems = rowType.keySet().iterator(); rowTypeItems
1746:                        .hasNext();) {
1747:                    String item = (String) (rowTypeItems).next();
1748:                    items.add(item);
1749:                }
1750:
1751:                int itemSize = items.size();
1752:                if (itemSize != 3) {
1753:                    throw new InvalidAttributeValueException(
1754:                            "Invalid Item Size: " + itemSize);
1755:                }
1756:
1757:                // getting the row index
1758:                List rowIndex = tabularDataIn.getTabularType().getIndexNames();
1759:                int rowIndexSize = rowIndex.size();
1760:                if (rowIndexSize > 1) {
1761:                    throw new InvalidAttributeValueException(
1762:                            "Invalid Row Index Size: " + rowIndexSize);
1763:                } else if (rowIndex.size() <= 0) {
1764:                    throw new InvalidAttributeValueException(
1765:                            "Invalid Row Index Size: " + rowIndexSize);
1766:                } else {
1767:                    mapKey = (String) rowIndex.get(0);
1768:                    if (mapKey == null || "".equals(mapKey)) {
1769:                        throw new InvalidAttributeValueException(
1770:                                "Invalid Row Index Key: " + mapKey);
1771:                    }
1772:                }
1773:
1774:                for (Iterator dataIter = tabularDataIn.values().iterator(); dataIter
1775:                        .hasNext();) {
1776:                    CompositeData rowData = (CompositeData) dataIter.next();
1777:
1778:                    String name = null;
1779:                    String value = null;
1780:                    String type = null;
1781:                    for (ListIterator<String> itemIt = items.listIterator(); itemIt
1782:                            .hasNext();) {
1783:                        String item = itemIt.next();
1784:                        if (mapKey.equals(item)) {
1785:                            name = (String) rowData.get(item);
1786:                        } else if ("value".equals(item)) {
1787:                            value = (String) rowData.get(item);
1788:                        } else {
1789:                            type = (String) rowData.get(item);
1790:                        }
1791:                    }
1792:                    environmentVariableMap.put(name,
1793:                            new String[] { value, type });
1794:                }
1795:                return environmentVariableMap;
1796:            }
1797:
1798:            /**
1799:             * 
1800:             * @return
1801:             * @throws OpenDataException
1802:             */
1803:            TabularData createEnvironmentVariableTabularStructure()
1804:                    throws OpenDataException {
1805:                TabularData tabularData = null;
1806:                CompositeType mEnvVarRowType = null;
1807:                TabularType mEnvVarTabularType = null;
1808:
1809:                String[] envVarRowAttrNames = { "name", "value", "type" };
1810:                String[] envVarRowAttrDesc = { "Environment variable name",
1811:                        "Environment variable value",
1812:                        "Environment variable type" };
1813:                OpenType[] envVarRowAttrTypes = { SimpleType.STRING,
1814:                        SimpleType.STRING, SimpleType.STRING };
1815:                String[] envVarRowIndex = { "name" };
1816:
1817:                if (mEnvVarRowType == null) {
1818:                    mEnvVarRowType = new CompositeType("NameValuePair",
1819:                            "Environment variable name and value pair",
1820:                            envVarRowAttrNames, envVarRowAttrDesc,
1821:                            envVarRowAttrTypes);
1822:                }
1823:
1824:                if (mEnvVarTabularType == null) {
1825:                    mEnvVarTabularType = new TabularType(
1826:                            "EnvironmentVariableList",
1827:                            "List of environment name and value pairs",
1828:                            mEnvVarRowType, envVarRowIndex);
1829:                }
1830:
1831:                tabularData = new TabularDataSupport(mEnvVarTabularType);
1832:
1833:                return tabularData;
1834:            }
1835:
1836:            /**
1837:             * 
1838:             * @param sensitiveString
1839:             * @param maskCharacter
1840:             * @return
1841:             */
1842:            String maskSensitiveString(String sensitiveString,
1843:                    char maskCharacter) {
1844:                String result = "";
1845:                if (sensitiveString == null) {
1846:                    return result;
1847:                }
1848:                for (int index = 0; index < sensitiveString.length(); index++) {
1849:                    result += maskCharacter;
1850:                }
1851:                return result;
1852:            }
1853:
1854:            /**
1855:             * 
1856:             * @param componentName
1857:             * @param targetName
1858:             * @return
1859:             */
1860:            Map<String /* targetInstanceName */, Properties /* configProps */> getComponentConfigurationProperties(
1861:                    String componentName, String targetName) {
1862:                Map<String /* targetInstanceName */, Map<MBeanServerConnection, ObjectName>> targetInstanceMap = null;
1863:                Map<MBeanServerConnection, ObjectName> serverObjectNameMap = null;
1864:                Map<String /* targetName */, Properties /* configProps */> result = null;
1865:
1866:                result = new HashMap<String /* targetInstanceName */, Properties /* configProps */>();
1867:                try {
1868:                    targetInstanceMap = this 
1869:                            .getComponentConfigurationMBeanNamesPerTargetInstance(
1870:                                    componentName, targetName);
1871:                    for (Entry<String /* targetInstanceName */, Map<MBeanServerConnection, ObjectName>> entry : targetInstanceMap
1872:                            .entrySet()) {
1873:                        String targetInstanceName = entry.getKey();
1874:                        if (targetInstanceName != null) {
1875:                            serverObjectNameMap = entry.getValue();
1876:                            if (serverObjectNameMap != null) {
1877:                                MBeanServerConnection connection = null;
1878:                                ObjectName objectName = null;
1879:                                for (Entry<MBeanServerConnection, ObjectName> innerEntry : serverObjectNameMap
1880:                                        .entrySet()) {
1881:                                    connection = innerEntry.getKey();
1882:                                    objectName = innerEntry.getValue();
1883:                                    if ((connection != null)
1884:                                            && (objectName != null)) {
1885:
1886:                                        Properties properties = null;
1887:                                        try {
1888:                                            properties = getMBeanAttributeValues(
1889:                                                    connection, objectName);
1890:                                            result.put(targetInstanceName,
1891:                                                    properties);
1892:                                        } catch (JBIRemoteException exception) {
1893:                                            properties = new Properties();
1894:                                            JBIManagementMessage mgmtMsg = null;
1895:                                            mgmtMsg = exception
1896:                                                    .extractJBIManagementMessage();
1897:                                            properties
1898:                                                    .setProperty(
1899:                                                            COMPONENT_CONFIG_INSTANCE_ERROR_KEY,
1900:                                                            mgmtMsg
1901:                                                                    .getMessage());
1902:                                            result.put(targetInstanceName,
1903:                                                    properties);
1904:                                        }
1905:                                    }
1906:                                }
1907:                            }
1908:                        }
1909:                    }
1910:                } catch (IOException e) {
1911:                } catch (JBIRemoteException e) {
1912:                } catch (Exception e) {
1913:                }
1914:
1915:                return result;
1916:            }
1917:
1918:            /**
1919:             * 
1920:             * @param componentName
1921:             * @param configurationValues
1922:             * @param targetName
1923:             * @return
1924:             * @throws JBIRemoteException
1925:             */
1926:            Properties /* targetInstanceName, success/failure */
1927:            setComponentConfigurationProperties(String componentName,
1928:                    Properties /* configProps */configurationValues,
1929:                    String targetName) throws JBIRemoteException {
1930:                Map<String /* targetInstanceName */, Map<MBeanServerConnection, ObjectName>> targetInstanceMap = null;
1931:                Map<MBeanServerConnection, ObjectName> serverObjectNameMap = null;
1932:                AttributeList list = null;
1933:                Properties result = new Properties();
1934:
1935:                try {
1936:                    targetInstanceMap = this 
1937:                            .getComponentConfigurationMBeanNamesPerTargetInstance(
1938:                                    componentName, targetName);
1939:                    for (Entry<String /* targetInstanceName */, Map<MBeanServerConnection, ObjectName>> entry : targetInstanceMap
1940:                            .entrySet()) {
1941:                        String targetInstanceName = entry.getKey();
1942:                        if (targetInstanceName != null) {
1943:                            serverObjectNameMap = entry.getValue();
1944:                            if (serverObjectNameMap != null) {
1945:                                MBeanServerConnection connection = null;
1946:                                ObjectName objectName = null;
1947:                                for (Entry<MBeanServerConnection, ObjectName> innerEntry : serverObjectNameMap
1948:                                        .entrySet()) {
1949:                                    connection = innerEntry.getKey();
1950:                                    objectName = innerEntry.getValue();
1951:                                    if ((connection != null)
1952:                                            && (objectName != null)) {
1953:                                        try {
1954:                                            list = this 
1955:                                                    .constructMBeanAttributes(
1956:                                                            connection,
1957:                                                            objectName,
1958:                                                            configurationValues);
1959:                                            this .setMBeanAttributes(connection,
1960:                                                    objectName, list);
1961:                                            result.put(targetInstanceName,
1962:                                                    componentName);
1963:                                        } catch (Exception ex) {
1964:                                            Exception exception = this 
1965:                                                    .createManagementException(
1966:                                                            "ui.mbean.install.config.mbean.error.set.attrs.error",
1967:                                                            null, ex);
1968:                                            JBIRemoteException remoteException = new JBIRemoteException(
1969:                                                    exception);
1970:                                            result.put(targetInstanceName,
1971:                                                    remoteException
1972:                                                            .getMessage());
1973:                                        }
1974:                                    }
1975:                                }
1976:                            }
1977:                        }
1978:                    }
1979:                } catch (IOException exception) {
1980:                    throw new JBIRemoteException(exception);
1981:                } catch (Exception exception) {
1982:                    throw new JBIRemoteException(exception);
1983:                }
1984:                return result;
1985:            }
1986:
1987:            /**
1988:             * Retrieve object names & connection per target instance for config MBeans
1989:             * 
1990:             * @param targetName -
1991:             *            target name
1992:             * @param componentName -
1993:             *            component name
1994:             * @return an array of ObjectNames of the Custom MBeans registered by this
1995:             *         component on an instance
1996:             * @throws IOException,
1997:             *             Exception on errors
1998:             */
1999:            private Map<String /* targetInstanceName */, Map<MBeanServerConnection, ObjectName>> getComponentConfigurationMBeanNamesPerTargetInstance(
2000:                    String componentName, String targetName)
2001:                    throws IOException, Exception {
2002:                Map<String /* targetInstanceName */, Map<MBeanServerConnection, ObjectName>> result = null;
2003:                Map<MBeanServerConnection, ObjectName> serverObjectNameMap = null;
2004:
2005:                result = new HashMap<String /* targetInstanceName */, Map<MBeanServerConnection, ObjectName>>();
2006:                serverObjectNameMap = new HashMap<MBeanServerConnection, ObjectName>();
2007:
2008:                // Custom MBeanName filter is :
2009:                // com.sun.jbi:JbiName=instanceName,CustomControlName=customName,ComponentName=mComponentName,ControlType=Custom,*
2010:                // com.sun.ebi:ServiceType=Configuration,InstallationType=bindingComponents,IdentificationName=sun-http-binding
2011:                String name = "com.sun.ebi:ServiceType=Configuration,IdentificationName="
2012:                        + componentName + ",*";
2013:                ObjectName objectNameFilter = new ObjectName(name);
2014:                // Get MBeanServer connections to different target instances
2015:                PlatformContext platformContext = this .getPlatformContext();
2016:                MBeanServerConnection server = null;
2017:                // Ensure we have a valid platform context
2018:                // also check for valid targetName
2019:                Set<ObjectName> objectNameSet = null;
2020:                if ((platformContext != null)
2021:                        && (true == platformContext.isValidTarget(targetName))) {
2022:                    if (true == platformContext.isStandaloneServer(targetName)) {
2023:                        server = platformContext
2024:                                .getMBeanServerConnection(targetName);
2025:                        if (server != null) {
2026:                            objectNameSet = server.queryNames(objectNameFilter,
2027:                                    null);
2028:                            for (ObjectName objectName : objectNameSet) {
2029:                                if (objectName != null) {
2030:                                    serverObjectNameMap.put(server, objectName);
2031:                                    result.put(targetName, serverObjectNameMap);
2032:                                    break;
2033:                                }
2034:                            }
2035:                        }
2036:
2037:                    } else {
2038:                        Set<String> targetInstanceNames = platformContext
2039:                                .getServersInCluster(targetName);
2040:                        for (String targetInstanceName : targetInstanceNames) {
2041:                            if (targetInstanceName != null) {
2042:                                server = platformContext
2043:                                        .getMBeanServerConnection(targetInstanceName);
2044:                                if (server != null) {
2045:                                    objectNameSet = server.queryNames(
2046:                                            objectNameFilter, null);
2047:                                    for (ObjectName objectName : objectNameSet) {
2048:                                        if (objectName != null) {
2049:                                            serverObjectNameMap.put(server,
2050:                                                    objectName);
2051:                                            result.put(targetInstanceName,
2052:                                                    serverObjectNameMap);
2053:                                            break;
2054:                                        }
2055:                                    }
2056:                                }
2057:                            }
2058:                        }
2059:                    }
2060:                }
2061:                return result;
2062:            }
2063:
2064:            /**
2065:             * returns the ObjectName for the Extension Mbean of this component.
2066:             * 
2067:             * @param componentName
2068:             * @param targetName
2069:             * 
2070:             * @return the ObjectName of the Extension MBean or null.
2071:             */
2072:            public ObjectName getExtensionMBeanObjectName(String componentName,
2073:                    String targetName) throws JBIRemoteException {
2074:                ObjectName extensionMBeanObjectNamePattern = null;
2075:                MBeanNames mbeanNames = this .mEnvContext.getMBeanNames();
2076:
2077:                String objectNamePatternString = JBIJMXObjectNames.JMX_JBI_DOMAIN
2078:                        + COLON
2079:                        + JBIJMXObjectNames.TARGET_KEY
2080:                        + EQUAL
2081:                        + targetName
2082:                        + COMMA
2083:                        + JBIJMXObjectNames.COMPONENT_ID_KEY
2084:                        + EQUAL
2085:                        + componentName
2086:                        + COMMA
2087:                        + JBIJMXObjectNames.SERVICE_TYPE_KEY
2088:                        + EQUAL
2089:                        + ComponentServiceType.Extension;
2090:
2091:                try {
2092:                    extensionMBeanObjectNamePattern = new ObjectName(
2093:                            objectNamePatternString);
2094:                } catch (MalformedObjectNameException exception) {
2095:                    return null;
2096:                } catch (NullPointerException exception) {
2097:                    return null;
2098:                }
2099:
2100:                MBeanServer mbeanServer = this .mEnvContext.getMBeanServer();
2101:
2102:                Set objectNames = mbeanServer.queryNames(
2103:                        extensionMBeanObjectNamePattern, null);
2104:
2105:                if (objectNames.isEmpty()) {
2106:                    String[] args = { componentName,
2107:                            extensionMBeanObjectNamePattern.toString() };
2108:                    Exception exception = this .createManagementException(
2109:                            "ui.mbean.extension.mbean.not.found.with.query",
2110:                            args, null);
2111:                    throw new JBIRemoteException(exception);
2112:
2113:                }
2114:
2115:                if (objectNames.size() > 1) {
2116:                    String[] args = { componentName,
2117:                            extensionMBeanObjectNamePattern.toString() };
2118:                    Exception exception = this .createManagementException(
2119:                            "ui.mbean.extension.mbean.not.found.with.query",
2120:                            args, null);
2121:                    throw new JBIRemoteException(exception);
2122:
2123:                }
2124:
2125:                ObjectName extensionMBeanObjectName = null;
2126:                extensionMBeanObjectName = (ObjectName) objectNames.iterator()
2127:                        .next();
2128:                logDebug("extensionMBeanObjectName Found : "
2129:                        + extensionMBeanObjectName);
2130:
2131:                return extensionMBeanObjectName;
2132:            }
2133:
2134:            Map<String /* propertyKeyName */, Properties> getRuntimeConfigurationMetadataInternal(
2135:                    String targetName) throws JBIRemoteException {
2136:                Properties properties = null;
2137:                Map<String /* propertyKeyName */, Properties> result = null;
2138:                result = new HashMap<String /* propertyKeyName */, Properties>();
2139:
2140:                ObjectName systemObjectName = null;
2141:                ObjectName installationObjectName = null;
2142:                ObjectName deploymentObjectName = null;
2143:
2144:                String SYSTEM_TYPE = "System";
2145:                String INSTALLATION_TYPE = "Installation";
2146:                String DEPLOYMENT_TYPE = "Deployment";
2147:
2148:                systemObjectName = this .getConfigurationMBeanObjectName(
2149:                        targetName, SYSTEM_TYPE);
2150:                installationObjectName = this .getConfigurationMBeanObjectName(
2151:                        targetName, INSTALLATION_TYPE);
2152:                deploymentObjectName = this .getConfigurationMBeanObjectName(
2153:                        targetName, DEPLOYMENT_TYPE);
2154:
2155:                MBeanServer mbeanServer = this .mEnvContext.getMBeanServer();
2156:
2157:                MBeanInfo mbeanSystemInfo = null;
2158:                MBeanInfo mbeanInstallationInfo = null;
2159:                MBeanInfo mbeanDeploymentInfo = null;
2160:
2161:                try {
2162:                    mbeanSystemInfo = mbeanServer
2163:                            .getMBeanInfo(systemObjectName);
2164:                } catch (InstanceNotFoundException exception) {
2165:                    throw new JBIRemoteException(exception);
2166:                } catch (IntrospectionException exception) {
2167:                    throw new JBIRemoteException(exception);
2168:                } catch (ReflectionException exception) {
2169:                    throw new JBIRemoteException(exception);
2170:                }
2171:
2172:                try {
2173:                    mbeanInstallationInfo = mbeanServer
2174:                            .getMBeanInfo(installationObjectName);
2175:                } catch (InstanceNotFoundException exception) {
2176:                    throw new JBIRemoteException(exception);
2177:                } catch (IntrospectionException exception) {
2178:                    throw new JBIRemoteException(exception);
2179:                } catch (ReflectionException exception) {
2180:                    throw new JBIRemoteException(exception);
2181:                }
2182:
2183:                try {
2184:                    mbeanDeploymentInfo = mbeanServer
2185:                            .getMBeanInfo(deploymentObjectName);
2186:                } catch (InstanceNotFoundException exception) {
2187:                    throw new JBIRemoteException(exception);
2188:                } catch (IntrospectionException exception) {
2189:                    throw new JBIRemoteException(exception);
2190:                } catch (ReflectionException exception) {
2191:                    throw new JBIRemoteException(exception);
2192:                }
2193:
2194:                Object attributeValueObject = null;
2195:                MBeanAttributeInfo[] systemAttributes = mbeanSystemInfo
2196:                        .getAttributes();
2197:                MBeanAttributeInfo[] installationAttributes = mbeanInstallationInfo
2198:                        .getAttributes();
2199:                MBeanAttributeInfo[] deploymentAttributes = mbeanDeploymentInfo
2200:                        .getAttributes();
2201:
2202:                if (systemAttributes != null) {
2203:                    for (MBeanAttributeInfo attributeInfo : systemAttributes) {
2204:                        String attributeName = attributeInfo.getName();
2205:                        if (attributeName != null) {
2206:                            properties = new Properties();
2207:                            if (attributeInfo instanceof  ModelMBeanAttributeInfo) {
2208:                                Descriptor descriptor = ((ModelMBeanAttributeInfo) attributeInfo)
2209:                                        .getDescriptor();
2210:                                String[] fields = descriptor.getFieldNames();
2211:                                for (String fieldName : fields) {
2212:                                    Object value = descriptor
2213:                                            .getFieldValue(fieldName);
2214:                                    if ((fieldName != null) && (value != null)) {
2215:                                        properties.setProperty(fieldName, value
2216:                                                + "");
2217:                                    }
2218:                                }
2219:                            }
2220:                            result.put(attributeName, properties);
2221:                        }
2222:                    }
2223:                }
2224:
2225:                if (installationAttributes != null) {
2226:                    for (MBeanAttributeInfo attributeInfo : installationAttributes) {
2227:                        String attributeName = attributeInfo.getName();
2228:                        if (attributeName != null) {
2229:                            properties = new Properties();
2230:                            if (attributeInfo instanceof  ModelMBeanAttributeInfo) {
2231:                                Descriptor descriptor = ((ModelMBeanAttributeInfo) attributeInfo)
2232:                                        .getDescriptor();
2233:                                String[] fields = descriptor.getFieldNames();
2234:                                for (String fieldName : fields) {
2235:                                    Object value = descriptor
2236:                                            .getFieldValue(fieldName);
2237:                                    if ((fieldName != null) && (value != null)) {
2238:                                        properties.setProperty(fieldName, value
2239:                                                + "");
2240:                                    }
2241:                                }
2242:                            }
2243:                            result.put(attributeName, properties);
2244:                        }
2245:                    }
2246:                }
2247:
2248:                if (deploymentAttributes != null) {
2249:                    for (MBeanAttributeInfo attributeInfo : deploymentAttributes) {
2250:                        String attributeName = attributeInfo.getName();
2251:                        if (attributeName != null) {
2252:                            properties = new Properties();
2253:                            if (attributeInfo instanceof  ModelMBeanAttributeInfo) {
2254:                                Descriptor descriptor = ((ModelMBeanAttributeInfo) attributeInfo)
2255:                                        .getDescriptor();
2256:                                String[] fields = descriptor.getFieldNames();
2257:                                for (String fieldName : fields) {
2258:                                    Object value = descriptor
2259:                                            .getFieldValue(fieldName);
2260:                                    if ((fieldName != null) && (value != null)) {
2261:                                        properties.setProperty(fieldName, value
2262:                                                + "");
2263:                                    }
2264:                                }
2265:                            }
2266:                            result.put(attributeName, properties);
2267:                        }
2268:                    }
2269:                }
2270:
2271:                return result;
2272:            }
2273:
2274:            boolean setRuntimeConfigurationInternal(Properties properties,
2275:                    String targetName) throws JBIRemoteException {
2276:                ObjectName systemObjectName = null;
2277:                ObjectName installationObjectName = null;
2278:                ObjectName deploymentObjectName = null;
2279:
2280:                final String SYSTEM_TYPE = "System";
2281:                final String INSTALLATION_TYPE = "Installation";
2282:                final String DEPLOYMENT_TYPE = "Deployment";
2283:
2284:                systemObjectName = this .getConfigurationMBeanObjectName(
2285:                        targetName, SYSTEM_TYPE);
2286:                installationObjectName = this .getConfigurationMBeanObjectName(
2287:                        targetName, INSTALLATION_TYPE);
2288:                deploymentObjectName = this .getConfigurationMBeanObjectName(
2289:                        targetName, DEPLOYMENT_TYPE);
2290:
2291:                MBeanServer mbeanServer = this .mEnvContext.getMBeanServer();
2292:
2293:                MBeanInfo mbeanSystemInfo = null;
2294:                MBeanInfo mbeanInstallationInfo = null;
2295:                MBeanInfo mbeanDeploymentInfo = null;
2296:
2297:                try {
2298:                    mbeanSystemInfo = mbeanServer
2299:                            .getMBeanInfo(systemObjectName);
2300:                } catch (InstanceNotFoundException exception) {
2301:                    throw new JBIRemoteException(exception);
2302:                } catch (IntrospectionException exception) {
2303:                    throw new JBIRemoteException(exception);
2304:                } catch (ReflectionException exception) {
2305:                    throw new JBIRemoteException(exception);
2306:                }
2307:
2308:                try {
2309:                    mbeanInstallationInfo = mbeanServer
2310:                            .getMBeanInfo(installationObjectName);
2311:                } catch (InstanceNotFoundException exception) {
2312:                    throw new JBIRemoteException(exception);
2313:                } catch (IntrospectionException exception) {
2314:                    throw new JBIRemoteException(exception);
2315:                } catch (ReflectionException exception) {
2316:                    throw new JBIRemoteException(exception);
2317:                }
2318:
2319:                try {
2320:                    mbeanDeploymentInfo = mbeanServer
2321:                            .getMBeanInfo(deploymentObjectName);
2322:                } catch (InstanceNotFoundException exception) {
2323:                    throw new JBIRemoteException(exception);
2324:                } catch (IntrospectionException exception) {
2325:                    throw new JBIRemoteException(exception);
2326:                } catch (ReflectionException exception) {
2327:                    throw new JBIRemoteException(exception);
2328:                }
2329:
2330:                Object attributeValueObject = null;
2331:                MBeanAttributeInfo[] systemAttributes = mbeanSystemInfo
2332:                        .getAttributes();
2333:                MBeanAttributeInfo[] installationAttributes = mbeanInstallationInfo
2334:                        .getAttributes();
2335:                MBeanAttributeInfo[] deploymentAttributes = mbeanDeploymentInfo
2336:                        .getAttributes();
2337:
2338:                Map<String /* Name */, Object /* Type */> attributeNameTypeMap = new HashMap<String /* Name */, Object /* Type */>();
2339:
2340:                Properties metaDataProperties = null;
2341:                // Validate to ensure there is no poison data
2342:                if (systemAttributes != null) {
2343:                    for (MBeanAttributeInfo attributeInfo : systemAttributes) {
2344:                        String attributeName = attributeInfo.getName();
2345:                        String stringValue = properties
2346:                                .getProperty(attributeName);
2347:                        if (stringValue != null) {
2348:                            String type = attributeInfo.getType();
2349:                            try {
2350:                                // construct the value object using reflection.
2351:                                attributeValueObject = Util.newInstance(type,
2352:                                        stringValue);
2353:                                attributeNameTypeMap.put(attributeName,
2354:                                        attributeValueObject);
2355:                            } catch (Exception ex) {
2356:                                String[] args = { stringValue, type,
2357:                                        attributeName };
2358:                                Exception exception = this 
2359:                                        .createManagementException(
2360:                                                "ui.mbean.install.config.mbean.attrib.type.convertion.error",
2361:                                                args, ex);
2362:                                throw new JBIRemoteException(exception);
2363:
2364:                            }
2365:                        }
2366:                    }
2367:                }
2368:
2369:                if (installationAttributes != null) {
2370:                    for (MBeanAttributeInfo attributeInfo : installationAttributes) {
2371:                        String attributeName = attributeInfo.getName();
2372:                        String stringValue = properties
2373:                                .getProperty(attributeName);
2374:                        if (stringValue != null) {
2375:                            String type = attributeInfo.getType();
2376:                            try {
2377:                                // construct the value object using reflection.
2378:                                attributeValueObject = Util.newInstance(type,
2379:                                        stringValue);
2380:                                attributeNameTypeMap.put(attributeName,
2381:                                        attributeValueObject);
2382:                            } catch (Exception ex) {
2383:                                String[] args = { stringValue, type,
2384:                                        attributeName };
2385:                                Exception exception = this 
2386:                                        .createManagementException(
2387:                                                "ui.mbean.install.config.mbean.attrib.type.convertion.error",
2388:                                                args, ex);
2389:                                throw new JBIRemoteException(exception);
2390:
2391:                            }
2392:                        }
2393:                    }
2394:                }
2395:
2396:                if (deploymentAttributes != null) {
2397:                    for (MBeanAttributeInfo attributeInfo : deploymentAttributes) {
2398:                        String attributeName = attributeInfo.getName();
2399:                        String stringValue = properties
2400:                                .getProperty(attributeName);
2401:                        if (stringValue != null) {
2402:                            String type = attributeInfo.getType();
2403:                            try {
2404:                                // construct the value object using reflection.
2405:                                attributeValueObject = Util.newInstance(type,
2406:                                        stringValue);
2407:                                attributeNameTypeMap.put(attributeName,
2408:                                        attributeValueObject);
2409:                            } catch (Exception ex) {
2410:                                String[] args = { stringValue, type,
2411:                                        attributeName };
2412:                                Exception exception = this 
2413:                                        .createManagementException(
2414:                                                "ui.mbean.install.config.mbean.attrib.type.convertion.error",
2415:                                                args, ex);
2416:                                throw new JBIRemoteException(exception);
2417:
2418:                            }
2419:                        }
2420:                    }
2421:                }
2422:
2423:                // Make sure the properties does not have bogus key values
2424:                // passed in.
2425:                Set keySet = properties.keySet();
2426:                Set attributeSet = attributeNameTypeMap.keySet();
2427:
2428:                for (Object keyObject : keySet) {
2429:                    String key = (String) keyObject;
2430:                    if (attributeSet.contains(key) == false) {
2431:                        // throw an exception
2432:                        String[] args = { key };
2433:                        Exception exception = this 
2434:                                .createManagementException(
2435:                                        "ui.mbean.runtime.config.mbean.attrib.key.invalid.error",
2436:                                        args, null);
2437:                        throw new JBIRemoteException(exception);
2438:                    }
2439:                }
2440:
2441:                // Retrieve runtime configuration metadata
2442:                final String IS_STATIC_KEY = "isStatic";
2443:                boolean isRestartRequired = false;
2444:                Map<String /* propertyKeyName */, Properties> metadata = null;
2445:                metadata = getRuntimeConfigurationMetadataInternal(targetName);
2446:
2447:                // Set Values
2448:                if (systemAttributes != null) {
2449:                    for (MBeanAttributeInfo attributeInfo : systemAttributes) {
2450:                        String attributeName = attributeInfo.getName();
2451:                        String stringValue = properties
2452:                                .getProperty(attributeName);
2453:                        if (stringValue != null) {
2454:                            String type = attributeInfo.getType();
2455:                            try {
2456:                                // construct the value object using reflection.
2457:                                attributeValueObject = Util.newInstance(type,
2458:                                        stringValue);
2459:                            } catch (Exception ex) {
2460:                                String[] args = { stringValue, type,
2461:                                        attributeName };
2462:                                Exception exception = this 
2463:                                        .createManagementException(
2464:                                                "ui.mbean.install.config.mbean.attrib.type.convertion.error",
2465:                                                args, ex);
2466:                                throw new JBIRemoteException(exception);
2467:
2468:                            }
2469:                            this .setAttributeValue(systemObjectName,
2470:                                    attributeName, attributeValueObject);
2471:
2472:                            metaDataProperties = metadata.get(attributeName);
2473:                            if (true == Boolean.valueOf(metaDataProperties
2474:                                    .getProperty(IS_STATIC_KEY))) {
2475:                                isRestartRequired = true;
2476:                            }
2477:
2478:                        }
2479:                    }
2480:                }
2481:
2482:                if (installationAttributes != null) {
2483:                    for (MBeanAttributeInfo attributeInfo : installationAttributes) {
2484:                        String attributeName = attributeInfo.getName();
2485:                        String stringValue = properties
2486:                                .getProperty(attributeName);
2487:                        if (stringValue != null) {
2488:                            String type = attributeInfo.getType();
2489:                            try {
2490:                                // construct the value object using reflection.
2491:                                attributeValueObject = Util.newInstance(type,
2492:                                        stringValue);
2493:                            } catch (Exception ex) {
2494:                                String[] args = { stringValue, type,
2495:                                        attributeName };
2496:                                Exception exception = this 
2497:                                        .createManagementException(
2498:                                                "ui.mbean.install.config.mbean.attrib.type.convertion.error",
2499:                                                args, ex);
2500:                                throw new JBIRemoteException(exception);
2501:
2502:                            }
2503:                            this .setAttributeValue(installationObjectName,
2504:                                    attributeName, attributeValueObject);
2505:
2506:                            metaDataProperties = metadata.get(attributeName);
2507:                            if (true == Boolean.valueOf(metaDataProperties
2508:                                    .getProperty(IS_STATIC_KEY))) {
2509:                                isRestartRequired = true;
2510:                            }
2511:
2512:                        }
2513:                    }
2514:                }
2515:
2516:                if (deploymentAttributes != null) {
2517:                    for (MBeanAttributeInfo attributeInfo : deploymentAttributes) {
2518:                        String attributeName = attributeInfo.getName();
2519:                        String stringValue = properties
2520:                                .getProperty(attributeName);
2521:                        if (stringValue != null) {
2522:                            String type = attributeInfo.getType();
2523:                            try {
2524:                                // construct the value object using reflection.
2525:                                attributeValueObject = Util.newInstance(type,
2526:                                        stringValue);
2527:                            } catch (Exception ex) {
2528:                                String[] args = { stringValue, type,
2529:                                        attributeName };
2530:                                Exception exception = this 
2531:                                        .createManagementException(
2532:                                                "ui.mbean.install.config.mbean.attrib.type.convertion.error",
2533:                                                args, ex);
2534:                                throw new JBIRemoteException(exception);
2535:
2536:                            }
2537:                            this .setAttributeValue(deploymentObjectName,
2538:                                    attributeName, attributeValueObject);
2539:
2540:                            metaDataProperties = metadata.get(attributeName);
2541:                            if (true == Boolean.valueOf(metaDataProperties
2542:                                    .getProperty(IS_STATIC_KEY))) {
2543:                                isRestartRequired = true;
2544:                            }
2545:
2546:                        }
2547:                    }
2548:                }
2549:
2550:                return isRestartRequired;
2551:            }
2552:
2553:            Properties getDefaultRuntimeConfigurationInternal(String targetName)
2554:                    throws JBIRemoteException {
2555:                final String DEFAULT_VALUE_KEY = "default";
2556:                Properties properties = new Properties();
2557:                ObjectName systemObjectName = null;
2558:                ObjectName installationObjectName = null;
2559:                ObjectName deploymentObjectName = null;
2560:
2561:                String SYSTEM_TYPE = "System";
2562:                String INSTALLATION_TYPE = "Installation";
2563:                String DEPLOYMENT_TYPE = "Deployment";
2564:
2565:                systemObjectName = this .getConfigurationMBeanObjectName(
2566:                        targetName, SYSTEM_TYPE);
2567:                installationObjectName = this .getConfigurationMBeanObjectName(
2568:                        targetName, INSTALLATION_TYPE);
2569:                deploymentObjectName = this .getConfigurationMBeanObjectName(
2570:                        targetName, DEPLOYMENT_TYPE);
2571:
2572:                MBeanServer mbeanServer = this .mEnvContext.getMBeanServer();
2573:
2574:                MBeanInfo mbeanSystemInfo = null;
2575:                MBeanInfo mbeanInstallationInfo = null;
2576:                MBeanInfo mbeanDeploymentInfo = null;
2577:
2578:                try {
2579:                    mbeanSystemInfo = mbeanServer
2580:                            .getMBeanInfo(systemObjectName);
2581:                } catch (InstanceNotFoundException exception) {
2582:                    throw new JBIRemoteException(exception);
2583:                } catch (IntrospectionException exception) {
2584:                    throw new JBIRemoteException(exception);
2585:                } catch (ReflectionException exception) {
2586:                    throw new JBIRemoteException(exception);
2587:                }
2588:
2589:                try {
2590:                    mbeanInstallationInfo = mbeanServer
2591:                            .getMBeanInfo(installationObjectName);
2592:                } catch (InstanceNotFoundException exception) {
2593:                    throw new JBIRemoteException(exception);
2594:                } catch (IntrospectionException exception) {
2595:                    throw new JBIRemoteException(exception);
2596:                } catch (ReflectionException exception) {
2597:                    throw new JBIRemoteException(exception);
2598:                }
2599:
2600:                try {
2601:                    mbeanDeploymentInfo = mbeanServer
2602:                            .getMBeanInfo(deploymentObjectName);
2603:                } catch (InstanceNotFoundException exception) {
2604:                    throw new JBIRemoteException(exception);
2605:                } catch (IntrospectionException exception) {
2606:                    throw new JBIRemoteException(exception);
2607:                } catch (ReflectionException exception) {
2608:                    throw new JBIRemoteException(exception);
2609:                }
2610:
2611:                MBeanAttributeInfo[] systemAttributes = mbeanSystemInfo
2612:                        .getAttributes();
2613:                if (systemAttributes != null) {
2614:                    for (MBeanAttributeInfo attributeInfo : systemAttributes) {
2615:                        String attributeName = attributeInfo.getName();
2616:                        if (attributeInfo instanceof  ModelMBeanAttributeInfo) {
2617:                            Descriptor descriptor = ((ModelMBeanAttributeInfo) attributeInfo)
2618:                                    .getDescriptor();
2619:                            String[] fields = descriptor.getFieldNames();
2620:                            for (String fieldName : fields) {
2621:                                Object value = descriptor
2622:                                        .getFieldValue(fieldName);
2623:                                if ((DEFAULT_VALUE_KEY.equals(fieldName) == true)
2624:                                        && (value != null)) {
2625:                                    properties.setProperty(attributeName, value
2626:                                            + "");
2627:                                }
2628:                            }
2629:                        }
2630:                    }
2631:                }
2632:
2633:                MBeanAttributeInfo[] installationAttributes = mbeanInstallationInfo
2634:                        .getAttributes();
2635:                if (installationAttributes != null) {
2636:                    for (MBeanAttributeInfo attributeInfo : installationAttributes) {
2637:                        String attributeName = attributeInfo.getName();
2638:                        if (attributeInfo instanceof  ModelMBeanAttributeInfo) {
2639:                            Descriptor descriptor = ((ModelMBeanAttributeInfo) attributeInfo)
2640:                                    .getDescriptor();
2641:                            String[] fields = descriptor.getFieldNames();
2642:                            for (String fieldName : fields) {
2643:                                Object value = descriptor
2644:                                        .getFieldValue(fieldName);
2645:                                if ((DEFAULT_VALUE_KEY.equals(fieldName) == true)
2646:                                        && (value != null)) {
2647:                                    properties.setProperty(attributeName, value
2648:                                            + "");
2649:                                }
2650:                            }
2651:                        }
2652:                    }
2653:                }
2654:
2655:                MBeanAttributeInfo[] deploymentAttributes = mbeanDeploymentInfo
2656:                        .getAttributes();
2657:                if (deploymentAttributes != null) {
2658:                    for (MBeanAttributeInfo attributeInfo : deploymentAttributes) {
2659:                        String attributeName = attributeInfo.getName();
2660:                        if (attributeInfo instanceof  ModelMBeanAttributeInfo) {
2661:                            Descriptor descriptor = ((ModelMBeanAttributeInfo) attributeInfo)
2662:                                    .getDescriptor();
2663:                            String[] fields = descriptor.getFieldNames();
2664:                            for (String fieldName : fields) {
2665:                                Object value = descriptor
2666:                                        .getFieldValue(fieldName);
2667:                                if ((DEFAULT_VALUE_KEY.equals(fieldName) == true)
2668:                                        && (value != null)) {
2669:                                    properties.setProperty(attributeName, value
2670:                                            + "");
2671:                                }
2672:                            }
2673:                        }
2674:                    }
2675:                }
2676:
2677:                return properties;
2678:            }
2679:
2680:            Properties getRuntimeConfigurationInternal(String targetName)
2681:                    throws JBIRemoteException {
2682:                Properties properties = new Properties();
2683:                ObjectName systemObjectName = null;
2684:                ObjectName installationObjectName = null;
2685:                ObjectName deploymentObjectName = null;
2686:
2687:                String SYSTEM_TYPE = "System";
2688:                String INSTALLATION_TYPE = "Installation";
2689:                String DEPLOYMENT_TYPE = "Deployment";
2690:
2691:                systemObjectName = this .getConfigurationMBeanObjectName(
2692:                        targetName, SYSTEM_TYPE);
2693:                installationObjectName = this .getConfigurationMBeanObjectName(
2694:                        targetName, INSTALLATION_TYPE);
2695:                deploymentObjectName = this .getConfigurationMBeanObjectName(
2696:                        targetName, DEPLOYMENT_TYPE);
2697:
2698:                MBeanServer mbeanServer = this .mEnvContext.getMBeanServer();
2699:
2700:                MBeanInfo mbeanSystemInfo = null;
2701:                MBeanInfo mbeanInstallationInfo = null;
2702:                MBeanInfo mbeanDeploymentInfo = null;
2703:
2704:                try {
2705:                    mbeanSystemInfo = mbeanServer
2706:                            .getMBeanInfo(systemObjectName);
2707:                } catch (InstanceNotFoundException exception) {
2708:                    throw new JBIRemoteException(exception);
2709:                } catch (IntrospectionException exception) {
2710:                    throw new JBIRemoteException(exception);
2711:                } catch (ReflectionException exception) {
2712:                    throw new JBIRemoteException(exception);
2713:                }
2714:
2715:                try {
2716:                    mbeanInstallationInfo = mbeanServer
2717:                            .getMBeanInfo(installationObjectName);
2718:                } catch (InstanceNotFoundException exception) {
2719:                    throw new JBIRemoteException(exception);
2720:                } catch (IntrospectionException exception) {
2721:                    throw new JBIRemoteException(exception);
2722:                } catch (ReflectionException exception) {
2723:                    throw new JBIRemoteException(exception);
2724:                }
2725:
2726:                try {
2727:                    mbeanDeploymentInfo = mbeanServer
2728:                            .getMBeanInfo(deploymentObjectName);
2729:                } catch (InstanceNotFoundException exception) {
2730:                    throw new JBIRemoteException(exception);
2731:                } catch (IntrospectionException exception) {
2732:                    throw new JBIRemoteException(exception);
2733:                } catch (ReflectionException exception) {
2734:                    throw new JBIRemoteException(exception);
2735:                }
2736:
2737:                MBeanAttributeInfo[] systemAttributes = mbeanSystemInfo
2738:                        .getAttributes();
2739:                if (systemAttributes != null) {
2740:                    for (MBeanAttributeInfo attributeInfo : systemAttributes) {
2741:                        String attributeName = attributeInfo.getName();
2742:                        Object attributeValue = getAttributeValue(
2743:                                systemObjectName, attributeName);
2744:                        properties.setProperty(attributeName, attributeValue
2745:                                + "");
2746:                    }
2747:                }
2748:
2749:                MBeanAttributeInfo[] installationAttributes = mbeanInstallationInfo
2750:                        .getAttributes();
2751:                if (installationAttributes != null) {
2752:                    for (MBeanAttributeInfo attributeInfo : installationAttributes) {
2753:                        String attributeName = attributeInfo.getName();
2754:                        Object attributeValue = getAttributeValue(
2755:                                installationObjectName, attributeName);
2756:                        properties.setProperty(attributeName, attributeValue
2757:                                + "");
2758:                    }
2759:                }
2760:
2761:                MBeanAttributeInfo[] deploymentAttributes = mbeanDeploymentInfo
2762:                        .getAttributes();
2763:                if (deploymentAttributes != null) {
2764:                    for (MBeanAttributeInfo attributeInfo : deploymentAttributes) {
2765:                        String attributeName = attributeInfo.getName();
2766:                        Object attributeValue = getAttributeValue(
2767:                                deploymentObjectName, attributeName);
2768:                        properties.setProperty(attributeName, attributeValue
2769:                                + "");
2770:                    }
2771:                }
2772:
2773:                return properties;
2774:            }
2775:
2776:            /**
2777:             * returns the ObjectName for the DeployerMBean for the component.
2778:             * 
2779:             * @return the ObjectName for the lifecycle Mbean.
2780:             * @param componentName
2781:             *            of a binding or engine component.
2782:             * @throws JBIRemoteException
2783:             *             on error
2784:             */
2785:            public ObjectName findDeployerMBean(String componentName)
2786:                    throws JBIRemoteException {
2787:
2788:                ObjectName deployerObjectNamePattern = null;
2789:                try {
2790:                    deployerObjectNamePattern = JBIJMXObjectNames
2791:                            .getComponentDeployerMBeanObjectNamePattern(componentName);
2792:                } catch (MalformedObjectNameException ex) {
2793:                    throw new JBIRemoteException(ex);
2794:                }
2795:
2796:                MBeanServer mbeanServer = this .mEnvContext.getMBeanServer();
2797:
2798:                Set objectNames = mbeanServer.queryNames(
2799:                        deployerObjectNamePattern, null);
2800:
2801:                if (objectNames.isEmpty()) {
2802:                    String[] args = { componentName,
2803:                            deployerObjectNamePattern.toString() };
2804:                    Exception exception = this .createManagementException(
2805:                            "ui.mbean.deployer.mbean.not.found.with.query",
2806:                            args, null);
2807:                    throw new JBIRemoteException(exception);
2808:
2809:                }
2810:
2811:                if (objectNames.size() > 1) {
2812:                    String[] args = { componentName,
2813:                            deployerObjectNamePattern.toString() };
2814:                    Exception exception = this 
2815:                            .createManagementException(
2816:                                    "ui.mbean.multiple.deployer.mbeans.found.with.query",
2817:                                    args, null);
2818:                    throw new JBIRemoteException(exception);
2819:
2820:                }
2821:
2822:                ObjectName deployerObjectName = (ObjectName) objectNames
2823:                        .iterator().next();
2824:                logDebug("DeployerMBean Found : " + deployerObjectName);
2825:
2826:                return deployerObjectName;
2827:
2828:            }
2829:
2830:            /**
2831:             * returns the ObjectName for the lifecycle Mbean of this component.
2832:             * 
2833:             * @return the ObjectName for the lifecycle Mbean.
2834:             * @param componentName
2835:             *            of a binding or engine component.
2836:             * @param targetName
2837:             * @throws JBIRemoteException
2838:             *             on error
2839:             */
2840:            public ObjectName getComponentLifeCycleMBeanObjectName(
2841:                    String componentName, String targetName)
2842:                    throws JBIRemoteException {
2843:
2844:                if (!isExistingComponent(componentName, targetName)) {
2845:                    String[] args = { componentName, targetName };
2846:                    Exception exception = this .createManagementException(
2847:                            "ui.mbean.lifecycle.mbean.not.found.with.query",
2848:                            args, null);
2849:                    throw new JBIRemoteException(exception);
2850:                }
2851:
2852:                ObjectName lifecycleObjectNamePattern = null;
2853:                try {
2854:                    lifecycleObjectNamePattern = JBIJMXObjectNames
2855:                            .getComponentLifeCycleMBeanObjectNamePattern(
2856:                                    componentName, targetName);
2857:                } catch (MalformedObjectNameException ex) {
2858:                    throw new JBIRemoteException(ex);
2859:                }
2860:
2861:                MBeanServer mbeanServer = this .mEnvContext.getMBeanServer();
2862:
2863:                Set objectNames = mbeanServer.queryNames(
2864:                        lifecycleObjectNamePattern, null);
2865:
2866:                if (objectNames.isEmpty()) {
2867:                    String[] args = { componentName, targetName };
2868:                    Exception exception = this .createManagementException(
2869:                            "ui.mbean.lifecycle.mbean.not.found.with.query",
2870:                            args, null);
2871:                    throw new JBIRemoteException(exception);
2872:
2873:                }
2874:
2875:                if (objectNames.size() > 1) {
2876:                    String[] args = { componentName, targetName };
2877:                    Exception exception = this 
2878:                            .createManagementException(
2879:                                    "ui.mbean.multiple.lifecycle.mbeans.found.with.query",
2880:                                    args, null);
2881:                    throw new JBIRemoteException(exception);
2882:                }
2883:
2884:                ObjectName lifecyleObjectName = (ObjectName) objectNames
2885:                        .iterator().next();
2886:                logDebug("LifecyleMBean : " + lifecyleObjectName);
2887:
2888:                return lifecyleObjectName;
2889:
2890:            }
2891:
2892:            /**
2893:             * return framework query
2894:             * 
2895:             * @param targetName
2896:             * 
2897:             * @return framework query interface
2898:             */
2899:            protected ComponentQuery getFrameworkComponentQuery(
2900:                    String targetName) {
2901:                ComponentQuery componentQuery = null;
2902:                /*
2903:                 * ==============================================================
2904:                 * According to IN=100359 at
2905:                 * http://inf.central.sun.com/inf/integrationReport.jsp?id=100359
2906:                 * 
2907:                 * The ComponentQueryImpl has been updated to support the "domain"
2908:                 * targetName as well, but is not plugged into the JBI Framework.
2909:                 * ==============================================================
2910:                 */
2911:                // if (JBIAdminCommands.DOMAIN_TARGET_KEY.equals(targetName) == false) {
2912:                // componentQuery = this.mEnvContext.getComponentQuery();
2913:                // }
2914:                componentQuery = this .mEnvContext.getComponentQuery(targetName);
2915:                return componentQuery;
2916:            }
2917:
2918:            /**
2919:             * checks the component name in the registry
2920:             * 
2921:             * @return true if component exists else false.
2922:             * @param componentName
2923:             *            name of the component
2924:             * @param targetName
2925:             */
2926:            public boolean isExistingComponent(String componentName,
2927:                    String targetName) {
2928:                List list = new ArrayList();
2929:                ComponentQuery componentQuery = this 
2930:                        .getFrameworkComponentQuery(targetName);
2931:                if (componentQuery != null) {
2932:                    list = componentQuery
2933:                            .getComponentIds(ComponentType.BINDINGS_AND_ENGINES);
2934:                }
2935:                return list.contains(componentName);
2936:            }
2937:
2938:            /**
2939:             * check for shared namespace
2940:             * 
2941:             * @return true if it is namespace id else false.
2942:             * @param sharedLibraryName
2943:             *            id String
2944:             * @param targetName
2945:             */
2946:            public boolean isExistingSharedLibrary(String sharedLibraryName,
2947:                    String targetName) {
2948:                List list = new ArrayList();
2949:                ComponentQuery componentQuery = this 
2950:                        .getFrameworkComponentQuery(targetName);
2951:                if (componentQuery != null) {
2952:                    list = componentQuery
2953:                            .getComponentIds(ComponentType.SHARED_LIBRARY);
2954:                }
2955:                return list.contains(sharedLibraryName);
2956:            }
2957:
2958:            /**
2959:             * list of component names
2960:             * 
2961:             * @return list of component names
2962:             * @param slibName
2963:             *            shared library name.
2964:             * @param targetName
2965:             */
2966:            public Collection getComponentNamesDependentOnSharedLibrary(
2967:                    String slibName, String targetName) {
2968:                List componentNames = new ArrayList();
2969:                try {
2970:                    ComponentQuery componentQuery = this 
2971:                            .getFrameworkComponentQuery(targetName);
2972:                    if (componentQuery != null) {
2973:                        componentNames = componentQuery
2974:                                .getDependentComponentIds(slibName);
2975:                    }
2976:                } catch (Exception ex) {
2977:                    // log exception
2978:                    logDebug(ex);
2979:                }
2980:                return componentNames;
2981:            }
2982:
2983:            /**
2984:             * list of component names
2985:             * 
2986:             * @return list of component names
2987:             * @param saId
2988:             *            service assembly name.
2989:             * @param targetName
2990:             */
2991:            public Collection getComponentNamesDependentOnServiceAssembly(
2992:                    String saId, String targetName) {
2993:                try {
2994:                    String[] componentNames = (String[]) this 
2995:                            .invokeMBeanOperation(
2996:                                    this 
2997:                                            .getDeploymentServiceMBeanObjectName(targetName),
2998:                                    "getComponentsForDeployedServiceAssembly",
2999:                                    saId);
3000:                    if (componentNames == null) {
3001:                        componentNames = new String[0];
3002:                    }
3003:                    return new HashSet(Arrays.asList(componentNames));
3004:                } catch (Exception ex) {
3005:                    // log exception
3006:                    logDebug(ex);
3007:                    // empty set
3008:                    return new HashSet();
3009:                }
3010:            }
3011:
3012:            /**
3013:             * list of component names
3014:             * 
3015:             * @return list of component names
3016:             * @param frameworkCompType
3017:             *            component type
3018:             * @param frameworkCompStatus
3019:             *            component state
3020:             * @param targetName
3021:             */
3022:            public Set getComponentNamesWithStatus(
3023:                    ComponentType frameworkCompType,
3024:                    ComponentState frameworkCompStatus, String targetName) {
3025:                List componentIdList = new ArrayList();
3026:                ComponentQuery componentQuery = getFrameworkComponentQuery(targetName);
3027:                if (componentQuery != null) {
3028:                    if (frameworkCompStatus == ComponentState.UNKNOWN) {
3029:                        // ANY STATE
3030:                        componentIdList = componentQuery
3031:                                .getComponentIds(frameworkCompType);
3032:                    } else {
3033:                        componentIdList = componentQuery.getComponentIds(
3034:                                frameworkCompType, frameworkCompStatus);
3035:                    }
3036:                }
3037:
3038:                // now retain only ones that has auID deployed.
3039:                return new HashSet(componentIdList);
3040:            }
3041:
3042:            /**
3043:             * list of component names
3044:             * 
3045:             * @return list of component names
3046:             * @param frameworkCompType
3047:             *            component type
3048:             * @param frameworkCompStatus
3049:             *            component state
3050:             * @param saName
3051:             *            service assembly name
3052:             * @param targetName
3053:             */
3054:            public Collection getComponentNamesDependentOnServiceAssembly(
3055:                    ComponentType frameworkCompType,
3056:                    ComponentState frameworkCompStatus, String saName,
3057:                    String targetName) {
3058:
3059:                Set compNameSet = new HashSet(getComponentNamesWithStatus(
3060:                        frameworkCompType, frameworkCompStatus, targetName));
3061:                Set saNameDepCompNameSet = new HashSet(this 
3062:                        .getComponentNamesDependentOnServiceAssembly(saName,
3063:                                targetName));
3064:                // now retain only ids in the compIdSet that are in compIdSetWithAuId
3065:                compNameSet.retainAll(saNameDepCompNameSet);
3066:                return compNameSet;
3067:            }
3068:
3069:            /**
3070:             * list of component names
3071:             * 
3072:             * @return list of component names
3073:             * @param frameworkCompType
3074:             *            component type
3075:             * @param frameworkCompStatus
3076:             *            component state
3077:             * @param slibName
3078:             *            shared library name
3079:             * @param targetName
3080:             */
3081:            public Collection getComponentNamesDependentOnSharedLibrary(
3082:                    ComponentType frameworkCompType,
3083:                    ComponentState frameworkCompStatus, String slibName,
3084:                    String targetName) {
3085:
3086:                Set compNameSet = new HashSet(this .getComponentNamesWithStatus(
3087:                        frameworkCompType, frameworkCompStatus, targetName));
3088:                Set slibNameDepCompNameSet = new HashSet(this 
3089:                        .getComponentNamesDependentOnSharedLibrary(slibName,
3090:                                targetName));
3091:                // now retain only ids in the compIdSet that are in compIdSetWithSnsd
3092:                compNameSet.retainAll(slibNameDepCompNameSet);
3093:                return compNameSet;
3094:            }
3095:
3096:            /**
3097:             * list of component names. this method requires non null inputs
3098:             * 
3099:             * @return list of component names.
3100:             * @param frameworkCompType
3101:             *            component type
3102:             * @param frameworkCompStatus
3103:             *            component state
3104:             * @param slibName
3105:             *            shared library name
3106:             * @param saName
3107:             *            service assembly name
3108:             * @param targetName
3109:             */
3110:            public Collection getComponentNamesDependentOnSharedLibraryAndServiceAssembly(
3111:                    ComponentType frameworkCompType,
3112:                    ComponentState frameworkCompStatus, String slibName,
3113:                    String saName, String targetName) {
3114:
3115:                Set compNameSet = new HashSet(this .getComponentNamesWithStatus(
3116:                        frameworkCompType, frameworkCompStatus, targetName));
3117:                Set slibNameDepCompNameSet = new HashSet(this 
3118:                        .getComponentNamesDependentOnSharedLibrary(slibName,
3119:                                targetName));
3120:                Set saNameDepCompNameSet = new HashSet(this 
3121:                        .getComponentNamesDependentOnServiceAssembly(saName,
3122:                                targetName));
3123:                // intersection of SLIB and SA
3124:                slibNameDepCompNameSet.retainAll(saNameDepCompNameSet);
3125:                // intersection of type, status, SLIB, SA
3126:                compNameSet.retainAll(slibNameDepCompNameSet);
3127:                return compNameSet;
3128:            }
3129:
3130:            /**
3131:             * updates the state in the service unit info
3132:             * 
3133:             * @param suInfo
3134:             *            service unit info object
3135:             * @param ObjectName
3136:             *            deploymentServiceMBean
3137:             */
3138:            protected void updateServiceUnitInfoState(ServiceUnitInfo suInfo,
3139:                    ObjectName deploymentServiceMBean) {
3140:                suInfo.setState(ServiceUnitInfo.UNKNOWN_STATE);
3141:
3142:                String compName = suInfo.getDeployedOn();
3143:                String suName = suInfo.getName();
3144:                try {
3145:                    // locate the deployer mbean on the component
3146:                    if (deploymentServiceMBean == null) {
3147:                        this .logDebug("DeployerMBean not found for component "
3148:                                + compName);
3149:                        return;
3150:                    }
3151:
3152:                    // get the state of the service unit from the deployer mbean
3153:                    // String getServiceUnitState(String componentName, String
3154:                    // serviceUnitName)
3155:                    Object[] params = new Object[2];
3156:                    params[0] = compName;
3157:                    params[1] = suName;
3158:
3159:                    String[] signature = new String[2];
3160:                    signature[0] = "java.lang.String";
3161:                    signature[1] = "java.lang.String";
3162:
3163:                    String frameworkState = (String) invokeMBeanOperation(
3164:                            deploymentServiceMBean, "getServiceUnitState",
3165:                            params, signature);
3166:
3167:                    this .logDebug("Framework State = " + frameworkState
3168:                            + " for Service UNIT = " + suName);
3169:
3170:                    String uiState = AbstractUIMBeanImpl
3171:                            .toUiServiceUnitState(frameworkState);
3172:
3173:                    suInfo.setState(uiState);
3174:
3175:                } catch (Exception ex) {
3176:                    // ignore the exception and log it
3177:                    this .log(AbstractUIMBeanImpl.getI18NBundle().getMessage(
3178:                            "ui.mbean.exception.getting.service.unit.state",
3179:                            suName, compName, ex.getMessage()));
3180:                    this .logDebug(ex);
3181:                }
3182:            }
3183:
3184:            /**
3185:             * update the state in each service unit info in service assembly info
3186:             * 
3187:             * @param saInfo
3188:             *            service assembly info object
3189:             * @param targetName
3190:             * @throws com.sun.jbi.ui.common.JBIRemoteException
3191:             *             on error
3192:             */
3193:            protected void updateEachServiceUnitInfoStateInServiceAssemblyInfo(
3194:                    ServiceAssemblyInfo saInfo, String targetName)
3195:                    throws JBIRemoteException {
3196:                List list = saInfo.getServiceUnitInfoList();
3197:                if (list == null) {
3198:                    return;
3199:                }
3200:
3201:                // /////////////////////////////////////////////////////
3202:                // As of Nov 09'06 the runtime team says:
3203:                // To get the actual runtime state of a ServiceAssembly
3204:                // invoke the getState() operation on the facade
3205:                // DeploymentServiceMBean(). You should not be using the
3206:                // DeployerMBean for anything, since you do not have
3207:                // access to the remote instance DeployerMBeans and
3208:                // it is not a standard MBean.
3209:                //
3210:                // Note that the DeploymentServiceMBean returns the
3211:                // state as a String (see
3212:                // javax.jbi.management.DeploymentServiceMBean for
3213:                // the string values returned
3214:                // {Started, Stopped, Shutdown}
3215:                // TODO: Need to comment out the following code once the runtime
3216:                // provides a way to get Service Unit State
3217:                ObjectName deploymentServiceMBean = this 
3218:                        .getDeploymentServiceMBeanObjectName(targetName);
3219:                for (Iterator itr = list.iterator(); itr.hasNext();) {
3220:                    ServiceUnitInfo suInfo = (ServiceUnitInfo) itr.next();
3221:                    updateServiceUnitInfoState(suInfo, deploymentServiceMBean);
3222:                }
3223:
3224:                // /////////////////////////////////////////////////////
3225:            }
3226:
3227:            /**
3228:             * update state in service assembly info
3229:             * 
3230:             * @param saInfo
3231:             *            service assembly info
3232:             * @param targetName
3233:             * @throws com.sun.jbi.ui.common.JBIRemoteException
3234:             *             on error
3235:             */
3236:            protected void updateServiceAssemblyInfoState(
3237:                    ServiceAssemblyInfo saInfo, String targetName)
3238:                    throws JBIRemoteException {
3239:                ObjectName deploymentServiceObjectName = this 
3240:                        .getDeploymentServiceMBeanObjectName(targetName);
3241:
3242:                String saName = saInfo.getName();
3243:                String frameworkState = FRAMEWORK_SA_ANY_STATE;
3244:                // if (targetName.equals(JBIAdminCommands.DOMAIN_TARGET_KEY) == false) {
3245:                try {
3246:                    frameworkState = (String) invokeMBeanOperation(
3247:                            deploymentServiceObjectName, "getState", saName);
3248:                } catch (Exception ex) {
3249:                    logDebug("issue 30: state invalid: " + ex.getMessage());
3250:                    frameworkState = "Unknown";
3251:                }
3252:                // }
3253:                this .logDebug("Framework State = " + frameworkState
3254:                        + " for Service Assembly = " + saName);
3255:                String uiState = AbstractUIMBeanImpl
3256:                        .toUiServiceAssemblyState(frameworkState);
3257:                saInfo.setState(uiState);
3258:            }
3259:
3260:            /**
3261:             * list of service assembly infos
3262:             * 
3263:             * @param frameworkState
3264:             *            state
3265:             * @param componentName
3266:             *            name
3267:             * @param targetName
3268:             * @throws com.sun.jbi.ui.common.JBIRemoteException
3269:             *             on error
3270:             * @return list of service assembly infos
3271:             */
3272:            protected List getServiceAssemblyInfoList(String frameworkState,
3273:                    String componentName, String targetName)
3274:                    throws JBIRemoteException {
3275:                String compName = null;
3276:
3277:                if (componentName != null) {
3278:                    compName = componentName.trim();
3279:                }
3280:
3281:                String[] saNames = new String[0];
3282:
3283:                ObjectName deploymentServiceObjectName = this 
3284:                        .getDeploymentServiceMBeanObjectName(targetName);
3285:
3286:                // filter them by component name
3287:                if (compName == null || compName.length() <= 0) {
3288:                    this 
3289:                            .logDebug("getting all the deployed service assemblies with state "
3290:                                    + frameworkState);
3291:
3292:                    saNames = (String[]) getMBeanAttribute(
3293:                            deploymentServiceObjectName,
3294:                            "DeployedServiceAssemblies");
3295:                } else {
3296:                    this 
3297:                            .logDebug("getting all the deployed service assemblies for the comp "
3298:                                    + compName);
3299:
3300:                    if (false == this .isExistingComponent(compName, targetName)) {
3301:                        String[] args = { compName };
3302:                        Exception exception = this .createManagementException(
3303:                                "ui.mbean.component.id.does.not.exist", args,
3304:                                null);
3305:                        throw new JBIRemoteException(exception);
3306:
3307:                    }
3308:
3309:                    saNames = (String[]) invokeMBeanOperation(
3310:                            deploymentServiceObjectName,
3311:                            "getDeployedServiceAssembliesForComponent",
3312:                            compName);
3313:                }
3314:
3315:                // construct service assembly infos from the descriptor
3316:
3317:                List saInfoByCompNameList = new ArrayList();
3318:
3319:                for (int i = 0; i < saNames.length; ++i) {
3320:                    String saName = saNames[i];
3321:                    logDebug("getting deployment descriptor for " + saName);
3322:                    String saDDText = (String) invokeMBeanOperation(
3323:                            deploymentServiceObjectName,
3324:                            "getServiceAssemblyDescriptor", saName);
3325:                    ServiceAssemblyInfo saInfo = ServiceAssemblyInfo
3326:                            .createFromServiceAssemblyDD(new StringReader(
3327:                                    saDDText));
3328:                    // update the state of the service assembly from runtime.
3329:                    this .updateServiceAssemblyInfoState(saInfo, targetName);
3330:
3331:                    saInfoByCompNameList.add(saInfo);
3332:                }
3333:
3334:                // && filter them by state.
3335:
3336:                List saInfoList = new ArrayList();
3337:
3338:                if (frameworkState
3339:                        .equalsIgnoreCase(this .FRAMEWORK_SA_ANY_STATE)) {
3340:                    saInfoList.addAll(saInfoByCompNameList);
3341:
3342:                } else {
3343:                    // filter by specific state
3344:                    String uiState = this 
3345:                            .toUiServiceAssemblyState(frameworkState);
3346:                    for (Iterator itr = saInfoByCompNameList.iterator(); itr
3347:                            .hasNext();) {
3348:                        ServiceAssemblyInfo saInfo = (ServiceAssemblyInfo) itr
3349:                                .next();
3350:                        if (uiState.equalsIgnoreCase(saInfo.getState())) {
3351:                            saInfoList.add(saInfo);
3352:                        }
3353:                    }
3354:                }
3355:
3356:                // update Each ServiceUnit's State In ServiceAssembly;
3357:
3358:                for (Iterator itr = saInfoList.iterator(); itr.hasNext();) {
3359:                    ServiceAssemblyInfo saInfo = (ServiceAssemblyInfo) itr
3360:                            .next();
3361:
3362:                    updateEachServiceUnitInfoStateInServiceAssemblyInfo(saInfo,
3363:                            targetName);
3364:                }
3365:
3366:                return saInfoList;
3367:
3368:            }
3369:
3370:            /**
3371:             * list of ui component infos
3372:             * 
3373:             * @return list of ui component infos
3374:             * @param frameworkCompType
3375:             *            type of the component
3376:             * @param targetName
3377:             */
3378:            public List getUiComponentInfoList(ComponentType frameworkCompType,
3379:                    String targetName) throws JBIRemoteException {
3380:                Set compNameSet = this .getComponentNamesWithStatus(
3381:                        frameworkCompType, ComponentState.UNKNOWN, targetName);
3382:                List frameworkCompList = this .getFrameworkComponentInfoList(
3383:                        new ArrayList(compNameSet), targetName);
3384:                List uiCompList = new ArrayList();
3385:                for (Iterator itr = frameworkCompList.iterator(); itr.hasNext();) {
3386:                    ComponentInfo frameworkCompInfo = (ComponentInfo) itr
3387:                            .next();
3388:                    JBIComponentInfo uiCompInfo = toUiComponentInfo(
3389:                            frameworkCompInfo, targetName);
3390:                    uiCompList.add(uiCompInfo);
3391:                }
3392:                return uiCompList;
3393:            }
3394:
3395:            /**
3396:             * convert to ui component info list
3397:             * 
3398:             * @return ui component info list
3399:             * @param frameworkCompList
3400:             *            framework component info list
3401:             */
3402:            public List toUiComponentInfoList(List frameworkCompList,
3403:                    String targetName) throws JBIRemoteException {
3404:                List uiCompList = new ArrayList();
3405:                for (Iterator itr = frameworkCompList.iterator(); itr.hasNext();) {
3406:                    ComponentInfo frameworkCompInfo = (ComponentInfo) itr
3407:                            .next();
3408:                    JBIComponentInfo uiCompInfo = toUiComponentInfo(
3409:                            frameworkCompInfo, targetName);
3410:                    uiCompList.add(uiCompInfo);
3411:                }
3412:                return uiCompList;
3413:            }
3414:
3415:            /**
3416:             * return component info object
3417:             * 
3418:             * @return object
3419:             * @param frameworkCompInfo
3420:             *            framework component info
3421:             * @param targetName
3422:             */
3423:            public JBIComponentInfo toUiComponentInfo(
3424:                    ComponentInfo frameworkCompInfo, String targetName)
3425:                    throws JBIRemoteException {
3426:
3427:                String state = JBIComponentInfo.UNKNOWN_STATE;
3428:
3429:                String componentName = frameworkCompInfo.getName();
3430:                String componentDescription = frameworkCompInfo
3431:                        .getDescription();
3432:
3433:                ComponentState componentStatus = ComponentState.UNKNOWN;
3434:                ComponentType componentType = frameworkCompInfo
3435:                        .getComponentType();
3436:                // Figure out the component state
3437:                if ((false == ComponentType.BINDING.equals(componentType))
3438:                        && (false == ComponentType.ENGINE.equals(componentType))
3439:                        && (false == ComponentType.BINDINGS_AND_ENGINES
3440:                                .equals(componentType))) {
3441:                    componentStatus = frameworkCompInfo.getStatus();
3442:                    state = toUiComponentInfoState(componentStatus);
3443:                } else {
3444:                    // /////////////////////////////////////////////////////////
3445:                    // According to the runtime team (as of Nov 09'06):
3446:                    // The ComponentQuery.getStatus() or
3447:                    // ComponentQuery.getComponentInfo().getStatus()
3448:                    // to get the state of the component actually
3449:                    // returns the desired state of the component
3450:                    // persisted in the registry.
3451:                    //
3452:                    // The getCurrentState() operation of the
3453:                    // ComponentLifeCycleMBean returns the actual runtime
3454:                    // state for a component, which can be used to get the
3455:                    // actual runtime state of the component.
3456:                    // Therefore the component state is retrieved from the
3457:                    // facade ComponentLifeCycleMBean instead of
3458:                    // using ComponentQuery
3459:                    //
3460:                    // Use the LifeCycleMBean for the domain target too.
3461:                    // The getCurrentState() for the domain target should
3462:                    // return the most advanced state of the component on all targets.
3463:                    try {
3464:                        ObjectName lifeCycleMBeanObjectName = null;
3465:                        lifeCycleMBeanObjectName = this 
3466:                                .getComponentLifeCycleMBeanObjectName(
3467:                                        componentName, targetName);
3468:                        state = (String) this .getMBeanAttribute(
3469:                                lifeCycleMBeanObjectName, "CurrentState");
3470:                    } catch (JBIRemoteException exception) {
3471:                        // do not rethrow it. The state is already defaulted to
3472:                        // JBIComponentInfo.UNKNOWN_STATE
3473:                        componentStatus = ComponentState.UNKNOWN;
3474:                        state = JBIComponentInfo.UNKNOWN_STATE;
3475:                    }
3476:                    // /////////////////////////////////////////////////////////
3477:                }
3478:                if (true == RUNNING_STATE.equals(state)) {
3479:                    state = JBIComponentInfo.STARTED_STATE;
3480:                }
3481:
3482:                String type = toUiComponentInfoType(componentType);
3483:
3484:                return new JBIComponentInfo(type, // Integer.toString(comp.getComponentType()),
3485:                        state, // Integer.toString(comp.getStatus()),
3486:                        componentName, componentDescription);
3487:            }
3488:
3489:            /**
3490:             * converts to deployment service service assembly state.
3491:             * 
3492:             * @return state
3493:             * @param uiState
3494:             *            state
3495:             */
3496:            public static String toFrameworkServiceAssemblyState(String uiState) {
3497:                if (uiState == null) {
3498:                    return FRAMEWORK_SA_ANY_STATE;
3499:                }
3500:
3501:                String saState = uiState.trim();
3502:
3503:                if (saState.length() <= 0) {
3504:                    return FRAMEWORK_SA_ANY_STATE;
3505:                }
3506:
3507:                if (ServiceAssemblyInfo.STARTED_STATE.equalsIgnoreCase(saState)) {
3508:                    return FRAMEWORK_SA_STARTED_STATE;
3509:                } else if (ServiceAssemblyInfo.STOPPED_STATE
3510:                        .equalsIgnoreCase(saState)) {
3511:                    return FRAMEWORK_SA_STOPPED_STATE;
3512:                } else if (ServiceAssemblyInfo.SHUTDOWN_STATE
3513:                        .equalsIgnoreCase(saState)) {
3514:                    return FRAMEWORK_SA_SHUTDOWN_STATE;
3515:                } else { // any other value
3516:                    return FRAMEWORK_SA_ANY_STATE;
3517:                }
3518:            }
3519:
3520:            /**
3521:             * converts to ui service assembly state
3522:             * 
3523:             * @return state
3524:             * @param frameworkState
3525:             *            state
3526:             */
3527:            public static String toUiServiceAssemblyState(String frameworkState) {
3528:                String uiState = ServiceAssemblyInfo.UNKNOWN_STATE;
3529:
3530:                if (frameworkState == null) {
3531:                    return ServiceAssemblyInfo.UNKNOWN_STATE;
3532:                }
3533:
3534:                String saState = frameworkState.trim();
3535:
3536:                if (saState.length() <= 0) {
3537:                    return ServiceAssemblyInfo.UNKNOWN_STATE;
3538:                }
3539:
3540:                if (FRAMEWORK_SA_STARTED_STATE.equalsIgnoreCase(saState)) {
3541:                    uiState = ServiceAssemblyInfo.STARTED_STATE;
3542:                } else if (FRAMEWORK_SA_STOPPED_STATE.equalsIgnoreCase(saState)) {
3543:                    uiState = ServiceAssemblyInfo.STOPPED_STATE;
3544:                } else if (FRAMEWORK_SA_SHUTDOWN_STATE
3545:                        .equalsIgnoreCase(saState)) {
3546:                    uiState = ServiceAssemblyInfo.SHUTDOWN_STATE;
3547:                } else {
3548:                    uiState = ServiceAssemblyInfo.UNKNOWN_STATE;
3549:                }
3550:                return uiState;
3551:            }
3552:
3553:            /**
3554:             * converts to ui service unit state
3555:             * 
3556:             * @return state
3557:             * @param frameworkState
3558:             *            state
3559:             */
3560:            public static String toUiServiceUnitState(String frameworkState) {
3561:                String uiState = ServiceUnitInfo.UNKNOWN_STATE;
3562:
3563:                if (frameworkState == null) {
3564:                    return ServiceUnitInfo.UNKNOWN_STATE;
3565:                }
3566:
3567:                String suState = frameworkState.trim();
3568:
3569:                if (suState.length() <= 0) {
3570:                    return ServiceUnitInfo.UNKNOWN_STATE;
3571:                }
3572:
3573:                if (FRAMEWORK_SU_STARTED_STATE.equalsIgnoreCase(suState)) {
3574:                    uiState = ServiceUnitInfo.STARTED_STATE;
3575:                } else if (FRAMEWORK_SU_STOPPED_STATE.equalsIgnoreCase(suState)) {
3576:                    uiState = ServiceUnitInfo.STOPPED_STATE;
3577:                } else if (FRAMEWORK_SU_SHUTDOWN_STATE
3578:                        .equalsIgnoreCase(suState)) {
3579:                    uiState = ServiceUnitInfo.SHUTDOWN_STATE;
3580:                } else {
3581:                    uiState = ServiceUnitInfo.UNKNOWN_STATE;
3582:                }
3583:                return uiState;
3584:            }
3585:
3586:            /**
3587:             * converts state
3588:             * 
3589:             * @return state
3590:             * @param frameworkCompState
3591:             *            state
3592:             */
3593:            public static String toUiComponentInfoState(
3594:                    ComponentState frameworkCompState) {
3595:                String uiState = JBIComponentInfo.UNKNOWN_STATE;
3596:                switch (frameworkCompState) {
3597:                case SHUTDOWN:
3598:                    uiState = JBIComponentInfo.SHUTDOWN_STATE;
3599:                    break;
3600:                case STARTED:
3601:                    uiState = JBIComponentInfo.STARTED_STATE;
3602:                    break;
3603:                case STOPPED:
3604:                    uiState = JBIComponentInfo.STOPPED_STATE;
3605:                    break;
3606:                default:
3607:                    uiState = JBIComponentInfo.UNKNOWN_STATE;
3608:                    break;
3609:                }
3610:                return uiState;
3611:            }
3612:
3613:            /**
3614:             * converts type
3615:             * 
3616:             * @return int type
3617:             * @param uiCompType
3618:             *            type
3619:             */
3620:            public static ComponentType toFrameworkComponentInfoType(
3621:                    String uiCompType) {
3622:                if (JBIComponentInfo.BINDING_TYPE.equalsIgnoreCase(uiCompType)) {
3623:                    return ComponentType.BINDING;
3624:                } else if (JBIComponentInfo.ENGINE_TYPE
3625:                        .equalsIgnoreCase(uiCompType)) {
3626:                    return ComponentType.BINDING;
3627:                } else if (JBIComponentInfo.SHARED_LIBRARY_TYPE
3628:                        .equalsIgnoreCase(uiCompType)) {
3629:                    return ComponentType.SHARED_LIBRARY;
3630:                } else {
3631:                    return ComponentType.BINDINGS_AND_ENGINES;
3632:                }
3633:            }
3634:
3635:            /**
3636:             * converts type
3637:             * 
3638:             * @return type
3639:             * @param frameworkCompType
3640:             *            type
3641:             */
3642:            public static String toUiComponentInfoType(
3643:                    ComponentType frameworkCompType) {
3644:                String uiType = JBIComponentInfo.UNKNOWN_TYPE;
3645:                switch (frameworkCompType) {
3646:                case BINDING:
3647:                    uiType = JBIComponentInfo.BINDING_TYPE;
3648:                    break;
3649:                case ENGINE:
3650:                    uiType = JBIComponentInfo.ENGINE_TYPE;
3651:                    break;
3652:                case SHARED_LIBRARY:
3653:                    uiType = JBIComponentInfo.SHARED_LIBRARY_TYPE;
3654:                    break;
3655:                default:
3656:                    uiType = JBIComponentInfo.UNKNOWN_TYPE;
3657:                    break;
3658:                }
3659:                return uiType;
3660:            }
3661:
3662:            /**
3663:             * validates the state value component info
3664:             * 
3665:             * @state component state. valid values null, "", "started", "stopped",
3666:             *        "shutdown"
3667:             * @throws JBIRemoteException
3668:             *             on validation failure
3669:             */
3670:            public void validateUiJBIComponentInfoState(String state)
3671:                    throws JBIRemoteException {
3672:                if (state == null || state.length() == 0) {
3673:                    // all states
3674:                    return;
3675:                }
3676:                String stateValue = state.toString();
3677:
3678:                if (!(JBIComponentInfo.STARTED_STATE
3679:                        .equalsIgnoreCase(stateValue)
3680:                        || JBIComponentInfo.STOPPED_STATE
3681:                                .equalsIgnoreCase(stateValue)
3682:                        || JBIComponentInfo.SHUTDOWN_STATE
3683:                                .equalsIgnoreCase(stateValue) || JBIComponentInfo.UNKNOWN_STATE
3684:                        .equalsIgnoreCase(stateValue))) {
3685:                    String[] args = { state };
3686:                    Exception exception = this .createManagementException(
3687:                            "ui.mbean.list.error.invalid.state", args, null);
3688:                    throw new JBIRemoteException(exception);
3689:
3690:                }
3691:
3692:            }
3693:
3694:            /**
3695:             * validates the state value for service assembly
3696:             * 
3697:             * @state component state. valid values null, "", "started", "stopped",
3698:             *        "shutdown"
3699:             * @throws JBIRemoteException
3700:             *             on validation failure
3701:             */
3702:            public void validateUiServiceAssemblyInfoState(String state)
3703:                    throws JBIRemoteException {
3704:                if (state == null || state.length() == 0) {
3705:                    // all sates
3706:                    return;
3707:                }
3708:                String stateValue = state;
3709:
3710:                if (!(ServiceAssemblyInfo.STARTED_STATE
3711:                        .equalsIgnoreCase(stateValue)
3712:                        || ServiceAssemblyInfo.STOPPED_STATE
3713:                                .equalsIgnoreCase(stateValue)
3714:                        || ServiceAssemblyInfo.SHUTDOWN_STATE
3715:                                .equalsIgnoreCase(stateValue) || ServiceAssemblyInfo.UNKNOWN_STATE
3716:                        .equalsIgnoreCase(stateValue))) {
3717:                    String[] args = { state };
3718:                    Exception exception = this .createManagementException(
3719:                            "ui.mbean.list.error.invalid.state", args, null);
3720:                    throw new JBIRemoteException(exception);
3721:
3722:                }
3723:            }
3724:
3725:            // //////////////////////////////////////////////////////
3726:            // -- Adjusted for ComponentType and ComponentState --
3727:            // //////////////////////////////////////////////////////
3728:            /**
3729:             * framework states
3730:             * 
3731:             * @return state
3732:             * @param uiCompState
3733:             *            state
3734:             */
3735:            public static ComponentState toFrameworkComponentInfoState(
3736:                    String uiCompState) {
3737:                if (uiCompState == null) {
3738:                    return ComponentState.UNKNOWN;
3739:                }
3740:
3741:                String compState = uiCompState.trim();
3742:
3743:                if (compState.length() <= 0) {
3744:                    return ComponentState.UNKNOWN;
3745:                }
3746:
3747:                if (JBIComponentInfo.SHUTDOWN_STATE.equalsIgnoreCase(compState)) {
3748:                    return ComponentState.SHUTDOWN;
3749:                } else if (JBIComponentInfo.STARTED_STATE
3750:                        .equalsIgnoreCase(compState)) {
3751:                    return ComponentState.STARTED;
3752:                } else if (JBIComponentInfo.STOPPED_STATE
3753:                        .equalsIgnoreCase(compState)) {
3754:                    return ComponentState.STOPPED;
3755:                } else { // any other value
3756:                    return ComponentState.UNKNOWN;
3757:                }
3758:            }
3759:
3760:            /**
3761:             * list of componentinfo objects. this methods check for valid inputs and
3762:             * take only a valid inputs. for example slib, saName both can be null
3763:             * 
3764:             * @param frameworkCompType
3765:             *            component type.
3766:             * @param frameworkCompState
3767:             *            component state
3768:             * @param sharedLibraryName
3769:             *            shared library name
3770:             * @param serviceAssemblyName
3771:             *            service assembly name
3772:             * @param targetName
3773:             * @throws com.sun.jbi.ui.common.JBIRemoteException
3774:             *             on error
3775:             * @return list of component info
3776:             */
3777:            protected List getFrameworkComponentInfoListForEnginesAndBindings(
3778:                    ComponentType frameworkCompType,
3779:                    ComponentState frameworkCompState,
3780:                    String sharedLibraryName, String serviceAssemblyName,
3781:                    String targetName) throws JBIRemoteException {
3782:                String slibName = null;
3783:                String saName = null;
3784:
3785:                if (sharedLibraryName != null
3786:                        && sharedLibraryName.trim().length() > 0) {
3787:                    slibName = sharedLibraryName.trim();
3788:                }
3789:
3790:                if (serviceAssemblyName != null
3791:                        && serviceAssemblyName.trim().length() > 0) {
3792:                    saName = serviceAssemblyName.trim();
3793:                }
3794:
3795:                logDebug("getFrameworkComponentInfoForEnginesAndBindings : Params : "
3796:                        + frameworkCompType
3797:                        + ", "
3798:                        + frameworkCompState
3799:                        + ", "
3800:                        + slibName + ", " + saName);
3801:
3802:                Collection componentNames = new HashSet();
3803:                // there are 4 options with snsId,auId (00,01,10,11)
3804:                if (slibName == null && saName == null) {
3805:                    // 00
3806:                    componentNames = getComponentNamesWithStatus(
3807:                            frameworkCompType, frameworkCompState, targetName);
3808:                } else if (slibName == null && saName != null) {
3809:                    // 01
3810:                    componentNames = getComponentNamesDependentOnServiceAssembly(
3811:                            frameworkCompType, frameworkCompState, saName,
3812:                            targetName);
3813:
3814:                } else if (slibName != null && saName == null) {
3815:                    // 10
3816:                    componentNames = getComponentNamesDependentOnSharedLibrary(
3817:                            frameworkCompType, frameworkCompState, slibName,
3818:                            targetName);
3819:
3820:                } else if (slibName != null && saName != null) {
3821:                    // 11
3822:                    componentNames = getComponentNamesDependentOnSharedLibraryAndServiceAssembly(
3823:                            frameworkCompType, frameworkCompState, slibName,
3824:                            saName, targetName);
3825:
3826:                } else {
3827:                    // not possible.
3828:                    componentNames = new HashSet();
3829:                }
3830:
3831:                return this .getFrameworkComponentInfoList(componentNames,
3832:                        targetName);
3833:            }
3834:
3835:            /**
3836:             * framework component info list
3837:             * 
3838:             * @param compNameList
3839:             *            list of component names
3840:             * @param targetName
3841:             * @return framework component info list
3842:             */
3843:            public List getFrameworkComponentInfoList(Collection compNameList,
3844:                    String targetName) {
3845:                ArrayList compInfoList = new ArrayList();
3846:                try {
3847:                    ComponentQuery componentQuery = getFrameworkComponentQuery(targetName);
3848:                    if (componentQuery != null) {
3849:                        for (Iterator itr = compNameList.iterator(); itr
3850:                                .hasNext();) {
3851:                            ComponentInfo componentInfo = componentQuery
3852:                                    .getComponentInfo((String) itr.next());
3853:                            if (componentInfo != null) {
3854:                                compInfoList.add(componentInfo);
3855:                            }
3856:                        }
3857:                    }
3858:                } catch (Exception ex) {
3859:                    // TODO propagate the exception to client.
3860:                    logDebug(ex);
3861:                }
3862:                return compInfoList;
3863:            }
3864:
3865:            /**
3866:             * this methods check for valid inputs and take only a valid inputs. for
3867:             * example slib, saName both can be null
3868:             * 
3869:             * @param componentName
3870:             *            name
3871:             * @param targetName
3872:             * @throws com.sun.jbi.ui.common.JBIRemoteException
3873:             *             on error
3874:             * @return list of componentInfo objects
3875:             */
3876:            protected List getFrameworkComponentInfoListForSharedLibraries(
3877:                    String componentName, String targetName)
3878:                    throws JBIRemoteException {
3879:                String compName = null;
3880:
3881:                if (componentName != null && componentName.trim().length() > 0) {
3882:                    compName = componentName.trim();
3883:                }
3884:
3885:                logDebug("getFrameworkComponentInfoForSharedLibraries: Params : "
3886:                        + compName);
3887:
3888:                List slibNames = new ArrayList();
3889:                List uiCompInfoList = new ArrayList();
3890:                List frameworkCompInfoList = new ArrayList();
3891:                ComponentQuery componentQuery = null;
3892:                if (compName == null) {
3893:                    logDebug("Listing All Shared Libraries in the system");
3894:                    componentQuery = this 
3895:                            .getFrameworkComponentQuery(targetName);
3896:                    if (componentQuery != null) {
3897:                        slibNames = componentQuery
3898:                                .getComponentIds(ComponentType.SHARED_LIBRARY);
3899:                    }
3900:                } else {
3901:                    logDebug("Listing Shared Libraries for the component "
3902:                            + compName);
3903:                    componentQuery = this 
3904:                            .getFrameworkComponentQuery(targetName);
3905:                    if (componentQuery != null) {
3906:                        ComponentInfo componentInfo = componentQuery
3907:                                .getComponentInfo(compName);
3908:                        if (componentInfo == null) {
3909:                            String[] args = { compName };
3910:                            Exception exception = this 
3911:                                    .createManagementException(
3912:                                            "ui.mbean.component.id.does.not.exist",
3913:                                            args, null);
3914:                            throw new JBIRemoteException(exception);
3915:
3916:                        }
3917:                        slibNames = componentInfo.getSharedLibraryNames();
3918:                    }
3919:                }
3920:
3921:                frameworkCompInfoList = this 
3922:                        .getFrameworkComponentInfoListForSharedLibraryNames(
3923:                                slibNames, targetName);
3924:
3925:                return frameworkCompInfoList;
3926:
3927:            }
3928:
3929:            /**
3930:             * list of component infos
3931:             * 
3932:             * @param targetName
3933:             * @return list of component infos
3934:             * @param slibNameList
3935:             *            shared library names
3936:             */
3937:            public List getFrameworkComponentInfoListForSharedLibraryNames(
3938:                    Collection slibNameList, String targetName) {
3939:                ArrayList compInfoList = new ArrayList();
3940:                try {
3941:                    ComponentQuery componentQuery = this 
3942:                            .getFrameworkComponentQuery(targetName);
3943:                    if (componentQuery != null) {
3944:                        for (Iterator itr = slibNameList.iterator(); itr
3945:                                .hasNext();) {
3946:                            ComponentInfo componentInfo = componentQuery
3947:                                    .getSharedLibraryInfo((String) itr.next());
3948:                            if (componentInfo != null) {
3949:                                compInfoList.add(componentInfo);
3950:                            }
3951:                        }
3952:                    }
3953:                } catch (Exception ex) {
3954:                    // TODO propagate the exception to client.
3955:                    logDebug(ex);
3956:                }
3957:                return compInfoList;
3958:            }
3959:
3960:            /**
3961:             * Retrieve the Component Installation descriptor for the server target.
3962:             * 
3963:             * The Installation descriptor will never be different for a component name
3964:             * in a JBI system because there's only one component allowed with that same
3965:             * name. Therefore, this implies a registry lookup for the server target.
3966:             * 
3967:             * @param Component
3968:             *            name as a string
3969:             * @param targetName
3970:             * @return the Component Installation descriptor as a string
3971:             * @throws JBIRemoteException
3972:             *             on error
3973:             */
3974:            public String getInstallationDescriptor(String componentName,
3975:                    String targetName) {
3976:                ComponentQuery componentQuery = null;
3977:                ComponentInfo componentInfo = null;
3978:                String jbiXml = null;
3979:
3980:                componentQuery = this .mEnvContext.getComponentQuery(targetName);
3981:                if (componentQuery != null) {
3982:                    componentInfo = componentQuery
3983:                            .getComponentInfo(componentName);
3984:                    if (componentInfo != null) {
3985:                        jbiXml = componentInfo.getInstallationDescriptor();
3986:                    }
3987:                }
3988:                return jbiXml;
3989:            }
3990:
3991:            /**
3992:             * Retrieve the Shared Library Installation descriptor for the server
3993:             * target.
3994:             * 
3995:             * The Installation descriptor will never be different for a library name in
3996:             * a JBI system because there's only one library allowed with that same
3997:             * name. Therefore, this implies a registry lookup for the domain target.
3998:             * 
3999:             * @param libraryName
4000:             *            name as a string
4001:             * @param targetName
4002:             * @return the Library Installation descriptor as a string
4003:             * @throws JBIRemoteException
4004:             *             on error
4005:             */
4006:            public String getSharedLibraryDescriptor(String libraryName,
4007:                    String targetName) {
4008:                ComponentQuery componentQuery = null;
4009:                ComponentInfo componentInfo = null;
4010:                String jbiXml = null;
4011:
4012:                componentQuery = this.mEnvContext.getComponentQuery(targetName);
4013:                if (componentQuery != null) {
4014:                    componentInfo = componentQuery
4015:                            .getSharedLibraryInfo(libraryName);
4016:                    if (componentInfo != null) {
4017:                        jbiXml = componentInfo.getInstallationDescriptor();
4018:                    }
4019:                }
4020:                return jbiXml;
4021:            }
4022:
4023:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.