jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r1055116 - in /jackrabbit/trunk/jackrabbit-webapp/src/main: java/org/apache/jackrabbit/j2ee/DerbyShutdown.java webapp/WEB-INF/web.xml
Date Tue, 04 Jan 2011 17:35:40 GMT
Author: jukka
Date: Tue Jan  4 17:35:40 2011
New Revision: 1055116

URL: http://svn.apache.org/viewvc?rev=1055116&view=rev
Log:
JCR-1301: Trouble undeploying jackrabbit-webapp from Tomcat

Use a servlet context listener to explicitly release all Derby resources when undeployed

Added:
    jackrabbit/trunk/jackrabbit-webapp/src/main/java/org/apache/jackrabbit/j2ee/DerbyShutdown.java
  (with props)
Modified:
    jackrabbit/trunk/jackrabbit-webapp/src/main/webapp/WEB-INF/web.xml

Added: jackrabbit/trunk/jackrabbit-webapp/src/main/java/org/apache/jackrabbit/j2ee/DerbyShutdown.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-webapp/src/main/java/org/apache/jackrabbit/j2ee/DerbyShutdown.java?rev=1055116&view=auto
==============================================================================
--- jackrabbit/trunk/jackrabbit-webapp/src/main/java/org/apache/jackrabbit/j2ee/DerbyShutdown.java
(added)
+++ jackrabbit/trunk/jackrabbit-webapp/src/main/java/org/apache/jackrabbit/j2ee/DerbyShutdown.java
Tue Jan  4 17:35:40 2011
@@ -0,0 +1,52 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.apache.jackrabbit.j2ee;
+
+import java.sql.Driver;
+import java.sql.DriverManager;
+import java.sql.SQLException;
+import java.util.Properties;
+
+import javax.servlet.ServletContextEvent;
+import javax.servlet.ServletContextListener;
+
+/**
+ * Servlet context listener that releases all remaining Derby resources
+ * when the web application is undeployed. Should only be used when the
+ * Derby library has been deployed as a part of this webapp.
+ *
+ * @see <a href="https://issues.apache.org/jira/browse/JCR-1301">JCR-1301</a>
+ */
+public class DerbyShutdown implements ServletContextListener {
+
+    public void contextInitialized(ServletContextEvent event) {
+    }
+
+    public void contextDestroyed(ServletContextEvent event) {
+        try {
+            String shutdown = "jdbc:derby:;shutdown=true";
+            Driver driver = DriverManager.getDriver(shutdown);
+            if (driver.getClass().getClassLoader()
+                    == DerbyShutdown.class.getClassLoader()) {
+                DriverManager.deregisterDriver(driver);
+                driver.connect(shutdown, new Properties());
+            }
+        } catch (SQLException ignore) {
+        }
+    }
+
+}
\ No newline at end of file

Propchange: jackrabbit/trunk/jackrabbit-webapp/src/main/java/org/apache/jackrabbit/j2ee/DerbyShutdown.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: jackrabbit/trunk/jackrabbit-webapp/src/main/webapp/WEB-INF/web.xml
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-webapp/src/main/webapp/WEB-INF/web.xml?rev=1055116&r1=1055115&r2=1055116&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-webapp/src/main/webapp/WEB-INF/web.xml (original)
+++ jackrabbit/trunk/jackrabbit-webapp/src/main/webapp/WEB-INF/web.xml Tue Jan  4 17:35:40
2011
@@ -20,6 +20,17 @@
 <web-app>
     <display-name>Jackrabbit JCR Server</display-name>
 
+    <listener>
+        <!-- Releases all Derby resources when the webapp is undeployed.  -->
+        <!-- You should comment out this entry if you are not using Derby -->
+        <!-- for Jackrabbit persistence, or if you've deployed the Derby  -->
+        <!-- outside the Jackrabbit webapp.                               -->
+        <!-- See https://issues.apache.org/jira/browse/JCR-1301           -->
+        <listener-class>
+            org.apache.jackrabbit.j2ee.DerbyShutdown
+        </listener-class>
+    </listener>
+
     <!-- ====================================================================== -->
     <!-- R E P O S I T O R Y   S T A R T U P  S E R V L E T                     -->
     <!-- ====================================================================== -->



Mime
View raw message