1 20 package org.apache.cactus.integration.ant.container.tomcat; 21 22 import java.io.File ; 23 import java.io.IOException ; 24 25 import org.apache.tools.ant.BuildException; 26 import org.apache.tools.ant.util.FileUtils; 27 28 33 public class Tomcat4xContainer extends AbstractCatalinaContainer 34 { 35 37 40 private File contextXml; 41 42 44 47 public final File getContextXml() 48 { 49 return this.contextXml; 50 } 51 52 58 public final void setContextXml(File theContextXml) 59 { 60 this.contextXml = theContextXml; 61 } 62 63 65 68 public final void init() 69 { 70 super.init(); 71 72 if (!getVersion().startsWith("4")) 73 { 74 throw new BuildException( 75 "This element doesn't support version " + getVersion() 76 + " of Tomcat"); 77 } 78 } 79 80 83 public final void startUp() 84 { 85 try 86 { 87 prepare("tomcat4x", "cactus/tomcat4x"); 88 invokeBootstrap("start"); 89 } 90 catch (IOException ioe) 91 { 92 getLog().error("Failed to startup the container", ioe); 93 throw new BuildException(ioe); 94 } 95 } 96 97 100 public final void shutDown() 101 { 102 invokeBootstrap("stop"); 103 } 104 105 115 protected void prepare(String theResourcePrefix, String theDirName) 116 throws IOException 117 { 118 super.prepare(theResourcePrefix, theDirName); 119 120 FileUtils fileUtils = FileUtils.newFileUtils(); 121 122 File webappsDir = new File (getTmpDir(), "webapps"); 125 if (getContextXml() != null) 126 { 127 fileUtils.copyFile(getContextXml(), 128 new File (webappsDir, getContextXml().getName())); 129 } 130 131 } 132 133 } 134 | Popular Tags |