1 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 39 public abstract class AbstractOrionContainer extends AbstractJavaContainer 40 { 41 42 44 47 private File dir; 48 49 52 private int port = 8080; 53 54 57 private File tmpDir; 58 59 61 66 public final void setDir(File theDir) 67 { 68 this.dir = theDir; 69 } 70 71 76 public final void setPort(int thePort) 77 { 78 this.port = thePort; 79 } 80 81 86 public final void setTmpDir(File theTmpDir) 87 { 88 this.tmpDir = theTmpDir; 89 } 90 91 93 98 public final int getPort() 99 { 100 return this.port; 101 } 102 103 106 public final void init() 107 { 108 if (!this.dir.isDirectory()) 109 { 110 throw new BuildException(this.dir + " is not a directory"); 111 } 112 } 113 114 117 public final void shutDown() 118 { 119 Java java = createJavaForShutDown(); 121 Path classpath = java.createClasspath(); 122 FileSet fileSet = new FileSet(); 123 fileSet.setDir(this.dir); 124 fileSet.createInclude().setName("*.jar"); 125 classpath.addFileset(fileSet); 126 java.setClassname("com.evermind.client.orion.OrionConsoleAdmin"); 127 java.createArg().setValue("ormi://localhost:23791/"); 128 java.createArg().setValue("admin"); 129 java.createArg().setValue("password"); 130 java.createArg().setValue("-shutdown"); 131 java.execute(); 132 } 133 134 136 139 protected final void invokeServer() 140 { 141 Java java = createJavaForStartUp(); 143 Path classpath = java.createClasspath(); 144 FileSet fileSet = new FileSet(); 145 fileSet.setDir(this.dir); 146 fileSet.createInclude().setName("*.jar"); 147 classpath.addFileset(fileSet); 148 addToolsJarToClasspath(classpath); 149 java.setClassname("com.evermind.server.ApplicationServer"); 150 java.createArg().setValue("-config"); 151 java.createArg().setFile(new File (tmpDir, "conf/server.xml")); 152 java.execute(); 153 } 154 155 165 protected final void prepare(String theResourcePrefix, String theDirName) 166 throws IOException 167 { 168 FileUtils fileUtils = FileUtils.newFileUtils(); 169 FilterChain filterChain = createFilterChain(); 170 171 this.tmpDir = setupTempDirectory(this.tmpDir, theDirName); 172 cleanTempDirectory(this.tmpDir); 173 174 176 File confDir = createDirectory(tmpDir, "conf"); 177 178 String sharePath = RESOURCE_PATH + theResourcePrefix + "/share"; 181 String specificPath; 182 if (getDeployableFile().isWar()) 183 { 184 specificPath = RESOURCE_PATH + theResourcePrefix + "/war"; 185 } 186 else 187 { 188 specificPath = RESOURCE_PATH + theResourcePrefix + "/ear"; 189 } 190 191 ResourceUtils.copyResource(getProject(), 192 specificPath + "/server.xml", 193 new File (confDir, "server.xml"), filterChain); 194 ResourceUtils.copyResource(getProject(), 195 specificPath + "/application.xml", 196 new File (confDir, "application.xml"), filterChain); 197 ResourceUtils.copyResource(getProject(), 198 specificPath + "/default-web-site.xml", 199 new File (confDir, "default-web-site.xml"), filterChain); 200 201 ResourceUtils.copyResource(getProject(), 202 sharePath + "/global-web-application.xml", 203 new File (confDir, "global-web-application.xml"), filterChain); 204 ResourceUtils.copyResource(getProject(), 205 sharePath + "/mime.types", 206 new File (confDir, "mime.types"), filterChain); 207 ResourceUtils.copyResource(getProject(), 208 sharePath + "/principals.xml", 209 new File (confDir, "principals.xml"), filterChain); 210 ResourceUtils.copyResource(getProject(), 211 sharePath + "/rmi.xml", 212 new File (confDir, "rmi.xml"), filterChain); 213 214 File defaultWebAppDir = createDirectory(tmpDir, 216 "default-web-app/WEB-INF"); 217 ResourceUtils.copyResource(getProject(), 218 sharePath + "/web.xml", 219 new File (defaultWebAppDir, "web.xml"), filterChain); 220 221 createDirectory(tmpDir, "persistence"); 224 225 File appDir = createDirectory(tmpDir, "applications"); 227 228 createDirectory(tmpDir, "application-deployments"); 230 231 createDirectory(tmpDir, "log"); 233 234 fileUtils.copyFile(getDeployableFile().getFile(), 235 new File (appDir, getDeployableFile().getFile().getName()), 236 null, true); 237 } 238 239 } 240 | Popular Tags |