[jboss-cvs] JBossAS SVN: r96655 - in projects/jboss-jca/trunk: fungal/src/main/java/org/jboss/jca/fungal/impl and 1 other directory.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Fri Nov 20 15:11:37 EST 2009
Author: jesper.pedersen
Date: 2009-11-20 15:11:36 -0500 (Fri, 20 Nov 2009)
New Revision: 96655
Modified:
projects/jboss-jca/trunk/doc/developerguide/en/modules/fungal.xml
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/ServiceLifecycle.java
Log:
[JBJCA-222] Throw a DeployException if a bean can't be installed
Modified: projects/jboss-jca/trunk/doc/developerguide/en/modules/fungal.xml
===================================================================
--- projects/jboss-jca/trunk/doc/developerguide/en/modules/fungal.xml 2009-11-20 19:54:52 UTC (rev 96654)
+++ projects/jboss-jca/trunk/doc/developerguide/en/modules/fungal.xml 2009-11-20 20:11:36 UTC (rev 96655)
@@ -191,6 +191,10 @@
<para><code>STOPPING</code></para>
<para>The bean is stopping.</para>
</listitem>
+ <listitem>
+ <para><code>ERROR</code></para>
+ <para>The bean is in error.</para>
+ </listitem>
</itemizedlist>
<para>Caveats: The kernel currently doesn't detect cyclic dependencies between deployment units.</para>
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-11-20 19:54:52 UTC (rev 96654)
+++ projects/jboss-jca/trunk/fungal/src/main/java/org/jboss/jca/fungal/impl/DeploymentDeployer.java 2009-11-20 20:11:36 UTC (rev 96655)
@@ -43,6 +43,7 @@
import java.util.List;
import java.util.Locale;
import java.util.Set;
+import java.util.concurrent.Callable;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.Future;
@@ -89,6 +90,7 @@
if (url == null || !url.toString().endsWith(".xml"))
return null;
+ DeployException deployException = null;
try
{
Unmarshaller deploymentU = new Unmarshaller();
@@ -97,19 +99,31 @@
if (deployment != null && deployment.getBean().size() > 0)
{
+ List<BeanDeployer> deployers = new ArrayList<BeanDeployer>(deployment.getBean().size());
List<String> beans = Collections.synchronizedList(new ArrayList<String>(deployment.getBean().size()));
beansLatch = new CountDownLatch(deployment.getBean().size());
for (BeanType bt : deployment.getBean())
{
- Runnable r = new ServiceRunnable(bt, beans, kernel, beansLatch, parent);
- Future<?> result = kernel.getExecutorService().submit(r);
+ BeanDeployer deployer = new BeanDeployer(bt, beans, kernel, beansLatch, parent);
+ deployers.add(deployer);
+
+ Future<?> result = kernel.getExecutorService().submit(deployer);
}
beansLatch.await();
- return new BeanDeployment(url, beans, kernel);
+ Iterator<BeanDeployer> it = deployers.iterator();
+ while (deployException == null && it.hasNext())
+ {
+ BeanDeployer deployer = it.next();
+ if (deployer.getDeployException() != null)
+ deployException = deployer.getDeployException();
+ }
+
+ if (deployException == null)
+ return new BeanDeployment(url, beans, kernel);
}
}
catch (Throwable t)
@@ -118,13 +132,16 @@
throw new DeployException("Deployment " + url + " failed", t);
}
+ if (deployException != null)
+ throw new DeployException("Deployment " + url + " failed", deployException);
+
return null;
}
/**
- * Service runnable
+ * Bean deployer
*/
- static class ServiceRunnable implements Runnable
+ static class BeanDeployer implements Runnable
{
/** The bean */
private BeanType bt;
@@ -141,6 +158,9 @@
/** The classloader */
private ClassLoader classLoader;
+ /** DeployException */
+ private DeployException deployException;
+
/**
* Constructor
* @param bt The bean
@@ -149,17 +169,18 @@
* @param beansLatch The beans latch
* @param classLoader The class loader
*/
- public ServiceRunnable(BeanType bt,
- List<String> beans,
- KernelImpl kernel,
- CountDownLatch beansLatch,
- ClassLoader classLoader)
+ public BeanDeployer(BeanType bt,
+ List<String> beans,
+ KernelImpl kernel,
+ CountDownLatch beansLatch,
+ ClassLoader classLoader)
{
this.bt = bt;
this.beans = beans;
this.kernel = kernel;
this.beansLatch = beansLatch;
this.classLoader = classLoader;
+ this.deployException = null;
}
/**
@@ -170,7 +191,6 @@
SecurityActions.setThreadContextClassLoader(classLoader);
String beanName = bt.getName();
-
try
{
if (kernel.getBean(beanName) == null)
@@ -209,6 +229,8 @@
}
catch (Throwable t)
{
+ deployException = new DeployException("Installing bean " + beanName, t);
+ kernel.setBeanStatus(beanName, ServiceLifecycle.ERROR);
error("Installing bean " + beanName, t);
}
@@ -216,6 +238,15 @@
}
/**
+ * Get deploy exception
+ * @return null if no error; otherwise the exception
+ */
+ public DeployException getDeployException()
+ {
+ return deployException;
+ }
+
+ /**
* Get the depedencies for a bean
* @paran bt The bean type
* @return The set of dependencies; <code>null</code> if no dependencies
@@ -271,7 +302,8 @@
for (String dependency : dependencies)
{
ServiceLifecycle dependencyStatus = kernel.getBeanStatus(dependency);
- if (dependencyStatus == null || dependencyStatus != ServiceLifecycle.STARTED)
+ if (dependencyStatus == null || (dependencyStatus != ServiceLifecycle.STARTED &&
+ dependencyStatus != ServiceLifecycle.ERROR))
count += 1;
}
Modified: projects/jboss-jca/trunk/fungal/src/main/java/org/jboss/jca/fungal/impl/ServiceLifecycle.java
===================================================================
--- projects/jboss-jca/trunk/fungal/src/main/java/org/jboss/jca/fungal/impl/ServiceLifecycle.java 2009-11-20 19:54:52 UTC (rev 96654)
+++ projects/jboss-jca/trunk/fungal/src/main/java/org/jboss/jca/fungal/impl/ServiceLifecycle.java 2009-11-20 20:11:36 UTC (rev 96655)
@@ -38,5 +38,8 @@
STARTED,
/** Service stopping */
- STOPPING
+ STOPPING,
+
+ /** Service error */
+ ERROR
}
More information about the jboss-cvs-commits
mailing list