|
|||||||||||||||||||
| 30 day Evaluation Version distributed via the Maven Jar Repository. Clover is not free. You have 30 days to evaluate it. Please visit http://www.thecortex.net/clover to obtain a licensed version of Clover | |||||||||||||||||||
| Source file | Conditionals | Statements | Methods | TOTAL | |||||||||||||||
| AbstractOrionContainer.java | 0% | 0% | 0% | 0% |
|
||||||||||||||
| 1 |
/*
|
|
| 2 |
* ========================================================================
|
|
| 3 |
*
|
|
| 4 |
* Copyright 2003 The Apache Software Foundation.
|
|
| 5 |
*
|
|
| 6 |
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
| 7 |
* you may not use this file except in compliance with the License.
|
|
| 8 |
* You may obtain a copy of the License at
|
|
| 9 |
*
|
|
| 10 |
* http://www.apache.org/licenses/LICENSE-2.0
|
|
| 11 |
*
|
|
| 12 |
* Unless required by applicable law or agreed to in writing, software
|
|
| 13 |
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
| 14 |
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
| 15 |
* See the License for the specific language governing permissions and
|
|
| 16 |
* limitations under the License.
|
|
| 17 |
*
|
|
| 18 |
* ========================================================================
|
|
| 19 |
*/
|
|
| 20 |
package org.apache.cactus.integration.ant.container.orion;
|
|
| 21 |
|
|
| 22 |
import java.io.File;
|
|
| 23 |
import java.io.IOException;
|
|
| 24 |
|
|
| 25 |
import org.apache.cactus.integration.ant.container.AbstractJavaContainer;
|
|
| 26 |
import org.apache.cactus.integration.ant.util.ResourceUtils;
|
|
| 27 |
import org.apache.tools.ant.BuildException;
|
|
| 28 |
import org.apache.tools.ant.taskdefs.Java;
|
|
| 29 |
import org.apache.tools.ant.types.FileSet;
|
|
| 30 |
import org.apache.tools.ant.types.FilterChain;
|
|
| 31 |
import org.apache.tools.ant.types.Path;
|
|
| 32 |
import org.apache.tools.ant.util.FileUtils;
|
|
| 33 |
|
|
| 34 |
/**
|
|
| 35 |
* Basic support for the Orin application server.
|
|
| 36 |
*
|
|
| 37 |
* @version $Id: AbstractOrionContainer.java 239130 2005-01-29 15:49:18Z vmassol $
|
|
| 38 |
*/
|
|
| 39 |
public abstract class AbstractOrionContainer extends AbstractJavaContainer |
|
| 40 |
{
|
|
| 41 |
|
|
| 42 |
// Instance Variables ------------------------------------------------------
|
|
| 43 |
|
|
| 44 |
/**
|
|
| 45 |
* The Orion 1.x installation directory.
|
|
| 46 |
*/
|
|
| 47 |
private File dir;
|
|
| 48 |
|
|
| 49 |
/**
|
|
| 50 |
* The port to which the container should be bound.
|
|
| 51 |
*/
|
|
| 52 |
private int port = 8080; |
|
| 53 |
|
|
| 54 |
/**
|
|
| 55 |
* The temporary directory from which the container will be started.
|
|
| 56 |
*/
|
|
| 57 |
private File tmpDir;
|
|
| 58 |
|
|
| 59 |
// Public Methods ----------------------------------------------------------
|
|
| 60 |
|
|
| 61 |
/**
|
|
| 62 |
* Sets the Orion installation directory.
|
|
| 63 |
*
|
|
| 64 |
* @param theDir The directory to set
|
|
| 65 |
*/
|
|
| 66 | 0 |
public final void setDir(File theDir) |
| 67 |
{
|
|
| 68 | 0 |
this.dir = theDir;
|
| 69 |
} |
|
| 70 |
|
|
| 71 |
/**
|
|
| 72 |
* Sets the port to which the container should listen.
|
|
| 73 |
*
|
|
| 74 |
* @param thePort The port to set
|
|
| 75 |
*/
|
|
| 76 | 0 |
public final void setPort(int thePort) |
| 77 |
{
|
|
| 78 | 0 |
this.port = thePort;
|
| 79 |
} |
|
| 80 |
|
|
| 81 |
/**
|
|
| 82 |
* Sets the temporary directory from which to start the container.
|
|
| 83 |
*
|
|
| 84 |
* @param theTmpDir The directory to set
|
|
| 85 |
*/
|
|
| 86 | 0 |
public final void setTmpDir(File theTmpDir) |
| 87 |
{
|
|
| 88 | 0 |
this.tmpDir = theTmpDir;
|
| 89 |
} |
|
| 90 |
|
|
| 91 |
// AbstractContainer Implementation ----------------------------------------
|
|
| 92 |
|
|
| 93 |
/**
|
|
| 94 |
* Returns the port to which the container should listen.
|
|
| 95 |
*
|
|
| 96 |
* @return The port
|
|
| 97 |
*/
|
|
| 98 | 0 |
public final int getPort() |
| 99 |
{
|
|
| 100 | 0 |
return this.port; |
| 101 |
} |
|
| 102 |
|
|
| 103 |
/**
|
|
| 104 |
* @see org.apache.cactus.integration.ant.container.Container#init
|
|
| 105 |
*/
|
|
| 106 | 0 |
public final void init() |
| 107 |
{
|
|
| 108 | 0 |
if (!this.dir.isDirectory()) |
| 109 |
{
|
|
| 110 | 0 |
throw new BuildException(this.dir + " is not a directory"); |
| 111 |
} |
|
| 112 |
} |
|
| 113 |
|
|
| 114 |
/**
|
|
| 115 |
* @see org.apache.cactus.integration.ant.container.Container#shutDown
|
|
| 116 |
*/
|
|
| 117 | 0 |
public final void shutDown() |
| 118 |
{
|
|
| 119 |
// invoke the main class
|
|
| 120 | 0 |
Java java = createJavaForShutDown(); |
| 121 | 0 |
Path classpath = java.createClasspath(); |
| 122 | 0 |
FileSet fileSet = new FileSet();
|
| 123 | 0 |
fileSet.setDir(this.dir);
|
| 124 | 0 |
fileSet.createInclude().setName("*.jar");
|
| 125 | 0 |
classpath.addFileset(fileSet); |
| 126 | 0 |
java.setClassname("com.evermind.client.orion.OrionConsoleAdmin");
|
| 127 | 0 |
java.createArg().setValue("ormi://" + this.getServer() + ":23791/"); |
| 128 | 0 |
java.createArg().setValue("admin");
|
| 129 | 0 |
java.createArg().setValue("password");
|
| 130 | 0 |
java.createArg().setValue("-shutdown");
|
| 131 | 0 |
java.execute(); |
| 132 |
} |
|
| 133 |
|
|
| 134 |
// Private Methods ---------------------------------------------------------
|
|
| 135 |
|
|
| 136 |
/**
|
|
| 137 |
* Invokes the command to start the Orion application server.
|
|
| 138 |
*/
|
|
| 139 | 0 |
protected final void invokeServer() |
| 140 |
{
|
|
| 141 |
// invoke the main class
|
|
| 142 | 0 |
Java java = createJavaForStartUp(); |
| 143 | 0 |
Path classpath = java.createClasspath(); |
| 144 | 0 |
FileSet fileSet = new FileSet();
|
| 145 | 0 |
fileSet.setDir(this.dir);
|
| 146 | 0 |
fileSet.createInclude().setName("*.jar");
|
| 147 | 0 |
classpath.addFileset(fileSet); |
| 148 | 0 |
addToolsJarToClasspath(classpath); |
| 149 | 0 |
java.setClassname("com.evermind.server.ApplicationServer");
|
| 150 | 0 |
java.createArg().setValue("-config");
|
| 151 | 0 |
java.createArg().setFile(new File(tmpDir, "conf/server.xml")); |
| 152 | 0 |
java.execute(); |
| 153 |
} |
|
| 154 |
|
|
| 155 |
/**
|
|
| 156 |
* Prepares a temporary installation of the container and deploys the
|
|
| 157 |
* web-application.
|
|
| 158 |
*
|
|
| 159 |
* @param theResourcePrefix The prefix to use when looking up container
|
|
| 160 |
* resource in the JAR
|
|
| 161 |
* @param theDirName The name of the temporary container installation
|
|
| 162 |
* directory
|
|
| 163 |
* @throws IOException If an I/O error occurs
|
|
| 164 |
*/
|
|
| 165 | 0 |
protected final void prepare(String theResourcePrefix, String theDirName) |
| 166 |
throws IOException
|
|
| 167 |
{
|
|
| 168 | 0 |
FileUtils fileUtils = FileUtils.newFileUtils(); |
| 169 | 0 |
FilterChain filterChain = createFilterChain(); |
| 170 |
|
|
| 171 | 0 |
this.tmpDir = setupTempDirectory(this.tmpDir, theDirName); |
| 172 | 0 |
cleanTempDirectory(this.tmpDir);
|
| 173 |
|
|
| 174 |
// Copy configuration files into the temporary container directory
|
|
| 175 |
|
|
| 176 | 0 |
File confDir = createDirectory(tmpDir, "conf");
|
| 177 |
|
|
| 178 |
// Configuration files are not the same whether we deploy a
|
|
| 179 |
// WAR or an EAR
|
|
| 180 | 0 |
String sharePath = RESOURCE_PATH + theResourcePrefix + "/share";
|
| 181 | 0 |
String specificPath; |
| 182 | 0 |
if (getDeployableFile().isWar())
|
| 183 |
{
|
|
| 184 | 0 |
specificPath = RESOURCE_PATH + theResourcePrefix + "/war";
|
| 185 |
} |
|
| 186 |
else
|
|
| 187 |
{
|
|
| 188 | 0 |
specificPath = RESOURCE_PATH + theResourcePrefix + "/ear";
|
| 189 |
} |
|
| 190 |
|
|
| 191 | 0 |
ResourceUtils.copyResource(getProject(), |
| 192 |
specificPath + "/server.xml",
|
|
| 193 |
new File(confDir, "server.xml"), filterChain); |
|
| 194 | 0 |
ResourceUtils.copyResource(getProject(), |
| 195 |
specificPath + "/application.xml",
|
|
| 196 |
new File(confDir, "application.xml"), filterChain); |
|
| 197 | 0 |
ResourceUtils.copyResource(getProject(), |
| 198 |
specificPath + "/default-web-site.xml",
|
|
| 199 |
new File(confDir, "default-web-site.xml"), filterChain); |
|
| 200 |
|
|
| 201 | 0 |
ResourceUtils.copyResource(getProject(), |
| 202 |
sharePath + "/global-web-application.xml",
|
|
| 203 |
new File(confDir, "global-web-application.xml"), filterChain); |
|
| 204 | 0 |
ResourceUtils.copyResource(getProject(), |
| 205 |
sharePath + "/mime.types",
|
|
| 206 |
new File(confDir, "mime.types"), filterChain); |
|
| 207 | 0 |
ResourceUtils.copyResource(getProject(), |
| 208 |
sharePath + "/principals.xml",
|
|
| 209 |
new File(confDir, "principals.xml"), filterChain); |
|
| 210 | 0 |
ResourceUtils.copyResource(getProject(), |
| 211 |
sharePath + "/rmi.xml",
|
|
| 212 |
new File(confDir, "rmi.xml"), filterChain); |
|
| 213 |
|
|
| 214 |
// Create default web app (required by Orion unfortunately...)
|
|
| 215 | 0 |
File defaultWebAppDir = createDirectory(tmpDir, |
| 216 |
"default-web-app/WEB-INF");
|
|
| 217 | 0 |
ResourceUtils.copyResource(getProject(), |
| 218 |
sharePath + "/web.xml",
|
|
| 219 |
new File(defaultWebAppDir, "web.xml"), filterChain); |
|
| 220 |
|
|
| 221 |
// Orion need to have a /persistence directory created, otherwise it
|
|
| 222 |
// throws an error
|
|
| 223 | 0 |
createDirectory(tmpDir, "persistence");
|
| 224 |
|
|
| 225 |
// Directory where modules to be deployed are located
|
|
| 226 | 0 |
File appDir = createDirectory(tmpDir, "applications");
|
| 227 |
|
|
| 228 |
// Deployment directory (i.e. where Orion expands modules)
|
|
| 229 | 0 |
createDirectory(tmpDir, "application-deployments");
|
| 230 |
|
|
| 231 |
// Orion log directory
|
|
| 232 | 0 |
createDirectory(tmpDir, "log");
|
| 233 |
|
|
| 234 | 0 |
fileUtils.copyFile(getDeployableFile().getFile(), |
| 235 |
new File(appDir, getDeployableFile().getFile().getName()),
|
|
| 236 |
null, true); |
|
| 237 |
} |
|
| 238 |
|
|
| 239 |
} |
|
| 240 |
|
|
||||||||||