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


0001:        /**
0002:         * $Id: IBMWAS5Impl.java,v 1.37 2006/09/27 08:06:43 pr150268 Exp $
0003:         * Copyright 2004 Sun Microsystems, Inc. All
0004:         * rights reserved. Use of this product is subject
0005:         * to license terms. Federal Acquisitions:
0006:         * Commercial Software -- Government Users
0007:         * Subject to Standard License Terms and
0008:         * Conditions.
0009:         *
0010:         * Sun, Sun Microsystems, the Sun logo, and Sun ONE
0011:         * are trademarks or registered trademarks of Sun Microsystems,
0012:         * Inc. in the United States and other countries.
0013:         */package com.sun.portal.fabric.tasks;
0014:
0015:        import java.io.File;
0016:        import java.util.Map;
0017:        import java.util.logging.Level;
0018:        import java.util.logging.Logger;
0019:        import java.util.logging.LogRecord;
0020:
0021:        import org.jdom.Element;
0022:
0023:        import com.sun.portal.admin.common.context.PSConfigContext;
0024:        import com.sun.portal.fabric.util.FileUtil;
0025:        import java.io.IOException;
0026:        import java.io.FileWriter;
0027:        import com.sun.portal.fabric.util.os.OSTasks;
0028:        import com.sun.portal.fabric.util.os.OSTasksFactory;
0029:        import com.sun.portal.log.common.PortalLogger;
0030:
0031:        public class IBMWAS5Impl extends WebContainerBase {
0032:
0033:            private String wcTargetInstance = null;
0034:            private String wcHomeDir = null;
0035:            private String wcDeployNode = null;
0036:            private String wcDeployCell = null;
0037:            private String wcAdminUser = null;
0038:            private String wcAdminPassword = null;
0039:            private String wcConfigdir = null;
0040:            private String wcJDKDir = null;
0041:            private String wcDocRootDir = null;
0042:            private static File wcConfigfile = null;
0043:            private static File setupFile = null;
0044:            private String amconfigScript = null;
0045:            private String wcDefaultHost;
0046:            private static Logger logger = PortalLogger
0047:                    .getLogger(IBMWAS5Impl.class);
0048:
0049:            /**
0050:             * Constructor
0051:             *
0052:             * @param wcAttributes WebContainer Information as a Map
0053:             * @param logger Logger
0054:             */
0055:            public IBMWAS5Impl(Map wcAttributes) {
0056:
0057:                super (wcAttributes);
0058:
0059:                wcHomeDir = (String) wcAttributes
0060:                        .get(WEB_CONTAINER_INSTALL_DIR);
0061:                wcTargetInstance = (String) wcAttributes
0062:                        .get(WEB_CONTAINER_INSTANCE);
0063:                wcDocRootDir = (String) wcAttributes
0064:                        .get(WEB_CONTAINER_DOC_ROOT);
0065:                wcJDKDir = (String) wcAttributes.get(WEB_CONTAINER_JDK_DIR);
0066:                // This one should be in webcontainer.properties.
0067:                wcAdminUser = (String) wcAttributes
0068:                        .get(WEB_CONTAINER_ADMIN_UID);
0069:                wcAdminPassword = (String) wcAttributes
0070:                        .get(WEB_CONTAINER_ADMIN_PASSWORD);
0071:
0072:                //wcDefaultHost = (String) wcAttributes.get(WEB_CONTAINER_DEFAULT_HOST);
0073:
0074:                wcDeployNode = (String) wcAttributes
0075:                        .get(WEB_CONTAINER_DEPLOY_NODE);
0076:                wcDeployCell = (String) wcAttributes
0077:                        .get(WEB_CONTAINER_DEPLOY_CELL);
0078:            }
0079:
0080:            public void postValidationInit() throws ConfigurationException {
0081:
0082:                wcConfigdir = wcHomeDir + fs + "config" + fs + "cells" + fs
0083:                        + wcDeployCell + fs + "nodes" + fs + wcDeployNode + fs
0084:                        + "servers" + fs + wcTargetInstance;
0085:
0086:                wcConfigfile = new File(wcConfigdir + fs + "server.xml");
0087:                logger.log(Level.FINEST, "PSFB_CSPFT0050", new String[] {
0088:                        "Config Dir", wcConfigdir });
0089:
0090:                setupFile = new File(wcHomeDir + fs + "bin" + fs
0091:                        + "setupCmdLine.sh");
0092:
0093:                wcPrintableInstanceName = wcDeployCell + "." + wcDeployNode
0094:                        + "." + wcTargetInstance;
0095:            }
0096:
0097:            /**
0098:             * Deploys the WAR file on to the webcontainer instance
0099:             *
0100:             * @param warFile WAR file including full path
0101:             * @param uri Deployment URI
0102:             */
0103:            public void deploy(String warFile, String uri)
0104:                    throws ConfigurationException {
0105:
0106:                File tmpFile = null;
0107:                try {
0108:                    tmpFile = File.createTempFile("deploy", ".jacl");
0109:                    //if (uri.startsWith("/")) {
0110:                    //    uri = FileUtil.replaceToken(uri, "/", "");
0111:                    //}
0112:                    StringBuffer command = new StringBuffer();
0113:                    command.append("$AdminApp install ");
0114:                    command.append(FileUtil.decoratePath(warFile));
0115:                    command
0116:                            .append(" {-contextroot "
0117:                                    + uri
0118:                                    + "  -usedefaultbindings -nopreCompileJSPs -distributeApp -nouseMetaDataFromBinary ");
0119:                    command.append(" -node ");
0120:                    command.append(wcDeployNode);
0121:                    command.append(" -cell ");
0122:                    command.append(wcDeployCell);
0123:                    command.append(" -server ");
0124:                    command.append(wcTargetInstance);
0125:                    command
0126:                            .append(" -appname "
0127:                                    + uri.substring(1)
0128:                                    + "  -createMBeansForResources -noreloadEnabled -reloadInterval 0 -nodeployws} ");
0129:                    FileUtil.appendToFile(tmpFile, command.toString(), false);
0130:                    logger.log(Level.FINEST, "PSFB_CSPFT0050", new String[] {
0131:                            "War deploy command", command.toString() });
0132:
0133:                    command = new StringBuffer();
0134:                    command.append("$AdminConfig save");
0135:                    FileUtil.appendToFile(tmpFile, command.toString(), false);
0136:                } catch (Exception ex) {
0137:                    throw new ConfigurationException(ex.toString());
0138:                }
0139:
0140:                String command = wcHomeDir + fs + "bin" + fs + "wsadmin.sh";
0141:
0142:                String[] serviceArgs = new String[2];
0143:                serviceArgs[0] = "-f";
0144:                serviceArgs[1] = FileUtil.decoratePath(tmpFile
0145:                        .getAbsolutePath());
0146:
0147:                try {
0148:                    int iRetCode = execUtil.exec(command, serviceArgs);
0149:                    tmpFile.delete();
0150:                    if (iRetCode != 0) {
0151:
0152:                        // 'deploy' failed for some reason
0153:                        String sError = execUtil.getError();
0154:                        if ((sError == null) || sError.trim().equals("")) {
0155:
0156:                            sError = "Deploy Failed";
0157:                        }
0158:
0159:                        // Throw configuration Exception
0160:                        throw new ConfigurationException(sError);
0161:                    }
0162:                } catch (Exception e) {
0163:                    throw new ConfigurationException(e.toString());
0164:                }
0165:            }
0166:
0167:            /**
0168:             * Undeploys the WAR file from the webcontainer instance
0169:             *
0170:             * @param uri Deployment URI
0171:             */
0172:            public void undeploy(String uri) throws ConfigurationException {
0173:                File tmpFile = null;
0174:                try {
0175:                    tmpFile = File.createTempFile("undeploy", ".jacl");
0176:
0177:                    StringBuffer command = new StringBuffer();
0178:                    command.append("$AdminApp uninstall ");
0179:                    //The uri is assumed to be of the type '/something'.
0180:                    command.append(uri.substring(1));
0181:                    command.append(" {-node ");
0182:                    command.append(wcDeployNode);
0183:                    command.append(" -cell ");
0184:                    command.append(wcDeployCell);
0185:                    command.append(" -server ");
0186:                    command.append(wcTargetInstance);
0187:                    command.append("}");
0188:                    FileUtil.appendToFile(tmpFile, command.toString(), false);
0189:                    logger.log(Level.FINEST, "PSFB_CSPFT0050", new String[] {
0190:                            "War undeploy command", command.toString() });
0191:
0192:                    command = new StringBuffer();
0193:                    command.append("$AdminConfig save");
0194:                    FileUtil.appendToFile(tmpFile, command.toString(), false);
0195:
0196:                } catch (Exception ex) {
0197:                    throw new ConfigurationException(ex.toString());
0198:                }
0199:
0200:                String command = wcHomeDir + fs + "bin" + fs + "wsadmin.sh";
0201:
0202:                String[] serviceArgs = new String[2];
0203:                serviceArgs[0] = "-f";
0204:                serviceArgs[1] = FileUtil.decoratePath(tmpFile
0205:                        .getAbsolutePath());
0206:
0207:                try {
0208:                    execUtil.exec(command, serviceArgs);
0209:                    tmpFile.delete();
0210:                } catch (Exception e) {
0211:                    throw new ConfigurationException(e.toString());
0212:                }
0213:            }
0214:
0215:            private final boolean isIdentityServerSDKConfigured(
0216:                    final PSConfigContext configContext)
0217:                    throws ConfigurationException {
0218:                boolean amConfigured = false;
0219:
0220:                String amSDKJar = FileUtil.findTextInFile(wcConfigfile,
0221:                        "am_sdk.jar");
0222:                if (amSDKJar != null && amSDKJar.trim().length() > 0) {
0223:                    amConfigured = true;
0224:                }
0225:                logger.log(Level.FINEST, "PSFB_CSPFT0051", new String[] {
0226:                        "am_sdk.jar", wcConfigfile.getAbsolutePath() });
0227:                logger.log(Level.FINEST, "PSFB_CSPFT0052",
0228:                        new String[] { amConfigured ? "true" : "false" });
0229:                return amConfigured;
0230:            }
0231:
0232:            /**
0233:             * Configures the WebContainer with the classpath
0234:             * settings, JVM options and other settings needed
0235:             * for Identity Server SDK
0236:             */
0237:            public void doIdentitySDKConfig(final PSConfigContext configContext)
0238:                    throws ConfigurationException {
0239:
0240:                if (isIdentityServerSDKConfigured(configContext)) {
0241:                    logger.log(Level.FINEST, "PSFB_CSPFT0014",
0242:                            new String[] { wcPrintableInstanceName });
0243:                    return;
0244:                }
0245:                logger.log(Level.FINEST, "PSFB_CSPFT0053",
0246:                        new String[] { wcPrintableInstanceName });
0247:
0248:                String protocol = (String) wcAttributes.get(SCHEME);
0249:                String host = (String) wcAttributes.get(HOST);
0250:                String port = (String) wcAttributes.get(PORT);
0251:
0252:                String amProductLoc = configContext.getISBaseDir();
0253:                String amConfigDir = configContext.getISConfigDir();
0254:                String psDataDir = configContext.getPSDataDir();
0255:
0256:                int index = amProductLoc.lastIndexOf(fs);
0257:                String amProductDir = amProductLoc.substring(index + 1);
0258:                String amBaseDir = amProductLoc.substring(0, index);
0259:
0260:                logger.log(Level.FINEST, "PSFB_CSPFT0015",
0261:                        new String[] { wcPrintableInstanceName });
0262:
0263:                String amSilentName = psDataDir + fs + "tmp" + fs
0264:                        + "amsilent_ps." + FileUtil.getRandomDirName();
0265:
0266:                StringBuffer fileData = new StringBuffer();
0267:                fileData.append("BASEDIR=" + amBaseDir + nl);
0268:                fileData.append("PRODUCT_DIR=" + amProductDir + nl);
0269:                fileData.append("CONFIG_DIR=" + amConfigDir + nl);
0270:
0271:                fileData.append("WAS51_HOME=" + wcHomeDir + nl);
0272:                fileData.append("WAS51_JDK_HOME=" + wcJDKDir + nl);
0273:                fileData.append("WAS51_NODE=" + wcDeployNode + nl);
0274:                fileData.append("WAS51_CELL=" + wcDeployCell + nl);
0275:                fileData.append("WAS51_INSTANCE=" + wcTargetInstance + nl);
0276:                fileData.append("WAS51_PROTOCOL=" + protocol + nl);
0277:                fileData.append("WAS51_HOST=" + host + nl);
0278:                fileData.append("WAS51_PORT=" + port + nl);
0279:                fileData.append("WAS51_ADMIN=" + wcAdminUser + nl);
0280:                fileData.append("WAS51_PASSWORD=" + wcAdminPassword + nl);
0281:                /**
0282:                 * If AM version is 6.x then use container configuration scripts
0283:                 * else use amconfig script for container configuration
0284:                 * See 6284663 for more info.
0285:                 */
0286:                if (configContext.getAMVersion().equals("6")) {
0287:                    fileData.append("DEPLOY_LEVEL=4" + nl);
0288:                    amconfigScript = "amwas51config";
0289:                } else {
0290:                    fileData.append("DEPLOY_LEVEL=7" + nl).append(
0291:                            "JAVA_HOME=" + configContext.getJavaHome() + nl)
0292:                            .append("WEB_CONTAINER=WAS5" + nl);
0293:                    amconfigScript = "amconfig";
0294:                }
0295:
0296:                File amSilentFile = new File(amSilentName);
0297:                try {
0298:                    FileWriter fwriter = new FileWriter(amSilentFile);
0299:                    fwriter.write(fileData.toString());
0300:                    fwriter.close();
0301:                } catch (IOException ioe) {
0302:                    if (logger.isLoggable(Level.SEVERE)) {
0303:                        logger.log(Level.SEVERE, "PSFB_CSPFT0016");
0304:                        LogRecord record = new LogRecord(Level.SEVERE,
0305:                                "PSFB_CSPFT0017");
0306:                        record
0307:                                .setParameters(new String[] { wcPrintableInstanceName });
0308:                        record.setThrown(ioe);
0309:                        record.setLoggerName(logger.getName());
0310:                        logger.log(record);
0311:                    }
0312:                    amSilentFile.delete();
0313:                    return;
0314:                }
0315:
0316:                String amwas51config = amProductLoc + fs + "bin" + fs
0317:                        + amconfigScript;
0318:                String args[] = { "-s", amSilentName };
0319:
0320:                logger.log(Level.FINEST, "PSFB_CSPFT0018",
0321:                        new String[] { amwas51config });
0322:                if (execUtil.exec(amwas51config, args) != 0) {
0323:                    logger.log(Level.SEVERE, "PSFB_CSPFT0019", new String[] {
0324:                            wcType, wcPrintableInstanceName });
0325:                } else {
0326:                    logger.log(Level.INFO, "PSFB_CSPFT0020", new String[] {
0327:                            wcType, wcPrintableInstanceName });
0328:                }
0329:
0330:                amSilentFile.delete();
0331:            }
0332:
0333:            /**
0334:             * Add string to JAVA_OPTIONS
0335:             */
0336:            public boolean addJVMOption(String option, String value) {
0337:                File tmpFile = null;
0338:                logger.log(Level.FINEST, "PSFB_CSPFT0054", new String[] {
0339:                        "addJVMOption", "Option Value Pair",
0340:                        option + "=" + value });
0341:                try {
0342:                    tmpFile = File.createTempFile("setjvmOptions", ".jacl");
0343:
0344:                    String jvmOptionsAttrXPath = "/Server/processDefinition/jvmEntries";
0345:                    String presentAttrValue = FileUtil.getAttributeValue(
0346:                            wcConfigfile, jvmOptionsAttrXPath,
0347:                            "genericJvmArguments");
0348:                    String optionValuePair = getJVMOptionString(option, value);
0349:                    //The separator between JVM options is a blank space
0350:                    String attrSeparator = " ";
0351:
0352:                    StringBuffer command = new StringBuffer();
0353:                    command.append("set dummyID [$AdminConfig getid /Cell:"
0354:                            + wcDeployCell + "/Node:" + wcDeployNode
0355:                            + "/Server:" + wcTargetInstance + "/] ");
0356:                    FileUtil.appendToFile(tmpFile, command.toString(), false);
0357:                    command = new StringBuffer();
0358:                    command
0359:                            .append("set jvm [$AdminConfig list JavaVirtualMachine $dummyID]");
0360:                    FileUtil.appendToFile(tmpFile, command.toString(), false);
0361:                    command = new StringBuffer();
0362:                    command
0363:                            .append("$AdminConfig modify $jvm {{genericJvmArguments \""
0364:                                    + presentAttrValue
0365:                                    + " "
0366:                                    + optionValuePair
0367:                                    + "\"}}");
0368:                    FileUtil.appendToFile(tmpFile, command.toString(), false);
0369:                    command = new StringBuffer();
0370:                    command.append("$AdminConfig save");
0371:                    FileUtil.appendToFile(tmpFile, command.toString(), false);
0372:
0373:                    String execCommand = wcHomeDir + fs + "bin" + fs
0374:                            + "wsadmin.sh";
0375:                    String[] serviceArgs = new String[2];
0376:                    serviceArgs[0] = "-f";
0377:                    serviceArgs[1] = FileUtil.decoratePath(tmpFile
0378:                            .getAbsolutePath());
0379:
0380:                    execUtil.exec(execCommand, serviceArgs);
0381:                    tmpFile.delete();
0382:                } catch (Exception e) {
0383:                    if (logger.isLoggable(Level.SEVERE)) {
0384:                        LogRecord record = new LogRecord(Level.SEVERE,
0385:                                "PSFB_CSPFT0069");
0386:                        record.setThrown(e);
0387:                        record.setLoggerName(logger.getName());
0388:                        logger.log(record);
0389:                    }
0390:                    return false;
0391:                }
0392:                return true;
0393:            }
0394:
0395:            private String getJVMOptionString(String key, String value) {
0396:                StringBuffer option = new StringBuffer();
0397:                if (key.startsWith("-")) {
0398:                    if (value == null || value.trim().equals("")) {
0399:                        //If no value specified
0400:                        return key;
0401:                    } else {
0402:                        //Any option other than user defined option (-D)
0403:                        option.append(key).append("=").append(value);
0404:                    }
0405:                } else {
0406:                    //user defined options
0407:                    option.append("-D").append(key).append("=").append(value);
0408:                }
0409:                return option.toString();
0410:            }
0411:
0412:            public boolean setNativeLibraryPath(String path) {
0413:                logger.log(Level.FINEST, "PSFB_CSPFT0054", new String[] {
0414:                        "setNativeLibraryPath", "path", path });
0415:                try {
0416:                    path = path + cps + "/usr/lib/lwp";
0417:                    String retStr = FileUtil.findTextInFile(setupFile, path);
0418:                    if (retStr != null && retStr.equals("")) {
0419:                        FileUtil.appendToFile(setupFile, "LD_LIBRARY_PATH="
0420:                                + path + ":$LD_LIBRARY_PATH", false);
0421:                        FileUtil.appendLineInFile(setupFile,
0422:                                "LD_LIBRARY_PATH=", " export LD_LIBRARY_PATH");
0423:                        logger.log(Level.FINEST, "PSFB_CSPFT0068",
0424:                                new String[] { path,
0425:                                        setupFile.getAbsolutePath() });
0426:                    } else {
0427:                        return false;
0428:                    }
0429:                } catch (Exception e) {
0430:                    if (logger.isLoggable(Level.SEVERE)) {
0431:                        LogRecord record = new LogRecord(Level.SEVERE,
0432:                                "PSFB_CSPFT0027");
0433:                        record.setThrown(e);
0434:                        record.setLoggerName(logger.getName());
0435:                        logger.log(record);
0436:                    }
0437:                    return false;
0438:                }
0439:                return true;
0440:            }
0441:
0442:            public boolean isPortalConfigured() {
0443:                // TODO: Make this check better
0444:                String str = FileUtil.findTextInFile(wcConfigfile,
0445:                        PORTAL_TEST_JAR);
0446:                if (str != null && !str.equals("")
0447:                        && str.indexOf(PORTAL_TEST_JAR) >= 0) {
0448:                    logger.log(Level.INFO, "PSFB_CSPFT0041");
0449:                    return true;
0450:                } else {
0451:                    return false;
0452:                }
0453:            }
0454:
0455:            public boolean appendClasspath(String classPath) {
0456:                logger.log(Level.FINEST, "PSFB_CSPFT0054", new String[] {
0457:                        "appendClasspath", "jars", classPath });
0458:                String cpTkn = FileUtil.findTextInFile(wcConfigfile,
0459:                        "<classpath>");
0460:                if (cpTkn != null || cpTkn.equals("")) {
0461:                    //filter out entries in classPath that already occour in serverCP
0462:                    String filteredClassPath = getFilteredClassPath(classPath,
0463:                            cpTkn);
0464:                    FileUtil.replaceTokenInFile(wcConfigfile, "<classpath>",
0465:                            "<classpath>" + filteredClassPath
0466:                                    + File.pathSeparator);
0467:                } else {
0468:                    //If classpath tag is found, it means AM SDK is not configured.
0469:                    return false;
0470:                }
0471:                return true;
0472:            }
0473:
0474:            public void createSymbolicLinks(final PSConfigContext configContext) {
0475:                // Copying the MA voice files to the document root directory.
0476:                String installTimeDeployDocroot = configContext.getPSBaseDir()
0477:                        + fs + "export" + fs + "voice";
0478:
0479:                String deployDocroot = wcDocRootDir;
0480:                if (installTimeDeployDocroot != null
0481:                        && installTimeDeployDocroot.equals(deployDocroot)) {
0482:                    FileUtil.copyFile(installTimeDeployDocroot + fs + "voice",
0483:                            deployDocroot + fs + "voice");
0484:                }
0485:                //Creating links for help, voice to webcontainer docs
0486:
0487:                String appDir = wcHomeDir + fs + "installedApps" + fs
0488:                        + wcDeployCell + fs + "DefaultApplication.ear";
0489:                String defWebApp = "DefaultWebApplication.war";
0490:                String docsDir = appDir + fs + defWebApp;
0491:                String helpDirStr = docsDir + fs + "online_help" + fs
0492:                        + "docs_en_US";
0493:                File helpDir = new File(helpDirStr);
0494:                if (!helpDir.exists())
0495:                    helpDir.mkdirs();
0496:
0497:                String psHelpDir = configContext.getPSBaseDir() + fs + "docs"
0498:                        + fs + "public_html" + fs + "online_help" + fs
0499:                        + "docs_en_US";
0500:                String voiceDir = configContext.getPSBaseDir() + fs + "export"
0501:                        + fs + "voice";
0502:
0503:                OSTasks osTasks = OSTasksFactory.getOSTasks(configContext);
0504:                osTasks.createSymbolicLink(voiceDir, docsDir);
0505:                osTasks.createSymbolicLink(psHelpDir + fs + "ps", helpDirStr);
0506:                osTasks.createSymbolicLink(psHelpDir + fs + "ma", helpDirStr);
0507:            }
0508:
0509:            public void doMiscTasks(PSConfigContext configContext) {
0510:                try {
0511:                    doJVMMemorySettings();
0512:                    tuneMinMaxHeap();
0513:
0514:                    //Partial fix for WSRP bug #6362385
0515:                    // adding jaxp-api.jar and sax.jar for wsrp to work on WebSphere
0516:                    String jaxpClasspath = configContext.getPSBaseDir() + fs
0517:                            + "lib" + fs + "endorsed" + fs + "jaxp-api.jar"
0518:                            + ":" + configContext.getPSBaseDir() + fs + "lib"
0519:                            + fs + "endorsed" + fs + "sax.jar" + ":"
0520:                            + configContext.getPSBaseDir() + fs + "lib" + fs
0521:                            + "endorsed" + fs + "xalan.jar";
0522:
0523:                    appendClasspath(jaxpClasspath);
0524:                    String jaxbClasspath = configContext.getSharedLibsDir()
0525:                            + fs + "jaxb-api.jar:"
0526:                            + configContext.getSharedLibsDir() + fs
0527:                            + "jaxb-impl.jar";
0528:                    FileUtil.replaceTokenInFile(wcConfigfile, "<classpath>",
0529:                            "<classpath>" + jaxbClasspath + File.pathSeparator);
0530:
0531:                } catch (Exception e) {
0532:                    if (logger.isLoggable(Level.SEVERE)) {
0533:                        LogRecord record = new LogRecord(Level.SEVERE,
0534:                                "PSFB_CSPFT0028");
0535:                        record.setThrown(e);
0536:                        record.setLoggerName(logger.getName());
0537:                        logger.log(record);
0538:                    }
0539:                }
0540:
0541:            }
0542:
0543:            public void configResource(Element root, String derbyHost,
0544:                    String derbyPort, String databaseName, String poolName) {
0545:
0546:                createResource(root, poolName, databaseName, derbyHost,
0547:                        derbyPort);
0548:                createConnectionPool(root, poolName);
0549:            }
0550:
0551:            public void createConnectionPool(Element root, String poolName) {
0552:                try {
0553:                    int endIndx = poolName.indexOf("Pool");
0554:                    String resourceName = poolName.substring(0, endIndx);
0555:                    String provider = resourceName + "Provider";
0556:                    File tmpFile = File.createTempFile("createconnectionpool",
0557:                            ".jacl");
0558:                    StringBuffer command = new StringBuffer();
0559:                    command.append("set newds [$AdminConfig getid /Cell:"
0560:                            + wcDeployCell + "/Node:" + wcDeployNode
0561:                            + "/JDBCProvider:" + provider + "/DataSource:"
0562:                            + resourceName + "/] ");
0563:                    FileUtil.appendToFile(tmpFile, command.toString(), false);
0564:                    command = new StringBuffer();
0565:                    command
0566:                            .append("$AdminConfig create ConnectionPool $newds {{maxConnections "
0567:                                    + root.getAttributeValue("maxActive")
0568:                                    + "}}");
0569:                    FileUtil.appendToFile(tmpFile, command.toString(), false);
0570:                    command = new StringBuffer();
0571:                    command.append("$AdminConfig save");
0572:                    FileUtil.appendToFile(tmpFile, command.toString(), false);
0573:
0574:                    String execCommand = wcHomeDir + fs + "bin" + fs
0575:                            + "wsadmin.sh";
0576:                    String[] serviceArgs = new String[2];
0577:                    serviceArgs[0] = "-f";
0578:                    serviceArgs[1] = FileUtil.decoratePath(tmpFile
0579:                            .getAbsolutePath());
0580:
0581:                    execUtil.exec(execCommand, serviceArgs);
0582:                    tmpFile.delete();
0583:                } catch (Exception e) {
0584:                    logger.log(Level.SEVERE, "PSFB_CSPFT0098", poolName);
0585:                    logger.log(Level.SEVERE, "PSFB_CSPFT0099", e);
0586:                }
0587:            }
0588:
0589:            public void createResource(Element root, String poolName,
0590:                    String databaseName, String derbyHost, String derbyPort) {
0591:
0592:                int endIndx = poolName.indexOf("Pool");
0593:                String resourceName = poolName.substring(0, endIndx);
0594:                String provider = resourceName + "Provider";
0595:                try {
0596:                    File tmpFile = File.createTempFile("createresource",
0597:                            ".jacl");
0598:                    StringBuffer command = new StringBuffer();
0599:                    command.append("set node [$AdminConfig getid /Cell:"
0600:                            + wcDeployCell + "/Node:" + wcDeployNode + "/] ");
0601:                    FileUtil.appendToFile(tmpFile, command.toString(), false);
0602:                    command = new StringBuffer();
0603:                    command.append("$AdminConfig required JDBCProvider");
0604:                    FileUtil.appendToFile(tmpFile, command.toString(), false);
0605:                    command = new StringBuffer();
0606:                    command.append("set n1 [list name " + provider + "]");
0607:                    FileUtil.appendToFile(tmpFile, command.toString(), false);
0608:                    command = new StringBuffer();
0609:                    String dataSourceClassName = root
0610:                            .getAttributeValue("dataSourceClassName.IBMWAS5");
0611:                    if (dataSourceClassName != null
0612:                            && !dataSourceClassName.equals("")
0613:                            && dataSourceClassName.length() > 0) {
0614:                        command.append("set c1 [list implementationClassName "
0615:                                + dataSourceClassName + "]");
0616:                    } else {
0617:                        command.append("set c1 [list implementationClassName "
0618:                                + root.getAttributeValue("dataSourceClassName")
0619:                                + "]");
0620:                    }
0621:                    FileUtil.appendToFile(tmpFile, command.toString(), false);
0622:                    command = new StringBuffer();
0623:                    command.append("set jdbcAttrs [list $n1 $c1]");
0624:                    FileUtil.appendToFile(tmpFile, command.toString(), false);
0625:                    command = new StringBuffer();
0626:                    command
0627:                            .append("$AdminConfig create JDBCProvider $node $jdbcAttrs");
0628:                    FileUtil.appendToFile(tmpFile, command.toString(), false);
0629:                    command = new StringBuffer();
0630:                    command.append("set newjdbc [$AdminConfig getid /Cell:"
0631:                            + wcDeployCell + "/Node:" + wcDeployNode
0632:                            + "/JDBCProvider:" + provider + "/] ");
0633:                    FileUtil.appendToFile(tmpFile, command.toString(), false);
0634:                    command = new StringBuffer();
0635:                    command.append("$AdminConfig required DataSource");
0636:                    FileUtil.appendToFile(tmpFile, command.toString(), false);
0637:                    command = new StringBuffer();
0638:                    command.append("set name [list name " + resourceName + "]");
0639:                    FileUtil.appendToFile(tmpFile, command.toString(), false);
0640:                    command = new StringBuffer();
0641:                    command.append("set dsAttrs [list $name]");
0642:                    FileUtil.appendToFile(tmpFile, command.toString(), false);
0643:                    command = new StringBuffer();
0644:                    command
0645:                            .append("set newds [$AdminConfig create DataSource $newjdbc $dsAttrs]");
0646:                    FileUtil.appendToFile(tmpFile, command.toString(), false);
0647:                    command = new StringBuffer();
0648:                    command
0649:                            .append("set propSet [$AdminConfig create J2EEResourcePropertySet $newds {}]");
0650:                    FileUtil.appendToFile(tmpFile, command.toString(), false);
0651:                    command = new StringBuffer();
0652:                    command
0653:                            .append("set attrs1 [subst {{name databaseName} {type java.lang.String} "
0654:                                    + "{value " + databaseName + "}}]");
0655:                    FileUtil.appendToFile(tmpFile, command.toString(), false);
0656:                    command = new StringBuffer();
0657:                    command
0658:                            .append("set attrs2 [subst {{name user} {type java.lang.String} "
0659:                                    + "{value "
0660:                                    + root.getAttributeValue("username")
0661:                                    + "}}]");
0662:                    FileUtil.appendToFile(tmpFile, command.toString(), false);
0663:                    command = new StringBuffer();
0664:                    command
0665:                            .append("set attrs3 [subst {{name password} {type java.lang.String} "
0666:                                    + "{value "
0667:                                    + root.getAttributeValue("password")
0668:                                    + "}}]");
0669:                    FileUtil.appendToFile(tmpFile, command.toString(), false);
0670:                    command = new StringBuffer();
0671:                    command
0672:                            .append("set attrs4 [subst {{name serverName} {type java.lang.String} "
0673:                                    + "{value " + derbyHost + "}}]");
0674:                    FileUtil.appendToFile(tmpFile, command.toString(), false);
0675:                    command = new StringBuffer();
0676:                    command
0677:                            .append("set attrs5 [subst {{name driverType} {type java.lang.String} "
0678:                                    + "{value "
0679:                                    + root.getAttributeValue("type") + "}}]");
0680:                    FileUtil.appendToFile(tmpFile, command.toString(), false);
0681:                    command = new StringBuffer();
0682:                    command
0683:                            .append("set attrs6 [subst {{name portNumber} {type java.lang.Integer} "
0684:                                    + "{value " + derbyPort + "}}]");
0685:                    FileUtil.appendToFile(tmpFile, command.toString(), false);
0686:                    command = new StringBuffer();
0687:                    command
0688:                            .append("set attrs7 [subst {{name driverClassName} {type java.lang.String} "
0689:                                    + "{value "
0690:                                    + root.getAttributeValue("driverClassName")
0691:                                    + "}}]");
0692:                    FileUtil.appendToFile(tmpFile, command.toString(), false);
0693:                    command = new StringBuffer();
0694:                    command
0695:                            .append("$AdminConfig create J2EEResourceProperty $propSet $attrs1");
0696:                    FileUtil.appendToFile(tmpFile, command.toString(), false);
0697:                    command = new StringBuffer();
0698:                    command
0699:                            .append("$AdminConfig create J2EEResourceProperty $propSet $attrs2");
0700:                    FileUtil.appendToFile(tmpFile, command.toString(), false);
0701:                    command = new StringBuffer();
0702:                    command
0703:                            .append("$AdminConfig create J2EEResourceProperty $propSet $attrs3");
0704:                    FileUtil.appendToFile(tmpFile, command.toString(), false);
0705:                    command = new StringBuffer();
0706:                    command
0707:                            .append("$AdminConfig create J2EEResourceProperty $propSet $attrs4");
0708:                    FileUtil.appendToFile(tmpFile, command.toString(), false);
0709:                    command = new StringBuffer();
0710:                    command
0711:                            .append("$AdminConfig create J2EEResourceProperty $propSet $attrs5");
0712:                    FileUtil.appendToFile(tmpFile, command.toString(), false);
0713:                    command = new StringBuffer();
0714:                    command
0715:                            .append("$AdminConfig create J2EEResourceProperty $propSet $attrs6");
0716:                    FileUtil.appendToFile(tmpFile, command.toString(), false);
0717:                    command = new StringBuffer();
0718:                    command
0719:                            .append("$AdminConfig create J2EEResourceProperty $propSet $attrs7");
0720:                    FileUtil.appendToFile(tmpFile, command.toString(), false);
0721:                    command = new StringBuffer();
0722:                    command.append("set attrs8 [subst {{jndiName "
0723:                            + root.getAttributeValue("name") + "}}]");
0724:                    FileUtil.appendToFile(tmpFile, command.toString(), false);
0725:                    command = new StringBuffer();
0726:                    command.append("$AdminConfig modify $newds $attrs8");
0727:                    FileUtil.appendToFile(tmpFile, command.toString(), false);
0728:                    command = new StringBuffer();
0729:                    command.append("$AdminConfig save");
0730:                    FileUtil.appendToFile(tmpFile, command.toString(), false);
0731:
0732:                    String execCommand = wcHomeDir + fs + "bin" + fs
0733:                            + "wsadmin.sh";
0734:                    String[] serviceArgs = new String[2];
0735:                    serviceArgs[0] = "-f";
0736:                    serviceArgs[1] = FileUtil.decoratePath(tmpFile
0737:                            .getAbsolutePath());
0738:
0739:                    execUtil.exec(execCommand, serviceArgs);
0740:                    tmpFile.delete();
0741:                } catch (Exception e) {
0742:                    logger.log(Level.SEVERE, "PSFB_CSPFT0097", resourceName);
0743:                    logger.log(Level.SEVERE, "PSFB_CSPFT0099", e);
0744:                }
0745:
0746:            }
0747:
0748:            public void unConfigResource(String jndiName, String poolName) {
0749:
0750:            }
0751:
0752:            /**
0753:             * Starts the webcontainer instance
0754:             *
0755:             */
0756:            public void start() {
0757:                String[] args = new String[1];
0758:                args[0] = wcTargetInstance;
0759:                String startWebshphereSh = wcHomeDir + fs + "bin" + fs
0760:                        + "startServer.sh";
0761:                execUtil.exec(startWebshphereSh, args);
0762:            }
0763:
0764:            /**
0765:             * Stops the webcontainer instance
0766:             *
0767:             */
0768:            public void stop() {
0769:                String[] args = new String[1];
0770:                args[0] = wcTargetInstance;
0771:                String stopWebshphereSh = wcHomeDir + fs + "bin" + fs
0772:                        + "stopServer.sh";
0773:                execUtil.exec(stopWebshphereSh, args);
0774:            }
0775:
0776:            /**
0777:             * Validate web container parameters provided to configurator.
0778:             */
0779:            public void validate() throws ValidationException {
0780:
0781:                // validate data before calling the constructor
0782:                if (!checkNotNullOrEmpty(WEB_CONTAINER_INSTANCE,
0783:                        wcTargetInstance)) {
0784:
0785:                    throw new ValidationException("Invalid Instance Name");
0786:                }
0787:
0788:                if (!checkNotNull(WEB_CONTAINER_ADMIN_UID, wcAdminUser)) {
0789:
0790:                    throw new ValidationException("Invalid Admin User");
0791:                }
0792:
0793:                if (!checkNotNull(WEB_CONTAINER_ADMIN_PASSWORD,
0794:                        wcAdminPassword, true)) {
0795:
0796:                    throw new ValidationException("Invalid Admin Password");
0797:                }
0798:
0799:                /*??if (!checkNotNullOrEmpty(WEB_CONTAINER_ADMIN_SCHEME, wcAdminProtocol)) {
0800:
0801:                    throw new ValidationException("Invalid Admin Scheme");
0802:                }
0803:
0804:                if (!checkNotNullOrEmpty(WEB_CONTAINER_ADMIN_HOST, wcAdminHost)) {
0805:
0806:                    throw new ValidationException("Invalid Admin Host");
0807:                }
0808:
0809:                if (!checkNotNullOrEmpty(WEB_CONTAINER_ADMIN_PORT, wcAdminPort)) {
0810:
0811:                    throw new ValidationException("Invalid Admin Port");
0812:                }??*/
0813:
0814:                if (!checkNotNullOrEmpty(WEB_CONTAINER_DEPLOY_NODE,
0815:                        wcDeployNode)) {
0816:
0817:                    throw new ValidationException("Invalid Deploy Node");
0818:                }
0819:
0820:                if (!checkNotNullOrEmpty(WEB_CONTAINER_DEPLOY_CELL,
0821:                        wcDeployCell)) {
0822:
0823:                    throw new ValidationException("Invalid Deploy Cell");
0824:                }
0825:
0826:                if (!checkDirExists(WEB_CONTAINER_INSTALL_DIR, wcHomeDir)) {
0827:
0828:                    throw new ValidationException(
0829:                            "Invalid Install Directory = " + wcHomeDir);
0830:                }
0831:
0832:                if (!checkDirExists(WEB_CONTAINER_JDK_DIR, wcJDKDir)) {
0833:
0834:                    throw new ValidationException("Invalid JDK Directory = "
0835:                            + wcJDKDir);
0836:                }
0837:
0838:                // Validate Instant host & port
0839:                String host = (String) wcAttributes.get(HOST);
0840:                String port = (String) wcAttributes.get(PORT);
0841:                boolean bIsValidHostNamePort = validateInstanceHostNamePort(
0842:                        host, port);
0843:
0844:                if (!bIsValidHostNamePort) {
0845:
0846:                    throw new ValidationException("Invalid Instance Host/Port");
0847:                }
0848:
0849:                // Validate Admin host & port
0850:                /*??bIsValidHostNamePort = validateAdminHostNamePort(wcAdminHost, wcAdminPort);
0851:
0852:                if (!bIsValidHostNamePort) {
0853:
0854:                   throw new ValidationException("Invalid Admin Host/Port");
0855:                }??*/
0856:
0857:                // TODO: Check if the Server is running by checking the Port Connection
0858:                // TODO: Validate instance uid/password
0859:                // TODO: Validate Admin uid/password/Port/Host
0860:            }
0861:
0862:            public static void main(String s[]) {
0863:            }
0864:
0865:            public boolean removeClasspath(String classpath) {
0866:                logger.log(Level.FINEST, "PSFB_CSPFT0082");
0867:                String[] classpathEntries = classpath.split(cps);
0868:                String retStr = null;
0869:                String currClasspathJar = null;
0870:                for (int i = 0; i < classpathEntries.length; i++) {
0871:                    currClasspathJar = classpathEntries[i] + cps;
0872:                    logger.log(Level.FINEST, "PSFB_CSPFT0243",
0873:                            classpathEntries[i]);
0874:                    retStr = FileUtil.findTextInFile(wcConfigfile,
0875:                            currClasspathJar);
0876:                    if (retStr != null && !retStr.equals("")
0877:                            && retStr.trim().startsWith("<classpath>")) {
0878:                        FileUtil.replaceTokenInFile(wcConfigfile,
0879:                                currClasspathJar, "");
0880:                    }
0881:                }
0882:                return true;
0883:            }
0884:
0885:            public boolean removeJVMOption(String option, String value) {
0886:                File tmpFile = null;
0887:                logger.log(Level.FINEST, "PSFB_CSPFT0054", new String[] {
0888:                        "removeJVMOption", "Option Value Pair",
0889:                        option + "=" + value });
0890:
0891:                try {
0892:                    tmpFile = File.createTempFile("removejvmOptions", ".jacl");
0893:
0894:                    String jvmOptionsAttrXPath = "/Server/processDefinition/jvmEntries";
0895:                    String presentAttrValue = FileUtil.getAttributeValue(
0896:                            wcConfigfile, jvmOptionsAttrXPath,
0897:                            "genericJvmArguments");
0898:                    String optionValuePair = "-D" + option + "=" + value;
0899:                    String modifiedAttrValue = presentAttrValue.replaceAll(
0900:                            optionValuePair, "");
0901:                    //The separator between JVM options is a blank space
0902:                    String attrSeparator = " ";
0903:
0904:                    StringBuffer command = new StringBuffer();
0905:                    command.append("set dummyID [$AdminConfig getid /Cell:"
0906:                            + wcDeployCell + "/Node:" + wcDeployNode
0907:                            + "/Server:" + wcTargetInstance + "/] ");
0908:                    FileUtil.appendToFile(tmpFile, command.toString(), false);
0909:                    command = new StringBuffer();
0910:                    command
0911:                            .append("set jvm [$AdminConfig list JavaVirtualMachine $dummyID]");
0912:                    FileUtil.appendToFile(tmpFile, command.toString(), false);
0913:                    command = new StringBuffer();
0914:                    command
0915:                            .append("$AdminConfig modify $jvm {{genericJvmArguments \""
0916:                                    + modifiedAttrValue + "\"}}");
0917:                    FileUtil.appendToFile(tmpFile, command.toString(), false);
0918:                    command = new StringBuffer();
0919:                    command.append("$AdminConfig save");
0920:                    FileUtil.appendToFile(tmpFile, command.toString(), false);
0921:
0922:                    String execCommand = wcHomeDir + fs + "bin" + fs
0923:                            + "wsadmin.sh";
0924:                    String[] serviceArgs = new String[2];
0925:                    serviceArgs[0] = "-f";
0926:                    serviceArgs[1] = FileUtil.decoratePath(tmpFile
0927:                            .getAbsolutePath());
0928:
0929:                    execUtil.exec(execCommand, serviceArgs);
0930:                    tmpFile.delete();
0931:                } catch (Exception e) {
0932:                    if (logger.isLoggable(Level.SEVERE)) {
0933:                        LogRecord record = new LogRecord(Level.SEVERE,
0934:                                "PSFB_CSPFT0056");
0935:                        record.setThrown(e);
0936:                        record.setLoggerName(logger.getName());
0937:                        logger.log(record);
0938:                    }
0939:                    return false;
0940:                }
0941:
0942:                return true;
0943:            }
0944:
0945:            // TODO: need to implement this method
0946:            public boolean removeNativeLibraryPath(String path) {
0947:                logger.log(Level.FINEST, "PSFB_CSPFT0054", new String[] {
0948:                        "removeNativeLibraryPath", "path", path });
0949:
0950:                try {
0951:                    String pathToDelete = "/usr/lib/lwp";
0952:                    String retStr = FileUtil.findTextInFile(setupFile,
0953:                            "LD_LIBRARY_PATH=");
0954:
0955:                    if (retStr != null && !retStr.equals("")
0956:                            && retStr.trim().startsWith("LD_LIBRARY_PATH=")) {
0957:                        FileUtil
0958:                                .replaceTokenInFile(setupFile, pathToDelete, "");
0959:                    } else {
0960:                        return false;
0961:                    }
0962:                } catch (Exception e) {
0963:                    if (logger.isLoggable(Level.SEVERE)) {
0964:                        LogRecord record = new LogRecord(Level.SEVERE,
0965:                                "PSFB_CSPFT0030");
0966:                        record.setThrown(e);
0967:                        record.setLoggerName(logger.getName());
0968:                        logger.log(record);
0969:                    }
0970:                    return false;
0971:                }
0972:
0973:                return true;
0974:            }
0975:
0976:            // TODO: need to implement this method
0977:            public void deleteSymbolicLinks(final PSConfigContext configContext) {
0978:                logger.log(Level.FINEST, "PSFB_CSPFT0055");
0979:
0980:                try {
0981:                    String appDir = wcHomeDir + fs + "installedApps" + fs
0982:                            + wcDeployCell + fs + "DefaultApplication.ear";
0983:                    String defWebApp = "DefaultWebApplication.war";
0984:                    String docsDir = appDir + fs + defWebApp;
0985:                    String helpDir = docsDir + fs + "online_help" + fs
0986:                            + "docs_en_US";
0987:                    OSTasks osTasks = OSTasksFactory.getOSTasks(configContext);
0988:                    osTasks.removeSymbolicLink(docsDir + fs + "voice");
0989:                    osTasks.removeSymbolicLink(helpDir + fs + "ps");
0990:                    osTasks.removeSymbolicLink(helpDir + fs + "ma");
0991:                } catch (Exception e) {
0992:                    if (logger.isLoggable(Level.SEVERE)) {
0993:                        LogRecord record = new LogRecord(Level.SEVERE,
0994:                                "PSFB_CSPFT0038");
0995:                        record.setThrown(e);
0996:                        record.setLoggerName(logger.getName());
0997:                        logger.log(record);
0998:                    }
0999:                }
1000:            }
1001:
1002:            // TODO: need to implement this method
1003:            public void undoMiscTasks(PSConfigContext configContext) {
1004:                String jaxpClasspath = configContext.getPSBaseDir() + fs
1005:                        + "lib" + fs + "endorsed" + fs + "jaxp-api.jar" + ":"
1006:                        + configContext.getPSBaseDir() + fs + "lib" + fs
1007:                        + "endorsed" + fs + "sax.jar" + ":"
1008:                        + configContext.getPSBaseDir() + fs + "lib" + fs
1009:                        + "endorsed" + fs + "xalan.jar";
1010:
1011:                removeClasspath(jaxpClasspath);
1012:                String jaxbClasspath = configContext.getSharedLibsDir() + fs
1013:                        + "jaxb-api.jar:" + configContext.getSharedLibsDir()
1014:                        + fs + "jaxb-impl.jar";
1015:                FileUtil.replaceTokenInFile(wcConfigfile, jaxbClasspath
1016:                        + File.pathSeparator, "");
1017:                undoJVMMemorySettings();
1018:            }
1019:
1020:            public boolean doJVMMemorySettings() {
1021:                try {
1022:                    String jvmOptionsAttrXPath = "/Server/processDefinition/jvmEntries";
1023:                    String presentAttrValue = FileUtil.getAttributeValue(
1024:                            wcConfigfile, jvmOptionsAttrXPath,
1025:                            "genericJvmArguments");
1026:
1027:                    //If no Xss settings are found
1028:                    if (presentAttrValue.indexOf("-Xss") < 0) {
1029:                        addJVMOption("-Xss128k  " + "-XX:NewSize=168M "
1030:                                + "-XX:MaxNewSize=168M " + "-XX:PermSize=192M "
1031:                                + "-XX:MaxPermSize=192M "
1032:                                + "-XX:+DisableExplicitGC "
1033:                                + "-XX:SoftRefLRUPolicyMSPerMB=0 "
1034:                                + "-XX:+PrintHeapAtGC "
1035:                                + "-XX:+PrintClassHistogram", "");
1036:
1037:                        return true;
1038:                    }
1039:                } catch (Exception e) {
1040:
1041:                    if (logger.isLoggable(Level.SEVERE)) {
1042:                        LogRecord record = new LogRecord(Level.SEVERE,
1043:                                "PSFB_CSPFT0101");
1044:                        record.setThrown(e);
1045:                        record.setLoggerName(logger.getName());
1046:                        logger.log(record);
1047:                    }
1048:                }
1049:
1050:                return false;
1051:            }
1052:
1053:            public boolean undoJVMMemorySettings() {
1054:                try {
1055:                    String jvmOptionsAttrXPath = "/Server/processDefinition/jvmEntries";
1056:                    String presentAttrValue = FileUtil.getAttributeValue(
1057:                            wcConfigfile, jvmOptionsAttrXPath,
1058:                            "genericJvmArguments");
1059:
1060:                    //If no Xss settings are found
1061:                    if (presentAttrValue.indexOf("-Xss") > 0) {
1062:                        removeJVMOption("-Xss128k  " + "-XX:NewSize=168M "
1063:                                + "-XX:MaxNewSize=168M " + "-XX:PermSize=192M "
1064:                                + "-XX:MaxPermSize=192M "
1065:                                + "-XX:+DisableExplicitGC "
1066:                                + "-XX:SoftRefLRUPolicyMSPerMB=0 "
1067:                                + "-XX:+PrintHeapAtGC "
1068:                                + "-XX:+PrintClassHistogram", "");
1069:
1070:                        return true;
1071:                    }
1072:                } catch (Exception e) {
1073:
1074:                    if (logger.isLoggable(Level.SEVERE)) {
1075:                        LogRecord record = new LogRecord(Level.SEVERE,
1076:                                "PSFB_CSPFT0101");
1077:                        record.setThrown(e);
1078:                        record.setLoggerName(logger.getName());
1079:                        logger.log(record);
1080:                    }
1081:                }
1082:
1083:                return false;
1084:            }
1085:
1086:            private void wcReconfig() {
1087:                stop();
1088:                start();
1089:                logger.log(Level.INFO, "PSFB_CSPFT0104");
1090:            }
1091:
1092:            public boolean tuneMinMaxHeap() {
1093:                File tmpFile;
1094:                try {
1095:                    tmpFile = File.createTempFile("setheapsize", ".jacl");
1096:                    FileUtil.appendToFile(tmpFile,
1097:                            "set dummyID [$AdminConfig getid /Cell:"
1098:                                    + wcDeployCell + "/Node:" + wcDeployNode
1099:                                    + "/Server:" + wcTargetInstance + "/] ",
1100:                            false);
1101:                    FileUtil
1102:                            .appendToFile(
1103:                                    tmpFile,
1104:                                    "set jvm [$AdminConfig list JavaVirtualMachine $dummyID]",
1105:                                    false);
1106:                    FileUtil
1107:                            .appendToFile(
1108:                                    tmpFile,
1109:                                    "$AdminConfig modify $jvm {{initialHeapSize \"512\"}}",
1110:                                    false);
1111:                    FileUtil
1112:                            .appendToFile(
1113:                                    tmpFile,
1114:                                    "$AdminConfig modify $jvm {{maximumHeapSize \"1024\"}}",
1115:                                    false);
1116:                    FileUtil.appendToFile(tmpFile, "$AdminConfig save", false);
1117:
1118:                    String execCommand = wcHomeDir + fs + "bin" + fs
1119:                            + "wsadmin.sh";
1120:                    String[] serviceArgs = new String[2];
1121:                    serviceArgs[0] = "-f";
1122:                    serviceArgs[1] = FileUtil.decoratePath(tmpFile
1123:                            .getAbsolutePath());
1124:                    execUtil.exec(execCommand, serviceArgs);
1125:                    tmpFile.delete();
1126:                } catch (Exception e) {
1127:                    if (logger.isLoggable(Level.SEVERE)) {
1128:                        LogRecord record = new LogRecord(Level.SEVERE,
1129:                                "PSFB_CSPFT0101");
1130:                        record.setThrown(e);
1131:                        record.setLoggerName(logger.getName());
1132:                        logger.log(record);
1133:                    }
1134:                    return false;
1135:                }
1136:                return true;
1137:            }
1138:
1139:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.