Author: rareddy
Date: 2010-06-09 10:45:23 -0400 (Wed, 09 Jun 2010)
New Revision: 2210
Added:
trunk/jboss-integration/src/main/java/org/teiid/jboss/JBossLifeCycleListener.java
trunk/runtime/src/main/java/org/teiid/deployers/ContainerLifeCycleListener.java
Modified:
trunk/build/kits/jboss-container/deployers/teiid.deployer/teiid-deployer-jboss-beans.xml
trunk/jboss-integration/src/main/java/org/teiid/adminapi/jboss/ManagedUtil.java
trunk/runtime/src/main/java/org/teiid/deployers/VDBDeployer.java
Log:
TEIID-1117: Capturing the Shutdown event of the container using a JMX notification, and
used that to determine the shutdown based undeploy vs a undeploy based on the user
activity. Then managed the cached directories based on these events.
Modified:
trunk/build/kits/jboss-container/deployers/teiid.deployer/teiid-deployer-jboss-beans.xml
===================================================================
---
trunk/build/kits/jboss-container/deployers/teiid.deployer/teiid-deployer-jboss-beans.xml 2010-06-08
21:28:18 UTC (rev 2209)
+++
trunk/build/kits/jboss-container/deployers/teiid.deployer/teiid-deployer-jboss-beans.xml 2010-06-09
14:45:23 UTC (rev 2210)
@@ -8,6 +8,8 @@
<bean name="ConnectorManagerRepository"
class="org.teiid.dqp.internal.datamgr.impl.ConnectorManagerRepository"/>
<bean name="SecurityHelper"
class="org.teiid.jboss.JBossSecurityHelper"/>
+ <bean name="JBossLifeCycleListener"
class="org.teiid.jboss.JBossLifeCycleListener"/>
+
<bean name="VDBParserDeployer"
class="org.teiid.deployers.VDBParserDeployer">
<property name="objectSerializer"><inject
bean="ObjectSerializer"/></property>
<property name="managedObjectFactory"><inject
bean="ManagedObjectFactory"/></property>
@@ -45,7 +47,8 @@
<property name="contextCache"><inject
bean="ContextCache"/></property>
<property name="objectSerializer"><inject
bean="ObjectSerializer"/></property>
<property name="connectorManagerRepository"><inject
bean="ConnectorManagerRepository"/></property>
- <property name="translatorRepository"><inject
bean="translatorRepository"/></property>
+ <property name="translatorRepository"><inject
bean="translatorRepository"/></property>
+ <property name="containerLifeCycleListener"><inject
bean="JBossLifeCycleListener"/></property>
<depends>SystemVDBDeployer</depends>
</bean>
Modified: trunk/jboss-integration/src/main/java/org/teiid/adminapi/jboss/ManagedUtil.java
===================================================================
---
trunk/jboss-integration/src/main/java/org/teiid/adminapi/jboss/ManagedUtil.java 2010-06-08
21:28:18 UTC (rev 2209)
+++
trunk/jboss-integration/src/main/java/org/teiid/adminapi/jboss/ManagedUtil.java 2010-06-09
14:45:23 UTC (rev 2210)
@@ -300,6 +300,7 @@
public static void removeArchive(DeploymentManager deploymentManager, String...
deploymentNames) throws AdminProcessingException{
try {
+ execute(deploymentManager.stop(deploymentNames),
IntegrationPlugin.Util.getString("failed_to_remove")); //$NON-NLS-1$
execute(deploymentManager.remove(deploymentNames),
IntegrationPlugin.Util.getString("failed_to_remove")); //$NON-NLS-1$
} catch (Exception e) {
handleException(e);
Added: trunk/jboss-integration/src/main/java/org/teiid/jboss/JBossLifeCycleListener.java
===================================================================
--- trunk/jboss-integration/src/main/java/org/teiid/jboss/JBossLifeCycleListener.java
(rev 0)
+++
trunk/jboss-integration/src/main/java/org/teiid/jboss/JBossLifeCycleListener.java 2010-06-09
14:45:23 UTC (rev 2210)
@@ -0,0 +1,67 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * 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 org.teiid.jboss;
+
+import javax.management.InstanceNotFoundException;
+import javax.management.MBeanServer;
+import javax.management.MBeanServerFactory;
+import javax.management.MalformedObjectNameException;
+import javax.management.Notification;
+import javax.management.NotificationListener;
+import javax.management.ObjectName;
+
+import org.jboss.bootstrap.spi.Server;
+import org.jboss.system.ServiceMBeanSupport;
+import org.teiid.deployers.ContainerLifeCycleListener;
+
+public class JBossLifeCycleListener extends ServiceMBeanSupport implements
NotificationListener, ContainerLifeCycleListener{
+
+ private boolean shutdownInProgress = false;
+
+ public JBossLifeCycleListener() {
+ try {
+ MBeanServer server = MBeanServerFactory.findMBeanServer(null).get(0);
+ ObjectName on = new ObjectName("jboss.system:type=Server"); //$NON-NLS-1$
+ server.addNotificationListener(on, this, null, null);
+ } catch (MalformedObjectNameException e) {
+ //ignore
+ } catch (InstanceNotFoundException e) {
+ //ignore
+ }
+ }
+
+ @Override
+ public void handleNotification(Notification msg, Object handback) {
+ String type = msg.getType();
+ if (type.equals(Server.START_NOTIFICATION_TYPE)) {
+ }
+
+ if (type.equals(Server.STOP_NOTIFICATION_TYPE)) {
+ shutdownInProgress = true;
+ }
+ }
+
+ @Override
+ public boolean isShutdownInProgress() {
+ return shutdownInProgress;
+ }
+}
Property changes on:
trunk/jboss-integration/src/main/java/org/teiid/jboss/JBossLifeCycleListener.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/runtime/src/main/java/org/teiid/deployers/ContainerLifeCycleListener.java
===================================================================
--- trunk/runtime/src/main/java/org/teiid/deployers/ContainerLifeCycleListener.java
(rev 0)
+++
trunk/runtime/src/main/java/org/teiid/deployers/ContainerLifeCycleListener.java 2010-06-09
14:45:23 UTC (rev 2210)
@@ -0,0 +1,26 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * 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 org.teiid.deployers;
+
+public interface ContainerLifeCycleListener {
+ boolean isShutdownInProgress();
+}
Property changes on:
trunk/runtime/src/main/java/org/teiid/deployers/ContainerLifeCycleListener.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: trunk/runtime/src/main/java/org/teiid/deployers/VDBDeployer.java
===================================================================
--- trunk/runtime/src/main/java/org/teiid/deployers/VDBDeployer.java 2010-06-08 21:28:18
UTC (rev 2209)
+++ trunk/runtime/src/main/java/org/teiid/deployers/VDBDeployer.java 2010-06-09 14:45:23
UTC (rev 2210)
@@ -62,6 +62,7 @@
private TranslatorRepository translatorRepository;
private DQPContextCache contextCache;
private ObjectSerializer serializer;
+ private ContainerLifeCycleListener shutdownListener;
public VDBDeployer() {
super(VDBMetaData.class);
@@ -277,7 +278,7 @@
}
private void deleteMetadataStore(VFSDeploymentUnit unit, VDBMetaData vdb) throws
IOException {
- if (!unit.getRoot().exists()) {
+ if (!unit.getRoot().exists() || !shutdownListener.isShutdownInProgress()) {
File cacheFileName = this.serializer.getAttachmentPath(unit,
vdb.getName()+"_"+vdb.getVersion()); //$NON-NLS-1$
if (cacheFileName.exists()) {
FileUtils.removeDirectoryAndChildren(cacheFileName.getParentFile());
@@ -332,4 +333,8 @@
public void setTranslatorRepository(TranslatorRepository repo) {
this.translatorRepository = repo;
}
+
+ public void setContainerLifeCycleListener(ContainerLifeCycleListener listener) {
+ shutdownListener = listener;
+ }
}