Source Code Cross Referenced for ConfigureInstancesCommand.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:         * Copyright 2004 Sun Microsystems, Inc. All
003:         * rights reserved. Use of this product is subject
004:         * to license terms. Federal Acquisitions:
005:         * Commercial Software -- Government Users
006:         * Subject to Standard License Terms and
007:         * Conditions.
008:         *
009:         * Sun, Sun Microsystems, the Sun logo, and Sun ONE
010:         * are trademarks or registered trademarks of Sun Microsystems,
011:         * Inc. in the United States and other countries.
012:         */package com.sun.portal.admin.cli.commands;
013:
014:        import java.text.MessageFormat;
015:        import java.io.File;
016:
017:        //JMX
018:        import javax.management.MBeanServerConnection;
019:        import javax.management.ObjectName;
020:        import javax.management.InstanceNotFoundException;
021:        import javax.management.MBeanException;
022:        import javax.management.ReflectionException;
023:        import javax.management.MalformedObjectNameException;
024:
025:        //PS Admin Common
026:        import com.sun.portal.admin.common.util.AdminClientUtil;
027:        import com.sun.portal.util.FileWildFilter;
028:
029:        //CLI framework
030:        import com.sun.enterprise.cli.framework.*;
031:
032:        /**
033:         * This class implements the psadmin configure-instances subcommand.
034:         * This CLI is meant as a private CLI used only during configuration
035:         * The configure-instances subcommand calls the PortalMBean:configureInstances call
036:         * for all instances that belong to that portal,  which does the the following tasks:
037:         * <UL>
038:         * <LI>adds to instance server classpath entries specified in the conf/server.classpath if present
039:         * <LI>add to instance jvm-options entries specified in the conf/jvmoptions.properties if present
040:         * <LI>add to instance server.policy entries specified in the conf/server.policy if present
041:         * <LI>adds to instance jdbc resources specified in the conf/*.datasource if present
042:         * <LI>adds to instance jndi lookups specified in the conf/*.jndi if present
043:         * <UL>
044:         * Note: All configuration should check if entries being configured already exist.
045:         * Note: These configuration require a webcontainer restart before coming into affect
046:         */
047:
048:        public class ConfigureInstancesCommand extends AdminBaseCommand {
049:
050:            // Option definitions
051:            public static final String OPT_CONF_DIR = "confdir";
052:
053:            //private member variables
054:            private File m_confDir;
055:
056:            /**
057:             * Executes the subcommand. 
058:             *
059:             * @exception com.sun.enterprise.cli.framework.CommandException If error occurrs during the execution.
060:             */
061:            public void runCommand() throws CommandException,
062:                    CommandValidationException {
063:                validateOptions();
064:                validatePortalId();
065:                validateConfiguration();
066:
067:                String operation = "";
068:
069:                try {
070:
071:                    // Get the MBean server connection
072:                    MBeanServerConnection msc = getMBeanServerConnection(
073:                            getUserId(), getPassword(), getHost());
074:
075:                    // Get the MBean object for the portal
076:                    ObjectName pObjName = AdminClientUtil
077:                            .getPortalMBeanObjectName(
078:                                    AdminClientUtil.DEFAULT_DOMAIN,
079:                                    getPortalId());
080:
081:                    // Setting the params and signature
082:                    Object[] params = new Object[] { m_confDir
083:                            .getAbsolutePath() };
084:                    String[] signature = new String[] { "java.lang.String" };
085:                    operation = "configureInstances";
086:
087:                    // Invoke the configureInstances operation on the PortalMBean
088:                    // This method returns a boolean true in case of successful configuration
089:                    Boolean ret = (Boolean) msc.invoke(pObjName, operation,
090:                            params, signature);
091:                    boolean success = ret.booleanValue();
092:                    if (!success) {
093:                        throw new CommandException(
094:                                getLocalizedString(ERROR_INSTANCE_CONF_FAILED));
095:                    }
096:
097:                } catch (InstanceNotFoundException ie) {
098:                    Object tok[] = { operation };
099:                    throw new CommandException(getLocalizedString(
100:                            ERROR_MBEAN_INSTANCE_NOT_FOUND, tok), ie);
101:                } catch (MBeanException me) {
102:                    Object tok[] = { operation };
103:                    throw new CommandException(getLocalizedString(
104:                            ERROR_JMX_INVOKE, tok), me);
105:                } catch (ReflectionException re) {
106:                    Object tok[] = { operation };
107:                    throw new CommandException(getLocalizedString(
108:                            ERROR_MBEAN_REFLECTION_ERROR, tok), re);
109:                } catch (MalformedObjectNameException mle) {
110:                    throw new CommandException(
111:                            getLocalizedString(ERROR_OBJECT_NAME), mle);
112:                } catch (CommandException ce) {
113:                    throw ce;
114:                } catch (Exception ex) {
115:                    throw new CommandException(
116:                            getLocalizedString(COMMAND_FAILED), ex);
117:                } finally {
118:                    closeMBeanServerConnection();
119:                }
120:            }
121:
122:            protected void validateConfiguration() throws CommandException {
123:                String confDir = getOption(OPT_CONF_DIR);
124:                m_confDir = new File(confDir);
125:                //If /conf does not exist or is not directory
126:                if (!m_confDir.exists() || !m_confDir.isDirectory()) {
127:                    Object tokens[] = new Object[] { confDir };
128:                    throw new CommandException(getLocalizedString(
129:                            ERROR_INVALID_INSTANCE_CONF_DIR, tokens));
130:                }
131:
132:                boolean doConfig = false;
133:
134:                //Does conf/server.classpath exist?
135:                if (!doConfig) {
136:                    doConfig = doConfigFilesExist("server.classpath");
137:                }
138:
139:                //Does conf/jvmoptions.properties exist?
140:                if (!doConfig) {
141:                    doConfig = doConfigFilesExist("jvmoptions.properties");
142:                }
143:
144:                //Does conf/server.policy exist?
145:                if (!doConfig) {
146:                    doConfig = doConfigFilesExist("server.policy");
147:                }
148:
149:                //Does conf/*.datasource exist?
150:                if (!doConfig) {
151:                    doConfig = doConfigFilesExist("[\\S|\\s]*\\.datasource");
152:                }
153:
154:                //Does conf/*.jndi exist?
155:                if (!doConfig) {
156:                    doConfig = doConfigFilesExist("[\\S|\\s]*\\.jndi");
157:                }
158:
159:                //if doConfig is still false then nothing to validate
160:                if (!doConfig) {
161:                    Object tokens[] = new Object[] { confDir };
162:                    throw new CommandException(getLocalizedString(
163:                            ERROR_INSTANCE_CONF_NOT_REQD, tokens));
164:                }
165:            }
166:
167:            private boolean doConfigFilesExist(String filesRegEx) {
168:                FileWildFilter filter = new FileWildFilter(filesRegEx, null,
169:                        FileWildFilter.ONLY_FILE);
170:                File[] files = m_confDir.listFiles(filter);
171:                if (files != null && files.length != 0)
172:                    return true;
173:                else
174:                    return false;
175:            }
176:
177:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.