aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGlyn Normington2010-07-13 05:01:58 (EDT)
committerGlyn Normington2010-07-13 05:01:58 (EDT)
commitc2e25cddc2ca47c04acbe99ca2aea39bae392e22 (patch)
treecaba06506bf85918010ffbe549c3f22c14d14ea9
parente9142ece90ac9c8c43ead7d0c32127ea42148302 (diff)
downloadorg.eclipse.gemini.web.gemini-web-container-c2e25cddc2ca47c04acbe99ca2aea39bae392e22.zip
org.eclipse.gemini.web.gemini-web-container-c2e25cddc2ca47c04acbe99ca2aea39bae392e22.tar.gz
org.eclipse.gemini.web.gemini-web-container-c2e25cddc2ca47c04acbe99ca2aea39bae392e22.tar.bz2
copyright & license headers
-rwxr-xr-xorg.eclipse.gemini.web.tomcat/src/main/java/org/eclipse/gemini/web/tomcat/internal/WebappConfigLocator.java79
-rwxr-xr-xorg.eclipse.gemini.web.tomcat/src/test/java/org/eclipse/gemini/web/tomcat/internal/WebappConfigLocatorTest.java16
2 files changed, 56 insertions, 39 deletions
diff --git a/org.eclipse.gemini.web.tomcat/src/main/java/org/eclipse/gemini/web/tomcat/internal/WebappConfigLocator.java b/org.eclipse.gemini.web.tomcat/src/main/java/org/eclipse/gemini/web/tomcat/internal/WebappConfigLocator.java
index 79cf128..579c84c 100755
--- a/org.eclipse.gemini.web.tomcat/src/main/java/org/eclipse/gemini/web/tomcat/internal/WebappConfigLocator.java
+++ b/org.eclipse.gemini.web.tomcat/src/main/java/org/eclipse/gemini/web/tomcat/internal/WebappConfigLocator.java
@@ -1,3 +1,19 @@
+/*******************************************************************************
+ * Copyright (c) 2010 SAP AG
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * and Apache License v2.0 which accompanies this distribution.
+ * The Eclipse Public License is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * and the Apache License v2.0 is available at
+ * http://www.opensource.org/licenses/apache2.0.php.
+ * You may elect to redistribute this code under either of these licenses.
+ *
+ * Contributors:
+ * Violeta Georgieva - initial contribution
+ *******************************************************************************/
+
package org.eclipse.gemini.web.tomcat.internal;
import java.io.File;
@@ -33,16 +49,13 @@ public class WebappConfigLocator {
private static final char HASH_SEPARATOR = '#';
/**
- * Resolves the default context.xml and returns a relative path to it, if it
- * exists in the main Tomcat's configuration directory, otherwise returns
- * <code>null</code>. The method returns <code>null</code> also in case main
- * Tomcat's configuration directory does not exists.
+ * Resolves the default context.xml and returns a relative path to it, if it exists in the main Tomcat's
+ * configuration directory, otherwise returns <code>null</code>. The method returns <code>null</code> also in case
+ * main Tomcat's configuration directory does not exists.
*
- * @param configLocation
- * the main Tomcat's configuration directory
- * @return a relative path to default context.xml file, if it exists in the
- * main Tomcat's configuration directory, otherwise returns
- * <code>null</code>.
+ * @param configLocation the main Tomcat's configuration directory
+ * @return a relative path to default context.xml file, if it exists in the main Tomcat's configuration directory,
+ * otherwise returns <code>null</code>.
*/
public static String resolveDefaultContextXml(File configLocation) {
if (configLocation == null) {
@@ -58,30 +71,22 @@ public class WebappConfigLocator {
}
/**
- * Resolves the web application's specific context.xml The algorithm is the
- * following:
+ * Resolves the web application's specific context.xml The algorithm is the following:
* <ol>
- * <li>The composite context path i.e. /foo/bar are formated. The "/" are
- * replaced with "#" i.e. foo#bar</li>
- * <li>Check for <code><formated-web-app-context-path>.xml</code> file in
- * the main Tomcat Host's configuration directory, use if found</li>
- * <li>If <code>docBase</code> is directory check for
- * <code>META-INF/context.xml</code> file, use if found</li>
- * <li>If <code>docBase</code> is an archive check for
- * <code>META-INF/context.xml</code> entry. If it exists, copy it to the
- * main Tomcat Host's configuration directory and use it. The next time this
- * copy will be used instead of the one in the archive.</li>
+ * <li>The composite context path i.e. /foo/bar are formated. The "/" are replaced with "#" i.e. foo#bar</li>
+ * <li>Check for <code><formated-web-app-context-path>.xml</code> file in the main Tomcat Host's configuration
+ * directory, use if found</li>
+ * <li>If <code>docBase</code> is directory check for <code>META-INF/context.xml</code> file, use if found</li>
+ * <li>If <code>docBase</code> is an archive check for <code>META-INF/context.xml</code> entry. If it exists, copy
+ * it to the main Tomcat Host's configuration directory and use it. The next time this copy will be used instead of
+ * the one in the archive.</li>
* <li>Return <code>null</code> in other cases.</li>
* </ol>
*
- * @param path
- * the context path
- * @param docBase
- * the root directory/file for the web application
- * @param configLocation
- * Host's configuration directory
- * @return the context.xml if it is found following the algorithm above,
- * otherwise <code>null</code>
+ * @param path the context path
+ * @param docBase the root directory/file for the web application
+ * @param configLocation Host's configuration directory
+ * @return the context.xml if it is found following the algorithm above, otherwise <code>null</code>
*/
public static File resolveWebappContextXml(String path, String docBase, File configLocation) {
path = formatContextPath(path);
@@ -112,8 +117,7 @@ public class WebappConfigLocator {
try {
copyFile(jar.getInputStream(contextXmlEntry), destination);
} catch (IOException e) {
- throw new ServletContainerException("Cannot copy " + contextXml.getAbsolutePath() + " to "
- + destination.getAbsolutePath(), e);
+ throw new ServletContainerException("Cannot copy " + contextXml.getAbsolutePath() + " to " + destination.getAbsolutePath(), e);
}
return destination;
}
@@ -122,13 +126,11 @@ public class WebappConfigLocator {
}
/**
- * Resolves the directory where the web application' context.xml files are
- * placed. Typically this is the Host's configuration directory.
+ * Resolves the directory where the web application' context.xml files are placed. Typically this is the Host's
+ * configuration directory.
*
- * @param mainConfigDir
- * the main Tomcat's configuration directory
- * @return the directory where the web applications' context.xml files are
- * placed.
+ * @param mainConfigDir the main Tomcat's configuration directory
+ * @return the directory where the web applications' context.xml files are placed.
*/
public static File resolveWebappConfigDir(File mainConfigDir, Host host) {
mainConfigDir = mainConfigDir != null ? mainConfigDir : new File(DEFAULT_CONFIG_DIRECTORY);
@@ -144,8 +146,7 @@ public class WebappConfigLocator {
}
private static String formatContextPath(String contextPath) {
- // Multi-level context paths may be defined using #, e.g. foo#bar.xml
- // for a context path of /foo/bar.
+ // Multi-level context paths may be defined using #, e.g. foo#bar.xml for a context path of /foo/bar.
if (contextPath.equals(ROOT_PATH)) {
contextPath = ROOT_CONTEXT_FILE;
} else if (SLASH_SEPARATOR == contextPath.charAt(0)) {
diff --git a/org.eclipse.gemini.web.tomcat/src/test/java/org/eclipse/gemini/web/tomcat/internal/WebappConfigLocatorTest.java b/org.eclipse.gemini.web.tomcat/src/test/java/org/eclipse/gemini/web/tomcat/internal/WebappConfigLocatorTest.java
index 1dd19c9..7243e74 100755
--- a/org.eclipse.gemini.web.tomcat/src/test/java/org/eclipse/gemini/web/tomcat/internal/WebappConfigLocatorTest.java
+++ b/org.eclipse.gemini.web.tomcat/src/test/java/org/eclipse/gemini/web/tomcat/internal/WebappConfigLocatorTest.java
@@ -1,3 +1,19 @@
+/*******************************************************************************
+ * Copyright (c) 2010 SAP AG
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * and Apache License v2.0 which accompanies this distribution.
+ * The Eclipse Public License is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * and the Apache License v2.0 is available at
+ * http://www.opensource.org/licenses/apache2.0.php.
+ * You may elect to redistribute this code under either of these licenses.
+ *
+ * Contributors:
+ * Violeta Georgieva - initial contribution
+ *******************************************************************************/
+
package org.eclipse.gemini.web.tomcat.internal;
import static org.junit.Assert.assertTrue;