|
|||||||||||||||||||
Source file | Conditionals | Statements | Methods | TOTAL | |||||||||||||||
AbstractOrionContainer.java | 0% | 0% | 0% | 0% |
|
1 |
/*
|
|
2 |
* ====================================================================
|
|
3 |
*
|
|
4 |
* The Apache Software License, Version 1.1
|
|
5 |
*
|
|
6 |
* Copyright (c) 2003 The Apache Software Foundation. All rights
|
|
7 |
* reserved.
|
|
8 |
*
|
|
9 |
* Redistribution and use in source and binary forms, with or without
|
|
10 |
* modification, are permitted provided that the following conditions
|
|
11 |
* are met:
|
|
12 |
*
|
|
13 |
* 1. Redistributions of source code must retain the above copyright
|
|
14 |
* notice, this list of conditions and the following disclaimer.
|
|
15 |
*
|
|
16 |
* 2. Redistributions in binary form must reproduce the above copyright
|
|
17 |
* notice, this list of conditions and the following disclaimer in
|
|
18 |
* the documentation and/or other materials provided with the
|
|
19 |
* distribution.
|
|
20 |
*
|
|
21 |
* 3. The end-user documentation included with the redistribution, if
|
|
22 |
* any, must include the following acknowlegement:
|
|
23 |
* "This product includes software developed by the
|
|
24 |
* Apache Software Foundation (http://www.apache.org/)."
|
|
25 |
* Alternately, this acknowlegement may appear in the software itself,
|
|
26 |
* if and wherever such third-party acknowlegements normally appear.
|
|
27 |
*
|
|
28 |
* 4. The names "The Jakarta Project", "Cactus" and "Apache Software
|
|
29 |
* Foundation" must not be used to endorse or promote products
|
|
30 |
* derived from this software without prior written permission. For
|
|
31 |
* written permission, please contact apache@apache.org.
|
|
32 |
*
|
|
33 |
* 5. Products derived from this software may not be called "Apache"
|
|
34 |
* nor may "Apache" appear in their names without prior written
|
|
35 |
* permission of the Apache Group.
|
|
36 |
*
|
|
37 |
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
|
|
38 |
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
|
39 |
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
40 |
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
|
|
41 |
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
42 |
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
43 |
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
|
|
44 |
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
|
45 |
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
46 |
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
|
47 |
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
48 |
* SUCH DAMAGE.
|
|
49 |
* ====================================================================
|
|
50 |
*
|
|
51 |
* This software consists of voluntary contributions made by many
|
|
52 |
* individuals on behalf of the Apache Software Foundation. For more
|
|
53 |
* information on the Apache Software Foundation, please see
|
|
54 |
* <http://www.apache.org/>.
|
|
55 |
*
|
|
56 |
*/
|
|
57 |
package org.apache.cactus.integration.ant.container.orion;
|
|
58 |
|
|
59 |
import java.io.File;
|
|
60 |
import java.io.FileNotFoundException;
|
|
61 |
import java.io.IOException;
|
|
62 |
|
|
63 |
import org.apache.cactus.integration.ant.container.AbstractJavaContainer;
|
|
64 |
import org.apache.cactus.integration.ant.util.ResourceUtils;
|
|
65 |
import org.apache.tools.ant.BuildException;
|
|
66 |
import org.apache.tools.ant.taskdefs.Java;
|
|
67 |
import org.apache.tools.ant.types.FileSet;
|
|
68 |
import org.apache.tools.ant.types.FilterChain;
|
|
69 |
import org.apache.tools.ant.types.Path;
|
|
70 |
import org.apache.tools.ant.util.FileUtils;
|
|
71 |
|
|
72 |
/**
|
|
73 |
* Basic support for the Orin application server.
|
|
74 |
*
|
|
75 |
* @author <a href="mailto:cmlenz@apache.org">Christopher Lenz</a>
|
|
76 |
*
|
|
77 |
* @version $Id: AbstractOrionContainer.java,v 1.4.2.2 2003/10/23 18:20:46 vmassol Exp $
|
|
78 |
*/
|
|
79 |
public abstract class AbstractOrionContainer extends AbstractJavaContainer |
|
80 |
{ |
|
81 |
|
|
82 |
// Instance Variables ------------------------------------------------------
|
|
83 |
|
|
84 |
/**
|
|
85 |
* The Orion 1.x installation directory.
|
|
86 |
*/
|
|
87 |
private File dir;
|
|
88 |
|
|
89 |
/**
|
|
90 |
* The port to which the container should be bound.
|
|
91 |
*/
|
|
92 |
private int port = 8080; |
|
93 |
|
|
94 |
/**
|
|
95 |
* The temporary directory from which the container will be started.
|
|
96 |
*/
|
|
97 |
private File tmpDir;
|
|
98 |
|
|
99 |
// Public Methods ----------------------------------------------------------
|
|
100 |
|
|
101 |
/**
|
|
102 |
* Sets the Orion installation directory.
|
|
103 |
*
|
|
104 |
* @param theDir The directory to set
|
|
105 |
*/
|
|
106 | 0 |
public final void setDir(File theDir) |
107 |
{ |
|
108 | 0 |
this.dir = theDir;
|
109 |
} |
|
110 |
|
|
111 |
/**
|
|
112 |
* Sets the port to which the container should listen.
|
|
113 |
*
|
|
114 |
* @param thePort The port to set
|
|
115 |
*/
|
|
116 | 0 |
public final void setPort(int thePort) |
117 |
{ |
|
118 | 0 |
this.port = thePort;
|
119 |
} |
|
120 |
|
|
121 |
/**
|
|
122 |
* Sets the temporary directory from which to start the container.
|
|
123 |
*
|
|
124 |
* @param theTmpDir The directory to set
|
|
125 |
*/
|
|
126 | 0 |
public final void setTmpDir(File theTmpDir) |
127 |
{ |
|
128 | 0 |
this.tmpDir = theTmpDir;
|
129 |
} |
|
130 |
|
|
131 |
// AbstractContainer Implementation ----------------------------------------
|
|
132 |
|
|
133 |
/**
|
|
134 |
* Returns the port to which the container should listen.
|
|
135 |
*
|
|
136 |
* @return The port
|
|
137 |
*/
|
|
138 | 0 |
public final int getPort() |
139 |
{ |
|
140 | 0 |
return this.port; |
141 |
} |
|
142 |
|
|
143 |
/**
|
|
144 |
* @see org.apache.cactus.integration.ant.container.Container#init
|
|
145 |
*/
|
|
146 | 0 |
public final void init() |
147 |
{ |
|
148 | 0 |
if (!this.dir.isDirectory()) |
149 |
{ |
|
150 | 0 |
throw new BuildException(this.dir + " is not a directory"); |
151 |
} |
|
152 |
} |
|
153 |
|
|
154 |
/**
|
|
155 |
* @see org.apache.cactus.integration.ant.container.Container#shutDown
|
|
156 |
*/
|
|
157 | 0 |
public final void shutDown() |
158 |
{ |
|
159 |
// invoke the main class
|
|
160 | 0 |
Java java = createJavaForShutDown(); |
161 | 0 |
Path classpath = java.createClasspath(); |
162 | 0 |
FileSet fileSet = new FileSet();
|
163 | 0 |
fileSet.setDir(this.dir);
|
164 | 0 |
fileSet.createInclude().setName("*.jar");
|
165 | 0 |
classpath.addFileset(fileSet); |
166 | 0 |
java.setClassname("com.evermind.client.orion.OrionConsoleAdmin");
|
167 | 0 |
java.createArg().setValue("ormi://localhost:23791/");
|
168 | 0 |
java.createArg().setValue("admin");
|
169 | 0 |
java.createArg().setValue("password");
|
170 | 0 |
java.createArg().setValue("-shutdown");
|
171 | 0 |
java.execute(); |
172 |
} |
|
173 |
|
|
174 |
// Private Methods ---------------------------------------------------------
|
|
175 |
|
|
176 |
/**
|
|
177 |
* Invokes the command to start the Orion application server.
|
|
178 |
*/
|
|
179 | 0 |
protected final void invokeServer() |
180 |
{ |
|
181 |
// invoke the main class
|
|
182 | 0 |
Java java = createJavaForStartUp(); |
183 | 0 |
Path classpath = java.createClasspath(); |
184 | 0 |
FileSet fileSet = new FileSet();
|
185 | 0 |
fileSet.setDir(this.dir);
|
186 | 0 |
fileSet.createInclude().setName("*.jar");
|
187 | 0 |
classpath.addFileset(fileSet); |
188 | 0 |
try
|
189 |
{ |
|
190 | 0 |
classpath.createPathElement().setLocation(getToolsJar()); |
191 |
} |
|
192 |
catch (FileNotFoundException fnfe)
|
|
193 |
{ |
|
194 | 0 |
getLog().warn( |
195 |
"Couldn't find tools.jar (needed for JSP compilation)");
|
|
196 |
} |
|
197 | 0 |
java.setClassname("com.evermind.server.ApplicationServer");
|
198 | 0 |
java.createArg().setValue("-config");
|
199 | 0 |
java.createArg().setFile(new File(tmpDir, "conf/server.xml")); |
200 | 0 |
java.execute(); |
201 |
} |
|
202 |
|
|
203 |
/**
|
|
204 |
* Prepares a temporary installation of the container and deploys the
|
|
205 |
* web-application.
|
|
206 |
*
|
|
207 |
* @param theResourcePrefix The prefix to use when looking up container
|
|
208 |
* resource in the JAR
|
|
209 |
* @param theDirName The name of the temporary container installation
|
|
210 |
* directory
|
|
211 |
* @throws IOException If an I/O error occurs
|
|
212 |
*/
|
|
213 | 0 |
protected final void prepare(String theResourcePrefix, String theDirName) |
214 |
throws IOException
|
|
215 |
{ |
|
216 | 0 |
FileUtils fileUtils = FileUtils.newFileUtils(); |
217 | 0 |
FilterChain filterChain = createFilterChain(); |
218 |
|
|
219 | 0 |
if (this.tmpDir == null) |
220 |
{ |
|
221 | 0 |
this.tmpDir = createTempDirectory(theDirName);
|
222 |
} |
|
223 |
|
|
224 |
// Copy configuration files into the temporary container directory
|
|
225 |
|
|
226 | 0 |
File confDir = createDirectory(tmpDir, "conf");
|
227 |
|
|
228 |
// Configuration files are not the same whether we deploy a
|
|
229 |
// WAR or an EAR
|
|
230 | 0 |
String sharePath = RESOURCE_PATH + theResourcePrefix + "/share";
|
231 | 0 |
String specificPath; |
232 | 0 |
if (getDeployableFile().isWar())
|
233 |
{ |
|
234 | 0 |
specificPath = RESOURCE_PATH + theResourcePrefix + "/war";
|
235 |
} |
|
236 |
else
|
|
237 |
{ |
|
238 | 0 |
specificPath = RESOURCE_PATH + theResourcePrefix + "/ear";
|
239 |
} |
|
240 |
|
|
241 | 0 |
ResourceUtils.copyResource(getProject(), |
242 |
specificPath + "/server.xml",
|
|
243 |
new File(confDir, "server.xml"), filterChain); |
|
244 | 0 |
ResourceUtils.copyResource(getProject(), |
245 |
specificPath + "/application.xml",
|
|
246 |
new File(confDir, "application.xml"), filterChain); |
|
247 | 0 |
ResourceUtils.copyResource(getProject(), |
248 |
specificPath + "/default-web-site.xml",
|
|
249 |
new File(confDir, "default-web-site.xml"), filterChain); |
|
250 |
|
|
251 | 0 |
ResourceUtils.copyResource(getProject(), |
252 |
sharePath + "/global-web-application.xml",
|
|
253 |
new File(confDir, "global-web-application.xml"), filterChain); |
|
254 | 0 |
ResourceUtils.copyResource(getProject(), |
255 |
sharePath + "/mime.types",
|
|
256 |
new File(confDir, "mime.types"), filterChain); |
|
257 | 0 |
ResourceUtils.copyResource(getProject(), |
258 |
sharePath + "/principals.xml",
|
|
259 |
new File(confDir, "principals.xml"), filterChain); |
|
260 | 0 |
ResourceUtils.copyResource(getProject(), |
261 |
sharePath + "/rmi.xml",
|
|
262 |
new File(confDir, "rmi.xml"), filterChain); |
|
263 |
|
|
264 |
// Create default web app (required by Orion unfortunately...)
|
|
265 | 0 |
File defaultWebAppDir = createDirectory(tmpDir, |
266 |
"default-web-app/WEB-INF");
|
|
267 | 0 |
ResourceUtils.copyResource(getProject(), |
268 |
sharePath + "/web.xml",
|
|
269 |
new File(defaultWebAppDir, "web.xml"), filterChain); |
|
270 |
|
|
271 |
// Orion need to have a /persistence directory created, otherwise it
|
|
272 |
// throws an error
|
|
273 | 0 |
createDirectory(tmpDir, "persistence");
|
274 |
|
|
275 |
// Directory where modules to be deployed are located
|
|
276 | 0 |
File appDir = createDirectory(tmpDir, "applications");
|
277 |
|
|
278 |
// Deployment directory (i.e. where Orion expands modules)
|
|
279 | 0 |
createDirectory(tmpDir, "application-deployments");
|
280 |
|
|
281 |
// Orion log directory
|
|
282 | 0 |
createDirectory(tmpDir, "log");
|
283 |
|
|
284 | 0 |
fileUtils.copyFile(getDeployableFile().getFile(), |
285 |
new File(appDir, getDeployableFile().getFile().getName()),
|
|
286 |
null, true); |
|
287 |
} |
|
288 |
|
|
289 |
} |
|
290 |
|
|