Source Code Cross Referenced for ConfigDataPlayback.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) 


001:        package com.sun.portal.fabric.tasks;
002:
003:        import java.io.File;
004:        import java.lang.IllegalAccessException;
005:        import java.lang.NoSuchMethodException;
006:        import java.lang.Object;
007:        import java.lang.reflect.*;
008:        import java.lang.String;
009:        import java.util.Enumeration;
010:        import java.util.Iterator;
011:        import java.util.List;
012:        import java.util.Map;
013:        import java.util.HashMap;
014:        import java.util.Properties;
015:        import java.util.logging.Level;
016:        import java.util.logging.Logger;
017:        import org.jdom.Element;
018:
019:        import com.sun.portal.fabric.util.XMLJdomUtil;
020:        import com.sun.portal.fabric.util.XMLJdomFileCreationException;
021:        import com.sun.portal.fabric.tasks.ConfigDataRecorderPlaybackException;
022:        import com.sun.portal.log.common.PortalLogger;
023:
024:        /**
025:         * This class implements the functionality needed
026:         * to do Portal Management tasks related to
027:         * WebContainer instances
028:         */
029:        public class ConfigDataPlayback extends ConfigDataConstants {
030:
031:            private static final String[] s_classPathTypes = new String[] {
032:                    PASCONFIG_ATTR_CLASSPATH, PASCONFIG_ATTR_NATIVE_LIB_PATH };
033:            private static final String[] s_classPathPlayerMethods = new String[] {
034:                    "appendClasspath", "setNativeLibraryPath" };
035:            private static final String[] s_classPathEraserMethods = new String[] {
036:                    "removeClasspath", "removeNativeLibraryPath" };
037:
038:            private Map m_valueMap = null;
039:            private WebContainerTasks m_wc = null;
040:            private static Logger logger = PortalLogger
041:                    .getLogger(ConfigDataPlayback.class);
042:
043:            /**
044:             * Constructor
045:             *
046:             * @param sPSLibDir Portal server Lib Directory
047:             * @param sPortalConfigDataDir
048:             * @param wc Web Container Instance
049:             * @param valueMap  Map that contains values for the token in Configuration Data File.
050:             */
051:            public ConfigDataPlayback(final String sPSLibDir,
052:                    final String sPortalConfigDataDir, WebContainerTasks wc,
053:                    final Map valueMap)
054:                    throws ConfigDataRecorderPlaybackException {
055:
056:                super (sPSLibDir, sPortalConfigDataDir);
057:
058:                m_valueMap = valueMap;
059:                m_wc = wc;
060:                if (m_wc == null) {
061:                    // log message
062:                    logger.log(Level.SEVERE, "PSFB_CSPFT0212");
063:                    throw new ConfigDataRecorderPlaybackException(
064:                            "Web Container instance is Null.");
065:                }
066:
067:                if (!m_bRecordingFound) {
068:                    // recording NOT found
069:                    // log message
070:                    logger.log(Level.FINEST, "PSFB_CSPFT0114",
071:                            new String[] { sPortalConfigDataDir });
072:                }
073:            }
074:
075:            /**
076:             * Replace Tokens by their actual values from the Value Map (arg#6 of Constructor)
077:             *
078:             * @param sTokenizedStr Tokenized String, which is to be UnTokenized.
079:             */
080:            private final String unTokenize(final String sTokenizedStr) {
081:
082:                String sUnTokenizedStr = sTokenizedStr;
083:                if ((sTokenizedStr != null) && (sTokenizedStr.length() > 0)
084:                        && (m_valueMap != null)) {
085:
086:                    for (Iterator itr = m_valueMap.keySet().iterator(); itr
087:                            .hasNext();) {
088:
089:                        String sToken = (String) itr.next();
090:                        String sValue = (String) m_valueMap.get(sToken);
091:                        sUnTokenizedStr = sUnTokenizedStr.replaceAll(sToken,
092:                                sValue);
093:                    }
094:                }
095:
096:                return sUnTokenizedStr;
097:            }
098:
099:            /**
100:             * Add various types of paths to the configuration file of the underlying web container.
101:             */
102:            private void doPlaybackErasePath(final String sMode,
103:                    final boolean bPlayback)
104:                    throws ConfigDataRecorderPlaybackException {
105:
106:                try {
107:                    String sClasspathPath = PASCONFIG_PORTAL_SERVER_CONFIGURATION
108:                            + ts + PASCONFIG_PATHS;
109:                    Properties props = (Properties) m_xmlJdomUtil
110:                            .getChildAsProperties(sClasspathPath);
111:                    if (props != null) {
112:
113:                        Class cls = Class
114:                                .forName("com.sun.portal.fabric.tasks.WebContainerTasks");
115:                        Class params[] = new Class[] { Class
116:                                .forName("java.lang.String") };
117:                        for (int i = 0; i < s_classPathTypes.length; i++) {
118:
119:                            // Get attribute value
120:                            String sClassPath = m_xmlJdomUtil.getAttribute(
121:                                    sClasspathPath, s_classPathTypes[i]);
122:                            String sUnTokenizedClassPath = unTokenize(sClassPath);
123:                            String sMethodName = bPlayback ? s_classPathPlayerMethods[i]
124:                                    : s_classPathEraserMethods[i];
125:
126:                            Method method2 = cls.getMethod(sMethodName, params);
127:                            Object values[] = new Object[] { sUnTokenizedClassPath };
128:                            method2.invoke(m_wc, values);
129:                            logger.log(Level.FINEST, "PSFB_CSPFT0115",
130:                                    new String[] { sMode, s_classPathTypes[i],
131:                                            sUnTokenizedClassPath });
132:                        }
133:                    }
134:                } catch (ClassNotFoundException e0) {
135:                    // log message
136:                    logger.log(Level.SEVERE, e0.getMessage());
137:                    throw new ConfigDataRecorderPlaybackException(e0);
138:                } catch (XMLJdomFileCreationException e1) {
139:                    // log message
140:                    logger.log(Level.SEVERE, e1.getMessage());
141:                    throw new ConfigDataRecorderPlaybackException(e1);
142:                } catch (NoSuchMethodException e2) {
143:                    // log message
144:                    logger.log(Level.SEVERE, e2.getMessage());
145:                    throw new ConfigDataRecorderPlaybackException(e2);
146:                } catch (InvocationTargetException e3) {
147:                    // log message
148:                    logger.log(Level.SEVERE, e3.getMessage());
149:                    throw new ConfigDataRecorderPlaybackException(e3);
150:                } catch (IllegalAccessException e4) {
151:                    // log message
152:                    logger.log(Level.SEVERE, e4.getMessage());
153:                    throw new ConfigDataRecorderPlaybackException(e4);
154:                }
155:            }
156:
157:            /**
158:             * Add JVM options to the configuration file of the underlying web container.
159:             */
160:            private void doPlaybackEraseJvmOptions(final String sMode,
161:                    final boolean bPlayback)
162:                    throws ConfigDataRecorderPlaybackException {
163:
164:                try {
165:                    String sJvmOptionsPath = PASCONFIG_PORTAL_SERVER_CONFIGURATION
166:                            + ts + PASCONFIG_JVM_OPTIONS;
167:                    Properties props = (Properties) m_xmlJdomUtil
168:                            .getChildAsProperties(sJvmOptionsPath);
169:                    if (props != null) {
170:
171:                        for (Enumeration e = props.propertyNames(); e
172:                                .hasMoreElements();) {
173:
174:                            String sJVMOptionName = (String) e.nextElement();
175:                            if ((sJVMOptionName != null)
176:                                    && (sJVMOptionName.trim().length() > 0)) {
177:
178:                                sJVMOptionName = sJVMOptionName.trim();
179:                                // Get attribute value
180:                                String sJVMOptionValue = (String) props
181:                                        .getProperty(sJVMOptionName);
182:                                if (sJVMOptionValue != null) {
183:
184:                                    String sUnTokenizedJVMOptionValue = unTokenize(sJVMOptionValue);
185:                                    if (bPlayback) {
186:
187:                                        m_wc.addJVMOption(sJVMOptionName,
188:                                                sUnTokenizedJVMOptionValue);
189:                                    } else {
190:
191:                                        m_wc.removeJVMOption(sJVMOptionName,
192:                                                sUnTokenizedJVMOptionValue);
193:                                    }
194:                                    logger
195:                                            .log(
196:                                                    Level.FINEST,
197:                                                    "PSFB_CSPFT0116",
198:                                                    new String[] { sMode,
199:                                                            sJVMOptionName,
200:                                                            sUnTokenizedJVMOptionValue });
201:                                }
202:                            }
203:                        }
204:                    }
205:                } catch (XMLJdomFileCreationException e) {
206:                    // log message
207:                    logger.log(Level.SEVERE, e.getMessage());
208:                    throw new ConfigDataRecorderPlaybackException(e);
209:                }
210:            }
211:
212:            /**
213:             * Create and register the resources to the configuration file of the underlying web container.
214:             */
215:            private void doPlaybackEraseResources(final String sMode,
216:                    final boolean bPlayback)
217:                    throws ConfigDataRecorderPlaybackException {
218:
219:                try {
220:                    String sResourcesPath = PASCONFIG_PORTAL_SERVER_CONFIGURATION
221:                            + ts + PASCONFIG_RESOURCES;
222:                    List resources = (List) m_xmlJdomUtil
223:                            .getChildrenAsElementsList(sResourcesPath, null);
224:                    if (resources != null) {
225:
226:                        for (Iterator e = resources.iterator(); e.hasNext();) {
227:
228:                            Element resource = (Element) e.next();
229:                            if (resource != null) {
230:
231:                                if (bPlayback) {
232:
233:                                    m_wc.createResource(resource);
234:                                } else {
235:
236:                                    m_wc.deleteResource(resource);
237:                                }
238:                                String sResourceName = resource
239:                                        .getAttributeValue("name");
240:                                logger.log(Level.FINEST, "PSFB_CSPFT0117",
241:                                        new String[] { sMode, sResourceName,
242:                                                resource.toString() });
243:                            }
244:                        }
245:                    }
246:                } catch (XMLJdomFileCreationException e) {
247:                    // log message
248:                    logger.log(Level.SEVERE, e.getMessage());
249:                    throw new ConfigDataRecorderPlaybackException(e);
250:                }
251:            }
252:
253:            /**
254:             * Play the recording of the configuration data on a web container instance.
255:             */
256:            public final boolean doPlayback()
257:                    throws ConfigDataRecorderPlaybackException {
258:
259:                if (m_bRecordingFound) {
260:
261:                    doPlaybackErasePath(MODE_PLAYBACK, true);
262:                    doPlaybackEraseJvmOptions(MODE_PLAYBACK, true);
263:                    doPlaybackEraseResources(MODE_PLAYBACK, true);
264:                }
265:
266:                return m_bRecordingFound;
267:            }
268:
269:            public final boolean doErase()
270:                    throws ConfigDataRecorderPlaybackException {
271:
272:                if (m_bRecordingFound) {
273:
274:                    doPlaybackEraseJvmOptions(MODE_ERASE, false);
275:                    doPlaybackErasePath(MODE_ERASE, false);
276:                    doPlaybackEraseResources(MODE_ERASE, false);
277:                }
278:
279:                return m_bRecordingFound;
280:            }
281:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.