Source Code Cross Referenced for WebLogic7xContainer.java in  » Testing » jakarta-cactus » org » apache » cactus » integration » ant » container » weblogic » 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 » Testing » jakarta cactus » org.apache.cactus.integration.ant.container.weblogic 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /* 
002:         * ========================================================================
003:         * 
004:         * Copyright 2003 The Apache Software Foundation.
005:         *
006:         * Licensed under the Apache License, Version 2.0 (the "License");
007:         * you may not use this file except in compliance with the License.
008:         * You may obtain a copy of the License at
009:         * 
010:         *   http://www.apache.org/licenses/LICENSE-2.0
011:         * 
012:         * Unless required by applicable law or agreed to in writing, software
013:         * distributed under the License is distributed on an "AS IS" BASIS,
014:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
015:         * See the License for the specific language governing permissions and
016:         * limitations under the License.
017:         * 
018:         * ========================================================================
019:         */
020:        package org.apache.cactus.integration.ant.container.weblogic;
021:
022:        import java.io.File;
023:        import java.io.IOException;
024:
025:        import org.apache.cactus.integration.ant.container.AbstractJavaContainer;
026:        import org.apache.cactus.integration.ant.util.ResourceUtils;
027:        import org.apache.tools.ant.BuildException;
028:        import org.apache.tools.ant.taskdefs.Jar;
029:        import org.apache.tools.ant.taskdefs.Java;
030:        import org.apache.tools.ant.types.FilterChain;
031:        import org.apache.tools.ant.types.Path;
032:        import org.apache.tools.ant.types.ZipFileSet;
033:        import org.apache.tools.ant.util.FileUtils;
034:
035:        /**
036:         * Special container support for the Bea WebLogic 7.x application server.
037:         * 
038:         * TODO: this doesn't work for me on JDK 1.3.1 and WL 7.0 SP2
039:         * 
040:         * @version $Id: WebLogic7xContainer.java 239130 2005-01-29 15:49:18Z vmassol $
041:         */
042:        public class WebLogic7xContainer extends AbstractJavaContainer {
043:
044:            // Instance Variables ------------------------------------------------------
045:
046:            /**
047:             * The Bea home directory.
048:             */
049:            private File beaHome;
050:
051:            /**
052:             * The WebLogic 7.x installation directory. For example:
053:             * "c:\bea\weblogic700".
054:             */
055:            private File dir;
056:
057:            /**
058:             * The port to which the container should be bound.
059:             */
060:            private int port = 8080;
061:
062:            /**
063:             * A user-specific <code>config.xml</code> WebLogic configuration file. 
064:             * If this variable is not set, the default configuration file from the 
065:             * JAR resources will be used.
066:             */
067:            private File configXml;
068:
069:            /**
070:             * The temporary directory from which the container will be started.
071:             */
072:            private File tmpDir;
073:
074:            // Public Methods ----------------------------------------------------------
075:
076:            /**
077:             * Sets the Bea home directory.
078:             * 
079:             * @param theBeaHome The BEA home directory
080:             */
081:            public final void setBeaHome(File theBeaHome) {
082:                this .beaHome = theBeaHome;
083:            }
084:
085:            /**
086:             * Sets the WebLogic 7.x installation directory.
087:             * 
088:             * @param theDir The directory to set
089:             */
090:            public final void setDir(File theDir) {
091:                this .dir = theDir;
092:            }
093:
094:            /**
095:             * Sets the port to which the container should listen.
096:             * 
097:             * @param thePort The port to set
098:             */
099:            public final void setPort(int thePort) {
100:                this .port = thePort;
101:            }
102:
103:            /**
104:             * Sets the configuration file to use for the test installation of 
105:             * WebLogic.
106:             * 
107:             * @param theConfigXml The custom <code>config.xml</code> file
108:             */
109:            public final void setConfigXml(File theConfigXml) {
110:                this .configXml = theConfigXml;
111:            }
112:
113:            /**
114:             * Sets the temporary installation directory.
115:             * 
116:             * @param theTmpDir The temporary directory to set
117:             */
118:            public final void setTmpDir(File theTmpDir) {
119:                this .tmpDir = theTmpDir;
120:            }
121:
122:            // AbstractContainer Implementation ----------------------------------------
123:
124:            /**
125:             * @see org.apache.cactus.integration.ant.container.Container#getName
126:             */
127:            public final String getName() {
128:                return "WebLogic 7.x";
129:            }
130:
131:            /**
132:             * Returns the port to which the container should listen.
133:             * 
134:             * @return The port
135:             */
136:            public final int getPort() {
137:                return this .port;
138:            }
139:
140:            /**
141:             * @see org.apache.cactus.integration.ant.container.Container#init
142:             */
143:            public final void init() {
144:                if (!this .dir.isDirectory()) {
145:                    throw new BuildException(this .dir + " is not a directory");
146:                }
147:
148:                // If the beaHome attribute is not set, guess the bea home
149:                // directory using the parent directory of this.dir 
150:                if (this .beaHome == null) {
151:                    getLog().debug(
152:                            "Extrapolating beaHome to be ["
153:                                    + this .dir.getParentFile() + "]");
154:                    this .beaHome = this .dir.getParentFile();
155:                }
156:            }
157:
158:            /**
159:             * @see org.apache.cactus.integration.ant.container.Container#startUp
160:             */
161:            public final void startUp() {
162:                try {
163:                    prepare("cactus/weblogic7x");
164:
165:                    Java java = createJavaForStartUp();
166:                    java.setDir(new File(this .tmpDir, "testdomain"));
167:
168:                    java.createJvmarg().setValue("-hotspot");
169:                    java.createJvmarg().setValue("-Xms32m");
170:                    java.createJvmarg().setValue("-Xmx200m");
171:
172:                    File serverDir = new File(this .dir, "server");
173:
174:                    java.addSysproperty(createSysProperty("weblogic.Name",
175:                            "testserver"));
176:                    java.addSysproperty(createSysProperty("bea.home",
177:                            this .beaHome));
178:                    java.addSysproperty(createSysProperty(
179:                            "weblogic.management.username", "weblogic"));
180:                    java.addSysproperty(createSysProperty(
181:                            "weblogic.management.password", "weblogic"));
182:
183:                    // Note: The "=" in the call below is on purpose. It is left so that
184:                    // we end up with: 
185:                    //   -Djava.security.policy==./server/lib/weblogic.policy
186:                    // (otherwise, we would end up with:
187:                    //   -Djava.security.policy=./server/lib/weblogic.policy, which
188:                    //  will not add to the security policy but instead replace it).
189:                    java.addSysproperty(createSysProperty(
190:                            "java.security.policy",
191:                            "=./server/lib/weblogic.policy"));
192:
193:                    Path classpath = java.createClasspath();
194:                    classpath.createPathElement().setLocation(
195:                            new File(serverDir, "lib/weblogic_sp.jar"));
196:                    classpath.createPathElement().setLocation(
197:                            new File(serverDir, "lib/weblogic.jar"));
198:
199:                    java.setClassname("weblogic.Server");
200:                    java.execute();
201:                } catch (IOException ioe) {
202:                    getLog().error("Failed to startup the container", ioe);
203:                    throw new BuildException(ioe);
204:                }
205:            }
206:
207:            /**
208:             * @see org.apache.cactus.integration.ant.container.Container#shutDown
209:             */
210:            public final void shutDown() {
211:                Java java = createJavaForShutDown();
212:
213:                File serverDir = new File(this .dir, "server");
214:
215:                Path classpath = java.createClasspath();
216:                classpath.createPathElement().setLocation(
217:                        new File(serverDir, "lib/weblogic_sp.jar"));
218:                classpath.createPathElement().setLocation(
219:                        new File(serverDir, "lib/weblogic.jar"));
220:
221:                java.setClassname("weblogic.Admin");
222:                java.createArg().setValue("-url");
223:                java.createArg().setValue(
224:                        "t3://" + this .getServer() + ":" + getPort());
225:                java.createArg().setValue("-username");
226:                java.createArg().setValue("weblogic");
227:                java.createArg().setValue("-password");
228:                java.createArg().setValue("weblogic");
229:
230:                // Forcing WebLogic shutdown to speed up the shutdown process
231:                java.createArg().setValue("FORCESHUTDOWN");
232:
233:                java.execute();
234:            }
235:
236:            // Private Methods ---------------------------------------------------------
237:
238:            /**
239:             * Prepares a temporary installation of the container and deploys the 
240:             * web-application.
241:             * 
242:             * @param theDirName The name of the temporary container installation
243:             *        directory
244:             * @throws IOException If an I/O error occurs
245:             */
246:            private void prepare(String theDirName) throws IOException {
247:                FileUtils fileUtils = FileUtils.newFileUtils();
248:                FilterChain filterChain = createFilterChain();
249:
250:                this .tmpDir = setupTempDirectory(this .tmpDir, theDirName);
251:                cleanTempDirectory(this .tmpDir);
252:
253:                File testDomainDir = createDirectory(this .tmpDir, "testdomain");
254:
255:                if (this .configXml != null) {
256:                    fileUtils.copyFile(this .configXml, new File(testDomainDir,
257:                            "config.xml"));
258:                } else {
259:                    ResourceUtils.copyResource(getProject(), RESOURCE_PATH
260:                            + "weblogic7x/config.xml", new File(testDomainDir,
261:                            "config.xml"), filterChain);
262:                }
263:
264:                ResourceUtils.copyResource(getProject(), RESOURCE_PATH
265:                        + "weblogic7x/DefaultAuthenticatorInit.ldift",
266:                        new File(testDomainDir,
267:                                "DefaultAuthenticatorInit.ldift"), filterChain);
268:
269:                // TODO: For improvement, do not copy the weblogic.xml file
270:                // in the tmpdir.
271:
272:                // Extract the weblogic.xml descriptor
273:                File weblogicXml = new File(this .tmpDir, "weblogic.xml");
274:                ResourceUtils.copyResource(getProject(), RESOURCE_PATH
275:                        + "weblogic7x/weblogic.xml", weblogicXml, filterChain);
276:
277:                // deploy the web-app by copying the WAR file into the applications
278:                // directory, adding the weblogic.xml descriptor in WEB-INF
279:                File applicationsDir = createDirectory(testDomainDir,
280:                        "applications");
281:                Jar jar = (Jar) createAntTask("jar");
282:                jar.setDestFile(new File(applicationsDir, getDeployableFile()
283:                        .getFile().getName()));
284:                ZipFileSet zip = new ZipFileSet();
285:                zip.setSrc(getDeployableFile().getFile());
286:                jar.addZipfileset(zip);
287:                ZipFileSet fileSet = new ZipFileSet();
288:                fileSet.setDir(this .tmpDir);
289:                fileSet.createInclude().setName("weblogic.xml");
290:                fileSet.setPrefix("WEB-INF");
291:                jar.addZipfileset(fileSet);
292:                jar.execute();
293:            }
294:
295:        }
www_.j_a___va2_s__.c___o_m_ | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.