Author: dain
Date: Wed Sep 19 19:23:07 2007
New Revision: 577505

URL: http://svn.apache.org/viewvc?rev=577505&view=rev
Log:
Merging 577352 from trunk
Added windows installer for Tomcat

Modified:
    
openejb/branches/3.0-beta-1/assembly/openejb-tomcat/src/main/java/org/apache/openejb/tomcat/installer/Installer.java
    
openejb/branches/3.0-beta-1/assembly/openejb-tomcat/src/main/java/org/apache/openejb/tomcat/installer/Paths.java

Modified: 
openejb/branches/3.0-beta-1/assembly/openejb-tomcat/src/main/java/org/apache/openejb/tomcat/installer/Installer.java
URL: 
http://svn.apache.org/viewvc/openejb/branches/3.0-beta-1/assembly/openejb-tomcat/src/main/java/org/apache/openejb/tomcat/installer/Installer.java?rev=577505&r1=577504&r2=577505&view=diff
==============================================================================
--- 
openejb/branches/3.0-beta-1/assembly/openejb-tomcat/src/main/java/org/apache/openejb/tomcat/installer/Installer.java
 (original)
+++ 
openejb/branches/3.0-beta-1/assembly/openejb-tomcat/src/main/java/org/apache/openejb/tomcat/installer/Installer.java
 Wed Sep 19 19:23:07 2007
@@ -158,6 +158,9 @@
             return;
         }
 
+        //
+        // bin/catalina.sh
+        //
 
         // read the catalina sh file
         String catalinaShOriginal = readAll(paths.getCatalinaShFile());
@@ -197,6 +200,50 @@
         // overwrite the catalina.sh file
         if (writeAll(paths.getCatalinaShFile(), newCatalinaSh)) {
             addInfo("Added OpenEJB javaagent to Tomcat catalina.sh file.");
+        }
+
+        //
+        // bin/catalina.bat
+        //
+
+        // read the catalina bat file
+        String catalinaBatOriginal = readAll(paths.getCatalinaBatFile());
+
+        // catalina bat will be null if we couldn't read the file
+        if (catalinaBatOriginal == null) {
+            return;
+        }
+
+        // does the catalina bat contain our comment... it is possible that 
they commented out the magic script code, but there is no way to detect that
+        if (catalinaBatOriginal.contains("Add OpenEJB javaagent")) {
+            addInfo("OpenEJB javaagent already declared in Tomcat catalina.bat 
file.");
+            return;
+        }
+
+        // if we can't backup the file, do not modify it
+        if (!backup(paths.getCatalinaBatFile())) {
+            return;
+        }
+
+        // add our magic bits to the catalina bat file
+        openejbJavaagentPath = openejbJavaagentPath.replace('/', '\\');
+        updatedAnnotationApiPath = updatedAnnotationApiPath.replace('/', '\\');
+        String newCatalinaBat = catalinaBatOriginal.replace("rem ----- Execute 
The Requested Command",
+                "rem Update non-compliant Tomcat annotation-api.jar\r\n" +
+                "if not exist \"%CATALINA_BASE%\\" + updatedAnnotationApiPath 
+ "\" goto noUpdatedAnnotationJar\r\n" +
+                "copy /Y \"%CATALINA_BASE%\\" + updatedAnnotationApiPath + "\" 
\"%CATALINA_HOME%\\lib\\annotations-api.jar\"\r\n" +
+                ":noUpdatedAnnotationJar\r\n" +
+                "\r\n" +
+                "rem Add OpenEJB javaagent\r\n" +
+                "if not exist \"%CATALINA_BASE%\\" + openejbJavaagentPath + 
"\" goto noOpenEJBJavaagent\r\n" +
+                "set JAVA_OPTS=\"-javaagent:%CATALINA_BASE%\\" + 
openejbJavaagentPath + "\" %JAVA_OPTS%\r\n" +
+                ":noOpenEJBJavaagent\r\n" +
+                "\r\n" +
+                "rem ----- Execute The Requested Command");
+
+        // overwrite the catalina.bat file
+        if (writeAll(paths.getCatalinaBatFile(), newCatalinaBat)) {
+            addInfo("Added OpenEJB javaagent to Tomcat catalina.bat file.");
         }
     }
 

Modified: 
openejb/branches/3.0-beta-1/assembly/openejb-tomcat/src/main/java/org/apache/openejb/tomcat/installer/Paths.java
URL: 
http://svn.apache.org/viewvc/openejb/branches/3.0-beta-1/assembly/openejb-tomcat/src/main/java/org/apache/openejb/tomcat/installer/Paths.java?rev=577505&r1=577504&r2=577505&view=diff
==============================================================================
--- 
openejb/branches/3.0-beta-1/assembly/openejb-tomcat/src/main/java/org/apache/openejb/tomcat/installer/Paths.java
 (original)
+++ 
openejb/branches/3.0-beta-1/assembly/openejb-tomcat/src/main/java/org/apache/openejb/tomcat/installer/Paths.java
 Wed Sep 19 19:23:07 2007
@@ -122,6 +122,14 @@
         return new File(binDir, "catalina.sh");
     }
 
+    public File getCatalinaBatFile() {
+        File binDir = getCatalinaBinDir();
+
+        if (binDir == null) return null;
+
+        return new File(binDir, "catalina.bat");
+    }
+
     public File getOpenEJBLibDir() {
         if (servletContext == null) return null;
 
@@ -181,6 +189,7 @@
         verifyDirectory("Catalina bin", getCatalinaBinDir());
         verifyWritableFile("Catalina server.xml", getServerXmlFile());
         verifyWritableFile("Catalina catalina.sh", getCatalinaShFile());
+        verifyWritableFile("Catalina catalina.sh", getCatalinaBatFile());
 
         verifyDirectory("OpenEJB lib", getOpenEJBLibDir());
 
@@ -293,6 +302,7 @@
         printFile(out, "Catalina lib: ", getCatalinaLibDir());
         printFile(out, "Catalina bin: ", getCatalinaBinDir());
         printFile(out, "Catalina catalina.sh: ", getCatalinaShFile());
+        printFile(out, "Catalina catalina.bat: ", getCatalinaBatFile());
         printFile(out, "OpenEJB lib: ", getOpenEJBLibDir());
         printFile(out, "OpenEJB loader jar: ", getOpenEJBLoaderJar());
         printFile(out, "OpenEJB javaagent jar: ", getOpenEJBJavaagentJar());


Reply via email to