Author: dain
Date: Wed Sep 19 19:05:14 2007
New Revision: 577501

URL: http://svn.apache.org/viewvc?rev=577501&view=rev
Log:
Merging 577148 from trunk
Changed installer to replace annotations-api.jar with patched (compliant) jar 
instead of simply deleteing the jar

Added:
    
openejb/branches/3.0-beta-1/assembly/openejb-tomcat/src/main/resources/tomcat/
      - copied from r577148, 
openejb/trunk/openejb3/assembly/openejb-tomcat/src/main/resources/tomcat/
    
openejb/branches/3.0-beta-1/assembly/openejb-tomcat/src/main/resources/tomcat/annotations-api.jar
      - copied unchanged from r577148, 
openejb/trunk/openejb3/assembly/openejb-tomcat/src/main/resources/tomcat/annotations-api.jar
Modified:
    openejb/branches/3.0-beta-1/assembly/openejb-tomcat/maven.xml
    
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/maven.xml
URL: 
http://svn.apache.org/viewvc/openejb/branches/3.0-beta-1/assembly/openejb-tomcat/maven.xml?rev=577501&r1=577500&r2=577501&view=diff
==============================================================================
--- openejb/branches/3.0-beta-1/assembly/openejb-tomcat/maven.xml (original)
+++ openejb/branches/3.0-beta-1/assembly/openejb-tomcat/maven.xml Wed Sep 19 
19:05:14 2007
@@ -36,7 +36,7 @@
 
     <goal name="tomcat6">
       <j:set var="tomcat.branch" value="6"/>
-      <j:set var="tomcat.version" value="6.0.10"/>
+      <j:set var="tomcat.version" value="6.0.14"/>
       <j:set var="tomcat.prefix" value="apache"/>
       <j:set var="tomcat.server.lib" value="lib"/>
       <j:set var="tomcat.server.webapps" value="webapps"/>

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=577501&r1=577500&r2=577501&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:05:14 2007
@@ -44,7 +44,6 @@
     private Status status = Status.NONE;
 
     private final boolean listenerInstalled;
-    private final boolean annotationJarRemoved;
     private final boolean agentInstalled;
 
     // Thi may need to be redesigned but the goal is to provide some feedback 
on what happened
@@ -60,21 +59,10 @@
         if (listenerInstalled == null) listenerInstalled = false;
         this.listenerInstalled = listenerInstalled;
 
-        // has the annotation jar been removed
-        boolean annotationJarRemoved = false;
-        try {
-            // Tomcat persistence context class is missing the properties 
method
-            Class<?> persistenceContextClass = 
Class.forName("javax.persistence.PersistenceContext");
-            persistenceContextClass.getMethod("properties", (Class[]) null);
-            annotationJarRemoved = true;
-        } catch (Exception e) {
-        }
-        this.annotationJarRemoved = annotationJarRemoved;
-
         // is the OpenEJB javaagent installed
         agentInstalled = 
invokeStaticNoArgMethod("org.apache.openejb.javaagent.Agent", 
"getInstrumentation") != null;
 
-        if (listenerInstalled && annotationJarRemoved && agentInstalled) {
+        if (listenerInstalled && agentInstalled) {
             status = Status.INSTALLED;
         }
     }
@@ -84,8 +72,6 @@
     }
 
     protected void install() {
-        removeAnnotationJar();
-
         installListener();
 
         installJavaagent();
@@ -97,28 +83,6 @@
         }
     }
 
-    private void removeAnnotationJar() {
-        if (annotationJarRemoved) {
-            addInfo("Annotation Jar already removed");
-            return;
-        }
-
-        File destination = new File(paths.getCatalinaLibDir(), 
"annotations-api.jar");
-
-        // if the file doesn't exist, there is nothing to do
-        if (!destination.exists()) {
-            return;
-        }
-
-        // attempt to delete the file
-        if (destination.delete()) {
-            addInfo("Deleted non-compliant (invalid) Tomcat annotation jar.");
-        } else {
-            // generally delete will fail on Windows
-            addWarning("Can not delete non-compliant (invalid) Tomcat 
annotation jar.  Jar havs been marked to be deleted on a normal VM exit.");
-        }
-    }
-
     private void installListener() {
         if (listenerInstalled) {
             addInfo("OpenEJB Listener already installed");
@@ -216,7 +180,13 @@
 
         // add our magic bits to the catalina sh file
         String openejbJavaagentPath = 
paths.getCatalinaBaseDir().toURI().relativize(paths.getOpenEJBJavaagentJar().toURI()).getPath();
+        String updatedAnnotationApiPath = 
paths.getCatalinaBaseDir().toURI().relativize(paths.getUpdatedAnnotationApiJar().toURI()).getPath();
         String newCatalinaSh = catalinaShOriginal.replace("# ----- Execute The 
Requested Command",
+                "# Update non-compliant Tomcat annotation-api.jar\n" +
+                "if [ -r \"$CATALINA_BASE\"/" + updatedAnnotationApiPath + " 
]; then\n" +
+                "  cp \"$CATALINA_BASE\"/" + updatedAnnotationApiPath + "  
\"$CATALINA_HOME\"/lib/annotations-api.jar \n" +
+                "fi\n" +
+                "\n" +
                 "# Add OpenEJB javaagent\n" +
                 "if [ -r \"$CATALINA_BASE\"/" + openejbJavaagentPath + " ]; 
then\n" +
                 "  JAVA_OPTS=\"\"-javaagent:$CATALINA_BASE/" + 
openejbJavaagentPath + "\" $JAVA_OPTS\"\n" +
@@ -486,6 +456,7 @@
         return warnings;
     }
 
+    @SuppressWarnings({"UnusedDeclaration"})
     private void addWarning(String message) {
         System.out.println(message);
     }

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=577501&r1=577500&r2=577501&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:05:14 2007
@@ -154,6 +154,12 @@
         return openejbLoaderJar;
     }
 
+    public File getUpdatedAnnotationApiJar() {
+        if (servletContext == null) return null;
+
+        return new 
File(servletContext.getRealPath("tomcat/annotations-api.jar"));
+    }
+
     public boolean verify() {
         if (getCatalinaHomeDir() == null) {
             addError("Catalina home directory is not defined");
@@ -194,6 +200,8 @@
         if (openejbCoreJar != null) {
             verifyFile("OpenEJB core jar", openejbCoreJar);
         }
+
+        verifyFile("Updated Tomcat annotation-api jar", 
getUpdatedAnnotationApiJar());
         
         return !hasErrors();
     }


Reply via email to