[jboss-svn-commits] JBoss Common SVN: r4582 - in shrinkwrap/trunk/extension-jetty: src/main/java/org/jboss/shrinkwrap/jetty/api and 1 other directories.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Mon Jun 28 18:15:01 EDT 2010


Author: dan.j.allen
Date: 2010-06-28 18:15:00 -0400 (Mon, 28 Jun 2010)
New Revision: 4582

Modified:
   shrinkwrap/trunk/extension-jetty/
   shrinkwrap/trunk/extension-jetty/pom.xml
   shrinkwrap/trunk/extension-jetty/src/main/java/org/jboss/shrinkwrap/jetty/api/ShrinkWrapWebAppContext.java
   shrinkwrap/trunk/extension-jetty/src/test/java/org/jboss/shrinkwrap/jetty/test/JettyDeploymentIntegrationUnitTestCase.java
Log:
SHRINKWRAP-196
SHRINKWRAP-197



Property changes on: shrinkwrap/trunk/extension-jetty
___________________________________________________________________
Name: svn:ignore
   - svn:ignore
target
.classpath
.project
.settings
bin

   + target
.classpath
.project
.settings
bin


Modified: shrinkwrap/trunk/extension-jetty/pom.xml
===================================================================
--- shrinkwrap/trunk/extension-jetty/pom.xml	2010-06-28 21:56:41 UTC (rev 4581)
+++ shrinkwrap/trunk/extension-jetty/pom.xml	2010-06-28 22:15:00 UTC (rev 4582)
@@ -1,11 +1,7 @@
 <?xml version="1.0" encoding="UTF-8"?>
-  <!--
-  vi:ts=2:sw=2:expandtab:
--->
 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
 
-  <!-- Parent -->
   <parent>
     <groupId>org.jboss.shrinkwrap</groupId>
     <artifactId>shrinkwrap-build</artifactId>
@@ -13,25 +9,20 @@
     <relativePath>../build/pom.xml</relativePath>
   </parent>
 
-  <!-- Model Version -->
   <modelVersion>4.0.0</modelVersion>
 
-  <!-- Artifact Configuration -->
   <artifactId>shrinkwrap-extension-jetty</artifactId>
   <name>ShrinkWrap Jetty Integration Extension</name>
   <description>ShrinkWrap integration extension for the Jetty Project</description>
 
-
-  <!-- Properties -->
   <properties>
   
-    <!-- Versioning -->
-    <version.org.mortbay.jetty_jetty>6.1.22</version.org.mortbay.jetty_jetty>
+    <!-- Known to work with Jetty version 6.1.0 and up -->
+    <version.org.mortbay.jetty_jetty>6.1.24</version.org.mortbay.jetty_jetty>
     <version.org.apache.httpcomponents_httpclient>4.0.1</version.org.apache.httpcomponents_httpclient>
 
   </properties>
 
-  <!-- Dependencies -->
   <dependencies>
 
     <!-- 
@@ -70,6 +61,15 @@
       <version>${version.org.mortbay.jetty_jetty}</version>
       <scope>provided</scope>
     </dependency> 
+    <!-- use artifactId jsp-2.1 for Jetty < 6.1.15 -->
+    <!--
+    <dependency>
+      <groupId>org.mortbay.jetty</groupId>
+      <artifactId>jsp-2.1</artifactId>
+      <version>${version.org.mortbay.jetty_jetty}</version>
+      <scope>provided</scope>
+    </dependency> 
+    -->
     
     <!-- org.apache.httpcomponents -->
     <dependency>
@@ -81,14 +81,7 @@
 
   </dependencies>
 
-  <!-- Build Configuration -->
-  <build>
-  
-    <plugins>
-
-    </plugins>
-    
-  </build>
-  
+<!--
+vi:ts=2:sw=2:expandtab:
+-->
 </project>
-

Modified: shrinkwrap/trunk/extension-jetty/src/main/java/org/jboss/shrinkwrap/jetty/api/ShrinkWrapWebAppContext.java
===================================================================
--- shrinkwrap/trunk/extension-jetty/src/main/java/org/jboss/shrinkwrap/jetty/api/ShrinkWrapWebAppContext.java	2010-06-28 21:56:41 UTC (rev 4581)
+++ shrinkwrap/trunk/extension-jetty/src/main/java/org/jboss/shrinkwrap/jetty/api/ShrinkWrapWebAppContext.java	2010-06-28 22:15:00 UTC (rev 4582)
@@ -17,6 +17,7 @@
 package org.jboss.shrinkwrap.jetty.api;
 
 import java.io.File;
+import java.io.IOException;
 import java.net.MalformedURLException;
 import java.net.URL;
 import java.security.AccessController;
@@ -56,6 +57,11 @@
    private static final String SYSPROP_KEY_TMP_DIR = "java.io.tmpdir";
 
    /**
+    * The prefix assigned to the temporary file where the archive is exported
+    */
+   private static final String EXPORT_FILE_PREFIX = "export";
+
+   /**
     * Temporary directory into which we'll extract the {@link WebArchive}s
     */
    private static final File TMP_DIR;
@@ -115,8 +121,22 @@
 
       // Flush to file
       final String name = archive.getName();
-      final File exported = new File(TMP_DIR, name);
-      archive.as(ZipExporter.class).exportZip(exported);
+      final int extensionOffset = name.lastIndexOf('.');
+      final String baseName = extensionOffset >= 0 ? name.substring(0, extensionOffset) : name;
+      final File exported;
+      try
+      {
+         // If this method returns successfully then it is guaranteed that:
+         // 1. The file denoted by the returned abstract pathname did not exist before this method was invoked, and
+         // 2. Neither this method nor any of its variants will return the same abstract pathname again in the current invocation of the virtual machine.
+         exported = File.createTempFile(EXPORT_FILE_PREFIX, name, TMP_DIR);
+      }
+      catch (IOException e)
+      {
+         throw new RuntimeException("Could not create temporary File in " + TMP_DIR + " to write exported archive", e);
+      }
+      // We are overwriting the temporary file placeholder reserved by File#createTemplateFile()
+      archive.as(ZipExporter.class).exportZip(exported, true);
 
       // Mark to delete when we come down
       exported.deleteOnExit();
@@ -131,11 +151,11 @@
       {
          throw new RuntimeException("Could not obtain URL of File " + exported.getAbsolutePath(), e);
       }
-      log.info("Webapp location: " + url);
+      log.info("Webapp archive location: " + url);
 
       // Set properties regarding the webbapp
       this.setWar(url.toExternalForm());
-      this.setContextPath(ROOT + name);
+      this.setContextPath(ROOT + baseName);
 
       // Remember the archive from which we're created
       this.archive = archive;

Modified: shrinkwrap/trunk/extension-jetty/src/test/java/org/jboss/shrinkwrap/jetty/test/JettyDeploymentIntegrationUnitTestCase.java
===================================================================
--- shrinkwrap/trunk/extension-jetty/src/test/java/org/jboss/shrinkwrap/jetty/test/JettyDeploymentIntegrationUnitTestCase.java	2010-06-28 21:56:41 UTC (rev 4581)
+++ shrinkwrap/trunk/extension-jetty/src/test/java/org/jboss/shrinkwrap/jetty/test/JettyDeploymentIntegrationUnitTestCase.java	2010-06-28 22:15:00 UTC (rev 4582)
@@ -166,7 +166,7 @@
       final List<NameValuePair> params = new ArrayList<NameValuePair>();
       params.add(new BasicNameValuePair("jsp", PATH_JSP));
       params.add(new BasicNameValuePair("echo", echoValue));
-      final URI uri = URIUtils.createURI("http", "localhost", HTTP_BIND_PORT, NAME_WAR + SEPARATOR
+      final URI uri = URIUtils.createURI("http", "localhost", HTTP_BIND_PORT, NAME_WEBAPP + SEPARATOR
             + servletClass.getSimpleName(), URLEncodedUtils.format(params, "UTF-8"), null);
       final HttpGet request = new HttpGet(uri);
 



More information about the jboss-svn-commits mailing list