[jboss-cvs] JBossAS SVN: r85364 - in branches/Branch_5_x: system/src/main/org/jboss/system and 1 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Thu Mar 5 17:56:02 EST 2009


Author: alesj
Date: 2009-03-05 17:56:02 -0500 (Thu, 05 Mar 2009)
New Revision: 85364

Added:
   branches/Branch_5_x/system/src/main/org/jboss/system/tools/
   branches/Branch_5_x/system/src/main/org/jboss/system/tools/AbstractDeploymentRepositoryAdapter.java
   branches/Branch_5_x/system/src/main/org/jboss/system/tools/DeploymentRepositoryAdapter.java
   branches/Branch_5_x/system/src/main/org/jboss/system/tools/DeploymentScanner.java
   branches/Branch_5_x/system/src/main/org/jboss/system/tools/DeploymentScannerMBean.java
   branches/Branch_5_x/system/src/main/org/jboss/system/tools/SerializableDeploymentRepositoryAdapter.java
Modified:
   branches/Branch_5_x/server/src/etc/conf/default/bootstrap/profile-repository.xml
Log:
[JBAS-6330]; tools deployment api.

Modified: branches/Branch_5_x/server/src/etc/conf/default/bootstrap/profile-repository.xml
===================================================================
--- branches/Branch_5_x/server/src/etc/conf/default/bootstrap/profile-repository.xml	2009-03-05 21:45:18 UTC (rev 85363)
+++ branches/Branch_5_x/server/src/etc/conf/default/bootstrap/profile-repository.xml	2009-03-05 22:56:02 UTC (rev 85364)
@@ -74,4 +74,17 @@
       <property name="matches">.make.state,.nse_depinfo,CVS,CVS.admin,RCS,RCSLOG,SCCS,TAGS,core,tags</property>
    </bean>
 
+   <bean name="SerializableDeploymentRepositoryAdapter" class="org.jboss.system.tools.SerializableDeploymentRepositoryAdapter">
+     <constructor>
+       <parameter><inject bean="ProfileService" property="deploymentRepository"/></parameter>
+     </constructor>
+   </bean>
+
+   <bean name="ToolsDeploymentScanner" class="org.jboss.system.tools.DeploymentScanner">
+     <constructor>
+       <parameter><inject bean="SerializableDeploymentRepositoryAdapter"/></parameter>
+     </constructor>
+     <property name="serverConfig"><inject bean="JBossServer" property="config"/></property>
+   </bean>
+
 </deployment>

Added: branches/Branch_5_x/system/src/main/org/jboss/system/tools/AbstractDeploymentRepositoryAdapter.java
===================================================================
--- branches/Branch_5_x/system/src/main/org/jboss/system/tools/AbstractDeploymentRepositoryAdapter.java	                        (rev 0)
+++ branches/Branch_5_x/system/src/main/org/jboss/system/tools/AbstractDeploymentRepositoryAdapter.java	2009-03-05 22:56:02 UTC (rev 85364)
@@ -0,0 +1,62 @@
+/*
+ * 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 org.jboss.profileservice.spi.DeploymentRepository;
+
+/**
+ * Abstract deployment repository adapter.
+ *
+ * @author <a href="mailto:ales.justin at jboss.org">Ales Justin</a>
+ */
+public abstract class AbstractDeploymentRepositoryAdapter implements DeploymentRepositoryAdapter
+{
+   private DeploymentRepository repository;
+
+   protected AbstractDeploymentRepositoryAdapter(DeploymentRepository repository)
+   {
+      if (repository == null)
+         throw new IllegalArgumentException("Null repository");
+
+      this.repository = repository;
+   }
+
+   /**
+    * Get repository.
+    *
+    * @return the repository
+    */
+   protected DeploymentRepository getRepository()
+   {
+      return repository;
+   }
+
+   public void suspend()
+   {
+      repository.acquireDeploymentContentLock();
+   }
+
+   public void resume()
+   {
+      repository.releaseDeploymentContentLock();
+   }
+}
\ No newline at end of file

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-05 22:56:02 UTC (rev 85364)
@@ -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

Added: 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	                        (rev 0)
+++ branches/Branch_5_x/system/src/main/org/jboss/system/tools/DeploymentScanner.java	2009-03-05 22:56:02 UTC (rev 85364)
@@ -0,0 +1,121 @@
+/*
+ * 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.MalformedURLException;
+import java.net.URISyntaxException;
+
+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.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>
+ */
+ at JMX(name = "jboss.deployment:flavor=URL,type=DeploymentScanner", exposedInterface = DeploymentScannerMBean.class, registerDirectly = true)
+public class DeploymentScanner implements DeploymentScannerMBean
+{
+   private ServerConfig serverConfig;
+   private URL serverHomeURL;
+
+   private DeploymentRepositoryAdapter adapter;
+
+   public DeploymentScanner(DeploymentRepositoryAdapter adapter)
+   {
+      if (adapter == null)
+         throw new IllegalArgumentException("Null adapter");
+
+      this.adapter = adapter;
+   }
+
+   /**
+    * Create server home.
+    */
+   public void create()
+   {
+      if (serverConfig == null)
+         throw new IllegalArgumentException("Null server config.");
+
+      serverHomeURL = serverConfig.getServerHomeURL();
+   }
+
+   @Start(ignored = true)
+   public void start()
+   {
+      adapter.resume();
+   }
+
+   @Stop(ignored = true)
+   public void stop()
+   {
+      adapter.suspend();
+   }
+
+   public void addURL(String url) throws MalformedURLException, URISyntaxException
+   {
+      addURL(makeURL(url));
+   }
+
+   public void addURL(URL url) throws URISyntaxException
+   {
+      adapter.addURL(url);
+   }
+
+   public void removeURL(String url) throws MalformedURLException, URISyntaxException
+   {
+      removeURL(makeURL(url));
+   }
+
+   public void removeURL(URL url) throws URISyntaxException
+   {
+      adapter.removeURL(url);
+   }
+
+   /**
+    * A helper to make a URL from a full url, or a filespec.
+    *
+    * @param urlspec the url string
+    * @return url based on server home
+    * @throws MalformedURLException for any error
+    */
+   protected URL makeURL(String urlspec) throws MalformedURLException
+   {
+      // First replace URL with appropriate properties
+      urlspec = StringPropertyReplacer.replaceProperties(urlspec);
+      return new URL(serverHomeURL, urlspec);
+   }
+
+   /**
+    * Set the server config.
+    *
+    * @param serverConfig the server config
+    */
+   public void setServerConfig(ServerConfig serverConfig)
+   {
+      this.serverConfig = serverConfig;
+   }
+}

Added: branches/Branch_5_x/system/src/main/org/jboss/system/tools/DeploymentScannerMBean.java
===================================================================
--- branches/Branch_5_x/system/src/main/org/jboss/system/tools/DeploymentScannerMBean.java	                        (rev 0)
+++ branches/Branch_5_x/system/src/main/org/jboss/system/tools/DeploymentScannerMBean.java	2009-03-05 22:56:02 UTC (rev 85364)
@@ -0,0 +1,78 @@
+/*
+ * 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.MalformedURLException;
+import java.net.URISyntaxException;
+
+/**
+ * Deployment api for tools.
+ *
+ * @author <a href="mailto:ales.justin at jboss.org">Ales Justin</a>
+ */
+public interface DeploymentScannerMBean
+{
+   /**
+    * Enable scanning.
+    */
+   void start();
+
+   /**
+    * Disable scanning.
+    */
+   void stop();
+
+   /**
+    * Add url to scanner.
+    *
+    * @param url the url
+    * @throws MalformedURLException for any error
+    * @throws URISyntaxException for any error
+    */
+   void addURL(String url) throws MalformedURLException, URISyntaxException;
+
+   /**
+    * Add url to scanner.
+    *
+    * @param url the url
+    * @throws URISyntaxException for any error
+    */
+   void addURL(URL url) throws URISyntaxException;
+
+   /**
+    * Add url to scanner.
+    *
+    * @param url the url
+    * @throws MalformedURLException for any error
+    * @throws URISyntaxException for any error
+    */
+   void removeURL(String url) throws MalformedURLException, URISyntaxException;
+
+   /**
+    * Add url to scanner.
+    *
+    * @param url the url
+    * @throws URISyntaxException for any error
+    */
+   void removeURL(URL url) throws URISyntaxException;
+}
\ No newline at end of file

Added: branches/Branch_5_x/system/src/main/org/jboss/system/tools/SerializableDeploymentRepositoryAdapter.java
===================================================================
--- branches/Branch_5_x/system/src/main/org/jboss/system/tools/SerializableDeploymentRepositoryAdapter.java	                        (rev 0)
+++ branches/Branch_5_x/system/src/main/org/jboss/system/tools/SerializableDeploymentRepositoryAdapter.java	2009-03-05 22:56:02 UTC (rev 85364)
@@ -0,0 +1,68 @@
+/*
+ * 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.List;
+import java.util.ArrayList;
+
+import org.jboss.system.server.profileservice.repository.SerializableDeploymentRepository;
+
+/**
+ * Serializable deployment repository adapter.
+ *
+ * @author <a href="mailto:ales.justin at jboss.org">Ales Justin</a>
+ */
+public class SerializableDeploymentRepositoryAdapter extends AbstractDeploymentRepositoryAdapter
+{
+   public SerializableDeploymentRepositoryAdapter(SerializableDeploymentRepository repository)
+   {
+      super(repository);
+   }
+
+   public void addURL(URL url) throws URISyntaxException
+   {
+      SerializableDeploymentRepository repository = (SerializableDeploymentRepository)getRepository();
+      URI[] uris = repository.getApplicationURIs();
+      int length = uris.length;
+      URI[] temp = new URI[length + 1];
+      System.arraycopy(uris, 0, temp, 0, length);
+      temp[length] = url.toURI();
+      repository.setApplicationURIs(temp);
+   }
+
+   public void removeURL(URL url) throws URISyntaxException
+   {
+      SerializableDeploymentRepository repository = (SerializableDeploymentRepository)getRepository();
+      URI toURI = url.toURI();
+      URI[] uris = repository.getApplicationURIs();
+      List<URI> temp = new ArrayList<URI>();
+      for (URI uri : uris)
+      {
+         if (uri.equals(toURI) == false)
+            temp.add(uri);
+      }
+      repository.setApplicationURIs(temp.toArray(new URI[temp.size()]));
+   }
+}
\ No newline at end of file




More information about the jboss-cvs-commits mailing list