incubator-connectors-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kwri...@apache.org
Subject svn commit: r1333735 - in /incubator/lcf/trunk: ./ framework/api-service/src/main/webapp/WEB-INF/ framework/authority-service/src/main/webapp/WEB-INF/ framework/core/src/main/java/org/apache/manifoldcf/core/system/ framework/crawler-ui/src/main/webapp/...
Date Fri, 04 May 2012 01:17:36 GMT
Author: kwright
Date: Fri May  4 01:17:35 2012
New Revision: 1333735

URL: http://svn.apache.org/viewvc?rev=1333735&view=rev
Log:
Fix for CONNECTORS-469.

Added:
    incubator/lcf/trunk/framework/core/src/main/java/org/apache/manifoldcf/core/system/ServletListener.java
  (with props)
Modified:
    incubator/lcf/trunk/CHANGES.txt
    incubator/lcf/trunk/framework/api-service/src/main/webapp/WEB-INF/web.xml
    incubator/lcf/trunk/framework/authority-service/src/main/webapp/WEB-INF/web.xml
    incubator/lcf/trunk/framework/core/src/main/java/org/apache/manifoldcf/core/system/ManifoldCF.java
    incubator/lcf/trunk/framework/crawler-ui/src/main/webapp/WEB-INF/web.xml

Modified: incubator/lcf/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/incubator/lcf/trunk/CHANGES.txt?rev=1333735&r1=1333734&r2=1333735&view=diff
==============================================================================
--- incubator/lcf/trunk/CHANGES.txt (original)
+++ incubator/lcf/trunk/CHANGES.txt Fri May  4 01:17:35 2012
@@ -3,6 +3,10 @@ $Id$
 
 ======================= 0.6-dev =====================
 
+CONNECTORS-469: Hook up context listener to catch web application
+shutdown more efficiently.
+(Karl Wright)
+
 CONNECTORS-453: Getting deadlock problems and other issues with
 Derby 10.8.1.1.
 (Karl Wright)

Modified: incubator/lcf/trunk/framework/api-service/src/main/webapp/WEB-INF/web.xml
URL: http://svn.apache.org/viewvc/incubator/lcf/trunk/framework/api-service/src/main/webapp/WEB-INF/web.xml?rev=1333735&r1=1333734&r2=1333735&view=diff
==============================================================================
--- incubator/lcf/trunk/framework/api-service/src/main/webapp/WEB-INF/web.xml (original)
+++ incubator/lcf/trunk/framework/api-service/src/main/webapp/WEB-INF/web.xml Fri May  4 01:17:35
2012
@@ -1,8 +1,8 @@
 <?xml version="1.0" encoding="ISO-8859-1"?>
 
 <!DOCTYPE web-app
-	PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN"
-	"http://java.sun.com/j2ee/dtds/web-app_2.2.dtd">
+    PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN"
+    "http://java.sun.com/j2ee/dtds/web-app_2.2.dtd">
 
 <!-- Licensed to the Apache Software Foundation (ASF) under one or more
      contributor license agreements. See the NOTICE file distributed with
@@ -26,17 +26,21 @@
   <description>ManifoldCF General API</description>
 
   <servlet>
-	<servlet-name>APIServlet</servlet-name>
-    	<servlet-class>org.apache.manifoldcf.api.APIServlet</servlet-class>
+    <servlet-name>APIServlet</servlet-name>
+    <servlet-class>org.apache.manifoldcf.api.APIServlet</servlet-class>
   </servlet>
 
   <servlet-mapping>
-        <servlet-name>APIServlet</servlet-name>
-        <url-pattern>/*</url-pattern>
+    <servlet-name>APIServlet</servlet-name>
+    <url-pattern>/*</url-pattern>
   </servlet-mapping>
 
   <session-config>
-	<session-timeout>5</session-timeout>
+    <session-timeout>5</session-timeout>
   </session-config>
 
+  <listener>
+    <listener-class>org.apache.manifoldcf.core.system.ServletListener</listener-class>
+  </listener>
+
 </web-app>

Modified: incubator/lcf/trunk/framework/authority-service/src/main/webapp/WEB-INF/web.xml
URL: http://svn.apache.org/viewvc/incubator/lcf/trunk/framework/authority-service/src/main/webapp/WEB-INF/web.xml?rev=1333735&r1=1333734&r2=1333735&view=diff
==============================================================================
--- incubator/lcf/trunk/framework/authority-service/src/main/webapp/WEB-INF/web.xml (original)
+++ incubator/lcf/trunk/framework/authority-service/src/main/webapp/WEB-INF/web.xml Fri May
 4 01:17:35 2012
@@ -26,17 +26,21 @@
   <description>ManifoldCF Authorities API</description>
 
   <servlet>
-	<servlet-name>UserACLServlet</servlet-name>
-    	<servlet-class>org.apache.manifoldcf.authorityservice.servlet.UserACLServlet</servlet-class>
+    <servlet-name>UserACLServlet</servlet-name>
+    <servlet-class>org.apache.manifoldcf.authorityservice.servlet.UserACLServlet</servlet-class>
   </servlet>
 
   <servlet-mapping>
-        <servlet-name>UserACLServlet</servlet-name>
-        <url-pattern>/UserACLs</url-pattern>
+    <servlet-name>UserACLServlet</servlet-name>
+    <url-pattern>/UserACLs</url-pattern>
   </servlet-mapping>
 
   <session-config>
-	<session-timeout>5</session-timeout>
+    <session-timeout>5</session-timeout>
   </session-config>
 
+  <listener>
+    <listener-class>org.apache.manifoldcf.core.system.ServletListener</listener-class>
+  </listener>
+
 </web-app>

Modified: incubator/lcf/trunk/framework/core/src/main/java/org/apache/manifoldcf/core/system/ManifoldCF.java
URL: http://svn.apache.org/viewvc/incubator/lcf/trunk/framework/core/src/main/java/org/apache/manifoldcf/core/system/ManifoldCF.java?rev=1333735&r1=1333734&r2=1333735&view=diff
==============================================================================
--- incubator/lcf/trunk/framework/core/src/main/java/org/apache/manifoldcf/core/system/ManifoldCF.java
(original)
+++ incubator/lcf/trunk/framework/core/src/main/java/org/apache/manifoldcf/core/system/ManifoldCF.java
Fri May  4 01:17:35 2012
@@ -77,6 +77,7 @@ public class ManifoldCF
   // Flag indicating whether system initialized or not, and synchronizer to protect that
flag.
   protected static boolean isInitialized = false;
   protected static boolean alreadyClosed = false;
+  protected static boolean alreadyShutdown = false;
   protected static Integer initializeFlagLock = new Integer(0);
 
   // Local member variables
@@ -132,14 +133,13 @@ public class ManifoldCF
   /** Reset environment.
   */
   public static void resetEnvironment()
-    throws ManifoldCFException
   {
     synchronized (initializeFlagLock)
     {
       if (!isInitialized)
         return;
       // Clean up the system doing the same thing the shutdown thread would have if the process
was killed
-      cleanUpSystem();
+      cleanUpEnvironment();
       masterDatabaseName = null;
       masterDatabaseUsername = null;
       masterDatabasePassword = null;
@@ -149,6 +149,7 @@ public class ManifoldCF
       propertyFilePath = null;
       isInitialized = false;
       alreadyClosed = false;
+      alreadyShutdown = false;
     }
   }
   
@@ -1155,27 +1156,31 @@ public class ManifoldCF
   }
   
   /** Perform system shutdown, using the registered shutdown hooks. */
-  protected static void cleanUpSystem()
+  public static void cleanUpEnvironment()
   {
     // It needs to call all registered shutdown hooks, in reverse order.
     // A failure of any one hook should cause the cleanup to continue, after a logging attempt
is made.
-    synchronized (cleanupHooks)
+    if (isInitialized && !alreadyShutdown)
     {
-      int i = cleanupHooks.size();
-      while (i > 0)
+      synchronized (cleanupHooks)
       {
-	i--;
-	IShutdownHook hook = (IShutdownHook)cleanupHooks.get(i);
-	try
-	{
-	  hook.doCleanup();
-	}
-	catch (ManifoldCFException e)
-	{
-	  Logging.root.warn("Error during system shutdown: "+e.getMessage(),e);
-	}
+        int i = cleanupHooks.size();
+        while (i > 0)
+        {
+          i--;
+          IShutdownHook hook = (IShutdownHook)cleanupHooks.get(i);
+          try
+          {
+            hook.doCleanup();
+          }
+          catch (ManifoldCFException e)
+          {
+            Logging.root.warn("Error during system shutdown: "+e.getMessage(),e);
+          }
+        }
+        cleanupHooks.clear();
       }
-      cleanupHooks.clear();
+      alreadyShutdown = true;
     }
   }
 
@@ -1319,7 +1324,7 @@ public class ManifoldCF
     public void run()
     {
       // This thread is run at shutdown time.
-      cleanUpSystem();
+      cleanUpEnvironment();
     }
   }
 

Added: incubator/lcf/trunk/framework/core/src/main/java/org/apache/manifoldcf/core/system/ServletListener.java
URL: http://svn.apache.org/viewvc/incubator/lcf/trunk/framework/core/src/main/java/org/apache/manifoldcf/core/system/ServletListener.java?rev=1333735&view=auto
==============================================================================
--- incubator/lcf/trunk/framework/core/src/main/java/org/apache/manifoldcf/core/system/ServletListener.java
(added)
+++ incubator/lcf/trunk/framework/core/src/main/java/org/apache/manifoldcf/core/system/ServletListener.java
Fri May  4 01:17:35 2012
@@ -0,0 +1,41 @@
+/* $Id$ */
+
+/**
+* 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.manifoldcf.core.system;
+
+import org.apache.manifoldcf.core.interfaces.*;
+import org.apache.manifoldcf.core.system.ManifoldCF;
+import javax.servlet.*;
+
+/** This class furnishes a servlet shutdown hook for ManifoldCF.  It should be referenced
in the
+* web.xml file for the application in order to do the right thing, however.
+*/
+public class ServletListener implements ServletContextListener
+{
+  public static final String _rcsid = "@(#)$Id$";
+
+  public void contextInitialized(ServletContextEvent sce)
+  {
+  }
+  
+  public void contextDestroyed(ServletContextEvent sce)
+  {
+    ManifoldCF.cleanUpEnvironment();
+  }
+
+}

Propchange: incubator/lcf/trunk/framework/core/src/main/java/org/apache/manifoldcf/core/system/ServletListener.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/lcf/trunk/framework/core/src/main/java/org/apache/manifoldcf/core/system/ServletListener.java
------------------------------------------------------------------------------
    svn:keywords = Id

Modified: incubator/lcf/trunk/framework/crawler-ui/src/main/webapp/WEB-INF/web.xml
URL: http://svn.apache.org/viewvc/incubator/lcf/trunk/framework/crawler-ui/src/main/webapp/WEB-INF/web.xml?rev=1333735&r1=1333734&r2=1333735&view=diff
==============================================================================
--- incubator/lcf/trunk/framework/crawler-ui/src/main/webapp/WEB-INF/web.xml (original)
+++ incubator/lcf/trunk/framework/crawler-ui/src/main/webapp/WEB-INF/web.xml Fri May  4 01:17:35
2012
@@ -26,41 +26,38 @@
   <description>ManifoldCF Crawler Interface</description>
 
   <session-config>
-	<session-timeout>5</session-timeout>
+    <session-timeout>5</session-timeout>
   </session-config>
 
   <jsp-config>
-  	<taglib>
-		<taglib-uri>http://java.sun.com/jstl/core</taglib-uri>
-		<taglib-location>/WEB-INF/jsp/c.tld</taglib-location>
-  	</taglib>
-
-  	<taglib>
-		<taglib-uri>http://java.sun.com/jstl/fmt</taglib-uri>
-		<taglib-location>/WEB-INF/jsp/fmt.tld</taglib-location>
-  	</taglib>
-
-  	<taglib>
-		<taglib-uri>http://java.sun.com/jstl/xml</taglib-uri>
-		<taglib-location>/WEB-INF/jsp/x.tld</taglib-location>
-  	</taglib>
-
-  	<taglib>
-		<taglib-uri>http://java.sun.com/jstl/sql</taglib-uri>
-		<taglib-location>/WEB-INF/jsp/sql.tld</taglib-location>
-  	</taglib>
+    <taglib>
+    <taglib-uri>http://java.sun.com/jstl/core</taglib-uri>
+    <taglib-location>/WEB-INF/jsp/c.tld</taglib-location>
+    </taglib>
+
+    <taglib>
+    <taglib-uri>http://java.sun.com/jstl/fmt</taglib-uri>
+    <taglib-location>/WEB-INF/jsp/fmt.tld</taglib-location>
+    </taglib>
+
+    <taglib>
+    <taglib-uri>http://java.sun.com/jstl/xml</taglib-uri>
+    <taglib-location>/WEB-INF/jsp/x.tld</taglib-location>
+    </taglib>
+
+    <taglib>
+    <taglib-uri>http://java.sun.com/jstl/sql</taglib-uri>
+    <taglib-location>/WEB-INF/jsp/sql.tld</taglib-location>
+    </taglib>
   </jsp-config>
 
   <context-param>
-	<param-name>javax.servlet.jsp.jstl.fmt.locale</param-name>
-	<param-value>ja_JP</param-value>
-  </context-param>
-  <context-param>
-	<param-name>javax.servlet.jsp.jstl.fmt.fallbackLocale</param-name>
-	<param-value>ja_JP</param-value>
-  </context-param>
-  <context-param>
-	<param-name>javax.servlet.jsp.jstl.fmt.localizationContext</param-name>
-	<param-value>messages</param-value>
+    <param-name>javax.servlet.jsp.jstl.fmt.localizationContext</param-name>
+    <param-value>messages</param-value>
   </context-param>
+
+  <listener>
+    <listener-class>org.apache.manifoldcf.core.system.ServletListener</listener-class>
+  </listener>
+
 </web-app>



Mime
View raw message