Source Code Cross Referenced for RedeployCommand.java in  » Portal » Open-Portal » com » sun » portal » admin » cli » commands » 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 » Portal » Open Portal » com.sun.portal.admin.cli.commands 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /**
002:         * $Id: RedeployCommand.java,v 1.10 2006/10/25 21:24:26 cathywu Exp $
003:         * Copyright 2004 Sun Microsystems, Inc. All
004:         * rights reserved. Use of this product is subject
005:         * to license terms. Federal Acquisitions:
006:         * Commercial Software -- Government Users
007:         * Subject to Standard License Terms and
008:         * Conditions.
009:         *
010:         * Sun, Sun Microsystems, the Sun logo, and Sun ONE
011:         * are trademarks or registered trademarks of Sun Microsystems,
012:         * Inc. in the United States and other countries.
013:         */package com.sun.portal.admin.cli.commands;
014:
015:        import java.text.MessageFormat;
016:        import java.util.logging.Level;
017:        import java.util.logging.Logger;
018:
019:        //JMX
020:        import javax.management.MBeanServerConnection;
021:        import javax.management.ObjectName;
022:        import javax.management.InstanceNotFoundException;
023:        import javax.management.MBeanException;
024:        import javax.management.ReflectionException;
025:        import javax.management.MalformedObjectNameException;
026:
027:        //PS Admin Common
028:        import com.sun.portal.admin.common.util.AdminClientUtil;
029:        import com.sun.portal.admin.common.PSMBeanException;
030:
031:        //CLI framework
032:        import com.sun.enterprise.cli.framework.*;
033:
034:        /**
035:         * This class implements the psadmin create-portal subcommand. The
036:         * create-portal subcommand calls the PortalDomainMBean and performs
037:         * the following tasks:
038:         * <UL>
039:         * <LI>loads the display profile basic services
040:         * and providers
041:         * <LI>creates necessary portal specific file directory
042:         * <LI>associates the portal in the portal domain
043:         * <LI>creates the portal war file
044:         * <UL>
045:         */
046:
047:        public class RedeployCommand extends AdminBaseCommand {
048:            public static final String OPT_ALLWEBAPPS = "allwebapps";
049:            public static final String ATTR_PORTALURI = "PortalWebAppUri";
050:
051:            /**
052:             * Executes the subcommand. 
053:             *
054:             * @exception CommandException If error occurrs during the execution.
055:             */
056:            public void runCommand() throws CommandException,
057:                    CommandValidationException {
058:                String instanceId = getInstanceId();
059:
060:                validateOptions();
061:                validatePortalId();
062:                if (instanceId != null) {
063:                    validateInstance();
064:                }
065:
066:                String operation = "";
067:
068:                try {
069:
070:                    // Get the MBean server connection
071:                    MBeanServerConnection msc = getMBeanServerConnection(
072:                            getUserId(), getPassword(), getHost());
073:
074:                    // Get the MBean object for the portal
075:                    ObjectName pObjName = AdminClientUtil
076:                            .getPortalMBeanObjectName(
077:                                    AdminClientUtil.DEFAULT_DOMAIN,
078:                                    getPortalId());
079:
080:                    // Setting the params and signature
081:                    Object[] params = new Object[] {};
082:                    String[] signature = new String[] {};
083:
084:                    if (getBooleanOption(OPT_ALLWEBAPPS)) {
085:                        // Setting the params and signature
086:                        Object[] iparams = { instanceId };
087:                        String[] isignature = { "java.lang.String" };
088:                        operation = "undeployAllWebApps";
089:
090:                        // Invoke the undeployAllInstances method on the instance MBean
091:                        msc.invoke(pObjName, operation, iparams, isignature);
092:
093:                        operation = "deployAllWebApps";
094:
095:                        // Invoke the deployAllInstances method on the instance MBean
096:                        msc.invoke(pObjName, operation, iparams, isignature);
097:                    } else if (instanceId != null) {
098:                        // Invoke the recreateWebApp operation on the newly
099:                        // created portal. This method returns the URI at
100:                        // which this created Webapp should be deployed. Use
101:                        // it as the input to the deploy command
102:                        operation = "createPortalWebApp";
103:                        String uri = (String) msc.invoke(pObjName, operation,
104:                                params, signature);
105:
106:                        // Get the Instance MBean object
107:                        ObjectName objName = AdminClientUtil
108:                                .getInstanceMBeanObjectName(
109:                                        AdminClientUtil.DEFAULT_DOMAIN,
110:                                        getPortalId(), getInstanceId());
111:
112:                        // Setting the params and signature
113:                        Object[] iparams = { uri };
114:                        String[] isignature = { "java.lang.String" };
115:                        operation = "undeploy";
116:
117:                        // Invoke the undeploy method on the instance MBean
118:                        msc.invoke(objName, operation, iparams, isignature);
119:
120:                        operation = "deploy";
121:                        // Invoke the deploy method on the instance MBean
122:                        msc.invoke(objName, operation, iparams, isignature);
123:                    } else {
124:                        Object[] iparams = {};
125:                        String[] isignature = {};
126:                        operation = "undeployPortalWebApp";
127:
128:                        // Invoke the undeployPortalAll method on the instance MBean
129:                        msc.invoke(pObjName, operation, iparams, isignature);
130:
131:                        operation = "deployPortalWebApp";
132:                        // Invoke the deployPortalAll method on the instance MBean
133:                        msc.invoke(pObjName, operation, iparams, isignature);
134:                    }
135:                } catch (InstanceNotFoundException ie) {
136:                    throw new CommandException(getLocalizedString(
137:                            ERROR_MBEAN_INSTANCE_NOT_FOUND,
138:                            new Object[] { operation }), ie);
139:                } catch (MBeanException me) {
140:                    Object tok[] = { operation };
141:                    logger.log(Level.SEVERE, "PSALI_CSPACC0006", me);
142:
143:                    boolean pe = me.getCause() instanceof  PSMBeanException;
144:                    if (getBooleanOption(OPT_DEBUG)) {
145:                        if (pe) {
146:                            String dbgMsg = me.getCause().getMessage();
147:                            if (dbgMsg != null) {
148:                                CLILogger.getInstance().printMessage(dbgMsg);
149:                            }
150:                        }
151:                    }
152:                    if (pe) {
153:                        Object tokens[] = ((PSMBeanException) me.getCause())
154:                                .getTokens();
155:                        if (tokens != null) {
156:                            throw new CommandException(getLocalizedString(
157:                                    ((PSMBeanException) me.getCause())
158:                                            .getErrorKey(), tokens), me);
159:                        } else {
160:                            throw new CommandException(
161:                                    getLocalizedString(((PSMBeanException) me
162:                                            .getCause()).getErrorKey()), me);
163:                        }
164:                    } else {
165:                        throw new CommandException(getLocalizedString(
166:                                ERROR_JMX_INVOKE, tok), me);
167:                    }
168:                } catch (ReflectionException re) {
169:                    throw new CommandException(getLocalizedString(
170:                            ERROR_MBEAN_REFLECTION_ERROR,
171:                            new Object[] { operation }), re);
172:                } catch (MalformedObjectNameException mle) {
173:                    throw new CommandException(
174:                            getLocalizedString(ERROR_OBJECT_NAME), mle);
175:                } catch (CommandException ce) {
176:                    throw ce;
177:                } catch (Exception ex) {
178:                    throw new CommandException(
179:                            getLocalizedString(COMMAND_FAILED), ex);
180:                } finally {
181:                    closeMBeanServerConnection();
182:                }
183:            }
184:
185:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.