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

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » ESB » open esb » com.sun.esb.management.impl.installation 
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:         * @(#)InstallationServiceMBeanImpl.java
0025:         * Copyright 2004-2007 Sun Microsystems, Inc. All Rights Reserved.
0026:         *
0027:         * END_HEADER - DO NOT EDIT
0028:         */
0029:
0030:        package com.sun.esb.management.impl.installation;
0031:
0032:        import java.io.File;
0033:        import java.io.Serializable;
0034:        import java.util.Map;
0035:        import java.util.Properties;
0036:        import java.util.concurrent.ConcurrentHashMap;
0037:
0038:        import javax.management.AttributeList;
0039:        import javax.management.ObjectName;
0040:
0041:        import com.sun.esb.management.api.installation.InstallationService;
0042:        import com.sun.esb.management.base.services.AbstractServiceMBeansImpl;
0043:        import com.sun.esb.management.common.ManagementRemoteException;
0044:        import com.sun.jbi.EnvironmentContext;
0045:        import com.sun.jbi.ui.common.JBIAdminCommands;
0046:        import com.sun.jbi.ui.common.JBIJMXObjectNames;
0047:
0048:        /**
0049:         * Defines operations for common installation services.
0050:         * 
0051:         * @author graj
0052:         */
0053:        public class InstallationServiceMBeanImpl extends
0054:                AbstractServiceMBeansImpl implements  InstallationService,
0055:                Serializable {
0056:
0057:            static final long serialVersionUID = -1L;
0058:
0059:            /**
0060:             * Constructor - Constructs a new instance of InstallationServiceMBeanImpl
0061:             * 
0062:             * @param anEnvContext
0063:             */
0064:            public InstallationServiceMBeanImpl(EnvironmentContext anEnvContext) {
0065:                super (anEnvContext);
0066:            }
0067:
0068:            /**
0069:             * installs component ( service engine, binding component)
0070:             * 
0071:             * @return name of the component.
0072:             * @param paramProps
0073:             *            Properties object contains name/value pair.
0074:             * @param zipFilePath
0075:             *            archive file in a zip format
0076:             * @param targetName
0077:             * @throws ManagementRemoteException
0078:             *             on error
0079:             * 
0080:             * @see com.sun.esb.management.api.installation.InstallationService#installComponent(java.lang.String,
0081:             *      java.util.Properties, java.lang.String)
0082:             */
0083:            public String installComponent(String zipFilePath,
0084:                    Properties paramProps, String targetName)
0085:                    throws ManagementRemoteException {
0086:                /*
0087:                 * ==================================================================
0088:                 * According to IN=100359 at
0089:                 * http://inf.central.sun.com/inf/integrationReport.jsp?id=100359
0090:                 * 
0091:                 * NOTE: Facade MBean operations for the InstallationService: When the
0092:                 * Installer is loaded for a component, it is added to the domain. When
0093:                 * the Installer is unloaded the component is removed from the domain if
0094:                 * it is not installed on any instances. For the domain targetName, the
0095:                 * ComponentLifeCycle MBean is not available.
0096:                 * ==================================================================
0097:                 */
0098:                logDebug("Installing Component zip file " + zipFilePath);
0099:
0100:                String fileURIString = null;
0101:
0102:                File file = new File(zipFilePath);
0103:                fileURIString = file.getAbsolutePath();
0104:
0105:                ObjectName installerServiceObjectName = this 
0106:                        .getInstallationServiceMBeanObjectName(targetName);
0107:
0108:                this 
0109:                        .checkForValidTarget(installerServiceObjectName,
0110:                                targetName);
0111:
0112:                ObjectName installerObjectName = null;
0113:                ObjectName lifecycleObjectName = null;
0114:                String componentName = null;
0115:
0116:                logDebug("Install Step 1 : Calling loadNewInstaller on InstallerServiceMBean : "
0117:                        + installerServiceObjectName);
0118:                // Load new installer
0119:                installerObjectName = (ObjectName) this .invokeMBeanOperation(
0120:                        installerServiceObjectName, "loadNewInstaller",
0121:                        fileURIString);
0122:
0123:                if (installerObjectName == null) {
0124:                    String[] args = { targetName };
0125:                    Exception exception = this .createManagementException(
0126:                            "ui.mbean.install.comp.error.installerMBean", args,
0127:                            null);
0128:                    throw new ManagementRemoteException(exception);
0129:
0130:                }
0131:
0132:                try {
0133:                    logDebug("Install Step 2 : Configuring Installer Configuration Parameters if present");
0134:                    // Configure InstallerConfigurationMBean
0135:                    this .configureComponentInstaller(installerObjectName,
0136:                            paramProps);
0137:
0138:                    logDebug("Install Step 3 : Calling Install on InstallerMbean : "
0139:                            + installerObjectName);
0140:
0141:                    // invoke install on the component installer
0142:                    lifecycleObjectName = (ObjectName) this 
0143:                            .invokeMBeanOperation(
0144:                                    (ObjectName) installerObjectName, "install");
0145:
0146:                    componentName = this 
0147:                            .getComponentNameFromJmxObjectName(installerObjectName);
0148:
0149:                    // Lifecycle object name is not available for the domain targetName
0150:                    if (JBIAdminCommands.DOMAIN_TARGET_KEY.equals(targetName) == false) {
0151:                        if (lifecycleObjectName == null) {
0152:                            String[] args = { installerObjectName.toString() };
0153:                            Exception exception = this 
0154:                                    .createManagementException(
0155:                                            "ui.mbean.install.comp.error.lifecycleMBean",
0156:                                            args, null);
0157:                            throw new ManagementRemoteException(exception);
0158:
0159:                        }
0160:
0161:                        // get the component id from the lifecycleObjectName
0162:                        componentName = this 
0163:                                .getComponentNameFromJmxObjectName(lifecycleObjectName);
0164:
0165:                        if (componentName == null) {
0166:                            String[] args = { lifecycleObjectName.toString() };
0167:                            Exception exception = this 
0168:                                    .createManagementException(
0169:                                            "ui.mbean.install.comp.error.compId",
0170:                                            args, null);
0171:                            throw new ManagementRemoteException(exception);
0172:
0173:                        }
0174:                    }
0175:                } finally {
0176:                    // // call unload installer to unregister the mbean
0177:                    boolean isRemoveComponent = false;
0178:                    boolean ignoreExceptions = false;
0179:                    if (componentName == null) {
0180:                        // install failed. ignore the unload exceptions to propagate the
0181:                        // install
0182:                        // fail exceptions to the client
0183:                        ignoreExceptions = true;
0184:                        isRemoveComponent = true; // since install failed, remove
0185:                        // component from disk also?
0186:                    }
0187:
0188:                    logDebug("Install Step 4 : unloading component installer "
0189:                            + installerObjectName);
0190:
0191:                    this .unloadComponentInstaller(installerObjectName,
0192:                            isRemoveComponent, ignoreExceptions, targetName);
0193:                }
0194:
0195:                return componentName;
0196:            }
0197:
0198:            /**
0199:             * installs component ( service engine, binding component)
0200:             * 
0201:             * @return name of the component.
0202:             * @param zipFilePath
0203:             *            archive file in a zip format
0204:             * @param targetName
0205:             * @throws ManagementRemoteException
0206:             *             on error
0207:             * 
0208:             * @see com.sun.esb.management.api.installation.InstallationService#installComponent(java.lang.String,
0209:             *      java.lang.String)
0210:             */
0211:            public String installComponent(String zipFilePath, String targetName)
0212:                    throws ManagementRemoteException {
0213:                Properties params = new Properties();
0214:                return this .installComponent(zipFilePath, params, targetName);
0215:            }
0216:
0217:            /**
0218:             * installs component ( service engine, binding component)
0219:             * 
0220:             * @param componentName
0221:             *            name of the component.
0222:             * @param component
0223:             *            configuration properties
0224:             * @param targetName
0225:             *            name of the target for this operation
0226:             * @return result.
0227:             * @throws ManagementRemoteException
0228:             *             on error
0229:             * @see com.sun.esb.management.api.installation.InstallationService#installComponentFromDomain(java.lang.String,
0230:             *      java.util.Properties, java.lang.String)
0231:             */
0232:            public String installComponentFromDomain(String componentName,
0233:                    Properties properties, String targetName)
0234:                    throws ManagementRemoteException {
0235:                if (true == targetName
0236:                        .equals(JBIAdminCommands.DOMAIN_TARGET_KEY)) {
0237:                    return componentName;
0238:                }
0239:
0240:                /*
0241:                 * ==================================================================
0242:                 * According to IN=100359 at
0243:                 * http://inf.central.sun.com/inf/integrationReport.jsp?id=100359
0244:                 * 
0245:                 * NOTE: Facade MBean operations for the InstallationService: When the
0246:                 * Installer is loaded for a component, it is added to the domain. When
0247:                 * the Installer is unloaded the component is removed from the domain if
0248:                 * it is not installed on any instances. For the domain targetName, the
0249:                 * ComponentLifeCycle MBean is not available.
0250:                 * ==================================================================
0251:                 */
0252:
0253:                ObjectName installerServiceObjectName = this 
0254:                        .getInstallationServiceMBeanObjectName(targetName);
0255:
0256:                this 
0257:                        .checkForValidTarget(installerServiceObjectName,
0258:                                targetName);
0259:
0260:                ObjectName installerObjectName = null;
0261:                ObjectName lifecycleObjectName = null;
0262:
0263:                logDebug("Install Step 1 : "
0264:                        + "Calling loadInstallerFromRepository which internally "
0265:                        + "performs loadNewInstaller on InstallerServiceMBean : "
0266:                        + installerServiceObjectName);
0267:                // Load new installer
0268:                installerObjectName = (ObjectName) this .invokeMBeanOperation(
0269:                        installerServiceObjectName,
0270:                        "loadInstallerFromRepository", componentName);
0271:
0272:                if (installerObjectName == null) {
0273:                    String[] args = { targetName };
0274:                    Exception exception = this .createManagementException(
0275:                            "ui.mbean.install.comp.error.installerMBean", args,
0276:                            null);
0277:                    throw new ManagementRemoteException(exception);
0278:
0279:                }
0280:
0281:                try {
0282:                    logDebug("Install Step 2 : Configuring Installer Configuration Parameters if present");
0283:                    // Configre InstallerConfigurationMBean
0284:                    this .configureComponentInstaller(installerObjectName,
0285:                            properties);
0286:
0287:                    logDebug("Install Step 3 : Calling Install on InstallerMbean : "
0288:                            + installerObjectName);
0289:
0290:                    // invoke install on the component installer
0291:                    lifecycleObjectName = (ObjectName) this 
0292:                            .invokeMBeanOperation(
0293:                                    (ObjectName) installerObjectName, "install");
0294:
0295:                    componentName = this 
0296:                            .getComponentNameFromJmxObjectName(installerObjectName);
0297:
0298:                    // Lifecycle object name is not available for the domain targetName
0299:                    if (JBIAdminCommands.DOMAIN_TARGET_KEY.equals(targetName) == false) {
0300:                        if (lifecycleObjectName == null) {
0301:                            String[] args = { installerObjectName.toString() };
0302:                            Exception exception = this 
0303:                                    .createManagementException(
0304:                                            "ui.mbean.install.comp.error.lifecycleMBean",
0305:                                            args, null);
0306:                            throw new ManagementRemoteException(exception);
0307:
0308:                        }
0309:
0310:                        // get the component id from the lifecycleObjectName
0311:                        componentName = this 
0312:                                .getComponentNameFromJmxObjectName(lifecycleObjectName);
0313:
0314:                        if (componentName == null) {
0315:                            String[] args = { lifecycleObjectName.toString() };
0316:                            Exception exception = this 
0317:                                    .createManagementException(
0318:                                            "ui.mbean.install.comp.error.compId",
0319:                                            args, null);
0320:                            throw new ManagementRemoteException(exception);
0321:
0322:                        }
0323:                    }
0324:                } finally {
0325:                    // // call unload installer to unregister the mbean
0326:                    boolean isRemoveComponent = false;
0327:                    boolean ignoreExceptions = false;
0328:                    if (componentName == null) {
0329:                        // install failed. ignore the unload exceptions to propagate the
0330:                        // install
0331:                        // fail exceptions to the client
0332:                        ignoreExceptions = true;
0333:                        isRemoveComponent = true; // since install failed, remove
0334:                        // component from disk also?
0335:                    }
0336:
0337:                    logDebug("Install Step 4 : unloading component installer "
0338:                            + installerObjectName);
0339:
0340:                    this .unloadComponentInstaller(installerObjectName,
0341:                            isRemoveComponent, ignoreExceptions, targetName);
0342:                }
0343:
0344:                return componentName;
0345:            }
0346:
0347:            /**
0348:             * installs component ( service engine, binding component)
0349:             * 
0350:             * @param componentName
0351:             *            name of the component.
0352:             * @param targetName
0353:             *            name of the target for this operation
0354:             * @return result.
0355:             * @throws ManagementRemoteException
0356:             *             on error
0357:             * @see com.sun.esb.management.api.installation.InstallationService#installComponentFromDomain(java.lang.String,
0358:             *      java.lang.String)
0359:             */
0360:            public String installComponentFromDomain(String componentName,
0361:                    String targetName) throws ManagementRemoteException {
0362:                if (true == targetName
0363:                        .equals(JBIAdminCommands.DOMAIN_TARGET_KEY)) {
0364:                    return componentName;
0365:                }
0366:                Properties params = new Properties();
0367:                return this .installComponentFromDomain(componentName, params,
0368:                        targetName);
0369:            }
0370:
0371:            /**
0372:             * installs shared library
0373:             * 
0374:             * @return shared library name.
0375:             * @param zipFilePath
0376:             *            archive file in a zip format
0377:             * @param targetName
0378:             * @throws ManagementRemoteException
0379:             *             on error
0380:             * 
0381:             * @see com.sun.esb.management.api.installation.InstallationService#installSharedLibrary(java.lang.String,
0382:             *      java.lang.String)
0383:             */
0384:            public String installSharedLibrary(String zipFilePath,
0385:                    String targetName) throws ManagementRemoteException {
0386:                logDebug("Installing Shared Library " + zipFilePath);
0387:
0388:                File file = new File(zipFilePath);
0389:                String fileURIString = null;
0390:                fileURIString = file.getAbsolutePath();
0391:
0392:                ObjectName installerServiceObjectName = this 
0393:                        .getInstallationServiceMBeanObjectName(targetName);
0394:
0395:                this 
0396:                        .checkForValidTarget(installerServiceObjectName,
0397:                                targetName);
0398:
0399:                logDebug("Calling installSharedLibrary on Installation Service MBean = "
0400:                        + installerServiceObjectName);
0401:
0402:                Object sharedLibName = null;
0403:
0404:                sharedLibName = this .invokeMBeanOperation(
0405:                        installerServiceObjectName, "installSharedLibrary",
0406:                        fileURIString);
0407:
0408:                if (sharedLibName == null) {
0409:                    Exception exception = this .createManagementException(
0410:                            "ui.mbean.install.sns.error", null, null);
0411:                    throw new ManagementRemoteException(exception);
0412:
0413:                }
0414:                return sharedLibName.toString();
0415:            }
0416:
0417:            /**
0418:             * installs shared library
0419:             * 
0420:             * @param libraryName
0421:             *            Shared Library Name
0422:             * @param targetName
0423:             *            name of the target for this operation
0424:             * @return Map of targetName and shared library name strings.
0425:             * @throws ManagementRemoteException
0426:             *             on error
0427:             * @see com.sun.esb.management.api.installation.InstallationService#installSharedLibraryFromDomain(java.lang.String,
0428:             *      java.lang.String)
0429:             */
0430:            public String installSharedLibraryFromDomain(String libraryName,
0431:                    String targetName) throws ManagementRemoteException {
0432:                if (true == targetName
0433:                        .equals(JBIAdminCommands.DOMAIN_TARGET_KEY)) {
0434:                    return libraryName;
0435:                }
0436:
0437:                ObjectName installerServiceObjectName = null;
0438:                Object sharedLibName = null;
0439:
0440:                installerServiceObjectName = this 
0441:                        .getInstallationServiceMBeanObjectName(targetName);
0442:                if (installerServiceObjectName == null) {
0443:                    String[] args = { targetName };
0444:                    Exception exception = this .createManagementException(
0445:                            "ui.mbean.install.comp.error.installerMBean", args,
0446:                            null);
0447:                    throw new ManagementRemoteException(exception);
0448:
0449:                }
0450:
0451:                this 
0452:                        .checkForValidTarget(installerServiceObjectName,
0453:                                targetName);
0454:
0455:                logDebug("Invoking installSharedLibraryFromRepository which "
0456:                        + "internally invokes installSharedLibrary on "
0457:                        + "Installation Service MBean = "
0458:                        + installerServiceObjectName);
0459:
0460:                sharedLibName = this .invokeMBeanOperation(
0461:                        installerServiceObjectName,
0462:                        "installSharedLibraryFromRepository", libraryName);
0463:
0464:                if (sharedLibName == null) {
0465:                    Exception exception = this .createManagementException(
0466:                            "ui.mbean.install.sns.error", null, null);
0467:                    throw new ManagementRemoteException(exception);
0468:
0469:                }
0470:                return sharedLibName.toString();
0471:            }
0472:
0473:            /**
0474:             * uninstalls component ( service engine, binding component)
0475:             * 
0476:             * @param componentName
0477:             *            name of the component
0478:             * @param forceDelete
0479:             *            true to delete, false to not
0480:             * @param retainInDomain
0481:             *            true to not delete it from the domain target, false to also
0482:             *            delete it from the domain target.
0483:             * @param targetName
0484:             *            name of the target for this operation
0485:             * @return component name string.
0486:             * @throws ManagementRemoteException
0487:             *             on error
0488:             * @see com.sun.esb.management.api.installation.InstallationService#uninstallComponent(java.lang.String,
0489:             *      boolean, boolean, java.lang.String)
0490:             */
0491:            public String uninstallComponent(String componentName,
0492:                    boolean forceDelete, boolean retainInDomain,
0493:                    String targetName) throws ManagementRemoteException {
0494:                return this .uninstallComponentInternal(componentName,
0495:                        forceDelete, retainInDomain, targetName);
0496:            }
0497:
0498:            /**
0499:             * uninstalls component ( service engine, binding component)
0500:             * 
0501:             * @param componentName
0502:             *            name of the component
0503:             * @param forceDelete
0504:             *            true to delete, false to not
0505:             * @param targetName
0506:             *            name of the target for this operation
0507:             * @return Map of targetName and component name strings.
0508:             * @throws ManagementRemoteException
0509:             *             on error
0510:             * @see com.sun.esb.management.api.installation.InstallationService#uninstallComponent(java.lang.String,
0511:             *      boolean, java.lang.String)
0512:             */
0513:            public String uninstallComponent(String componentName,
0514:                    boolean forceDelete, String targetName)
0515:                    throws ManagementRemoteException {
0516:                if (false == forceDelete) {
0517:                    return this .uninstallComponent(componentName, targetName);
0518:                }
0519:                return this .uninstallComponentInternal(componentName,
0520:                        forceDelete, targetName);
0521:            }
0522:
0523:            /**
0524:             * uninstalls component ( service engine, binding component)
0525:             * 
0526:             * @param componentName
0527:             *            name of the component
0528:             * @param targetName
0529:             * @return name of the component.
0530:             * @throws ManagementRemoteException
0531:             *             on error
0532:             * 
0533:             * @see com.sun.esb.management.api.installation.InstallationService#uninstallComponent(java.lang.String,
0534:             *      java.lang.String)
0535:             */
0536:            public String uninstallComponent(String componentName,
0537:                    String targetName) throws ManagementRemoteException {
0538:                boolean force = false;
0539:                return this .uninstallComponentInternal(componentName, force,
0540:                        targetName);
0541:            }
0542:
0543:            /**
0544:             * uninstalls shared library
0545:             * 
0546:             * @param sharedLibraryName
0547:             *            name of the shared library
0548:             * @param forceDelete
0549:             *            true to delete, false to not
0550:             * @param retainInDomain
0551:             *            true to not delete it from the domain target, false to also
0552:             *            delete it from the domain target.
0553:             * @param targetName
0554:             *            name of the target for this operation
0555:             * @return shared library name string.
0556:             * @throws ManagementRemoteException
0557:             *             on error
0558:             * @see com.sun.esb.management.api.installation.InstallationService#uninstallSharedLibrary(java.lang.String,
0559:             *      boolean, boolean, java.lang.String)
0560:             */
0561:            public String uninstallSharedLibrary(String sharedLibraryName,
0562:                    boolean forceDelete, boolean retainInDomain,
0563:                    String targetName) throws ManagementRemoteException {
0564:                logDebug("uninstalling shared library " + sharedLibraryName);
0565:
0566:                ObjectName installerServiceObjectName = this 
0567:                        .getInstallationServiceMBeanObjectName(targetName);
0568:                // ////////////////////////////////////////
0569:                // Start Check to make sure target is valid
0570:                // ////////////////////////////////////////
0571:                this 
0572:                        .checkForValidTarget(installerServiceObjectName,
0573:                                targetName);
0574:                // ////////////////////////////////////////
0575:                // End Check to make sure target is valid
0576:                // ////////////////////////////////////////
0577:
0578:                logDebug("Calling uninstallSharedLibrary on InstallerServiceMBean = "
0579:                        + installerServiceObjectName);
0580:
0581:                Object resultObject = null;
0582:
0583:                Object[] params = new Object[2];
0584:                params[0] = sharedLibraryName;
0585:                params[1] = Boolean.valueOf(retainInDomain);
0586:
0587:                String[] signature = new String[2];
0588:                signature[0] = "java.lang.String";
0589:                signature[1] = "boolean";
0590:
0591:                resultObject = this .invokeMBeanOperation(
0592:                        installerServiceObjectName, "uninstallSharedLibrary",
0593:                        params, signature);
0594:
0595:                if (resultObject == null || !(resultObject instanceof  Boolean)
0596:                        || !((Boolean) resultObject).booleanValue()) {
0597:                    Exception exception = this .createManagementException(
0598:                            "ui.mbean.uninstall.sns.error", null, null);
0599:                    throw new ManagementRemoteException(exception);
0600:                }
0601:
0602:                return sharedLibraryName;
0603:            }
0604:
0605:            /**
0606:             * uninstalls shared library
0607:             * 
0608:             * @param sharedLibraryName
0609:             *            name of the shared library
0610:             * @param forceDelete
0611:             *            true to delete, false to not
0612:             * @param targetName
0613:             *            name of the target for this operation
0614:             * @return Map of targetName and shared library name strings.
0615:             * @throws ManagementRemoteException
0616:             *             on error
0617:             * @see com.sun.esb.management.api.installation.InstallationService#uninstallSharedLibrary(java.lang.String,
0618:             *      boolean, java.lang.String)
0619:             */
0620:            public String uninstallSharedLibrary(String sharedLibraryName,
0621:                    boolean forceDelete, String targetName)
0622:                    throws ManagementRemoteException {
0623:                if (false == forceDelete) {
0624:                    return this .uninstallSharedLibrary(sharedLibraryName,
0625:                            targetName);
0626:                }
0627:                return this .uninstallSharedLibraryInternal(sharedLibraryName,
0628:                        forceDelete, targetName);
0629:            }
0630:
0631:            /**
0632:             * uninstalls shared library
0633:             * 
0634:             * @param sharedLibraryName
0635:             *            name of the shared library
0636:             * @param targetName
0637:             * @return shared library name.
0638:             * @throws ManagementRemoteException
0639:             *             on error
0640:             * 
0641:             * @see com.sun.esb.management.api.installation.InstallationService#uninstallSharedLibrary(java.lang.String,
0642:             *      java.lang.String)
0643:             */
0644:            public String uninstallSharedLibrary(String sharedLibraryName,
0645:                    String targetName) throws ManagementRemoteException {
0646:                logDebug("uninstalling shared library " + sharedLibraryName);
0647:
0648:                ObjectName installerServiceObjectName = this 
0649:                        .getInstallationServiceMBeanObjectName(targetName);
0650:                // ////////////////////////////////////////
0651:                // Start Check to make sure target is valid
0652:                // ////////////////////////////////////////
0653:                this 
0654:                        .checkForValidTarget(installerServiceObjectName,
0655:                                targetName);
0656:                // ////////////////////////////////////////
0657:                // End Check to make sure target is valid
0658:                // ////////////////////////////////////////
0659:
0660:                logDebug("Calling uninstallSharedLibrary on InstallerServiceMBean = "
0661:                        + installerServiceObjectName);
0662:
0663:                Object resultObject = null;
0664:
0665:                resultObject = this .invokeMBeanOperation(
0666:                        installerServiceObjectName, "uninstallSharedLibrary",
0667:                        sharedLibraryName);
0668:
0669:                if (resultObject == null || !(resultObject instanceof  Boolean)
0670:                        || !((Boolean) resultObject).booleanValue()) {
0671:                    Exception exception = this .createManagementException(
0672:                            "ui.mbean.uninstall.sns.error", null, null);
0673:                    throw new ManagementRemoteException(exception);
0674:                }
0675:
0676:                return sharedLibraryName;
0677:            }
0678:
0679:            /**
0680:             * updates component ( service engine, binding component)
0681:             * 
0682:             * @param componentName
0683:             *            Name of the component to update.
0684:             * @param zipFilePath
0685:             *            archive file in a zip format
0686:             * @return The name of the component if successful
0687:             * @throws ManagementRemoteException
0688:             *             on error
0689:             * @see com.sun.esb.management.api.installation.InstallationService#upgradeComponent(java.lang.String,
0690:             *      java.lang.String)
0691:             */
0692:            public String upgradeComponent(String componentName,
0693:                    String zipFilePath) throws ManagementRemoteException {
0694:                logDebug("Updating Component zip file " + zipFilePath);
0695:
0696:                String fileURIString = null;
0697:
0698:                File file = new File(zipFilePath);
0699:                fileURIString = file.getAbsolutePath();
0700:
0701:                ObjectName installerServiceObjectName = this 
0702:                        .getInstallationServiceMBeanObjectName(JBIAdminCommands.DOMAIN_TARGET_KEY);
0703:
0704:                this .checkForValidTarget(installerServiceObjectName,
0705:                        JBIAdminCommands.DOMAIN_TARGET_KEY);
0706:
0707:                // update component
0708:                Object[] params = new Object[2];
0709:                params[0] = componentName;
0710:                params[1] = fileURIString;
0711:
0712:                String[] signature = new String[2];
0713:                signature[0] = "java.lang.String";
0714:                signature[1] = "java.lang.String";
0715:
0716:                this .invokeMBeanOperation(installerServiceObjectName,
0717:                        "upgradeComponent", params, signature);
0718:                return componentName;
0719:            }
0720:
0721:            /////////////////////////////////////////////
0722:            // Start of Cumulative Operation Definitions
0723:            /////////////////////////////////////////////
0724:
0725:            /**
0726:             * installs component ( service engine, binding component)
0727:             * 
0728:             * @return name of the component as map of [targetName,string].
0729:             * @param paramProps
0730:             *            Properties object contains name/value pair.
0731:             * @param zipFilePath
0732:             *            archive file in a zip format
0733:             * @param targetNames
0734:             * @throws ManagementRemoteException
0735:             *             on error
0736:             * 
0737:             */
0738:            public Map<String, String> installComponent(String zipFilePath,
0739:                    Properties paramProps, String[] targetNames)
0740:                    throws ManagementRemoteException {
0741:
0742:                String xmlString = null;
0743:                ConcurrentHashMap<String, String> result = new ConcurrentHashMap<String, String>();
0744:                for (int index = 0; index < targetNames.length; index++) {
0745:                    try {
0746:                        xmlString = this .installComponent(zipFilePath,
0747:                                paramProps, targetNames[index]);
0748:                        if (xmlString != null) {
0749:                            result.putIfAbsent(targetNames[index], xmlString);
0750:                        }
0751:                    } catch (ManagementRemoteException exception) {
0752:                        xmlString = this .getStackTrace(exception);
0753:                        result.putIfAbsent(targetNames[index], xmlString);
0754:                    }
0755:
0756:                }
0757:                return (Map<String, String>) result;
0758:            }
0759:
0760:            /**
0761:             * installs component ( service engine, binding component)
0762:             * 
0763:             * @return name of the component as map of [targetName,string].
0764:             * @param paramProps
0765:             *            Properties object contains name/value pair.
0766:             * @param zipFilePath
0767:             *            archive file in a zip format
0768:             * @param targetNames
0769:             * @throws ManagementRemoteException
0770:             *             on error
0771:             * 
0772:             */
0773:            public Map<String, String> installComponent(String zipFilePath,
0774:                    String[] targetNames) throws ManagementRemoteException {
0775:
0776:                String xmlString = null;
0777:                ConcurrentHashMap<String, String> result = new ConcurrentHashMap<String, String>();
0778:                for (int index = 0; index < targetNames.length; index++) {
0779:                    try {
0780:                        xmlString = this .installComponent(zipFilePath,
0781:                                targetNames[index]);
0782:                        if (xmlString != null) {
0783:                            result.putIfAbsent(targetNames[index], xmlString);
0784:                        }
0785:                    } catch (ManagementRemoteException exception) {
0786:                        xmlString = this .getStackTrace(exception);
0787:                        result.putIfAbsent(targetNames[index], xmlString);
0788:                    }
0789:
0790:                }
0791:                return (Map<String, String>) result;
0792:
0793:            }
0794:
0795:            /**
0796:             * installs shared library
0797:             * 
0798:             * @param zipFilePath
0799:             *            archive file in a zip format
0800:             * @param targetNames
0801:             * @return shared library name as map of [targetName,string].
0802:             * @throws ManagementRemoteException
0803:             *             on error
0804:             * 
0805:             */
0806:            public Map<String, String> installSharedLibrary(String zipFilePath,
0807:                    String[] targetNames) throws ManagementRemoteException {
0808:
0809:                String xmlString = null;
0810:                ConcurrentHashMap<String, String> result = new ConcurrentHashMap<String, String>();
0811:                for (int index = 0; index < targetNames.length; index++) {
0812:                    try {
0813:                        xmlString = this .installSharedLibrary(zipFilePath,
0814:                                targetNames[index]);
0815:                        if (xmlString != null) {
0816:                            result.putIfAbsent(targetNames[index], xmlString);
0817:                        }
0818:                    } catch (ManagementRemoteException exception) {
0819:                        xmlString = this .getStackTrace(exception);
0820:                        result.putIfAbsent(targetNames[index], xmlString);
0821:                    }
0822:                }
0823:                return (Map<String, String>) result;
0824:
0825:            }
0826:
0827:            /**
0828:             * uninstalls component ( service engine, binding component)
0829:             * 
0830:             * @param componentName
0831:             *            name of the component
0832:             * @param targetNames
0833:             * @return name of the component as [targetName, String] map.
0834:             * @throws ManagementRemoteException
0835:             *             on error
0836:             * 
0837:             */
0838:            public Map<String, String> uninstallComponent(String componentName,
0839:                    String[] targetNames) throws ManagementRemoteException {
0840:
0841:                String xmlString = null;
0842:                ConcurrentHashMap<String, String> result = new ConcurrentHashMap<String, String>();
0843:                for (int index = 0; index < targetNames.length; index++) {
0844:                    try {
0845:                        xmlString = this .uninstallComponent(componentName,
0846:                                targetNames[index]);
0847:                        if (xmlString != null) {
0848:                            result.putIfAbsent(targetNames[index], xmlString);
0849:                        }
0850:                    } catch (ManagementRemoteException exception) {
0851:                        xmlString = this .getStackTrace(exception);
0852:                        result.putIfAbsent(targetNames[index], xmlString);
0853:                    }
0854:                }
0855:                return (Map<String, String>) result;
0856:
0857:            }
0858:
0859:            /**
0860:             * uninstalls shared library
0861:             * 
0862:             * @param sharedLibraryName
0863:             *            name of the shared library
0864:             * @param targetNames
0865:             * @return shared library name as [targetName, string] map.
0866:             * @throws ManagementRemoteException
0867:             *             on error
0868:             * 
0869:             */
0870:            public Map<String, String> uninstallSharedLibrary(
0871:                    String sharedLibraryName, String[] targetNames)
0872:                    throws ManagementRemoteException {
0873:
0874:                String xmlString = null;
0875:                ConcurrentHashMap<String, String> result = new ConcurrentHashMap<String, String>();
0876:                for (int index = 0; index < targetNames.length; index++) {
0877:                    try {
0878:                        xmlString = this .uninstallSharedLibrary(
0879:                                sharedLibraryName, targetNames[index]);
0880:                        if (xmlString != null) {
0881:                            result.putIfAbsent(targetNames[index], xmlString);
0882:                        }
0883:                    } catch (ManagementRemoteException exception) {
0884:                        xmlString = this .getStackTrace(exception);
0885:                        result.putIfAbsent(targetNames[index], xmlString);
0886:                    }
0887:
0888:                }
0889:                return (Map<String, String>) result;
0890:
0891:            }
0892:
0893:            /**
0894:             * installs component from Domain( service engine, binding component)
0895:             * 
0896:             * @param componentName
0897:             *            name of the component
0898:             * @param targetNames
0899:             *            array of targets for this operation
0900:             * @return Map of targetName and component name strings.
0901:             * @throws ManagementRemoteException
0902:             *             on error
0903:             */
0904:            public Map<String /* targetName */, String /* targetResult */> installComponentFromDomain(
0905:                    String componentName, String[] targetNames)
0906:                    throws ManagementRemoteException {
0907:                String xmlString = null;
0908:                ConcurrentHashMap<String, String> result = new ConcurrentHashMap<String, String>();
0909:                for (int index = 0; index < targetNames.length; index++) {
0910:                    try {
0911:                        xmlString = this .installComponentFromDomain(
0912:                                componentName, targetNames[index]);
0913:                        if (xmlString != null) {
0914:                            result.putIfAbsent(targetNames[index], xmlString);
0915:                        }
0916:                    } catch (ManagementRemoteException exception) {
0917:                        xmlString = this .getStackTrace(exception);
0918:                        result.putIfAbsent(targetNames[index], xmlString);
0919:                    }
0920:
0921:                }
0922:                return (Map<String, String>) result;
0923:            }
0924:
0925:            /**
0926:             * installs component from Domain( service engine, binding component)
0927:             * 
0928:             * @param componentName
0929:             *            name of the component
0930:             * @param component
0931:             *            configuration properties
0932:             * @param targetNames
0933:             *            array of targets for this operation
0934:             * @return Map of targetName and component name strings.
0935:             * @throws ManagementRemoteException
0936:             *             on error
0937:             */
0938:            public Map<String /* targetName */, String /* targetResult */> installComponentFromDomain(
0939:                    String componentName, Properties properties,
0940:                    String[] targetNames) throws ManagementRemoteException {
0941:                String xmlString = null;
0942:                ConcurrentHashMap<String, String> result = new ConcurrentHashMap<String, String>();
0943:                for (int index = 0; index < targetNames.length; index++) {
0944:                    try {
0945:                        xmlString = this .installComponentFromDomain(
0946:                                componentName, properties, targetNames[index]);
0947:                        if (xmlString != null) {
0948:                            result.putIfAbsent(targetNames[index], xmlString);
0949:                        }
0950:                    } catch (ManagementRemoteException exception) {
0951:                        xmlString = this .getStackTrace(exception);
0952:                        result.putIfAbsent(targetNames[index], xmlString);
0953:                    }
0954:
0955:                }
0956:                return (Map<String, String>) result;
0957:            }
0958:
0959:            /**
0960:             * uninstalls component ( service engine, binding component)
0961:             * 
0962:             * @param componentName
0963:             *            name of the component
0964:             * @param forceDelete
0965:             *            true to delete, false to not
0966:             * @param targetName
0967:             *            name of the target for this operation
0968:             * @return Map of targetName and component name strings.
0969:             * @throws ManagementRemoteException
0970:             *             on error
0971:             */
0972:            public Map<String /* targetName */, String /* targetResult */> uninstallComponent(
0973:                    String componentName, boolean forceDelete,
0974:                    String[] targetNames) throws ManagementRemoteException {
0975:                String xmlString = null;
0976:                ConcurrentHashMap<String, String> result = new ConcurrentHashMap<String, String>();
0977:                for (int index = 0; index < targetNames.length; index++) {
0978:                    try {
0979:                        xmlString = this .uninstallComponent(componentName,
0980:                                forceDelete, targetNames[index]);
0981:                        if (xmlString != null) {
0982:                            result.putIfAbsent(targetNames[index], xmlString);
0983:                        }
0984:                    } catch (ManagementRemoteException exception) {
0985:                        xmlString = this .getStackTrace(exception);
0986:                        result.putIfAbsent(targetNames[index], xmlString);
0987:                    }
0988:
0989:                }
0990:                return (Map<String, String>) result;
0991:
0992:            }
0993:
0994:            /**
0995:             * installs shared library
0996:             * 
0997:             * @param libraryName
0998:             *            name of the library
0999:             * @param targetName
1000:             *            name of the target for this operation
1001:             * @return Map of targetName and shared library name strings.
1002:             * @throws ManagementRemoteException
1003:             *             on error
1004:             */
1005:            public Map<String /* targetName */, String /* targetResult */> installSharedLibraryFromDomain(
1006:                    String libraryName, String[] targetNames)
1007:                    throws ManagementRemoteException {
1008:                String xmlString = null;
1009:                ConcurrentHashMap<String, String> result = new ConcurrentHashMap<String, String>();
1010:                for (int index = 0; index < targetNames.length; index++) {
1011:                    try {
1012:                        xmlString = this .installSharedLibraryFromDomain(
1013:                                libraryName, targetNames[index]);
1014:                        if (xmlString != null) {
1015:                            result.putIfAbsent(targetNames[index], xmlString);
1016:                        }
1017:                    } catch (ManagementRemoteException exception) {
1018:                        xmlString = this .getStackTrace(exception);
1019:                        result.putIfAbsent(targetNames[index], xmlString);
1020:                    }
1021:
1022:                }
1023:                return (Map<String, String>) result;
1024:
1025:            }
1026:
1027:            /**
1028:             * uninstalls shared library
1029:             * 
1030:             * @param sharedLibraryName
1031:             *            name of the shared library
1032:             * @param forceDelete
1033:             *            true to delete, false to not
1034:             * @param targetName
1035:             *            name of the target for this operation
1036:             * @return Map of targetName and shared library name strings.
1037:             * @throws ManagementRemoteException
1038:             *             on error
1039:             */
1040:            public Map<String /* targetName */, String /* targetResult */> uninstallSharedLibrary(
1041:                    String sharedLibraryName, boolean forceDelete,
1042:                    String[] targetNames) throws ManagementRemoteException {
1043:                String xmlString = null;
1044:                ConcurrentHashMap<String, String> result = new ConcurrentHashMap<String, String>();
1045:                for (int index = 0; index < targetNames.length; index++) {
1046:                    try {
1047:                        xmlString = this .uninstallSharedLibrary(
1048:                                sharedLibraryName, forceDelete,
1049:                                targetNames[index]);
1050:                        if (xmlString != null) {
1051:                            result.putIfAbsent(targetNames[index], xmlString);
1052:                        }
1053:                    } catch (ManagementRemoteException exception) {
1054:                        xmlString = this .getStackTrace(exception);
1055:                        result.putIfAbsent(targetNames[index], xmlString);
1056:                    }
1057:
1058:                }
1059:                return (Map<String, String>) result;
1060:            }
1061:
1062:            /**
1063:             * uninstalls component ( service engine, binding component)
1064:             * 
1065:             * @param componentName
1066:             *            name of the component
1067:             * @param forceDelete
1068:             *            true to delete, false to not
1069:             * @param retainInDomain
1070:             *            true to not delete it from the domain target, false to also
1071:             *            delete it from the domain target.
1072:             * @param targetNames
1073:             *            array of targets for this operation
1074:             * @return Map of targetName and component name strings.
1075:             * @throws ManagementRemoteException
1076:             *             on error
1077:             */
1078:
1079:            public Map<String /* targetName */, String /* targetResult */> uninstallComponent(
1080:                    String componentName, boolean forceDelete,
1081:                    boolean retainInDomain, String[] targetNames)
1082:                    throws ManagementRemoteException {
1083:                String xmlString = null;
1084:                ConcurrentHashMap<String, String> result = new ConcurrentHashMap<String, String>();
1085:                for (int index = 0; index < targetNames.length; index++) {
1086:                    try {
1087:                        xmlString = this 
1088:                                .uninstallComponent(componentName, forceDelete,
1089:                                        retainInDomain, targetNames[index]);
1090:                        if (xmlString != null) {
1091:                            result.putIfAbsent(targetNames[index], xmlString);
1092:                        }
1093:                    } catch (ManagementRemoteException exception) {
1094:                        xmlString = this .getStackTrace(exception);
1095:                        result.putIfAbsent(targetNames[index], xmlString);
1096:                    }
1097:
1098:                }
1099:                return (Map<String, String>) result;
1100:            }
1101:
1102:            /**
1103:             * uninstalls shared library
1104:             * 
1105:             * @param sharedLibraryName
1106:             *            name of the shared library
1107:             * @param forceDelete
1108:             *            true to delete, false to not
1109:             * @param retainInDomain
1110:             *            true to not delete it from the domain target, false to also
1111:             *            delete it from the domain target.
1112:             * @param targetNames
1113:             *            array of targets for this operation
1114:             * @return Map of targetName and shared library name strings.
1115:             * @throws ManagementRemoteException
1116:             *             on error
1117:             */
1118:            public Map<String /* targetName */, String /* targetResult */> uninstallSharedLibrary(
1119:                    String sharedLibraryName, boolean forceDelete,
1120:                    boolean retainInDomain, String[] targetNames)
1121:                    throws ManagementRemoteException {
1122:                String xmlString = null;
1123:                ConcurrentHashMap<String, String> result = new ConcurrentHashMap<String, String>();
1124:                for (int index = 0; index < targetNames.length; index++) {
1125:                    try {
1126:                        xmlString = this .uninstallSharedLibrary(
1127:                                sharedLibraryName, forceDelete, retainInDomain,
1128:                                targetNames[index]);
1129:                        if (xmlString != null) {
1130:                            result.putIfAbsent(targetNames[index], xmlString);
1131:                        }
1132:                    } catch (ManagementRemoteException exception) {
1133:                        xmlString = this .getStackTrace(exception);
1134:                        result.putIfAbsent(targetNames[index], xmlString);
1135:                    }
1136:
1137:                }
1138:                return (Map<String, String>) result;
1139:            }
1140:
1141:            /////////////////////////////////////////////
1142:            // End of Cumulative Operation Definitions
1143:            /////////////////////////////////////////////
1144:
1145:            /**
1146:             * set the installer configuration parameters
1147:             * 
1148:             * @param installerObjectName
1149:             *            objectname
1150:             * @param paramProps
1151:             *            name,value pair list
1152:             * @throws ManagementRemoteException
1153:             *             on error.
1154:             */
1155:            protected void configureComponentInstaller(
1156:                    ObjectName installerObjectName, Properties paramProps)
1157:                    throws ManagementRemoteException {
1158:                if (paramProps == null || paramProps.size() == 0) {
1159:                    logDebug("No Installer Params for " + installerObjectName);
1160:                    return;
1161:                }
1162:
1163:                ObjectName configObjectName = null;
1164:                configObjectName = (ObjectName) this .getMBeanAttribute(
1165:                        installerObjectName, "InstallerConfigurationMBean");
1166:
1167:                if (configObjectName == null) {
1168:                    Exception exception = this .createManagementException(
1169:                            "ui.mbean.install.config.mbean.error.not.exist",
1170:                            null, null);
1171:                    throw new ManagementRemoteException(exception);
1172:
1173:                }
1174:
1175:                // Test is a Configuration MBean is registered. If it is not
1176:                // registered, decide what needs to be done
1177:                if (this .isMBeanRegistered(configObjectName) == false) {
1178:                    // TODO need to decide what to do here.
1179:                    // Throw an exception? OR return?
1180:                    logDebug("Configuration MBean for " + installerObjectName);
1181:                    logDebug("No ConfigurationMBean registered with name: "
1182:                            + configObjectName);
1183:                    return;
1184:                }
1185:
1186:                logDebug("Setting the Installer Params on ConfigMBean "
1187:                        + configObjectName);
1188:
1189:                AttributeList attrList = constructMBeanAttributes(
1190:                        configObjectName, paramProps);
1191:                try {
1192:
1193:                    this .setMBeanAttributes(configObjectName, attrList);
1194:                } catch (Exception ex) {
1195:                    Exception exception = this 
1196:                            .createManagementException(
1197:                                    "ui.mbean.install.config.mbean.error.set.attrs.error",
1198:                                    null, ex);
1199:                    throw new ManagementRemoteException(exception);
1200:
1201:                }
1202:            }
1203:
1204:            /**
1205:             * finds the component id property in the object name
1206:             * 
1207:             * @param jmxObjectName
1208:             *            jmx obj name
1209:             * @return componentId of the component if embbeded in object name else
1210:             *         null.
1211:             */
1212:            protected String getComponentNameFromJmxObjectName(
1213:                    ObjectName jmxObjectName) {
1214:                String componentName = null;
1215:                try {
1216:                    // TODO change COMPONENT_ID_KEY to Component Name when mgmt api
1217:                    // changes.
1218:                    componentName = ((ObjectName) jmxObjectName)
1219:                            .getKeyProperty(JBIJMXObjectNames.COMPONENT_ID_KEY);
1220:
1221:                } catch (NullPointerException nullEx) {
1222:                    componentName = null;
1223:                }
1224:                return componentName;
1225:            }
1226:
1227:            /**
1228:             * unloads the installer from memory and removes the component optionally
1229:             * 
1230:             * @param installerObjectName
1231:             *            installerObjectName.
1232:             * @param isIgnoreExceptions
1233:             *            true or false.
1234:             * @param isRemoveComponent
1235:             *            true if this should cleanup disk or false. true is usded in
1236:             *            uninstall process
1237:             * @param targetName
1238:             * @return true or false
1239:             * @throws ManagementRemoteException
1240:             *             on error
1241:             */
1242:            protected boolean unloadComponentInstaller(
1243:                    ObjectName installerObjectName, boolean isRemoveComponent,
1244:                    boolean isIgnoreExceptions, String targetName)
1245:                    throws ManagementRemoteException {
1246:                String componentName = null;
1247:                if (installerObjectName == null) {
1248:                    Exception exception = this .createManagementException(
1249:                            "ui.mbean.install.installer.mbean.not.exist", null,
1250:                            null);
1251:                    throw new ManagementRemoteException(exception);
1252:
1253:                }
1254:                // get the component name from intaller.
1255:                componentName = this 
1256:                        .getComponentNameFromJmxObjectName(installerObjectName);
1257:
1258:                if (componentName == null || componentName.trim().length() <= 0) {
1259:                    String[] args = { installerObjectName.toString() };
1260:                    Exception exception = this 
1261:                            .createManagementException(
1262:                                    "ui.mbean.install.installer.mbean.has.no.component.name",
1263:                                    args, null);
1264:                    throw new ManagementRemoteException(exception);
1265:                }
1266:
1267:                return this .unloadComponentInstaller(componentName,
1268:                        isRemoveComponent, isIgnoreExceptions, targetName);
1269:            }
1270:
1271:            /**
1272:             * Unloads the installer from memory and removes the component optionally
1273:             * 
1274:             * @param componentName
1275:             *            componentName.
1276:             * @param isIgnoreExceptions
1277:             *            true or false.
1278:             * @param isRemoveComponent
1279:             *            true if this should cleanup disk or false. true is
1280:             * @param targetName
1281:             *            usded in uninstall process
1282:             * @return true or false
1283:             * @throws ManagementRemoteException
1284:             *             on error.
1285:             */
1286:            protected boolean unloadComponentInstaller(String componentName,
1287:                    boolean isRemoveComponent, boolean isIgnoreExceptions,
1288:                    String targetName) throws ManagementRemoteException {
1289:                boolean retainInDomain = false;
1290:                if (retainInDomain == true) {
1291:                    isRemoveComponent = false;
1292:                    return this .unloadComponentInstallerInternal(componentName,
1293:                            isRemoveComponent, isIgnoreExceptions, targetName);
1294:                }
1295:                return this .unloadComponentInstallerInternal(componentName,
1296:                        isRemoveComponent, isIgnoreExceptions, targetName);
1297:            }
1298:
1299:            /**
1300:             * Unloads the installer from memory and removes the component optionally
1301:             * 
1302:             * @param componentName
1303:             *            componentName.
1304:             * @param isRemoveComponent
1305:             *            true if this should cleanup disk or false. true is
1306:             * @param retainInDomain
1307:             *            true if this should be kept in domain target, false if not
1308:             * @param isIgnoreExceptions
1309:             *            true or false.
1310:             * @param targetName
1311:             *            used in uninstall process
1312:             * @return true or false
1313:             * @throws ManagementRemoteException
1314:             *             on error.
1315:             */
1316:            protected boolean unloadComponentInstallerInternal(
1317:                    String componentName, boolean isRemoveComponent,
1318:                    boolean isIgnoreExceptions, String targetName)
1319:                    throws ManagementRemoteException {
1320:                boolean result = false;
1321:                logDebug("unloadComponentInstaller ComponentName: "
1322:                        + componentName + " isremoveComponent "
1323:                        + isRemoveComponent + " isIgnoreExceptions "
1324:                        + isIgnoreExceptions + " targetName " + targetName);
1325:                try {
1326:                    ObjectName installerServiceObjectName = this 
1327:                            .getInstallationServiceMBeanObjectName(targetName);
1328:
1329:                    // call unload installer to unregister the mbean
1330:                    Object[] params = new Object[2];
1331:                    params[0] = componentName;
1332:                    params[1] = Boolean.valueOf(isRemoveComponent);
1333:
1334:                    String[] signature = new String[2];
1335:                    signature[0] = "java.lang.String";
1336:                    signature[1] = "boolean";
1337:
1338:                    logDebug("Calling unloadInstaller with params ( "
1339:                            + params[0] + " , " + params[1]
1340:                            + " ) on InstallerServiceMBean : "
1341:                            + installerServiceObjectName.toString());
1342:
1343:                    Object resultObject = invokeMBeanOperation(
1344:                            installerServiceObjectName, "unloadInstaller",
1345:                            params, signature);
1346:                    result = ((Boolean) resultObject).booleanValue();
1347:                } catch (Exception ex) {
1348:
1349:                    if (isIgnoreExceptions) {
1350:                        logError(ex);
1351:                    } else {
1352:                        throw ManagementRemoteException.filterJmxExceptions(ex);
1353:                    }
1354:                }
1355:                return result;
1356:            }
1357:
1358:            /**
1359:             * uninstalls component ( service engine, binding component)
1360:             * 
1361:             * @param componentName
1362:             *            name of the component
1363:             * @param targetName
1364:             * @return name of the component.
1365:             * @throws ManagementRemoteException
1366:             *             on error
1367:             */
1368:            protected String uninstallComponentInternal(String componentName,
1369:                    boolean force, String targetName)
1370:                    throws ManagementRemoteException {
1371:                boolean retainInDomain = false;
1372:                return this .uninstallComponentInternal(componentName, force,
1373:                        retainInDomain, targetName);
1374:            }
1375:
1376:            /**
1377:             * uninstalls component ( service engine, binding component)
1378:             * 
1379:             * @param componentName
1380:             *            name of the component
1381:             * @param force
1382:             * @param retainInDomain
1383:             * @param targetName
1384:             * @return name of the component.
1385:             * @throws ManagementRemoteException
1386:             *             on error
1387:             */
1388:            protected String uninstallComponentInternal(String componentName,
1389:                    boolean force, boolean retainInDomain, String targetName)
1390:                    throws ManagementRemoteException {
1391:                logDebug("Uninstalling Component " + componentName);
1392:
1393:                // //////////////////////////////////////////////////////////////////
1394:                // TODO
1395:                // NOTE:
1396:                // Commenting this code out for now based on discussions within the team
1397:                // between Nikita, Keith, Chikkala, and team during the team meeting
1398:                // on Sept 20'06 between 2:00pm to 3:00pm.
1399:                // Will revisit if this causes a problem.
1400:                // //////////////////////////////////////////////////////////////////
1401:                // boolean isExistingComponent = isExistingComponent(componentName,
1402:                // targetName);
1403:                // if (isExistingComponent == false) {
1404:                // throw new
1405:                // ManagementRemoteException(AbstractUIMBeanImpl.getI18NBundle()
1406:                // .getMessage("ui.mbean.component.id.does.not.exist",
1407:                // componentName));
1408:                // }
1409:                // //////////////////////////////////////////////////////////////////
1410:
1411:                ObjectName installerServiceObjectName = this 
1412:                        .getInstallationServiceMBeanObjectName(targetName);
1413:                // ////////////////////////////////////////
1414:                // Start Check to make sure target is valid
1415:                // ////////////////////////////////////////
1416:                this 
1417:                        .checkForValidTarget(installerServiceObjectName,
1418:                                targetName);
1419:                // ////////////////////////////////////////
1420:                // End Check to make sure target is valid
1421:                // ////////////////////////////////////////
1422:
1423:                logDebug("Uninstall Step 1 : Calling loadInstaller on InstallerServiceMBean : "
1424:                        + installerServiceObjectName);
1425:                // // load installer
1426:                ObjectName installerObjectName = null;
1427:                installerObjectName = (ObjectName) this .invokeMBeanOperation(
1428:                        installerServiceObjectName, "loadInstaller",
1429:                        componentName);
1430:
1431:                if (installerObjectName == null) {
1432:                    Exception exception = this .createManagementException(
1433:                            "ui.mbean.uninstall.comp.error.installerMBean",
1434:                            null, null);
1435:                    throw new ManagementRemoteException(exception);
1436:                }
1437:
1438:                boolean uninstalled = false;
1439:                try {
1440:                    logDebug("Uninstall Step 2 : Calling Unisntall on InstallerMbean : "
1441:                            + installerObjectName);
1442:
1443:                    Object[] params = new Object[1];
1444:                    params[0] = Boolean.valueOf(force);
1445:
1446:                    String[] signature = new String[1];
1447:                    signature[0] = "boolean";
1448:
1449:                    // invoke uninstall on the component installer
1450:                    this .invokeMBeanOperation(installerObjectName, "uninstall",
1451:                            params, signature);
1452:                    uninstalled = true;
1453:                } finally {
1454:                    // execute always after uninstall
1455:                    // call unload installer to unregister the mbean and remove the
1456:                    // component jars
1457:                    boolean isRemoveComponent = true;
1458:                    boolean ignoreExceptions = false;
1459:                    if (!uninstalled) {
1460:                        // uninstall not successful,ignore unload exceptions. so that
1461:                        // the uninstall exception can be propagated to client.
1462:                        ignoreExceptions = true;
1463:                        isRemoveComponent = false;
1464:                    }
1465:                    logDebug("Uninstall Step 2 : unloading component installer "
1466:                            + installerObjectName);
1467:                    if (retainInDomain == true) {
1468:                        isRemoveComponent = false;
1469:                    }
1470:                    this .unloadComponentInstaller(installerObjectName,
1471:                            isRemoveComponent, ignoreExceptions, targetName);
1472:                }
1473:                return componentName;
1474:
1475:            }
1476:
1477:            /**
1478:             * uninstalls shared library
1479:             * 
1480:             * @param sharedLibraryName
1481:             *            name of the shared library
1482:             * @param forceDelete
1483:             *            true to delete, false to not
1484:             * @param targetName
1485:             *            name of the target for this operation
1486:             * @return Map of targetName and shared library name strings.
1487:             * @throws ManagementRemoteException
1488:             *             on error
1489:             */
1490:            protected String uninstallSharedLibraryInternal(
1491:                    String sharedLibraryName, boolean forceDelete,
1492:                    String targetName) throws ManagementRemoteException {
1493:                return this.uninstallSharedLibrary(sharedLibraryName,
1494:                        targetName);
1495:            }
1496:
1497:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.