[jboss-cvs] JBossAS SVN: r60016 - in trunk/system/src/main/org/jboss: system/server/profile/basic and 2 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Fri Jan 26 05:39:17 EST 2007


Author: wolfc
Date: 2007-01-26 05:39:17 -0500 (Fri, 26 Jan 2007)
New Revision: 60016

Modified:
   trunk/system/src/main/org/jboss/profileservice/spi/Profile.java
   trunk/system/src/main/org/jboss/system/server/profile/basic/ProfileImpl.java
   trunk/system/src/main/org/jboss/system/server/profile/repository/ProfileImpl.java
   trunk/system/src/main/org/jboss/system/server/profileservice/VFSBootstrapScannerImpl.java
   trunk/system/src/main/org/jboss/system/server/profileservice/VFSDeployerScannerImpl.java
   trunk/system/src/main/org/jboss/system/server/profileservice/VFSDeploymentScannerImpl.java
Log:
JBCTS-509: fixed NPE by adding hasDeployment to Profile

Modified: trunk/system/src/main/org/jboss/profileservice/spi/Profile.java
===================================================================
--- trunk/system/src/main/org/jboss/profileservice/spi/Profile.java	2007-01-26 05:55:29 UTC (rev 60015)
+++ trunk/system/src/main/org/jboss/profileservice/spi/Profile.java	2007-01-26 10:39:17 UTC (rev 60016)
@@ -153,4 +153,12 @@
     */
    public Map<String, Object> getConfig();
 
+   /**
+    * Checks whether a deployment context is available in the basic profile service.
+    * 
+    * @param    name    the name of the deployment
+    * @param    phase   optionally a deployment phase, if null search all
+    * @return   true if the deployment is found or false otherwise
+    */
+   public boolean hasDeployment(String name, DeploymentPhase phase);
 }

Modified: trunk/system/src/main/org/jboss/system/server/profile/basic/ProfileImpl.java
===================================================================
--- trunk/system/src/main/org/jboss/system/server/profile/basic/ProfileImpl.java	2007-01-26 05:55:29 UTC (rev 60015)
+++ trunk/system/src/main/org/jboss/system/server/profile/basic/ProfileImpl.java	2007-01-26 10:39:17 UTC (rev 60016)
@@ -129,8 +129,14 @@
    
    }
 
-   public DeploymentContext getDeployment(String name, DeploymentPhase phase)
-      throws NoSuchDeploymentException
+   /**
+    * Find a deployment context from the basic profile service.
+    * 
+    * @param    name    the name of the deployment
+    * @param    phase   optionally a deployment phase, if null search all
+    * @return   the deployment or null if not found
+    */
+   private DeploymentContext findDeployment(String name, DeploymentPhase phase)
    {
       DeploymentContext ctx = null;
       if( phase == null )
@@ -157,12 +163,39 @@
                break;
          }
       }
+      return ctx;
+   }
+   
+   /**
+    * Get a deployment context from the basic profile service.
+    * 
+    * @param    name    the name of the deployment
+    * @param    phase   optionally a deployment phase, if null search all
+    * @return   the deployment or NoSuchDeploymentException
+    * @throws   NoSuchDeploymentException   if the deployment can't be found
+    */
+   public DeploymentContext getDeployment(String name, DeploymentPhase phase)
+      throws NoSuchDeploymentException
+   {
+      DeploymentContext ctx = findDeployment(name, phase);
       // Make sure we don't return null
       if( ctx == null )
          throw new NoSuchDeploymentException("name="+name+", phase="+phase);
       return ctx;
    }
 
+   /**
+    * Checks whether a deployment context is available in the basic profile service.
+    * 
+    * @param    name    the name of the deployment
+    * @param    phase   optionally a deployment phase, if null search all
+    * @return   true if the deployment is found or false otherwise
+    */
+   public boolean hasDeployment(String name, DeploymentPhase phase)
+   {
+      return findDeployment(name, phase) != null;
+   }
+   
    public Set<String> getDeploymentNames(DeploymentPhase phase)
    {
       HashSet<String> names = new HashSet<String>();

Modified: trunk/system/src/main/org/jboss/system/server/profile/repository/ProfileImpl.java
===================================================================
--- trunk/system/src/main/org/jboss/system/server/profile/repository/ProfileImpl.java	2007-01-26 05:55:29 UTC (rev 60015)
+++ trunk/system/src/main/org/jboss/system/server/profile/repository/ProfileImpl.java	2007-01-26 10:39:17 UTC (rev 60016)
@@ -30,6 +30,7 @@
 import org.jboss.profileservice.spi.DeploymentRepository;
 import org.jboss.profileservice.spi.NoSuchDeploymentException;
 import org.jboss.profileservice.spi.Profile;
+import org.jboss.profileservice.spi.Profile.DeploymentPhase;
 import org.jboss.util.JBossObject;
 import org.jboss.virtual.VFS;
 import org.jboss.virtual.VirtualFile;
@@ -132,4 +133,23 @@
       // TODO Auto-generated method stub
       return null;
    }
+   
+   public boolean hasDeployment(String name, DeploymentPhase phase)
+   {
+      // TODO: Wolf: needs refactoring / review
+      try
+      {
+         getDeployment(name, phase);
+         return true;
+      }
+      catch(NoSuchDeploymentException e)
+      {
+         return false;
+      }
+      catch(Exception e)
+      {
+         log.warn("getDeployment return exception", e);
+         return false;
+      }
+   }
 }

Modified: trunk/system/src/main/org/jboss/system/server/profileservice/VFSBootstrapScannerImpl.java
===================================================================
--- trunk/system/src/main/org/jboss/system/server/profileservice/VFSBootstrapScannerImpl.java	2007-01-26 05:55:29 UTC (rev 60015)
+++ trunk/system/src/main/org/jboss/system/server/profileservice/VFSBootstrapScannerImpl.java	2007-01-26 10:39:17 UTC (rev 60016)
@@ -38,7 +38,7 @@
    protected DeploymentContext add(Profile profile, VirtualFile file) throws Exception
    {
       DeploymentContext deployment = new AbstractDeploymentContext(file);
-      if( profile.getDeployment(deployment.getName(), DeploymentPhase.BOOTSTRAP) == null )
+      if( !profile.hasDeployment(deployment.getName(), DeploymentPhase.BOOTSTRAP) )
             profile.addDeployment(deployment, DeploymentPhase.BOOTSTRAP);
       return deployment;
    }

Modified: trunk/system/src/main/org/jboss/system/server/profileservice/VFSDeployerScannerImpl.java
===================================================================
--- trunk/system/src/main/org/jboss/system/server/profileservice/VFSDeployerScannerImpl.java	2007-01-26 05:55:29 UTC (rev 60015)
+++ trunk/system/src/main/org/jboss/system/server/profileservice/VFSDeployerScannerImpl.java	2007-01-26 10:39:17 UTC (rev 60016)
@@ -38,7 +38,7 @@
    protected DeploymentContext add(Profile profile, VirtualFile file) throws Exception
    {
       DeploymentContext deployment = new AbstractDeploymentContext(file);
-      if( profile.getDeployment(deployment.getName(), DeploymentPhase.DEPLOYER) == null )
+      if( !profile.hasDeployment(deployment.getName(), DeploymentPhase.DEPLOYER) )
          profile.addDeployment(deployment, DeploymentPhase.DEPLOYER);
       return deployment;
    }

Modified: trunk/system/src/main/org/jboss/system/server/profileservice/VFSDeploymentScannerImpl.java
===================================================================
--- trunk/system/src/main/org/jboss/system/server/profileservice/VFSDeploymentScannerImpl.java	2007-01-26 05:55:29 UTC (rev 60015)
+++ trunk/system/src/main/org/jboss/system/server/profileservice/VFSDeploymentScannerImpl.java	2007-01-26 10:39:17 UTC (rev 60016)
@@ -38,7 +38,7 @@
    protected DeploymentContext add(Profile profile, VirtualFile file) throws Exception
    {
       DeploymentContext deployment = new AbstractDeploymentContext(file);
-      if( profile.getDeployment(deployment.getName(), DeploymentPhase.APPLICATION) == null )
+      if( !profile.hasDeployment(deployment.getName(), DeploymentPhase.APPLICATION) )
          profile.addDeployment(deployment, DeploymentPhase.APPLICATION);
       return deployment;
    }




More information about the jboss-cvs-commits mailing list