[jboss-dev-forums] [Design the new POJO MicroContainer] - Re: Locks on MainDeployerImpl

alesj do-not-reply at jboss.com
Fri Feb 20 09:03:58 EST 2009


What about if I just simply do this:

  |    public void process()
  |    {
  |       if (deployers == null)
  |          throw new IllegalStateException("No deployers");
  | 
  |       lockRead();
  |       try
  |       {
  |          if (shutdown.get())
  |             throw new IllegalStateException("The main deployer is shutdown");
  | 
  |          Map<String, Deployment> copy = new LinkedHashMap<String, Deployment>(toRedeploy);
  |          toRedeploy.clear();
  | 
  |          try
  |          {
  |             processToUndeploy(copy.keySet());   
  |          }
  |          catch (DeploymentException e)
  |          {
  |             throw new RuntimeException("Error while removing re-deployments", e);
  |          }
  | 
  |          List<DeploymentContext> undeployContexts = null;
  |          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));
  |             if (reverted != null)
  |                Collections.sort(undeployContexts, reverted);
  |             undeploy.clear();
  |          }
  | 
  |          if (undeployContexts != null)
  |          {
  |             deployers.process(null, undeployContexts);
  |          }
  | 
  |          try
  |          {
  |             processToDeploy(copy.values());
  |          }
  |          catch (DeploymentException e)
  |          {
  |             throw new RuntimeException("Error while adding -redeployments", e);
  |          }
  | 
  |          List<DeploymentContext> deployContexts = null;
  |          if (deploy.isEmpty() == false)
  |          {
  |             deployContexts = new ArrayList<DeploymentContext>(deploy);
  |             if (comparator != null)
  |                Collections.sort(deployContexts, comparator);
  |             deploy.clear();
  |          }
  | 
  |          if (deployContexts != null)
  |          {
  |             deployers.process(deployContexts, null);
  |          }
  |       }
  |       finally
  |       {
  |          unlockRead();
  |       }
  |    }
  | 

Where I make a copy of currently existing re-deployments.
Then I don't care if some come in between.

Or am I missing something?

View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4211818#4211818

Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4211818



More information about the jboss-dev-forums mailing list