diff --git a/ccm-core/src/main/java/com/arsdigita/web/CCMApplicationContextListener.java b/ccm-core/src/main/java/com/arsdigita/web/CCMApplicationContextListener.java
new file mode 100644
index 000000000..83d418d8d
--- /dev/null
+++ b/ccm-core/src/main/java/com/arsdigita/web/CCMApplicationContextListener.java
@@ -0,0 +1,87 @@
+/*
+ * Copyright (C) 2015 LibreCCM Foundation.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301 USA
+ */
+package com.arsdigita.web;
+
+import com.arsdigita.runtime.CCMResourceManager;
+
+import org.apache.log4j.LogManager;
+import org.apache.log4j.Logger;
+
+import javax.servlet.ServletContext;
+import javax.servlet.ServletContextEvent;
+import javax.servlet.ServletContextListener;
+import javax.servlet.annotation.WebListener;
+
+/**
+ * Listener used to initialise several parameters for legacy CCM classes. This
+ * class is not identical with the class with same name in old versions. It has
+ * been modified so that only those things are done which necessary to get the
+ * legacy classes, for instance the classes derived from
+ * {@link com.arsdigita.runtime.AbstractConfig} working. Also it is not longer
+ * necessary to include an entry in the {@code web.xml} for this class because
+ * this can be done using {@link @WebListener} annotation in the Servlet API
+ * 3.0.
+ *
+ * The following is the documentation from the original class which is provided
+ * here for reference. The information is outdated!
+ *
+ * Web application lifecycle listener, used to perform central initialisation
+ * tasks at CCM startup in a Servlet container / web application server,
+ * expecially setting the runtime context (file locations) and (in the future)
+ * the database connection.
+ *
+ * The methods of this classes are by definition only invoked by the Servlet
+ * container / web application server, not by any Servlet or java class of the
+ * application itself! Invocation is managed by the deployment descriptor.
+ *
+ * Note! Don't forget to configure it in web.xml deployment descriptor!
+ *
+ *
+ * com.arsdigita.runtime.CCMApplicationContextListener
+ *
+ *
+ * According to the 2.3 specification these tags must be placed after the filter
+ * tags and before the Servlet tags!
+ *
+ * @author pboy
+ * @author Jens Pelzetter Jens
+ * Pelzetter
+ */
+@WebListener
+public class CCMApplicationContextListener implements ServletContextListener {
+
+ public static final Logger logger = LogManager.getLogger(
+ CCMApplicationContextListener.class);
+
+ @Override
+ public void contextInitialized(final ServletContextEvent event) {
+ final ServletContext context = event.getServletContext();
+
+ final String appBase = context.getRealPath("/");
+
+ logger.info(String.format("Setting base directory to %s", appBase));
+ CCMResourceManager.setBaseDirectory(appBase);
+ }
+
+ @Override
+ public void contextDestroyed(final ServletContextEvent event) {
+ //Nothing yet
+ }
+
+}
diff --git a/ccm-core/src/test/java/com/arsdigita/kernel/KernelConfigTest.java b/ccm-core/src/test/java/com/arsdigita/kernel/KernelConfigTest.java
index 861797f34..bca875ec0 100644
--- a/ccm-core/src/test/java/com/arsdigita/kernel/KernelConfigTest.java
+++ b/ccm-core/src/test/java/com/arsdigita/kernel/KernelConfigTest.java
@@ -47,26 +47,26 @@ import static org.junit.Assert.*;
@RunWith(Arquillian.class)
@Category(IntegrationTest.class)
public class KernelConfigTest {
-
+
public KernelConfigTest() {
}
-
+
@BeforeClass
public static void setUpClass() {
}
-
+
@AfterClass
public static void tearDownClass() {
}
-
+
@Before
public void setUp() {
}
-
+
@After
public void tearDown() {
}
-
+
@Deployment
public static WebArchive createDeployment() {
final PomEquippedResolveStage pom = Maven
@@ -75,15 +75,15 @@ public class KernelConfigTest {
final PomEquippedResolveStage dependencies = pom
.importCompileAndRuntimeDependencies();
final File[] libs = dependencies.resolve().withTransitivity().asFile();
-
+
for (File lib : libs) {
System.err.printf("Adding file '%s' to test archive...%n",
lib.getName());
}
-
+
return ShrinkWrap
.create(WebArchive.class,
- "LibreCCM-org.libreccm.core.KernelConfigTest.war")
+ "LibreCCM-com.arsdigita.kernel.KernelConfigTest.war")
//.addPackage(CcmObject.class.getPackage())
.addPackage(com.arsdigita.kernel.KernelConfig.class.getPackage())
.addPackage(com.arsdigita.runtime.AbstractConfig.class.getPackage())
@@ -91,10 +91,14 @@ public class KernelConfigTest {
getPackage())
.addPackage(com.arsdigita.util.JavaPropertyReader.class.
getPackage())
+ .addPackage(com.arsdigita.web.CCMApplicationContextListener.class
+ .getPackage())
+ .addPackage(com.arsdigita.xml.XML.class.getPackage())
+ .addPackage(com.arsdigita.xml.formatters.DateFormatter.class.getPackage())
.addPackage(org.libreccm.tests.categories.IntegrationTest.class
.getPackage())
.addAsLibraries(libs)
- .addAsWebInfResource(
+ .addAsResource(
"configtests/com/arsdigita/kernel/KernelConfigTest/ccm-core.config",
"ccm-core.config")
.addAsWebInfResource(
@@ -106,13 +110,13 @@ public class KernelConfigTest {
.addAsResource(
"com/arsdigita/kernel/KernelConfig_parameter.properties",
"com/arsdigita/kernel/KernelConfig_parameter.properties")
- .addAsWebInfResource(EmptyAsset.INSTANCE, "WEB-INF/beans.xml");
+ .addAsWebInfResource(EmptyAsset.INSTANCE, "beans.xml");
}
-
+
@Test
public void verifyKernelConfig() {
final KernelConfig kernelConfig = KernelConfig.getConfig();
-
+
assertThat(kernelConfig.isDebugEnabled(),
is(true));
assertThat(kernelConfig.isDataPermissionCheckEnabled(),
@@ -132,5 +136,5 @@ public class KernelConfigTest {
assertThat(kernelConfig.getLanguagesIndependentCode(),
is(equalTo("--")));
}
-
+
}
diff --git a/ccm-core/src/test/resources/configtests/com/arsdigita/kernel/KernelConfigTest/registry.properties b/ccm-core/src/test/resources/configtests/com/arsdigita/kernel/KernelConfigTest/registry.properties
index e69de29bb..9bb7b6ea9 100644
--- a/ccm-core/src/test/resources/configtests/com/arsdigita/kernel/KernelConfigTest/registry.properties
+++ b/ccm-core/src/test/resources/configtests/com/arsdigita/kernel/KernelConfigTest/registry.properties
@@ -0,0 +1 @@
+waf.config.packages=ccm-core
\ No newline at end of file