summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorShireesh Anjal <shireesh@gluster.com>2011-08-18 21:37:41 +0530
committerShireesh Anjal <shireesh@gluster.com>2011-08-18 21:37:41 +0530
commit3db6ac956fea2138d2a1b09022612b8c6ead2df9 (patch)
treec6d322f8e8cd71ae295845a05aa33a6e05cf8ee8 /src
parent94cbfe27ed034535f7ebeecf7aa0122fc01193e4 (diff)
Shutdown listener - shuts down derby when Gateway is stopped.
Diffstat (limited to 'src')
-rw-r--r--src/com.gluster.storage.management.gateway/WebContent/WEB-INF/web.xml3
-rw-r--r--src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/listeners/ShutdownListener.java46
2 files changed, 49 insertions, 0 deletions
diff --git a/src/com.gluster.storage.management.gateway/WebContent/WEB-INF/web.xml b/src/com.gluster.storage.management.gateway/WebContent/WEB-INF/web.xml
index 54872639..750ef171 100644
--- a/src/com.gluster.storage.management.gateway/WebContent/WEB-INF/web.xml
+++ b/src/com.gluster.storage.management.gateway/WebContent/WEB-INF/web.xml
@@ -22,6 +22,9 @@
<listener>
<listener-class>org.springframework.web.context.request.RequestContextListener</listener-class>
</listener>
+ <listener>
+ <listener-class>com.gluster.storage.management.gateway.listeners.ShutdownListener</listener-class>
+ </listener>
<servlet>
<servlet-name>gluster-resources-1.0</servlet-name>
<servlet-class>com.sun.jersey.spi.spring.container.servlet.SpringServlet</servlet-class>
diff --git a/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/listeners/ShutdownListener.java b/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/listeners/ShutdownListener.java
new file mode 100644
index 00000000..23ae36ae
--- /dev/null
+++ b/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/listeners/ShutdownListener.java
@@ -0,0 +1,46 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Gluster, Inc. <http://www.gluster.com>
+ * This file is part of Gluster Management Console.
+ *
+ * Gluster Management Console is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Affero General Public License as published
+ * by the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Gluster Management Console 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 Affero General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see
+ * <http://www.gnu.org/licenses/>.
+ *******************************************************************************/
+package com.gluster.storage.management.gateway.listeners;
+
+import javax.servlet.ServletContextEvent;
+import javax.servlet.ServletContextListener;
+
+import com.gluster.storage.management.gateway.utils.DBUtil;
+
+/**
+ * Shuts down the Derby database when gateway is being stopped.
+ */
+public class ShutdownListener implements ServletContextListener {
+
+ /* (non-Javadoc)
+ * @see javax.servlet.ServletContextListener#contextDestroyed(javax.servlet.ServletContextEvent)
+ */
+ @Override
+ public void contextDestroyed(ServletContextEvent arg0) {
+ // Embedded derby must be shut down when the gateway stops.
+ DBUtil.shutdownDerby();
+ }
+
+ /* (non-Javadoc)
+ * @see javax.servlet.ServletContextListener#contextInitialized(javax.servlet.ServletContextEvent)
+ */
+ @Override
+ public void contextInitialized(ServletContextEvent arg0) {
+ }
+}