[jboss-cvs] JBossAS SVN: r67219 - projects/microcontainer/trunk/deployers-impl/src/main/org/jboss/deployers/plugins/main.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Sat Nov 17 09:21:39 EST 2007
Author: alesj
Date: 2007-11-17 09:21:39 -0500 (Sat, 17 Nov 2007)
New Revision: 67219
Modified:
projects/microcontainer/trunk/deployers-impl/src/main/org/jboss/deployers/plugins/main/MainDeployerImpl.java
Log:
Adding read lock to shutdown checkers.
Modified: projects/microcontainer/trunk/deployers-impl/src/main/org/jboss/deployers/plugins/main/MainDeployerImpl.java
===================================================================
--- projects/microcontainer/trunk/deployers-impl/src/main/org/jboss/deployers/plugins/main/MainDeployerImpl.java 2007-11-17 07:53:29 UTC (rev 67218)
+++ projects/microcontainer/trunk/deployers-impl/src/main/org/jboss/deployers/plugins/main/MainDeployerImpl.java 2007-11-17 14:21:39 UTC (rev 67219)
@@ -250,48 +250,56 @@
if (shutdown.get())
throw new DeploymentException("The main deployer is shutdown");
- String name = deployment.getName();
- log.debug("Add deployment: " + name);
-
- DeploymentContext previous = topLevelDeployments.get(name);
- boolean topLevelFound = false;
- if (previous != null)
+ lockRead();
+ try
{
- log.debug("Removing previous deployment: " + previous.getName());
- removeContext(previous, addToDeploy);
- topLevelFound = true;
- }
+ String name = deployment.getName();
+ log.debug("Add deployment: " + name);
- if (topLevelFound == false)
- {
- previous = allDeployments.get(name);
+ DeploymentContext previous = topLevelDeployments.get(name);
+ boolean topLevelFound = false;
if (previous != null)
- throw new IllegalStateException("Deployment already exists as a subdeployment: " + name);
- }
+ {
+ log.debug("Removing previous deployment: " + previous.getName());
+ removeContext(previous, addToDeploy);
+ topLevelFound = true;
+ }
- DeploymentContext context = null;
- try
+ if (topLevelFound == false)
+ {
+ previous = allDeployments.get(name);
+ if (previous != null)
+ throw new IllegalStateException("Deployment already exists as a subdeployment: " + name);
+ }
+
+ DeploymentContext context = null;
+ try
{
context = determineStructure(deployment);
- if (DeploymentState.ERROR.equals(context.getState()))
- errorDeployments.put(name, context);
+ if (DeploymentState.ERROR.equals(context.getState()))
+ errorDeployments.put(name, context);
- topLevelDeployments.put(name, context);
- addContext(context, addToDeploy);
+ topLevelDeployments.put(name, context);
+ addContext(context, addToDeploy);
+ }
+ catch (DeploymentException e)
+ {
+ missingDeployers.put(name, deployment);
+ throw e;
+ }
+ catch (Throwable t)
+ {
+ // was structure determined?
+ if (context != null)
+ missingDeployers.put(name, deployment);
+
+ throw DeploymentException.rethrowAsDeploymentException("Error determining deployment structure for " + name, t);
+ }
}
- catch (DeploymentException e)
+ finally
{
- missingDeployers.put(name, deployment);
- throw e;
+ unlockRead();
}
- catch (Throwable t)
- {
- // was structure determined?
- if (context != null)
- missingDeployers.put(name, deployment);
-
- throw DeploymentException.rethrowAsDeploymentException("Error determining deployment structure for " + name, t);
- }
}
public boolean removeDeployment(Deployment deployment) throws DeploymentException
@@ -336,15 +344,23 @@
if (shutdown.get())
throw new IllegalStateException("The main deployer is shutdown");
- log.debug("Remove deployment context: " + name);
+ lockRead();
+ try
+ {
+ log.debug("Remove deployment context: " + name);
- DeploymentContext context = topLevelDeployments.remove(name);
- if (context == null)
- return false;
+ DeploymentContext context = topLevelDeployments.remove(name);
+ if (context == null)
+ return false;
- removeContext(context, addToUndeploy);
+ removeContext(context, addToUndeploy);
- return true;
+ return true;
+ }
+ finally
+ {
+ unlockRead();
+ }
}
public void deploy(Deployment... deployments) throws DeploymentException
@@ -455,51 +471,59 @@
public void process()
{
- if (shutdown.get())
- throw new IllegalStateException("The main deployer is shutdown");
+ lockRead();
+ try
+ {
+ if (shutdown.get())
+ throw new IllegalStateException("The main deployer is shutdown");
- List<DeploymentContext> undeployContexts = null;
- List<DeploymentContext> deployContexts = null;
+ List<DeploymentContext> undeployContexts = null;
+ List<DeploymentContext> deployContexts = null;
- if (deployers == null)
- throw new IllegalStateException("No deployers");
+ if (deployers == null)
+ throw new IllegalStateException("No deployers");
- if (undeploy.isEmpty() == false)
- {
- // Undeploy in reverse order (subdeployments first)
- undeployContexts = new ArrayList<DeploymentContext>(undeploy.size());
- for (int i = undeploy.size() - 1; i >= 0; --i)
- undeployContexts.add(undeploy.get(i));
- undeploy.clear();
- }
- if (deploy.isEmpty() == false)
- {
- deployContexts = new ArrayList<DeploymentContext>(deploy);
- deploy.clear();
- }
+ if (undeploy.isEmpty() == false)
+ {
+ // Undeploy in reverse order (subdeployments first)
+ undeployContexts = new ArrayList<DeploymentContext>(undeploy.size());
+ for (int i = undeploy.size() - 1; i >= 0; --i)
+ undeployContexts.add(undeploy.get(i));
+ undeploy.clear();
+ }
+ if (deploy.isEmpty() == false)
+ {
+ deployContexts = new ArrayList<DeploymentContext>(deploy);
+ deploy.clear();
+ }
- if (undeployContexts == null && deployContexts == null)
- {
- log.debug("Asked to process() when there is nothing to do.");
- return;
- }
+ if (undeployContexts == null && deployContexts == null)
+ {
+ log.debug("Asked to process() when there is nothing to do.");
+ return;
+ }
- try
+ try
{
deployers.process(deployContexts, undeployContexts);
+ }
+ catch (RuntimeException e)
+ {
+ throw e;
+ }
+ catch (Error e)
+ {
+ throw e;
+ }
+ catch (Throwable t)
+ {
+ throw new RuntimeException("Unexpected error in process()", t);
+ }
}
- catch (RuntimeException e)
+ finally
{
- throw e;
+ unlockRead();
}
- catch (Error e)
- {
- throw e;
- }
- catch (Throwable t)
- {
- throw new RuntimeException("Unexpected error in process()", t);
- }
}
// enable locking - so that we don't pick up current single deployments
More information about the jboss-cvs-commits
mailing list