[jboss-cvs] JBossAS SVN: r85553 - in branches/Branch_5_x: 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
Fri Mar 6 11:54:05 EST 2009


Author: alesj
Date: 2009-03-06 11:54:04 -0500 (Fri, 06 Mar 2009)
New Revision: 85553

Added:
   branches/Branch_5_x/system/src/main/org/jboss/system/tools/DeploymentRepositoryAdapter.java
   branches/Branch_5_x/system/src/main/org/jboss/system/tools/ProfileServiceDeploymentRepositoryAdapter.java
Modified:
   branches/Branch_5_x/profileservice/src/resources/hdscanner-jboss-beans.xml
   branches/Branch_5_x/system/src/main/org/jboss/system/tools/DeploymentScanner.java
Log:
[JBAS-6330]; bring back adapter.

Modified: branches/Branch_5_x/profileservice/src/resources/hdscanner-jboss-beans.xml
===================================================================
--- branches/Branch_5_x/profileservice/src/resources/hdscanner-jboss-beans.xml	2009-03-06 16:08:02 UTC (rev 85552)
+++ branches/Branch_5_x/profileservice/src/resources/hdscanner-jboss-beans.xml	2009-03-06 16:54:04 UTC (rev 85553)
@@ -16,10 +16,18 @@
         <property name="scanPeriod">5000</property>
         <property name="scanThreadName">HDScanner</property>
     </bean>
-    
+
     <bean name="ToolsDeploymentScanner" class="org.jboss.system.tools.DeploymentScanner">
-     <property name="serverConfig"><inject bean="JBossServer" property="config"/></property>
-     <property name="profileService"><inject bean="ProfileService"/></property>
-   </bean>
-    
+      <constructor>
+        <parameter><inject bean="ProfileServiceDeploymentRepositoryAdapter"/></parameter>
+      </constructor>
+      <property name="serverConfig"><inject bean="JBossServer" property="config"/></property>
+    </bean>
+
+    <bean name="ProfileServiceDeploymentRepositoryAdapter" class="org.jboss.system.tools.ProfileServiceDeploymentRepositoryAdapter">
+      <constructor>
+        <parameter><inject bean="ProfileService"/></parameter>
+      </constructor>
+    </bean>
+
 </deployment>

Added: branches/Branch_5_x/system/src/main/org/jboss/system/tools/DeploymentRepositoryAdapter.java
===================================================================
--- branches/Branch_5_x/system/src/main/org/jboss/system/tools/DeploymentRepositoryAdapter.java	                        (rev 0)
+++ branches/Branch_5_x/system/src/main/org/jboss/system/tools/DeploymentRepositoryAdapter.java	2009-03-06 16:54:04 UTC (rev 85553)
@@ -0,0 +1,59 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.system.tools;
+
+import java.net.URL;
+import java.net.URISyntaxException;
+
+/**
+ * Deployment repository adapter.
+ *
+ * @author <a href="mailto:ales.justin at jboss.org">Ales Justin</a>
+ */
+public interface DeploymentRepositoryAdapter
+{
+   /**
+    * Suspend scan.
+    */
+   void suspend();
+
+   /**
+    * Resume scan.
+    */
+   void resume();
+
+   /**
+    * Add url.
+    *
+    * @param url the url
+    * @throws URISyntaxException for any error
+    */
+   void addURL(URL url) throws URISyntaxException;
+
+   /**
+    * Remove url.
+    *
+    * @param url the url
+    * @throws URISyntaxException for any error
+    */
+   void removeURL(URL url) throws URISyntaxException;
+}
\ No newline at end of file

Modified: branches/Branch_5_x/system/src/main/org/jboss/system/tools/DeploymentScanner.java
===================================================================
--- branches/Branch_5_x/system/src/main/org/jboss/system/tools/DeploymentScanner.java	2009-03-06 16:08:02 UTC (rev 85552)
+++ branches/Branch_5_x/system/src/main/org/jboss/system/tools/DeploymentScanner.java	2009-03-06 16:54:04 UTC (rev 85553)
@@ -21,126 +21,59 @@
  */
 package org.jboss.system.tools;
 
+import java.net.URL;
 import java.net.MalformedURLException;
-import java.net.URI;
 import java.net.URISyntaxException;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.List;
 
 import org.jboss.aop.microcontainer.aspects.jmx.JMX;
 import org.jboss.beans.metadata.api.annotations.Start;
 import org.jboss.beans.metadata.api.annotations.Stop;
-import org.jboss.bootstrap.spi.ServerConfig;
-import org.jboss.logging.Logger;
-import org.jboss.profileservice.spi.ModificationInfo;
-import org.jboss.profileservice.spi.MutableProfile;
-import org.jboss.profileservice.spi.ProfileDeployment;
-import org.jboss.profileservice.spi.ProfileKey;
-import org.jboss.profileservice.spi.ProfileService;
-import org.jboss.system.server.profileservice.repository.MutableDeploymentRepository;
 import org.jboss.util.StringPropertyReplacer;
+import org.jboss.bootstrap.spi.ServerConfig;
 
 /**
  * Deployment scanner impl - hooking into ProfileService.
  *
  * @author <a href="mailto:ales.justin at jboss.org">Ales Justin</a>
- * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
  */
 @JMX(name = "jboss.deployment:flavor=URL,type=DeploymentScanner", exposedInterface = DeploymentScannerMBean.class, registerDirectly = true)
 public class DeploymentScanner implements DeploymentScannerMBean
 {
-   
-   private static final ProfileKey profileName = new ProfileKey("deployment-scanner-profile"); 
    private ServerConfig serverConfig;
    private URL serverHomeURL;
-   private ProfileService ps;
-   private DeploymentScannerProfile profile;
-   private static final Logger log = Logger.getLogger(DeploymentScanner.class);
-   
-   public ProfileService getProfileService()
+
+   private DeploymentRepositoryAdapter adapter;
+
+   public DeploymentScanner(DeploymentRepositoryAdapter adapter)
    {
-      return ps;
+      if (adapter == null)
+         throw new IllegalArgumentException("Null adapter");
+
+      this.adapter = adapter;
    }
-   
-   public void setProfileService(ProfileService ps)
-   {
-      this.ps = ps;
-   }
 
    /**
     * Create server home.
     */
-   public void create() throws Exception
+   public void create()
    {
       if (serverConfig == null)
          throw new IllegalArgumentException("Null server config.");
 
       serverHomeURL = serverConfig.getServerHomeURL();
-      this.profile = new DeploymentScannerProfile();
-      // Create the profile
-      registerProfile();
    }
-   
-   public void registerProfile() throws Exception
-   {
-      if(this.ps == null)
-         throw new IllegalStateException("Null profile service.");
-      
-      // Register
-      this.ps.registerProfile(profile);
-      // Activate
-      {
-         log.debug("activating deployment scanner profile " + profileName);
-         this.ps.activateProfile(profileName);
-      }
-   }
-   
+
    @Start(ignored = true)
    public void start()
    {
-      profile.enableModifiedDeploymentChecks(true);
+      adapter.resume();
    }
 
    @Stop(ignored = true)
    public void stop()
    {
-      profile.enableModifiedDeploymentChecks(false);      
+      adapter.suspend();
    }
-   
-   public void destroy()
-   {
-      stopProfile();
-   }
-   
-   /**
-    * Stop deactivates and unregisters the transient deployments profile.
-    */
-   public void stopProfile()
-   {
-      try
-      {
-         // Deactivate
-         log.debug("deactivating deployment scanner profile: " + profileName);
-         this.ps.deactivateProfile(profileName);
-      }
-      catch(Exception e)
-      {
-         log.debug("Failed to deactivate deployment scanner profile: ", e);
-      }
-      try
-      {
-         // Unregister
-         log.debug("unregistering transient profile: " + profileName);
-         this.ps.unregisterProfile(profileName);
-      }
-      catch(Exception e)
-      {
-         log.debug("Failed to unregister deployment scanner profile: ", e);
-      }
-   }
 
    public void addURL(String url) throws MalformedURLException, URISyntaxException
    {
@@ -149,7 +82,7 @@
 
    public void addURL(URL url) throws URISyntaxException
    {
-      
+      adapter.addURL(url);
    }
 
    public void removeURL(String url) throws MalformedURLException, URISyntaxException
@@ -159,7 +92,7 @@
 
    public void removeURL(URL url) throws URISyntaxException
    {
-      // FIXME
+      adapter.removeURL(url);
    }
 
    /**
@@ -185,73 +118,4 @@
    {
       this.serverConfig = serverConfig;
    }
-   
-   public static class DeploymentScannerProfile extends MutableDeploymentRepository implements MutableProfile
-   {
-
-      private List<URI> uris = new ArrayList<URI>();
-      
-      private volatile boolean enableHotDeployment;
-
-      public DeploymentScannerProfile()
-      {
-         super(profileName, new URI[0]);
-      }
-      
-      @Override
-      public URI[] getRepositoryURIs()
-      {
-         return this.uris.toArray(new URI[this.uris.size()]);
-      }
-      
-      public List<URI> getUris()
-      {
-         return uris;
-      }
-      
-      public void setUris(List<URI> uris)
-      {
-         this.uris = uris;
-      }
-      
-      public void addDeployment(ProfileDeployment deployment) throws Exception
-      {
-         super.addDeployment(deployment.getName(), deployment);  
-      }
-
-      public void enableModifiedDeploymentChecks(boolean flag)
-      {
-         this.enableHotDeployment = flag;
-      }
-      
-      @Override
-      public Collection<ModificationInfo> getModifiedDeployments() throws Exception
-      {
-         if(this.enableHotDeployment == false)
-            return Collections.emptySet();
-         return super.getModifiedDeployments();
-      }
-
-      public ProfileKey getKey()
-      {
-         return profileName;
-      }
-
-      public Collection<ProfileKey> getSubProfiles()
-      {
-         return Collections.emptySet();
-      }
-
-      public boolean hasDeployment(String name)
-      {
-         // FIXME
-         return false;
-      }
-
-      public boolean isMutable()
-      {
-         return true;
-      }
-      
-   }
 }

Copied: branches/Branch_5_x/system/src/main/org/jboss/system/tools/ProfileServiceDeploymentRepositoryAdapter.java (from rev 85545, branches/Branch_5_x/system/src/main/org/jboss/system/tools/DeploymentScanner.java)
===================================================================
--- branches/Branch_5_x/system/src/main/org/jboss/system/tools/ProfileServiceDeploymentRepositoryAdapter.java	                        (rev 0)
+++ branches/Branch_5_x/system/src/main/org/jboss/system/tools/ProfileServiceDeploymentRepositoryAdapter.java	2009-03-06 16:54:04 UTC (rev 85553)
@@ -0,0 +1,213 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.system.tools;
+
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+
+import org.jboss.logging.Logger;
+import org.jboss.profileservice.spi.ModificationInfo;
+import org.jboss.profileservice.spi.MutableProfile;
+import org.jboss.profileservice.spi.ProfileDeployment;
+import org.jboss.profileservice.spi.ProfileKey;
+import org.jboss.profileservice.spi.ProfileService;
+import org.jboss.system.server.profileservice.repository.MutableDeploymentRepository;
+
+/**
+ * Profile deployment repository adapter.
+ *
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
+ * @author <a href="mailto:ales.justin at jboss.org">Ales Justin</a>
+ */
+public class ProfileServiceDeploymentRepositoryAdapter implements DeploymentRepositoryAdapter
+{
+   private static final Logger log = Logger.getLogger(ProfileServiceDeploymentRepositoryAdapter.class);
+   private static final ProfileKey profileName = new ProfileKey("deployment-scanner-profile");
+
+   private ProfileService ps;
+   private DeploymentScannerProfile profile;
+
+   public ProfileServiceDeploymentRepositoryAdapter(ProfileService ps)
+   {
+      if (ps == null)
+         throw new IllegalArgumentException("Null profile service.");
+
+      this.ps = ps;
+   }
+
+   /**
+    * Create profile.
+    *
+    * @throws Exception for any error
+    */
+   public void create() throws Exception
+   {
+      this.profile = new DeploymentScannerProfile();
+      // Create the profile
+      registerProfile();
+   }
+
+   /**
+    * Stop profile.
+    */
+   public void destroy()
+   {
+      stopProfile();
+   }
+
+   /**
+    * Register profile.
+    *
+    * @throws Exception for any error
+    */
+   protected void registerProfile() throws Exception
+   {
+      if(this.ps == null)
+         throw new IllegalStateException("Null profile service.");
+
+      // Register
+      this.ps.registerProfile(profile);
+
+      // Activate
+      log.debug("Activating deployment scanner profile " + profileName);
+      this.ps.activateProfile(profileName);
+   }
+
+   public void resume()
+   {
+      profile.enableModifiedDeploymentChecks(true);
+   }
+
+   public void suspend()
+   {
+      profile.enableModifiedDeploymentChecks(false);
+   }
+
+   /**
+    * Stop deactivates and unregisters the transient deployments profile.
+    */
+   public void stopProfile()
+   {
+      try
+      {
+         // Deactivate
+         log.debug("Deactivating deployment scanner profile: " + profileName);
+         this.ps.deactivateProfile(profileName);
+      }
+      catch(Exception e)
+      {
+         log.debug("Failed to deactivate deployment scanner profile: ", e);
+      }
+      try
+      {
+         // Unregister
+         log.debug("Unregistering transient profile: " + profileName);
+         this.ps.unregisterProfile(profileName);
+      }
+      catch(Exception e)
+      {
+         log.debug("Failed to unregister deployment scanner profile: ", e);
+      }
+   }
+
+   public void addURL(URL url) throws URISyntaxException
+   {
+      // TODO
+   }
+
+   public void removeURL(URL url) throws URISyntaxException
+   {
+      // TODO
+   }
+
+   public static class DeploymentScannerProfile extends MutableDeploymentRepository implements MutableProfile
+   {
+      private List<URI> uris = new ArrayList<URI>();
+      private volatile boolean enableHotDeployment;
+
+      public DeploymentScannerProfile()
+      {
+         super(profileName, new URI[0]);
+      }
+
+      @Override
+      public URI[] getRepositoryURIs()
+      {
+         return this.uris.toArray(new URI[this.uris.size()]);
+      }
+
+      public List<URI> getUris()
+      {
+         return uris;
+      }
+
+      public void setUris(List<URI> uris)
+      {
+         this.uris = uris;
+      }
+
+      public void addDeployment(ProfileDeployment deployment) throws Exception
+      {
+         super.addDeployment(deployment.getName(), deployment);
+      }
+
+      public void enableModifiedDeploymentChecks(boolean flag)
+      {
+         this.enableHotDeployment = flag;
+      }
+
+      @Override
+      public Collection<ModificationInfo> getModifiedDeployments() throws Exception
+      {
+         if(this.enableHotDeployment == false)
+            return Collections.emptySet();
+
+         return super.getModifiedDeployments();
+      }
+
+      public ProfileKey getKey()
+      {
+         return profileName;
+      }
+
+      public Collection<ProfileKey> getSubProfiles()
+      {
+         return Collections.emptySet();
+      }
+
+      public boolean hasDeployment(String name)
+      {
+         // FIXME
+         return false;
+      }
+
+      public boolean isMutable()
+      {
+         return true;
+      }
+   }
+}
\ No newline at end of file




More information about the jboss-cvs-commits mailing list