[jboss-cvs] JBossAS SVN: r65030 - trunk/system/src/main/org/jboss/system/server/profileservice/repository.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Tue Sep 4 01:04:01 EDT 2007


Author: scott.stark at jboss.org
Date: 2007-09-04 01:04:01 -0400 (Tue, 04 Sep 2007)
New Revision: 65030

Modified:
   trunk/system/src/main/org/jboss/system/server/profileservice/repository/SerializableDeploymentRepository.java
   trunk/system/src/main/org/jboss/system/server/profileservice/repository/SerializableDeploymentRepositoryFactory.java
Log:
Support multiple application dirs via the applicationURIs property

Modified: trunk/system/src/main/org/jboss/system/server/profileservice/repository/SerializableDeploymentRepository.java
===================================================================
--- trunk/system/src/main/org/jboss/system/server/profileservice/repository/SerializableDeploymentRepository.java	2007-09-04 05:03:33 UTC (rev 65029)
+++ trunk/system/src/main/org/jboss/system/server/profileservice/repository/SerializableDeploymentRepository.java	2007-09-04 05:04:01 UTC (rev 65030)
@@ -81,7 +81,7 @@
    /** The deployers phase deployments dir */
    private File deployersDir;
    /** The application phase deployments dir */
-   private File applicationDir;
+   private File[] applicationDirs;
    /** The deployment post edit */
    private File adminEditsRoot;
    /** The profile key this repository is associated with */
@@ -95,10 +95,11 @@
    /** The {@link VFSDeployment#getTransientManagedObjects()} serializer */
    private AttachmentsSerializer serializer;
 
-   public SerializableDeploymentRepository(File root, ProfileKey key)
+   public SerializableDeploymentRepository(File root, URI[] appURIs, ProfileKey key)
    {
       this.root = root;
       this.key = key;
+      this.setApplicationURIs(appURIs);
    }
 
    public AttachmentsSerializer getSerializer()
@@ -110,6 +111,26 @@
       this.serializer = serializer;
    }
 
+   public URI[] getApplicationURIs()
+   {
+      URI[] appURIs = new URI[applicationDirs.length];
+      for (int n = 0; n < applicationDirs.length; n ++)
+      {
+         File applicationDir = applicationDirs[n];
+         appURIs[n] = applicationDir.toURI();
+      }
+      return appURIs;
+   }
+   public void setApplicationURIs(URI[] uris)
+   {
+      applicationDirs = new File[uris.length];
+      for (int n = 0; n < uris.length; n ++)
+      {
+         URI uri = uris[n];
+         applicationDirs[n] = new File(uri);
+      }
+   }
+
    public boolean exists()
    {
       File profileRoot = new File(root, key.getName());
@@ -144,7 +165,7 @@
             this.setDeployersURI(uri);
             break;
          case APPLICATION:
-            this.setApplicationURI(uri);
+            this.setApplicationURIs(new URI[]{uri});
             break;
       }
    }
@@ -327,18 +348,21 @@
             // TODO: this could check metadata files modifications as well
          }
          // Now check for additions
-         VFS deployVFS = VFS.getVFS(applicationDir.toURI());
-         VirtualFile deployDir = deployVFS.getRoot();
-         List<VirtualFile> children = deployDir.getChildren();
-         for(VirtualFile vf : children)
+         for (File applicationDir : applicationDirs)
          {
-            URI uri = vf.toURI();
-            if( applicationCtxs.containsKey(uri.toString()) == false )
+            VFS deployVFS = VFS.getVFS(applicationDir.toURI());
+            VirtualFile deployDir = deployVFS.getRoot();
+            List<VirtualFile> children = deployDir.getChildren();
+            for(VirtualFile vf : children)
             {
-               VFSDeployment ctx = loadDeploymentData(vf);
-               ModificationInfo info = new ModificationInfo(ctx, vf.getLastModified(), ModifyStatus.ADDED);
-               modified.add(info);
-               applicationCtxs.put(vf.getName(), ctx);
+               URI uri = vf.toURI();
+               if( applicationCtxs.containsKey(uri.toString()) == false )
+               {
+                  VFSDeployment ctx = loadDeploymentData(vf);
+                  ModificationInfo info = new ModificationInfo(ctx, vf.getLastModified(), ModifyStatus.ADDED);
+                  modified.add(info);
+                  applicationCtxs.put(vf.getName(), ctx);
+               }
             }
          }
       }
@@ -416,9 +440,11 @@
          throw new IOException("Failed to create profile deployers dir: "+deployersDir);
 
       // server/{name}/deploy
-      applicationDir = new File(profileRoot, "deploy");
-      if( applicationDir.mkdirs() == false )
-         throw new IOException("Failed to create profile deploy dir: "+applicationDir);
+      for (File applicationDir : applicationDirs)
+      {
+         if( applicationDir.mkdirs() == false )
+            throw new IOException("Failed to create profile deploy dir: "+applicationDir);
+      }
       // server/{name}/lib
       libDir = new File(profileRoot, "lib");
       if( libDir.mkdirs() == false )
@@ -458,9 +484,11 @@
          throw new FileNotFoundException("Profile contains no deployers dir: "+deployersDir);
 
       // server/{name}/deploy
-      applicationDir = new File(profileRoot, "deploy");
-      if( applicationDir.exists() == false )
-         throw new FileNotFoundException("Profile contains no deploy dir: "+applicationDir);
+      for (File applicationDir : applicationDirs)
+      {
+         if( applicationDir.exists() == false )
+            throw new FileNotFoundException("Profile contains no deploy dir: "+applicationDir);
+      }
 
       adminEditsRoot = new File(profileRoot, "profile/edits");
 
@@ -476,8 +504,11 @@
       }
       VFS deployersVFS = VFS.getVFS(deployersDir.toURI());
       loadDeployers(deployersVFS.getRoot());
-      VFS deployVFS = VFS.getVFS(applicationDir.toURI());
-      loadApplications(deployVFS.getRoot());
+      for (File applicationDir : applicationDirs)
+      {
+         VFS deployVFS = VFS.getVFS(applicationDir.toURI());
+         loadApplications(deployVFS.getRoot());
+      }
    }
 
    /**
@@ -548,9 +579,9 @@
    }
    protected URI getApplicationURI()
    {
+      File applicationDir = applicationDirs[0];
       return applicationDir.toURI();
    }
-
    protected VFSDeployment getDeployer(String vfsPath)
       throws Exception
    {
@@ -599,6 +630,8 @@
    }
    protected VFSDeployment removeApplication(String vfsPath) throws IOException
    {
+      // Find the application dir
+      File applicationDir = applicationDirs[0];
       File deploymentFile = new File(applicationDir, vfsPath);
       if( Files.delete(deploymentFile) == false )
          throw new IOException("Failed to delete: "+deploymentFile);
@@ -612,10 +645,6 @@
    {
       deployersDir = new File(uri);
    }
-   protected void setApplicationURI(URI uri)
-   {
-      applicationDir = new File(uri);
-   }
 
    /**
     * Load the bootstrap descriptors under bootstrapDir:

Modified: trunk/system/src/main/org/jboss/system/server/profileservice/repository/SerializableDeploymentRepositoryFactory.java
===================================================================
--- trunk/system/src/main/org/jboss/system/server/profileservice/repository/SerializableDeploymentRepositoryFactory.java	2007-09-04 05:03:33 UTC (rev 65029)
+++ trunk/system/src/main/org/jboss/system/server/profileservice/repository/SerializableDeploymentRepositoryFactory.java	2007-09-04 05:04:01 UTC (rev 65030)
@@ -22,6 +22,7 @@
 package org.jboss.system.server.profileservice.repository;
 
 import java.io.File;
+import java.net.URI;
 
 import org.jboss.profileservice.spi.AttachmentsSerializer;
 import org.jboss.profileservice.spi.DeploymentRepository;
@@ -39,6 +40,9 @@
 {
    /** The server root container the deployments */
    private File root;
+   /** The URIs for the application deployments */
+   private URI[] appURIs = {};
+   /** */
    private AttachmentsSerializer serializer;
 
    /**
@@ -60,6 +64,15 @@
       this.root = root;
    }
 
+   public URI[] getApplicationURIs()
+   {
+      return appURIs;
+   }
+   public void setApplicationURIs(URI[] appURIs)
+   {
+      this.appURIs = appURIs;
+   }
+
    public AttachmentsSerializer getSerializer()
    {
       return serializer;
@@ -72,7 +85,7 @@
 
    public DeploymentRepository getDeploymentRepository(ProfileKey key)
    {
-      SerializableDeploymentRepository repo = new SerializableDeploymentRepository(root, key);
+      SerializableDeploymentRepository repo = new SerializableDeploymentRepository(root, appURIs, key);
       repo.setSerializer(serializer);
       return repo;
    }




More information about the jboss-cvs-commits mailing list