0 Replies Latest reply on May 30, 2008 7:40 AM by Ales Justin

    fixing AbstractComponentDeployer

    Ales Justin Master

      I did a couple of small fixes to AbstractComponentDeployer.
      I'll comment my changes on the svn diff

       public void internalDeploy(DeploymentUnit unit) throws DeploymentException
       {
       super.internalDeploy(unit);
      
       try
       {
       deployComponents(unit);
       }
       catch (Throwable t)
       {
      // we need to unwind the super too
      // the actual component unwinding is done
      // at the point of failure
      - undeployComponents(unit);
      + super.internalUndeploy(unit);
       throw DeploymentException.rethrowAsDeploymentException("Error deploying: " + unit.getName(), t);
       }
       }
      
       public void internalUndeploy(DeploymentUnit unit)
       {
      // make it asymetric
      - super.internalUndeploy(unit);
       undeployComponents(unit);
      + super.internalUndeploy(unit);
       }
      
       protected void deployComponents(DeploymentUnit unit) throws DeploymentException
      @@ -100,9 +101,7 @@
       if (compVisitor == null)
       return;
      
      // this now uses extracted super method - see below
      - Set<? extends C> components = unit.getAllMetaData(getOutput());
      - for (C component : components)
      - compVisitor.deploy(unit, component);
      + deploy(unit, compVisitor);
       }
      

      The extracted deploy method - for both, deployment and components:
       protected <U> void deploy(DeploymentUnit unit, DeploymentVisitor<U> visitor) throws DeploymentException
       {
       List<U> visited = new ArrayList<U>();
       try
       {
       Set<? extends U> deployments = unit.getAllMetaData(visitor.getVisitorType());
       for (U deployment : deployments)
       {
       visitor.deploy(unit, deployment);
       visited.add(deployment);
       }
       }
       catch (Throwable t)
       {
       for (int i = visited.size()-1; i >= 0; --i)
       {
       try
       {
       visitor.undeploy(unit, visited.get(i));
       }
       catch (Throwable ignored)
       {
       log.warn("Error during undeploy: " + unit.getName(), ignored);
       }
       }
       throw DeploymentException.rethrowAsDeploymentException("Error deploying: " + unit.getName(), t);
       }
       }