[jboss-cvs] JBossAS SVN: r83707 - trunk/cluster/src/main/org/jboss/ha/singleton.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Fri Jan 30 15:44:39 EST 2009


Author: bstansberry at jboss.com
Date: 2009-01-30 15:44:38 -0500 (Fri, 30 Jan 2009)
New Revision: 83707

Modified:
   trunk/cluster/src/main/org/jboss/ha/singleton/HASingletonDeploymentScanner.java
Log:
[JBAS-6439] Require a DeploymentManager
[JBAS-6440] Dependency inject the DeploymentManager
[JBAS-6441] Handle no-content case

Modified: trunk/cluster/src/main/org/jboss/ha/singleton/HASingletonDeploymentScanner.java
===================================================================
--- trunk/cluster/src/main/org/jboss/ha/singleton/HASingletonDeploymentScanner.java	2009-01-30 20:43:18 UTC (rev 83706)
+++ trunk/cluster/src/main/org/jboss/ha/singleton/HASingletonDeploymentScanner.java	2009-01-30 20:44:38 UTC (rev 83707)
@@ -26,7 +26,6 @@
 import java.util.Set;
 import java.util.StringTokenizer;
 
-import org.jboss.deployers.client.spi.main.MainDeployer;
 import org.jboss.deployers.spi.management.deploy.DeploymentManager;
 import org.jboss.deployers.spi.management.deploy.DeploymentProgress;
 import org.jboss.deployers.vfs.spi.client.VFSDeployment;
@@ -34,7 +33,7 @@
 import org.jboss.profileservice.spi.Profile;
 import org.jboss.profileservice.spi.ProfileKey;
 import org.jboss.profileservice.spi.ProfileService;
-import org.jboss.system.server.profileservice.DeploymentPhaseVFSScanner;
+import org.jboss.system.server.profileservice.VFSScanner;
 import org.jboss.virtual.VirtualFile;
 
 /**
@@ -44,12 +43,10 @@
  * @author <a href="brian.stansberry at jboss.com">Brian Stansberry</a>
  * @version $Revision$
  */
-public class HASingletonDeploymentScanner extends DeploymentPhaseVFSScanner implements HASingletonDeploymentScannerMBean
+public class HASingletonDeploymentScanner extends VFSScanner implements HASingletonDeploymentScannerMBean
 {   
    private static final DeploymentPhase DEPLOYMENT_PHASE = DeploymentPhase.APPLICATION;
    
-   private MainDeployer mainDeployer;
-   
    private DeploymentManager deploymentManager;
    
    private boolean deployed;
@@ -64,35 +61,42 @@
     */
    public HASingletonDeploymentScanner()
    {
-      super(DEPLOYMENT_PHASE);
+      super();
    }
    
    // ----------------------------------------------------------  Properties
    
-   public MainDeployer getMainDeployer()
-   {
-      return mainDeployer;
-   }
 
-   public void setMainDeployer(MainDeployer mainDeployer)
-   {
-      this.mainDeployer = mainDeployer;
-   }
-
    @Override
    public void setProfileService(ProfileService profileService)
    {
       super.setProfileService(profileService);
       if (profileService != null)
       {
-         this.deploymentManager = profileService.getDeploymentManager();
+         // In case someone forgot to dependency inject DeploymentManager
+         // AND we're lucky enough that the DeploymentManager is already
+         // installed into the ProfileService
+         if (this.deploymentManager == null)
+         {
+            this.deploymentManager = profileService.getDeploymentManager();
+         }
       }
       else
       {
          this.deploymentManager = null;
       }
    }
+   
+   public DeploymentManager getDeploymentManager()
+   {
+      return deploymentManager;
+   }
 
+   public void setDeploymentManager(DeploymentManager deploymentManager)
+   {
+      this.deploymentManager = deploymentManager;
+   }
+
    // -----------------------------------------------------------------  Public
    
    /**
@@ -105,10 +109,10 @@
    {
       if (!this.deployed)
       {         
-         if (this.deploymentManager == null && this.mainDeployer == null)
+         if (this.deploymentManager == null)
          {
             throw new IllegalStateException("Configuration must either provide " +
-            		"a ProfileService with a DeploymentManager or a MainDeployer");
+            		"a ProfileService with a DeploymentManager or directly inject a DeploymentManager");
          }
          
          StringTokenizer tokenizer = new StringTokenizer(uris, ",");
@@ -121,15 +125,9 @@
          
          scan();
          
-         if (this.deploymentManager == null)
+         String[] allUploaded = getAllUploadedNames();
+         if (allUploaded.length > 0) // JBAS-6441
          {
-            this.mainDeployer.process();
-            // We don't call mainDeployer.checkComplete() as we may be in the
-            // middle of the initial startup deployments; i.e. not expected to be complete 
-         }
-         else
-         {
-            String[] allUploaded = getAllUploadedNames();
             DeploymentProgress progress = this.deploymentManager.start(DEPLOYMENT_PHASE, allUploaded);
             progress.run();
          }
@@ -148,10 +146,10 @@
    {
       if (this.deployed)
       {         
-         if (this.deploymentManager == null && this.mainDeployer == null)
+         if (this.deploymentManager == null)
          {
             throw new IllegalStateException("Configuration must either provide " +
-                    "a ProfileService with a DeploymentManager or a MainDeployer");
+                    "a ProfileService with a DeploymentManager or directly inject a DeploymentManager");
          }
          
          StringTokenizer tokenizer = new StringTokenizer(uris, ",");
@@ -164,18 +162,12 @@
          
          scan();
          
-         if (this.deploymentManager == null)
-         {
-            this.mainDeployer.process();
-            // We don't call mainDeployer.checkComplete() as we may be in the
-            // middle of the main shutdown startup deployments; i.e. not expected to be complete 
-         }
-         else
-         {
-            String[] allUploaded = getAllUploadedNames();
+         String[] allUploaded = getAllUploadedNames();
             
-            this.uploadedNames.clear();
-            
+         this.uploadedNames.clear();
+         
+         if (allUploaded.length > 0) // JBAS-6441
+         {
             DeploymentProgress progress = this.deploymentManager.stop(DEPLOYMENT_PHASE, allUploaded);
             progress.run();
             progress = this.deploymentManager.undeploy(DEPLOYMENT_PHASE, allUploaded);
@@ -192,43 +184,29 @@
    protected VFSDeployment add(Profile profile, VirtualFile file) throws Exception
    {
       VFSDeployment deployment = createDeployment(file);
-      if (this.deploymentManager == null)
-      {         
-         if(profile.hasDeployment(deployment.getName()) == false)
-         {
-            profile.addDeployment(deployment);
-            this.mainDeployer.addDeployment(deployment);
-         }
-      }
-      else 
-      {
-         activateProfile(profile.getKey());
+
+      activateProfile(profile.getKey());
          
-         String name = file.getPathName();
-         DeploymentProgress progress = this.deploymentManager.distribute(name, DEPLOYMENT_PHASE, file.toURL());
-         progress.run();
-         
-         String[] repoNames = progress.getDeploymentID().getRepositoryNames();
-         if (repoNames != null)
+      String name = file.getPathName();
+      DeploymentProgress progress = this.deploymentManager.distribute(name, DEPLOYMENT_PHASE, file.toURL(), true);
+      progress.run();
+      
+      String[] repoNames = progress.getDeploymentID().getRepositoryNames();
+      if (repoNames != null)
+      {
+         for (String repoName : repoNames)
          {
-            for (String repoName : repoNames)
-            {
-               uploadedNames.add(repoName);
-            }
+            uploadedNames.add(repoName);
          }
       }
+
       return deployment;
    }
 
    @Override
    protected void remove(Profile profile, String name) throws Exception
    {
-      if(this.deploymentManager == null && profile.hasDeployment(name))
-      {
-         profile.removeDeployment(name);
-         this.mainDeployer.removeDeployment(name);
-      }
-      // else we deal with everything at the end of undeploySingletons
+      // we deal with everything at the end of undeploySingletons
    }
    
    // ----------------------------------------------------------------  Private




More information about the jboss-cvs-commits mailing list