[jboss-svn-commits] JBoss Common SVN: r4732 - in shrinkwrap/trunk/extension-tomcat/src: main/java/org/jboss/shrinkwrap/tomcat and 9 other directories.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Thu Jul 15 00:59:22 EDT 2010
Author: dan.j.allen
Date: 2010-07-15 00:59:21 -0400 (Thu, 15 Jul 2010)
New Revision: 4732
Added:
shrinkwrap/trunk/extension-tomcat/src/main/java/org/jboss/shrinkwrap/tomcat_6/
shrinkwrap/trunk/extension-tomcat/src/main/java/org/jboss/shrinkwrap/tomcat_6/api/
shrinkwrap/trunk/extension-tomcat/src/main/java/org/jboss/shrinkwrap/tomcat_6/api/ShrinkWrapStandardContext.java
shrinkwrap/trunk/extension-tomcat/src/main/resources/META-INF/services/org.jboss.shrinkwrap.tomcat_6.api.ShrinkWrapStandardContext
shrinkwrap/trunk/extension-tomcat/src/test/java/org/jboss/shrinkwrap/tomcat_6/
shrinkwrap/trunk/extension-tomcat/src/test/java/org/jboss/shrinkwrap/tomcat_6/servlet/
shrinkwrap/trunk/extension-tomcat/src/test/java/org/jboss/shrinkwrap/tomcat_6/test/
Removed:
shrinkwrap/trunk/extension-tomcat/src/main/java/org/jboss/shrinkwrap/tomcat/api/
shrinkwrap/trunk/extension-tomcat/src/main/java/org/jboss/shrinkwrap/tomcat_6/api/ShrinkWrapStandardContext.java
shrinkwrap/trunk/extension-tomcat/src/main/resources/META-INF/services/org.jboss.shrinkwrap.tomcat.api.ShrinkWrapStandardContext
shrinkwrap/trunk/extension-tomcat/src/test/java/org/jboss/shrinkwrap/tomcat/servlet/
shrinkwrap/trunk/extension-tomcat/src/test/java/org/jboss/shrinkwrap/tomcat/test/
Modified:
shrinkwrap/trunk/extension-tomcat/src/test/java/org/jboss/shrinkwrap/tomcat_6/servlet/ForwardingServlet.java
shrinkwrap/trunk/extension-tomcat/src/test/java/org/jboss/shrinkwrap/tomcat_6/servlet/RequestParamEchoServlet.java
shrinkwrap/trunk/extension-tomcat/src/test/java/org/jboss/shrinkwrap/tomcat_6/test/TomcatDeploymentIntegrationUnitTestCase.java
shrinkwrap/trunk/extension-tomcat/src/test/resources/webxml/servletForwarding.xml
Log:
SHRINKWRAP-198 introduce version
Copied: shrinkwrap/trunk/extension-tomcat/src/main/java/org/jboss/shrinkwrap/tomcat_6/api (from rev 4728, shrinkwrap/trunk/extension-tomcat/src/main/java/org/jboss/shrinkwrap/tomcat/api)
Deleted: shrinkwrap/trunk/extension-tomcat/src/main/java/org/jboss/shrinkwrap/tomcat_6/api/ShrinkWrapStandardContext.java
===================================================================
--- shrinkwrap/trunk/extension-tomcat/src/main/java/org/jboss/shrinkwrap/tomcat/api/ShrinkWrapStandardContext.java 2010-07-14 22:18:21 UTC (rev 4728)
+++ shrinkwrap/trunk/extension-tomcat/src/main/java/org/jboss/shrinkwrap/tomcat_6/api/ShrinkWrapStandardContext.java 2010-07-15 04:59:21 UTC (rev 4732)
@@ -1,176 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2010, Red Hat Middleware LLC, and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * http://www.apache.org/licenses/LICENSE-2.0
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jboss.shrinkwrap.tomcat.api;
-
-import java.io.File;
-import java.io.IOException;
-import java.security.AccessController;
-import java.security.PrivilegedAction;
-import java.util.logging.Logger;
-import org.apache.catalina.Lifecycle;
-import org.apache.catalina.core.StandardContext;
-import org.apache.catalina.session.StandardManager;
-import org.apache.catalina.startup.ContextConfig;
-
-import org.jboss.shrinkwrap.api.Archive;
-import org.jboss.shrinkwrap.api.Assignable;
-import org.jboss.shrinkwrap.api.exporter.ZipExporter;
-import org.jboss.shrinkwrap.api.spec.WebArchive;
-
-/**
- * Tomcat's {@link StandardContext} backed by a ShrinkWrap
- * {@link Archive}; capable of being deployed into
- * the Tomcat Embedded container
- *
- * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
- * @author Dan Allen
- * @version $Revision: $
- */
-public class ShrinkWrapStandardContext extends StandardContext implements Assignable
-{
-
- //-------------------------------------------------------------------------------------||
- // Class Members ----------------------------------------------------------------------||
- //-------------------------------------------------------------------------------------||
-
- /**
- * Logger
- */
- private static final Logger log = Logger.getLogger(ShrinkWrapStandardContext.class.getName());
-
- /**
- * System property denoting the name of the temp directory
- */
- 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";
-
- /**
- * The folder name of the Tomcat work directory
- */
- private static final String WORK_FOLDER = "work";
-
- /**
- * Temporary directory into which we'll extract the {@link WebArchive}s
- */
- private static final File TMP_DIR;
- static
- {
- TMP_DIR = new File(AccessController.doPrivileged(new PrivilegedAction<String>()
- {
-
- @Override
- public String run()
- {
- return System.getProperty(SYSPROP_KEY_TMP_DIR);
- }
-
- }));
- // If the temp location doesn't exist or isn't a directory
- if (!TMP_DIR.exists() || !TMP_DIR.isDirectory())
- {
- throw new IllegalStateException("Could not obtain temp directory \"" + TMP_DIR.getAbsolutePath() + "\"");
- }
- }
-
- /**
- * /
- */
- private static final char ROOT = '/';
-
- //-------------------------------------------------------------------------------------||
- // Instance Members -------------------------------------------------------------------||
- //-------------------------------------------------------------------------------------||
-
- /**
- * Underlying delegate
- */
- private final Archive<?> archive;
-
- //-------------------------------------------------------------------------------------||
- // Constructor ------------------------------------------------------------------------||
- //-------------------------------------------------------------------------------------||
-
- /**
- * Creates a new {@link ShrinkWrapStandardContext} using the
- * specified underlying archive
- *
- * @throws IllegalArgumentException If the archive is not specified
- */
- public ShrinkWrapStandardContext(final Archive<?> archive) throws IllegalArgumentException
- {
- // Invoke super
- super();
-
- // Precondition checks
- if (archive == null)
- {
- throw new IllegalArgumentException("archive must be specified");
- }
-
- // Flush to file
- final String archiveName = archive.getName();
- final int extensionOffset = archiveName.lastIndexOf('.');
- final String baseName = extensionOffset >= 0 ? archiveName.substring(0, extensionOffset) : archiveName;
- 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, archiveName, 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();
-
- // Add the context
- log.info("Webapp archive location: " + exported.getAbsolutePath());
- this.setDocBase(exported.getAbsolutePath());
- // context path must begin with a /
- this.setPath(ROOT + baseName);
- // we want to be as efficient as possible, so default to not unpack, save config or cache
- this.setUnpackWAR(false);
- this.setSaveConfig(false);
- this.setCachingAllowed(false);
- // Remember the archive from which we're created
- this.archive = archive;
- }
-
- //-------------------------------------------------------------------------------------||
- // Required Implementations -----------------------------------------------------------||
- //-------------------------------------------------------------------------------------||
-
- /**
- * {@inheritDoc}
- * @see org.jboss.shrinkwrap.api.Assignable#as(java.lang.Class)
- */
- @Override
- public <TYPE extends Assignable> TYPE as(final Class<TYPE> clazz)
- {
- return archive.as(clazz);
- }
-}
Copied: shrinkwrap/trunk/extension-tomcat/src/main/java/org/jboss/shrinkwrap/tomcat_6/api/ShrinkWrapStandardContext.java (from rev 4731, shrinkwrap/trunk/extension-tomcat/src/main/java/org/jboss/shrinkwrap/tomcat/api/ShrinkWrapStandardContext.java)
===================================================================
--- shrinkwrap/trunk/extension-tomcat/src/main/java/org/jboss/shrinkwrap/tomcat_6/api/ShrinkWrapStandardContext.java (rev 0)
+++ shrinkwrap/trunk/extension-tomcat/src/main/java/org/jboss/shrinkwrap/tomcat_6/api/ShrinkWrapStandardContext.java 2010-07-15 04:59:21 UTC (rev 4732)
@@ -0,0 +1,170 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jboss.shrinkwrap.tomcat_6.api;
+
+import java.io.File;
+import java.io.IOException;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.util.logging.Logger;
+
+import org.apache.catalina.core.StandardContext;
+import org.jboss.shrinkwrap.api.Archive;
+import org.jboss.shrinkwrap.api.Assignable;
+import org.jboss.shrinkwrap.api.exporter.ZipExporter;
+import org.jboss.shrinkwrap.api.spec.WebArchive;
+
+/**
+ * Tomcat's {@link StandardContext} backed by a ShrinkWrap
+ * {@link Archive}; capable of being deployed into
+ * the Tomcat Embedded container
+ *
+ * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
+ * @author Dan Allen
+ * @version $Revision: $
+ */
+public class ShrinkWrapStandardContext extends StandardContext implements Assignable
+{
+
+ //-------------------------------------------------------------------------------------||
+ // Class Members ----------------------------------------------------------------------||
+ //-------------------------------------------------------------------------------------||
+
+ private static final long serialVersionUID = 1L;
+
+ /**
+ * Logger
+ */
+ private static final Logger log = Logger.getLogger(ShrinkWrapStandardContext.class.getName());
+
+ /**
+ * System property denoting the name of the temp directory
+ */
+ 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;
+ static
+ {
+ TMP_DIR = new File(AccessController.doPrivileged(new PrivilegedAction<String>()
+ {
+
+ @Override
+ public String run()
+ {
+ return System.getProperty(SYSPROP_KEY_TMP_DIR);
+ }
+
+ }));
+ // If the temp location doesn't exist or isn't a directory
+ if (!TMP_DIR.exists() || !TMP_DIR.isDirectory())
+ {
+ throw new IllegalStateException("Could not obtain temp directory \"" + TMP_DIR.getAbsolutePath() + "\"");
+ }
+ }
+
+ /**
+ * /
+ */
+ private static final char ROOT = '/';
+
+ //-------------------------------------------------------------------------------------||
+ // Instance Members -------------------------------------------------------------------||
+ //-------------------------------------------------------------------------------------||
+
+ /**
+ * Underlying delegate
+ */
+ private final Archive<?> archive;
+
+ //-------------------------------------------------------------------------------------||
+ // Constructor ------------------------------------------------------------------------||
+ //-------------------------------------------------------------------------------------||
+
+ /**
+ * Creates a new {@link ShrinkWrapStandardContext} using the
+ * specified underlying archive
+ *
+ * @throws IllegalArgumentException If the archive is not specified
+ */
+ public ShrinkWrapStandardContext(final Archive<?> archive) throws IllegalArgumentException
+ {
+ // Invoke super
+ super();
+
+ // Precondition checks
+ if (archive == null)
+ {
+ throw new IllegalArgumentException("archive must be specified");
+ }
+
+ // Flush to file
+ final String archiveName = archive.getName();
+ final int extensionOffset = archiveName.lastIndexOf('.');
+ final String baseName = extensionOffset >= 0 ? archiveName.substring(0, extensionOffset) : archiveName;
+ 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, archiveName, 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();
+
+ // Add the context
+ log.info("Webapp archive location: " + exported.getAbsolutePath());
+ this.setDocBase(exported.getAbsolutePath());
+ // context path must begin with a /
+ this.setPath(ROOT + baseName);
+ // we want to be as efficient as possible, so disable unpack, save config or cache by default
+ this.setUnpackWAR(false);
+ this.setSaveConfig(false);
+ this.setCachingAllowed(false);
+ // Remember the archive from which we're created
+ this.archive = archive;
+ }
+
+ //-------------------------------------------------------------------------------------||
+ // Required Implementations -----------------------------------------------------------||
+ //-------------------------------------------------------------------------------------||
+
+ /**
+ * {@inheritDoc}
+ * @see org.jboss.shrinkwrap.api.Assignable#as(java.lang.Class)
+ */
+ @Override
+ public <TYPE extends Assignable> TYPE as(final Class<TYPE> clazz)
+ {
+ return archive.as(clazz);
+ }
+}
Deleted: shrinkwrap/trunk/extension-tomcat/src/main/resources/META-INF/services/org.jboss.shrinkwrap.tomcat.api.ShrinkWrapStandardContext
===================================================================
--- shrinkwrap/trunk/extension-tomcat/src/main/resources/META-INF/services/org.jboss.shrinkwrap.tomcat.api.ShrinkWrapStandardContext 2010-07-15 04:54:51 UTC (rev 4731)
+++ shrinkwrap/trunk/extension-tomcat/src/main/resources/META-INF/services/org.jboss.shrinkwrap.tomcat.api.ShrinkWrapStandardContext 2010-07-15 04:59:21 UTC (rev 4732)
@@ -1 +0,0 @@
-implementingClassName=org.jboss.shrinkwrap.tomcat.api.ShrinkWrapStandardContext
Copied: shrinkwrap/trunk/extension-tomcat/src/main/resources/META-INF/services/org.jboss.shrinkwrap.tomcat_6.api.ShrinkWrapStandardContext (from rev 4730, shrinkwrap/trunk/extension-tomcat/src/main/resources/META-INF/services/org.jboss.shrinkwrap.tomcat.api.ShrinkWrapStandardContext)
===================================================================
--- shrinkwrap/trunk/extension-tomcat/src/main/resources/META-INF/services/org.jboss.shrinkwrap.tomcat_6.api.ShrinkWrapStandardContext (rev 0)
+++ shrinkwrap/trunk/extension-tomcat/src/main/resources/META-INF/services/org.jboss.shrinkwrap.tomcat_6.api.ShrinkWrapStandardContext 2010-07-15 04:59:21 UTC (rev 4732)
@@ -0,0 +1 @@
+implementingClassName=org.jboss.shrinkwrap.tomcat_6.api.ShrinkWrapStandardContext
Copied: shrinkwrap/trunk/extension-tomcat/src/test/java/org/jboss/shrinkwrap/tomcat_6/servlet (from rev 4728, shrinkwrap/trunk/extension-tomcat/src/test/java/org/jboss/shrinkwrap/tomcat/servlet)
Modified: shrinkwrap/trunk/extension-tomcat/src/test/java/org/jboss/shrinkwrap/tomcat_6/servlet/ForwardingServlet.java
===================================================================
--- shrinkwrap/trunk/extension-tomcat/src/test/java/org/jboss/shrinkwrap/tomcat/servlet/ForwardingServlet.java 2010-07-14 22:18:21 UTC (rev 4728)
+++ shrinkwrap/trunk/extension-tomcat/src/test/java/org/jboss/shrinkwrap/tomcat_6/servlet/ForwardingServlet.java 2010-07-15 04:59:21 UTC (rev 4732)
@@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.jboss.shrinkwrap.tomcat.servlet;
+package org.jboss.shrinkwrap.tomcat_6.servlet;
import java.io.IOException;
import java.util.logging.Logger;
Modified: shrinkwrap/trunk/extension-tomcat/src/test/java/org/jboss/shrinkwrap/tomcat_6/servlet/RequestParamEchoServlet.java
===================================================================
--- shrinkwrap/trunk/extension-tomcat/src/test/java/org/jboss/shrinkwrap/tomcat/servlet/RequestParamEchoServlet.java 2010-07-14 22:18:21 UTC (rev 4728)
+++ shrinkwrap/trunk/extension-tomcat/src/test/java/org/jboss/shrinkwrap/tomcat_6/servlet/RequestParamEchoServlet.java 2010-07-15 04:59:21 UTC (rev 4732)
@@ -1,4 +1,4 @@
-package org.jboss.shrinkwrap.tomcat.servlet;
+package org.jboss.shrinkwrap.tomcat_6.servlet;
import java.io.IOException;
import javax.servlet.ServletException;
Copied: shrinkwrap/trunk/extension-tomcat/src/test/java/org/jboss/shrinkwrap/tomcat_6/test (from rev 4728, shrinkwrap/trunk/extension-tomcat/src/test/java/org/jboss/shrinkwrap/tomcat/test)
Modified: shrinkwrap/trunk/extension-tomcat/src/test/java/org/jboss/shrinkwrap/tomcat_6/test/TomcatDeploymentIntegrationUnitTestCase.java
===================================================================
--- shrinkwrap/trunk/extension-tomcat/src/test/java/org/jboss/shrinkwrap/tomcat/test/TomcatDeploymentIntegrationUnitTestCase.java 2010-07-14 22:18:21 UTC (rev 4728)
+++ shrinkwrap/trunk/extension-tomcat/src/test/java/org/jboss/shrinkwrap/tomcat_6/test/TomcatDeploymentIntegrationUnitTestCase.java 2010-07-15 04:59:21 UTC (rev 4732)
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-package org.jboss.shrinkwrap.tomcat.test;
+package org.jboss.shrinkwrap.tomcat_6.test;
import java.io.BufferedReader;
import java.io.InputStreamReader;
@@ -45,9 +45,9 @@
import org.apache.http.message.BasicNameValuePair;
import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.spec.WebArchive;
-import org.jboss.shrinkwrap.tomcat.api.ShrinkWrapStandardContext;
-import org.jboss.shrinkwrap.tomcat.servlet.ForwardingServlet;
-import org.jboss.shrinkwrap.tomcat.servlet.RequestParamEchoServlet;
+import org.jboss.shrinkwrap.tomcat_6.api.ShrinkWrapStandardContext;
+import org.jboss.shrinkwrap.tomcat_6.servlet.ForwardingServlet;
+import org.jboss.shrinkwrap.tomcat_6.servlet.RequestParamEchoServlet;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
Modified: shrinkwrap/trunk/extension-tomcat/src/test/resources/webxml/servletForwarding.xml
===================================================================
--- shrinkwrap/trunk/extension-tomcat/src/test/resources/webxml/servletForwarding.xml 2010-07-15 04:54:51 UTC (rev 4731)
+++ shrinkwrap/trunk/extension-tomcat/src/test/resources/webxml/servletForwarding.xml 2010-07-15 04:59:21 UTC (rev 4732)
@@ -3,7 +3,7 @@
version="2.5">
<servlet>
<servlet-name>ForwardingServlet</servlet-name>
- <servlet-class>org.jboss.shrinkwrap.tomcat.servlet.ForwardingServlet</servlet-class>
+ <servlet-class>org.jboss.shrinkwrap.tomcat_6.servlet.ForwardingServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>ForwardingServlet</servlet-name>
@@ -11,7 +11,7 @@
</servlet-mapping>
<servlet>
<servlet-name>RequestParamEchoServlet</servlet-name>
- <servlet-class>org.jboss.shrinkwrap.tomcat.servlet.RequestParamEchoServlet</servlet-class>
+ <servlet-class>org.jboss.shrinkwrap.tomcat_6.servlet.RequestParamEchoServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>RequestParamEchoServlet</servlet-name>
More information about the jboss-svn-commits
mailing list