[jboss-cvs] JBossAS SVN: r93995 - projects/jboss-jca/trunk/fungal/src/main/java/org/jboss/jca/fungal/impl.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Thu Sep 24 12:18:19 EDT 2009
Author: jesper.pedersen
Date: 2009-09-24 12:18:18 -0400 (Thu, 24 Sep 2009)
New Revision: 93995
Modified:
projects/jboss-jca/trunk/fungal/src/main/java/org/jboss/jca/fungal/impl/BeanDeployment.java
projects/jboss-jca/trunk/fungal/src/main/java/org/jboss/jca/fungal/impl/DeploymentDeployer.java
projects/jboss-jca/trunk/fungal/src/main/java/org/jboss/jca/fungal/impl/KernelImpl.java
Log:
[JBJCA-166] Check for dependants during stop
Modified: projects/jboss-jca/trunk/fungal/src/main/java/org/jboss/jca/fungal/impl/BeanDeployment.java
===================================================================
--- projects/jboss-jca/trunk/fungal/src/main/java/org/jboss/jca/fungal/impl/BeanDeployment.java 2009-09-24 14:15:09 UTC (rev 93994)
+++ projects/jboss-jca/trunk/fungal/src/main/java/org/jboss/jca/fungal/impl/BeanDeployment.java 2009-09-24 16:18:18 UTC (rev 93995)
@@ -27,8 +27,10 @@
import java.lang.reflect.Method;
import java.net.URL;
import java.util.Collections;
+import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
+import java.util.Set;
/**
* A bean deployment for JCA/Fungal
@@ -78,9 +80,37 @@
/**
* Stop
+ * @exception Throwable If the unit cant be stopped
*/
- public void stop()
+ public void stop() throws Throwable
{
+ Set<String> remaining = new HashSet<String>();
+ remaining.addAll(beans);
+
+ for (String bean : beans)
+ {
+ Set<String> dependants = kernel.getBeanDependants(bean);
+
+ if (dependants != null)
+ {
+ for (String dependant : dependants)
+ {
+ remaining.remove(dependant);
+ }
+ }
+
+ remaining.remove(bean);
+ }
+
+ if (remaining.size() > 0)
+ throw new Exception("Cannot stop deployment " + deployment + " due to remaining dependants " + remaining);
+ }
+
+ /**
+ * Destroy
+ */
+ public void destroy()
+ {
List<String> shutdownBeans = new LinkedList<String>(beans);
Collections.reverse(shutdownBeans);
@@ -113,11 +143,4 @@
kernel.removeBean(name);
}
}
-
- /**
- * Destroy
- */
- public void destroy()
- {
- }
}
Modified: projects/jboss-jca/trunk/fungal/src/main/java/org/jboss/jca/fungal/impl/DeploymentDeployer.java
===================================================================
--- projects/jboss-jca/trunk/fungal/src/main/java/org/jboss/jca/fungal/impl/DeploymentDeployer.java 2009-09-24 14:15:09 UTC (rev 93994)
+++ projects/jboss-jca/trunk/fungal/src/main/java/org/jboss/jca/fungal/impl/DeploymentDeployer.java 2009-09-24 16:18:18 UTC (rev 93995)
@@ -245,6 +245,8 @@
{
InjectType it = (InjectType)element;
result.add(it.getBean());
+
+ kernel.addBeanDependants(it.getBean(), bt.getName());
}
}
}
Modified: projects/jboss-jca/trunk/fungal/src/main/java/org/jboss/jca/fungal/impl/KernelImpl.java
===================================================================
--- projects/jboss-jca/trunk/fungal/src/main/java/org/jboss/jca/fungal/impl/KernelImpl.java 2009-09-24 14:15:09 UTC (rev 93994)
+++ projects/jboss-jca/trunk/fungal/src/main/java/org/jboss/jca/fungal/impl/KernelImpl.java 2009-09-24 16:18:18 UTC (rev 93995)
@@ -34,9 +34,11 @@
import java.net.URL;
import java.util.Collections;
import java.util.HashMap;
+import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
+import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.ExecutorService;
@@ -73,6 +75,9 @@
/** Services status */
private ConcurrentMap<String, ServiceLifecycle> servicesStatus = new ConcurrentHashMap<String, ServiceLifecycle>();
+ /** Services status */
+ private ConcurrentMap<String, Set<String>> beanDependants = new ConcurrentHashMap<String, Set<String>>();
+
/** Executor service */
private ExecutorService executorService;
@@ -159,9 +164,9 @@
if (root != null && root.exists())
{
- libDirectory = new File(root, "/lib/");
- configDirectory = new File(root, "/config/");
- deployDirectory = new File(root, "/deploy/");
+ libDirectory = new File(root, File.separator + "lib" + File.separator);
+ configDirectory = new File(root, File.separator + "config" + File.separator);
+ deployDirectory = new File(root, File.separator + "deploy" + File.separator);
}
oldClassLoader = SecurityActions.getThreadContextClassLoader();
@@ -458,6 +463,37 @@
}
/**
+ * Get the set of dependants for a bean
+ * @param name The name of the bean
+ * @return The set of dependants; <code>null</code> if there are no dependants
+ */
+ Set<String> getBeanDependants(String name)
+ {
+ return beanDependants.get(name);
+ }
+
+ /**
+ * Add a bean to the dependants map
+ * @param from The name of the from bean
+ * @param to The name of the to bean
+ */
+ void addBeanDependants(String from, String to)
+ {
+ Set<String> dependants = beanDependants.get(from);
+ if (dependants == null)
+ {
+ Set<String> newDependants = new HashSet<String>();
+ dependants = beanDependants.putIfAbsent(from, newDependants);
+ if (dependants == null)
+ {
+ dependants = newDependants;
+ }
+ }
+
+ dependants.add(to);
+ }
+
+ /**
* Register deployment
* @param deployment The deployment
*/
More information about the jboss-cvs-commits
mailing list