[jboss-cvs] JBossAS SVN: r85603 - in branches/Branch_5_0/system/src/main/org/jboss/system: tools and 1 other directory.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Sat Mar 7 14:25:19 EST 2009


Author: alesj
Date: 2009-03-07 14:25:19 -0500 (Sat, 07 Mar 2009)
New Revision: 85603

Modified:
   branches/Branch_5_0/system/src/main/org/jboss/system/server/profileservice/repository/SerializableDeploymentRepository.java
   branches/Branch_5_0/system/src/main/org/jboss/system/tools/AbstractDeploymentRepositoryAdapter.java
   branches/Branch_5_0/system/src/main/org/jboss/system/tools/DeploymentRepositoryAdapter.java
   branches/Branch_5_0/system/src/main/org/jboss/system/tools/DeploymentScanner.java
   branches/Branch_5_0/system/src/main/org/jboss/system/tools/DeploymentScannerMBean.java
   branches/Branch_5_0/system/src/main/org/jboss/system/tools/SerializableDeploymentRepositoryAdapter.java
Log:
[JBAS-6330]; port 5_x changes.
FIXME! on repository locking.

Modified: branches/Branch_5_0/system/src/main/org/jboss/system/server/profileservice/repository/SerializableDeploymentRepository.java
===================================================================
--- branches/Branch_5_0/system/src/main/org/jboss/system/server/profileservice/repository/SerializableDeploymentRepository.java	2009-03-07 18:07:20 UTC (rev 85602)
+++ branches/Branch_5_0/system/src/main/org/jboss/system/server/profileservice/repository/SerializableDeploymentRepository.java	2009-03-07 19:25:19 UTC (rev 85603)
@@ -420,6 +420,7 @@
       return flags;
    }
 
+   // FIXME!! http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4215949#4215949
    public void acquireDeploymentContentLock()
    {
       contentLock.writeLock().lock();

Modified: branches/Branch_5_0/system/src/main/org/jboss/system/tools/AbstractDeploymentRepositoryAdapter.java
===================================================================
--- branches/Branch_5_0/system/src/main/org/jboss/system/tools/AbstractDeploymentRepositoryAdapter.java	2009-03-07 18:07:20 UTC (rev 85602)
+++ branches/Branch_5_0/system/src/main/org/jboss/system/tools/AbstractDeploymentRepositoryAdapter.java	2009-03-07 19:25:19 UTC (rev 85603)
@@ -21,6 +21,13 @@
  */
 package org.jboss.system.tools;
 
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+import org.jboss.deployers.vfs.spi.client.VFSDeployment;
+import org.jboss.logging.Logger;
 import org.jboss.profileservice.spi.DeploymentRepository;
 
 /**
@@ -30,6 +37,7 @@
  */
 public abstract class AbstractDeploymentRepositoryAdapter implements DeploymentRepositoryAdapter
 {
+   protected Logger log = Logger.getLogger(getClass());
    private DeploymentRepository repository;
 
    protected AbstractDeploymentRepositoryAdapter(DeploymentRepository repository)
@@ -59,4 +67,25 @@
    {
       repository.releaseDeploymentContentLock();
    }
+
+   public URL[] listDeployedURLs()
+   {
+      List<URL> urls = new ArrayList<URL>();
+      try
+      {
+         Collection<VFSDeployment> deployments = repository.getDeployments();
+         if (deployments != null && deployments.isEmpty() == false)
+         {
+            for (VFSDeployment deployment : deployments)
+            {
+               urls.add(deployment.getRoot().toURL());
+            }
+         }
+      }
+      catch (Exception e)
+      {
+         log.warn("Exception getting deployments: " + e);
+      }
+      return urls.toArray(new URL[urls.size()]);
+   }
 }
\ No newline at end of file

Modified: branches/Branch_5_0/system/src/main/org/jboss/system/tools/DeploymentRepositoryAdapter.java
===================================================================
--- branches/Branch_5_0/system/src/main/org/jboss/system/tools/DeploymentRepositoryAdapter.java	2009-03-07 18:07:20 UTC (rev 85602)
+++ branches/Branch_5_0/system/src/main/org/jboss/system/tools/DeploymentRepositoryAdapter.java	2009-03-07 19:25:19 UTC (rev 85603)
@@ -56,4 +56,20 @@
     * @throws URISyntaxException for any error
     */
    void removeURL(URL url) throws URISyntaxException;
+
+   /**
+    * Does this repository contain a url.
+    *
+    * @param url the url
+    * @return true if the url is contained
+    * @throws URISyntaxException for any error
+    */
+   boolean hasURL(URL url) throws URISyntaxException;
+
+   /**
+    * List deployed urls.
+    *
+    * @return the list of deployed urls
+    */
+   URL[] listDeployedURLs();
 }
\ No newline at end of file

Modified: branches/Branch_5_0/system/src/main/org/jboss/system/tools/DeploymentScanner.java
===================================================================
--- branches/Branch_5_0/system/src/main/org/jboss/system/tools/DeploymentScanner.java	2009-03-07 18:07:20 UTC (rev 85602)
+++ branches/Branch_5_0/system/src/main/org/jboss/system/tools/DeploymentScanner.java	2009-03-07 19:25:19 UTC (rev 85603)
@@ -77,24 +77,57 @@
 
    public void addURL(String url) throws MalformedURLException, URISyntaxException
    {
+      if (url == null)
+         throw new IllegalArgumentException("Null url");
+
       addURL(makeURL(url));
    }
 
    public void addURL(URL url) throws URISyntaxException
    {
+      if (url == null)
+         throw new IllegalArgumentException("Null url");
+
       adapter.addURL(url);
    }
 
    public void removeURL(String url) throws MalformedURLException, URISyntaxException
    {
+      if (url == null)
+         throw new IllegalArgumentException("Null url");
+
       removeURL(makeURL(url));
    }
 
    public void removeURL(URL url) throws URISyntaxException
    {
+      if (url == null)
+         throw new IllegalArgumentException("Null url");
+
       adapter.removeURL(url);
    }
 
+   public boolean hasURL(String url) throws MalformedURLException, URISyntaxException
+   {
+      if (url == null)
+         throw new IllegalArgumentException("Null url");
+
+      return hasURL(makeURL(url));
+   }
+
+   public boolean hasURL(URL url) throws URISyntaxException
+   {
+      if (url == null)
+         throw new IllegalArgumentException("Null url");
+
+      return adapter.hasURL(url);
+   }
+
+   public URL[] listDeployedURLs()
+   {
+      return adapter.listDeployedURLs();
+   }
+
    /**
     * A helper to make a URL from a full url, or a filespec.
     *

Modified: branches/Branch_5_0/system/src/main/org/jboss/system/tools/DeploymentScannerMBean.java
===================================================================
--- branches/Branch_5_0/system/src/main/org/jboss/system/tools/DeploymentScannerMBean.java	2009-03-07 18:07:20 UTC (rev 85602)
+++ branches/Branch_5_0/system/src/main/org/jboss/system/tools/DeploymentScannerMBean.java	2009-03-07 19:25:19 UTC (rev 85603)
@@ -75,4 +75,30 @@
     * @throws URISyntaxException for any error
     */
    void removeURL(URL url) throws URISyntaxException;
+
+   /**
+    * Does this repository contain a url.
+    *
+    * @param url the url
+    * @return true if the url is contained
+    * @throws MalformedURLException for any error
+    * @throws URISyntaxException for any error
+    */
+   boolean hasURL(String url) throws MalformedURLException, URISyntaxException;
+
+   /**
+    * Does this repository contain a url.
+    *
+    * @param url the url
+    * @return true if the url is contained
+    * @throws URISyntaxException for any error
+    */
+   boolean hasURL(URL url) throws URISyntaxException;
+
+   /**
+    * List deployed urls.
+    *
+    * @return the list of deployed urls
+    */
+   URL[] listDeployedURLs();
 }
\ No newline at end of file

Modified: branches/Branch_5_0/system/src/main/org/jboss/system/tools/SerializableDeploymentRepositoryAdapter.java
===================================================================
--- branches/Branch_5_0/system/src/main/org/jboss/system/tools/SerializableDeploymentRepositoryAdapter.java	2009-03-07 18:07:20 UTC (rev 85602)
+++ branches/Branch_5_0/system/src/main/org/jboss/system/tools/SerializableDeploymentRepositoryAdapter.java	2009-03-07 19:25:19 UTC (rev 85603)
@@ -65,4 +65,17 @@
       }
       repository.setApplicationURIs(temp.toArray(new URI[temp.size()]));
    }
+
+   public boolean hasURL(URL url) throws URISyntaxException
+   {
+      SerializableDeploymentRepository repository = (SerializableDeploymentRepository)getRepository();
+      URI toURI = url.toURI();
+      URI[] uris = repository.getApplicationURIs();
+      for (URI uri : uris)
+      {
+         if (uri.equals(toURI))
+            return true;
+      }
+      return false;
+   }
 }
\ No newline at end of file




More information about the jboss-cvs-commits mailing list