aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGlyn Normington2010-07-13 06:54:04 (EDT)
committerGlyn Normington2010-07-13 06:54:04 (EDT)
commitd54f545f7e9accd456b2b94ec279217ee91bdf5c (patch)
treed9bc8bfdfdfb07001b5b91755bad33d5b1b176fd
parentc2e25cddc2ca47c04acbe99ca2aea39bae392e22 (diff)
downloadorg.eclipse.gemini.web.gemini-web-container-d54f545f7e9accd456b2b94ec279217ee91bdf5c.zip
org.eclipse.gemini.web.gemini-web-container-d54f545f7e9accd456b2b94ec279217ee91bdf5c.tar.gz
org.eclipse.gemini.web.gemini-web-container-d54f545f7e9accd456b2b94ec279217ee91bdf5c.tar.bz2
place generated config directory in target directory
-rw-r--r--org.eclipse.gemini.web.core/.classpath2
-rw-r--r--org.eclipse.gemini.web.test/config/Catalina/localhost/war-with-context-xml-resources.xml9
-rw-r--r--org.eclipse.gemini.web.test/src/test/java/org/eclipse/gemini/web/test/tomcat/TomcatServletContainerTests.java12
-rw-r--r--org.eclipse.gemini.web.tomcat/src/main/java/org/eclipse/gemini/web/tomcat/internal/TomcatConfigLocator.java38
4 files changed, 43 insertions, 18 deletions
diff --git a/org.eclipse.gemini.web.core/.classpath b/org.eclipse.gemini.web.core/.classpath
index dfeb4f0..e185010 100644
--- a/org.eclipse.gemini.web.core/.classpath
+++ b/org.eclipse.gemini.web.core/.classpath
@@ -21,7 +21,7 @@
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
- <classpathentry kind="var" path="WEB_CONTAINER_IVY_CACHE/org.junit/com.springsource.org.junit/4.7.0/com.springsource.org.junit-4.7.0.jar" sourcepath="/WEB_CONTAINER_IVY_CACHE/org.junit/com.springsource.org.junit/4.5.0/com.springsource.org.junit-sources-4.5.0.jar"/>
+ <classpathentry kind="var" path="WEB_CONTAINER_IVY_CACHE/org.junit/com.springsource.org.junit/4.7.0/com.springsource.org.junit-4.7.0.jar" sourcepath="/WEB_CONTAINER_IVY_CACHE/org.junit/com.springsource.org.junit/4.7.0/com.springsource.org.junit-sources-4.7.0.jar"/>
<classpathentry kind="var" path="WEB_CONTAINER_IVY_CACHE/org.eclipse.osgi/org.eclipse.osgi/3.5.1.R35x_v20091005/org.eclipse.osgi-3.5.1.R35x_v20091005.jar" sourcepath="/WEB_CONTAINER_IVY_CACHE/org.eclipse.osgi/org.eclipse.osgi/3.5.1.R35x_v20091005/org.eclipse.osgi-sources-3.5.1.R35x_v20091005.jar"/>
<classpathentry kind="var" path="WEB_CONTAINER_IVY_CACHE/org.eclipse.virgo.util/org.eclipse.virgo.util.osgi/2.1.0.D-20100420091708/org.eclipse.virgo.util.osgi-2.1.0.D-20100420091708.jar" sourcepath="/WEB_CONTAINER_IVY_CACHE/org.eclispe.virgo.util/org.eclipse.virgo.util.osgi/2.0.0.RELEASE/org.eclipse.virgo.util.osgi-sources-2.0.0.RELEASE.jar"/>
<classpathentry kind="var" path="WEB_CONTAINER_IVY_CACHE/org.eclipse.virgo.util/org.eclipse.virgo.util.io/2.1.0.D-20100420091708/org.eclipse.virgo.util.io-2.1.0.D-20100420091708.jar" sourcepath="/WEB_CONTAINER_IVY_CACHE/org.eclispe.virgo.util/org.eclipse.virgo.util.io/2.0.0.RELEASE/org.eclipse.virgo.util.io-sources-2.0.0.RELEASE.jar"/>
diff --git a/org.eclipse.gemini.web.test/config/Catalina/localhost/war-with-context-xml-resources.xml b/org.eclipse.gemini.web.test/config/Catalina/localhost/war-with-context-xml-resources.xml
new file mode 100644
index 0000000..b0623f6
--- /dev/null
+++ b/org.eclipse.gemini.web.test/config/Catalina/localhost/war-with-context-xml-resources.xml
@@ -0,0 +1,9 @@
+<Context>
+
+ <Resource name="mail/Session"
+ auth="Container"
+ type="javax.mail.Session"
+ mail.smtp.host="localhost"/>
+
+</Context>
+
diff --git a/org.eclipse.gemini.web.test/src/test/java/org/eclipse/gemini/web/test/tomcat/TomcatServletContainerTests.java b/org.eclipse.gemini.web.test/src/test/java/org/eclipse/gemini/web/test/tomcat/TomcatServletContainerTests.java
index 2acfffd..c21b9d6 100644
--- a/org.eclipse.gemini.web.test/src/test/java/org/eclipse/gemini/web/test/tomcat/TomcatServletContainerTests.java
+++ b/org.eclipse.gemini.web.test/src/test/java/org/eclipse/gemini/web/test/tomcat/TomcatServletContainerTests.java
@@ -38,6 +38,7 @@ import java.util.Set;
import javax.servlet.ServletContext;
import org.junit.Before;
+import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.osgi.framework.Bundle;
@@ -87,6 +88,11 @@ public class TomcatServletContainerTests {
private BundleContext bundleContext;
private ServletContainer container;
+
+ @BeforeClass
+ public static void beforeClass() throws Exception {
+ System.setProperty("org.eclipse.gemini.web.tomcat.config.path", "target/config");
+ }
@Before
public void before() throws Exception {
@@ -351,17 +357,17 @@ public class TomcatServletContainerTests {
@Test
public void testWarWithContextXml() throws Exception {
// Copy default context.xml
- File defaultContextXml = new File("config/context.xml");
+ File defaultContextXml = new File("target/config/context.xml");
createFileWithContent(defaultContextXml, "<Context crossContext=\"true\"/>");
// Copy default context.xml.default
- File defaultHostContextXml = new File("config/Catalina/localhost/context.xml.default");
+ File defaultHostContextXml = new File("target/config/Catalina/localhost/context.xml.default");
String content = "<Context>"
+ "<Resource name=\"mail/Session1\" auth=\"Container\" type=\"javax.mail.Session\" mail.smtp.host=\"localhost\"/>"
+ "</Context>";
createFileWithContent(defaultHostContextXml, content);
- File tomcatServerXml = new File("config/tomcat-server.xml");
+ File tomcatServerXml = new File("target/config/tomcat-server.xml");
createFileWithContent(tomcatServerXml, "");
String location1 = LOCATION_WAR_WITH_CONTEXT_XML_RESOURCES;
diff --git a/org.eclipse.gemini.web.tomcat/src/main/java/org/eclipse/gemini/web/tomcat/internal/TomcatConfigLocator.java b/org.eclipse.gemini.web.tomcat/src/main/java/org/eclipse/gemini/web/tomcat/internal/TomcatConfigLocator.java
index 160a2a3..0126e30 100644
--- a/org.eclipse.gemini.web.tomcat/src/main/java/org/eclipse/gemini/web/tomcat/internal/TomcatConfigLocator.java
+++ b/org.eclipse.gemini.web.tomcat/src/main/java/org/eclipse/gemini/web/tomcat/internal/TomcatConfigLocator.java
@@ -48,7 +48,7 @@ final class TomcatConfigLocator {
private static final Logger LOGGER = LoggerFactory.getLogger(TomcatConfigLocator.class);
static final String CONFIG_PATH_FRAMEWORK_PROPERTY = "org.eclipse.gemini.web.tomcat.config.path";
-
+
static final String DEFAULT_CONFIG_FILE_PATH = "config" + File.separator + "tomcat-server.xml";
static final String CONFIG_PATH = "META-INF/tomcat";
@@ -73,22 +73,23 @@ final class TomcatConfigLocator {
*
* The location algorithm is as follows:
* <ol>
- * <li>Check for <code>org.eclipse.gemini.web.tomcat.config.path</code>
- * framework property, use if found</li>
- * <li>Check for <code>config/tomcat-server.xml</code> in the current
- * working directory, use if found</li>
- * <li>If the previous checks do not return a result, return
- * <code>null</code></li>
+ * <li>Check for <code>org.eclipse.gemini.web.tomcat.config.path</code> framework property, use if found</li>
+ * <li>Check for <code>config/tomcat-server.xml</code> in the current working directory, use if found</li>
+ * <li>If the previous checks do not return a result, return <code>null</code></li>
* </ol>
*
- * @param context
- * the bundle context
+ * @param context the bundle context
* @return the directory where the Tomcat configuration files resides.
*/
public static File resolveConfigDir(BundleContext context) {
File configFile = null;
- // Search for the property 'org.eclipse.gemini.web.tomcat.config.path'
+ /*
+ * Search for the framework property 'org.eclipse.gemini.web.tomcat.config.path'
+ *
+ * Note: this is supposed to search framework and system properties but appears to ignore system properties which
+ * are set after the framework has initialised. See https://bugs.eclipse.org/bugs/show_bug.cgi?id=319679.
+ */
String path = context.getProperty(TomcatConfigLocator.CONFIG_PATH_FRAMEWORK_PROPERTY);
if (path != null) {
configFile = new File(path);
@@ -97,6 +98,15 @@ final class TomcatConfigLocator {
}
}
+ // Search for the system property 'org.eclipse.gemini.web.tomcat.config.path'
+ path = System.getProperty(TomcatConfigLocator.CONFIG_PATH_FRAMEWORK_PROPERTY);
+ if (path != null) {
+ configFile = new File(path);
+ if (configFile.exists()) {
+ return configFile.getParentFile();
+ }
+ }
+
// Search for the 'config' directory
configFile = new File(TomcatConfigLocator.DEFAULT_CONFIG_FILE_PATH);
if (configFile.exists()) {
@@ -110,11 +120,11 @@ final class TomcatConfigLocator {
InputStream result = null;
String path = context.getProperty(CONFIG_PATH_FRAMEWORK_PROPERTY);
- if(path != null) {
+ if (path != null) {
result = tryGetStreamForFilePath(path);
}
-
- if(result == null) {
+
+ if (result == null) {
result = tryGetStreamForFilePath(DEFAULT_CONFIG_FILE_PATH);
}
return result;
@@ -149,7 +159,7 @@ final class TomcatConfigLocator {
entry = bundle.getEntry(DEFAULT_CONFIG_PATH);
if (entry == null) {
throw new IllegalStateException("Unable to locate default Tomcat configuration. Is the '" + bundle + "' bundle corrupt?");
- } else if(LOGGER.isInfoEnabled()) {
+ } else if (LOGGER.isInfoEnabled()) {
LOGGER.info("Configuring Tomcat from default config file");
}
}