[jboss-cvs] JBossAS SVN: r74397 - in trunk: connector/src/resources/deployers and 12 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Wed Jun 11 12:39:20 EDT 2008


Author: scott.stark at jboss.org
Date: 2008-06-11 12:39:19 -0400 (Wed, 11 Jun 2008)
New Revision: 74397

Added:
   trunk/system/src/main/org/jboss/deployers/plugins/managed/
   trunk/system/src/main/org/jboss/deployers/plugins/managed/TypedManagedDeploymentCreator.java
   trunk/system/src/main/org/jboss/deployers/spi/management/KnownDeploymentTypes.java
Modified:
   trunk/bootstrap/.classpath
   trunk/connector/src/resources/deployers/jca-deployers-beans.xml
   trunk/ejb3/src/resources/META-INF/ejb3-deployers-beans.xml
   trunk/profileservice/src/main/org/jboss/profileservice/management/ManagementViewImpl.java
   trunk/server/src/etc/conf/default/deployers.xml
   trunk/server/src/etc/deployers/ear-deployer-beans.xml
   trunk/server/src/etc/deployers/ejb-deployer-beans.xml
   trunk/system-jmx/src/main/org/jboss/system/metadata/ServiceDeployment.java
   trunk/system/src/main/org/jboss/profileservice/spi/DeploymentRepository.java
   trunk/system/src/main/org/jboss/profileservice/spi/Profile.java
   trunk/system/src/main/org/jboss/system/server/profile/repository/ProfileImpl.java
   trunk/testsuite/src/main/org/jboss/test/profileservice/test/DeployUnitTestCase.java
   trunk/testsuite/src/main/org/jboss/test/profileservice/test/ProfileServiceUnitTestCase.java
   trunk/tomcat/src/resources/war-deployers-beans.xml
Log:
JBAS-5557, reimplement the deployment type at the management layer


Modified: trunk/bootstrap/.classpath
===================================================================
--- trunk/bootstrap/.classpath	2008-06-11 16:34:54 UTC (rev 74396)
+++ trunk/bootstrap/.classpath	2008-06-11 16:39:19 UTC (rev 74397)
@@ -4,7 +4,7 @@
 	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
 	<classpathentry exported="true" kind="src" path="/main"/>
 	<classpathentry exported="true" kind="lib" path="/thirdparty/jboss/jbossxb/lib/jboss-xml-binding.jar" sourcepath="/thirdparty/jboss/jbossxb/lib/jboss-xml-binding-sources.jar"/>
-	<classpathentry exported="true" kind="lib" path="/thirdparty/jboss/jboss-reflect/lib/jboss-reflect.jar" sourcepath="/thirdparty/jboss/jboss-reflect/lib/jboss-reflect.sources.jar"/>
+	<classpathentry exported="true" kind="lib" path="/thirdparty/jboss/jboss-reflect/lib/jboss-reflect.jar" sourcepath="/thirdparty/jboss/jboss-reflect/lib/jboss-reflect-sources.jar"/>
 	<classpathentry exported="true" kind="lib" path="/thirdparty/jboss/jboss-mdr/lib/jboss-mdr.jar" sourcepath="/thirdparty/jboss/jboss-mdr/lib/jboss-mdr.sources.jar"/>
 	<classpathentry exported="true" kind="lib" path="/thirdparty/jboss/microcontainer/lib/jboss-dependency.jar" sourcepath="/thirdparty/jboss/microcontainer/lib/jboss-dependency-sources.jar"/>
 	<classpathentry exported="true" kind="lib" path="/thirdparty/jboss/microcontainer/lib/jboss-kernel.jar" sourcepath="/thirdparty/jboss/microcontainer/lib/jboss-kernel-sources.jar"/>

Modified: trunk/connector/src/resources/deployers/jca-deployers-beans.xml
===================================================================
--- trunk/connector/src/resources/deployers/jca-deployers-beans.xml	2008-06-11 16:34:54 UTC (rev 74396)
+++ trunk/connector/src/resources/deployers/jca-deployers-beans.xml	2008-06-11 16:39:19 UTC (rev 74397)
@@ -44,9 +44,21 @@
    <bean name="MetaDataTypeMappingBuilder" class="org.jboss.resource.deployers.builder.MetaDataTypeMappingBuilder"/>
    
    <bean name="ManagedConnectionFactoryParserDeployer" class="org.jboss.resource.deployers.ManagedConnectionFactoryParserDeployer">
+      <install bean="ManagedDeploymentCreator" method="addAttachmentType">
+         <parameter>
+            <value>org.jboss.resource.metadata.mcf.ManagedConnectionFactoryDeploymentGroup</value>
+         </parameter>
+         <parameter>
+            <value>jca-ds</value>
+         </parameter>
+      </install>
+      <uninstall bean="ManagedDeploymentCreator" method="removeAttachmentType">
+         <parameter>
+            <value>org.jboss.resource.metadata.mcf.ManagedConnectionFactoryDeploymentGroup</value>
+         </parameter>
+      </uninstall>
       <property name="repository"><inject bean="JCAMetaDataRepository"></inject></property>
       <property name="suffix">-ds.xml</property>      
-      <property name="type">jca-ds</property>
    </bean>
 
    <bean name="ManagedConnectionFactoryDeployer" class="org.jboss.resource.deployers.ManagedConnectionFactoryDeployer">      

Modified: trunk/ejb3/src/resources/META-INF/ejb3-deployers-beans.xml
===================================================================
--- trunk/ejb3/src/resources/META-INF/ejb3-deployers-beans.xml	2008-06-11 16:34:54 UTC (rev 74396)
+++ trunk/ejb3/src/resources/META-INF/ejb3-deployers-beans.xml	2008-06-11 16:39:19 UTC (rev 74397)
@@ -8,7 +8,25 @@
    <bean name="DefaultPersistenceProperties" class="org.jboss.ejb3.DefaultPersistenceProperties"/>
 
    <bean name="Ejb3Deployer" class="org.jboss.ejb3.deployers.Ejb3Deployer">
-      <property name="type">ejb3x</property>
+      <install bean="ManagedDeploymentCreator" method="addVersionedAttachmentType">
+         <parameter>
+            <value>org.jboss.metadata.ejb.jboss.JBossMetaData</value>
+         </parameter>
+         <parameter>
+            <value>ejb3x</value>
+         </parameter>
+         <parameter>
+            <value>3.*</value>
+         </parameter>
+      </install>
+      <uninstall bean="ManagedDeploymentCreator" method="removeVersionedAttachmentType">
+         <parameter>
+            <value>org.jboss.metadata.ejb.jboss.JBossMetaData</value>
+         </parameter>
+         <parameter>
+            <value>ejb3x</value>
+         </parameter>
+      </uninstall>
       <property name="kernel"><inject bean="jboss.kernel:service=Kernel"/></property>
       <property name="mbeanServer"><inject bean="JMXKernel" property="mbeanServer"/></property>
       <property name="defaultPersistenceProperties"><inject bean="DefaultPersistenceProperties" property="properties"/></property>
@@ -131,7 +149,19 @@
    </bean>
 
    <bean name="Ejb3ClientDeployer" class="org.jboss.ejb3.deployers.Ejb3ClientDeployer">
-      <property name="type">car</property>
+      <install bean="ManagedDeploymentCreator" method="addAttachmentType">
+         <parameter>
+            <value>org.jboss.metadata.client.jboss.JBossClientMetaData</value>
+         </parameter>
+         <parameter>
+            <value>car</value>
+         </parameter>
+      </install>
+      <uninstall bean="ManagedDeploymentCreator" method="removeAttachmentType">
+         <parameter>
+            <value>org.jboss.metadata.client.jboss.JBossClientMetaData</value>
+         </parameter>
+      </uninstall>
       <property name="kernel"><inject bean="jboss.kernel:service=Kernel"/></property>
       <property name="mbeanServer"><inject bean="JMXKernel" property="mbeanServer"/></property>
       <!-- TODO: check depends -->
@@ -247,6 +277,19 @@
    
    <!-- Persistence Unit deployers -->
    <bean name="PersistenceUnitParsingDeployer" class="org.jboss.ejb3.deployers.PersistenceUnitParsingDeployer">
+      <install bean="ManagedDeploymentCreator" method="addAttachmentType">
+         <parameter>
+            <value>org.jboss.metadata.jpa.spec.PersistenceMetaData</value>
+         </parameter>
+         <parameter>
+            <value>par</value>
+         </parameter>
+      </install>
+      <uninstall bean="ManagedDeploymentCreator" method="removeAttachmentType">
+         <parameter>
+            <value>org.jboss.metadata.jpa.spec.PersistenceMetaData</value>
+         </parameter>
+      </uninstall>
    </bean>
    
 </deployment>

Modified: trunk/profileservice/src/main/org/jboss/profileservice/management/ManagementViewImpl.java
===================================================================
--- trunk/profileservice/src/main/org/jboss/profileservice/management/ManagementViewImpl.java	2008-06-11 16:34:54 UTC (rev 74396)
+++ trunk/profileservice/src/main/org/jboss/profileservice/management/ManagementViewImpl.java	2008-06-11 16:39:19 UTC (rev 74397)
@@ -192,14 +192,12 @@
       {
          try
          {
-            if(name.endsWith("hsqldb-ds.xml"))
-               log.info("Creating hsqldb-ds.xml ManagedDeployment");
             ManagedDeployment md = mainDeployer.getManagedDeployment(name);
             processManagedDeployment(md, 0, log.isTraceEnabled());
          }
          catch(Exception e)
          {
-            log.debug("Failed to create ManagedDeployment for: " + name, e);
+            log.warn("Failed to create ManagedDeployment for: " + name, e);
          }
       }
       if(this.runtimeMOs.size() > 0)
@@ -227,8 +225,6 @@
       {
          processManagedObject(mo, md);
       }
-      if(name.endsWith("hsqldb-ds.xml"))
-         log.debug("processManagedDeployment, hsqldb-ds.xml");
       managedDeployments.put(name, md);
       List<ManagedDeployment> mdChildren = md.getChildren();
       if(mdChildren != null && mdChildren.isEmpty() == false)
@@ -516,7 +512,23 @@
     */
    public Set<String> getDeploymentNamesForType(String type)
    {
-      return activeProfile.getDeploymentNamesForType(type);
+      HashSet<String> matches = new HashSet<String>();
+      for(ManagedDeployment md : managedDeployments.values())
+      {
+         String name = md.getName();
+         if(name.indexOf("jbossweb.sar") >= 0)
+            log.info("Processing jbossweb.sar: "+md);
+         Set<String> types = md.getTypes();
+         if(types != null)
+         {
+            if(types.contains(type))
+            {
+               log.debug(name+" matches type: "+type+", types:"+types);
+               matches.add(name);
+            }
+         }
+      }
+      return matches;
    }
 
    public Set<String> getMatchingDeploymentName(String regex)

Modified: trunk/server/src/etc/conf/default/deployers.xml
===================================================================
--- trunk/server/src/etc/conf/default/deployers.xml	2008-06-11 16:34:54 UTC (rev 74396)
+++ trunk/server/src/etc/conf/default/deployers.xml	2008-06-11 16:39:19 UTC (rev 74397)
@@ -32,8 +32,10 @@
       <property name="comparator"><inject bean="dsContextComparator"/></property>
    </bean>
 
-   <!-- The ManagedDeploymentCreator implementation -->
-   <bean name="ManagedDeploymentCreator" class="org.jboss.deployers.plugins.managed.DefaultManagedDeploymentCreator" />
+   <!-- The ManagedDeploymentCreator implementation that supports mapping
+      attachment types to ManagedDeployment#getTypes
+   -->
+   <bean name="ManagedDeploymentCreator" class="org.jboss.deployers.plugins.managed.TypedManagedDeploymentCreator" />
 
    <!-- The holder for deployers that determine structure -->
    <bean name="StructuralDeployers" class="org.jboss.deployers.vfs.plugins.structure.VFSStructuralDeployersImpl">
@@ -146,26 +148,33 @@
 
    <!-- POJO Deployment -->
    <bean name="BeanDeployer" class="org.jboss.deployers.vfs.deployer.kernel.BeanDeployer">
-      <property name="type">beans</property>
    </bean>
    <bean name="KernelDeploymentDeployer" class="org.jboss.deployers.vfs.deployer.kernel.KernelDeploymentDeployer">
-      <property name="type">beans</property>
+      <install bean="ManagedDeploymentCreator" method="addAttachmentType">
+         <parameter>
+            <value>org.jboss.kernel.spi.deployment.KernelDeployment</value>
+         </parameter>
+         <parameter>
+            <value>beans</value>
+         </parameter>
+      </install>
+      <uninstall bean="ManagedDeploymentCreator" method="removeAttachmentType">
+         <parameter>
+            <value>org.jboss.kernel.spi.deployment.KernelDeployment</value>
+         </parameter>        
+      </uninstall>
    </bean>
    <bean name="BeanMetaDataDeployer" class="org.jboss.deployers.vfs.deployer.kernel.BeanMetaDataDeployer">
       <constructor><parameter><inject bean="jboss.kernel:service=Kernel"/></parameter></constructor>
-      <property name="type">beans</property>
    </bean>
 
    <!-- JMX Deployment -->
    <bean name="SARDeployer" class="org.jboss.system.deployers.SARDeployer">
-      <property name="type">sar</property>
    </bean>
    <bean name="ServiceDeploymentDeployer" class="org.jboss.system.deployers.ServiceDeploymentDeployer">
-       <property name="type">sar</property>
    </bean>
    <bean name="ServiceDeployer" class="org.jboss.system.deployers.ServiceDeployer">
        <constructor><parameter><inject bean="JMXKernel" property="serviceController"/></parameter></constructor>
-       <property name="type">sar</property>
    </bean>
 
    <!-- FIXME Remove this -->

Modified: trunk/server/src/etc/deployers/ear-deployer-beans.xml
===================================================================
--- trunk/server/src/etc/deployers/ear-deployer-beans.xml	2008-06-11 16:34:54 UTC (rev 74396)
+++ trunk/server/src/etc/deployers/ear-deployer-beans.xml	2008-06-11 16:39:19 UTC (rev 74397)
@@ -27,6 +27,19 @@
    </bean>
    <!-- jboss-app.xml parsing deployer -->
    <bean name="JBossAppParsingDeployer" class="org.jboss.deployment.JBossAppParsingDeployer">
+      <install bean="ManagedDeploymentCreator" method="addAttachmentType">
+         <parameter>
+            <value>org.jboss.metadata.ear.jboss.JBossAppMetaData</value>
+         </parameter>
+         <parameter>
+            <value>ear</value>
+         </parameter>
+      </install>
+      <uninstall bean="ManagedDeploymentCreator" method="removeAttachmentType">
+         <parameter>
+            <value>org.jboss.metadata.ear.jboss.JBossAppMetaData</value>
+         </parameter>
+      </uninstall>
       <property name="type">ear</property>
       <!-- A flag indicating if ear deployments should have their own scoped
          class loader to isolate their classes from other deployments.

Modified: trunk/server/src/etc/deployers/ejb-deployer-beans.xml
===================================================================
--- trunk/server/src/etc/deployers/ejb-deployer-beans.xml	2008-06-11 16:34:54 UTC (rev 74396)
+++ trunk/server/src/etc/deployers/ejb-deployer-beans.xml	2008-06-11 16:39:19 UTC (rev 74397)
@@ -6,14 +6,12 @@
 
    <!-- ejb-jar.xml parsing deployer -->
    <bean name="Ejb2ParsingDeployer" class="org.jboss.deployment.EjbParsingDeployer">
-      <property name="type">ejb2x</property>
       <!--
       <property name="useSchemaValidation">false</property>
       -->      
       <property name="relativeOrder">3000</property>
    </bean>
    <bean name="JBossEjb2ParsingDeployer" class="org.jboss.deployment.JBossEjbParsingDeployer">
-      <property name="type">ejb2x</property>      
       <property name="relativeOrder">3001</property>
       <property name="useSchemaValidation">false</property>
       <property name="ignoreMissingStandardJBossXml">false</property>
@@ -22,8 +20,27 @@
    </bean>
 
     <bean name="EJB2xDeployer" class="org.jboss.ejb.deployers.EjbDeployer">
-        <!-- The EJBDeployer needs the JTA transaction manager service -->
-        <property name="transactionManagerServiceName">jboss:service=TransactionManager</property>
+       <install bean="ManagedDeploymentCreator" method="addVersionedAttachmentType">
+          <parameter>
+             <value>org.jboss.metadata.ejb.jboss.JBossMetaData</value>
+          </parameter>
+          <parameter>
+             <value>ejb2x</value>
+          </parameter>
+          <parameter>
+             <value>[1-2].*</value>
+          </parameter>
+       </install>
+       <uninstall bean="ManagedDeploymentCreator" method="removeVersionedAttachmentType">
+          <parameter>
+             <value>org.jboss.metadata.ejb.jboss.JBossMetaData</value>
+          </parameter>
+          <parameter>
+             <value>ejb2x</value>
+          </parameter>          
+       </uninstall>
+       <!-- The EJBDeployer needs the JTA transaction manager service -->
+       <property name="transactionManagerServiceName">jboss:service=TransactionManager</property>
        <!-- The dynamic class loading simple web server -->
        <property name="webServiceName">jboss:service=WebService</property>
        <!-- The CachedConnectionManager service used by the CachedConnectionInterceptor -->

Added: trunk/system/src/main/org/jboss/deployers/plugins/managed/TypedManagedDeploymentCreator.java
===================================================================
--- trunk/system/src/main/org/jboss/deployers/plugins/managed/TypedManagedDeploymentCreator.java	                        (rev 0)
+++ trunk/system/src/main/org/jboss/deployers/plugins/managed/TypedManagedDeploymentCreator.java	2008-06-11 16:39:19 UTC (rev 74397)
@@ -0,0 +1,262 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt 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.deployers.plugins.managed;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import org.jboss.deployers.spi.deployer.managed.ManagedDeploymentCreator;
+import org.jboss.deployers.spi.management.KnownDeploymentTypes;
+import org.jboss.deployers.structure.spi.DeploymentUnit;
+import org.jboss.logging.Logger;
+import org.jboss.managed.api.ManagedDeployment;
+import org.jboss.managed.api.ManagedObject;
+import org.jboss.managed.api.ManagedDeployment.DeploymentPhase;
+import org.jboss.managed.api.annotation.ManagementDeployment;
+import org.jboss.managed.plugins.ManagedDeploymentImpl;
+
+/**
+ * A ManagedDeploymentCreator that looks for {@linkplain KnownDeploymentTypes}
+ * attachments and maps those to the {@linkplain ManagedDeployment#getTypes()}
+ * set.
+ * 
+ * This also does attachment type mapping based on the registered attachment
+ * type class to deployment type mapping.
+ * @see {@link #addAttachmentType(Class, String)}
+ * 
+ * @author Scott.Stark at jboss.org
+ * @version $Revision:$
+ */
+public class TypedManagedDeploymentCreator
+   implements ManagedDeploymentCreator
+{
+   private static Logger log = Logger.getLogger(TypedManagedDeploymentCreator.class);
+   /** A mapping from a deployment attachment type to the {@link ManagedDeployment#addType(String)} type */
+   private Map<Class, String> attachmentToTypeMap = new ConcurrentHashMap<Class, String>();
+   private Map<Class, List<TypeVersion>> attachmentToTypeVersionsMap = new ConcurrentHashMap<Class, List<TypeVersion>>();
+
+   /**
+    * 
+    */
+   public ManagedDeployment build(DeploymentUnit unit,
+         Map<String, ManagedObject> unitMOs,
+         ManagedDeployment parent)
+   {
+      DeploymentPhase phase = unit.getAttachment(DeploymentPhase.class);
+      ManagementDeployment mdAnnotation = null;
+      if(unit.getName().endsWith("-service.xml"))
+         log.info("-service.xml: "+unitMOs);
+
+      for(ManagedObject mo : unitMOs.values())
+      {
+         Map<String, Annotation> annotations = mo.getAnnotations();
+         if(annotations != null && mdAnnotation == null)
+            mdAnnotation = (ManagementDeployment) annotations.get(ManagementDeployment.class.getName());
+      }
+      String simpleName = unit.getSimpleName();
+      String[] types = {};
+      if(mdAnnotation != null)
+      {
+         log.info("Saw ManagementDeployment: "+mdAnnotation);
+         if(phase == null)
+            phase = mdAnnotation.phase();
+         if(mdAnnotation.simpleName().length() > 0)
+            simpleName = mdAnnotation.simpleName();
+         types = mdAnnotation.types();
+      }
+      if( phase == null )
+         phase = DeploymentPhase.APPLICATION;
+      ManagedDeployment md = new ManagedDeploymentImpl(unit.getName(), simpleName,
+            phase, parent, unitMOs);
+      if(types.length > 0)
+      {
+         for(String type : types)
+            addType(md, type);
+      }
+
+      // Check for KnownDeploymentTypes attachment(s)
+      Set<? extends KnownDeploymentTypes> knownTypes = unit.getAllMetaData(KnownDeploymentTypes.class);
+      if(knownTypes != null)
+      {
+         for(KnownDeploymentTypes type : knownTypes)
+         {
+            addType(md, type.getType());
+         }
+      }
+
+      // Check for attachment to type mappings
+      for(Class attachmentType : attachmentToTypeMap.keySet())
+      {
+         if(unit.isAttachmentPresent(attachmentType))
+         {
+            String type = attachmentToTypeMap.get(attachmentType);
+            addType(md, type);
+         }
+      }
+
+      //
+      for(Class attachmentType : attachmentToTypeVersionsMap.keySet())
+      {
+         if(unit.isAttachmentPresent(attachmentType))
+         {
+            List<TypeVersion> versions = attachmentToTypeVersionsMap.get(attachmentType);
+            Object attachment = unit.getAttachment(attachmentType);
+            if(attachment == null)
+               continue;
+            String version = getVersion(attachment);
+            if(version == null)
+               continue;
+
+            for(TypeVersion tv : versions)
+            {
+               if(version != null)
+               {
+                  Matcher m = tv.versionPattern.matcher(version);
+                  if(m.matches())
+                     addType(md, tv.type);
+               }
+            }
+         }
+      }
+      return md;
+   }
+
+   /**
+    * 
+    * @param attachmentType
+    * @param deploymentType
+    */
+   public void addAttachmentType(Class attachmentType, String deploymentType)
+   {
+      log.info("addAttachmentType, "+attachmentType+":"+deploymentType);
+      attachmentToTypeMap.put(attachmentType, deploymentType);
+   }
+   public void addVersionedAttachmentType(Class attachmentType, String deploymentType,
+         String versionPattern)
+   {
+      Pattern p = Pattern.compile(versionPattern);
+      log.info("addVersionedAttachmentType, "+attachmentType+":"+deploymentType
+            +", version: "+versionPattern);
+      TypeVersion tv = new TypeVersion(deploymentType, p);
+      List<TypeVersion> tvlist = attachmentToTypeVersionsMap.get(attachmentType);
+      if(tvlist == null)
+      {
+         tvlist = new ArrayList<TypeVersion>();
+         attachmentToTypeVersionsMap.put(attachmentType, tvlist);         
+      }
+      tvlist.add(tv);
+   }
+
+   public void removeAttachmentType(Class attachmentType)
+   {
+      log.info("removeAttachmentType, "+attachmentType);
+      attachmentToTypeMap.remove(attachmentType);
+   }
+   public void removeVersionedAttachmentType(Class attachmentType, String deploymentType)
+   {
+      log.info("removeVersionedAttachmentType, "+attachmentType);
+      List<TypeVersion> tvlist = attachmentToTypeVersionsMap.get(attachmentType);
+      if(tvlist != null)
+      {
+         Iterator<TypeVersion> iter = tvlist.iterator();
+         while(iter.hasNext())
+         {
+            TypeVersion tv = iter.next();
+            if(deploymentType.equals(tv.type))
+               iter.remove();
+         }
+         attachmentToTypeVersionsMap.put(attachmentType, tvlist);         
+         if(tvlist.size() == 0)
+            attachmentToTypeVersionsMap.remove(attachmentType);      
+      }
+   }
+
+   /**
+    * Look for a String getVersion method using reflection
+    * @param attachment
+    * @return the attachment version if found, null otherwise
+    */
+   private String getVersion(Object attachment)
+   {
+      String version = null;
+      try
+      {
+         Class[] parameterTypes = {};
+         Method getVersion = attachment.getClass().getMethod("getVersion", parameterTypes);
+         Object[] args = {};
+         version = (String) getVersion.invoke(attachment, args);
+      }
+      catch(Throwable t)
+      {
+         log.debug("Failed to get version:"+t);
+      }
+      return version;
+   }
+
+   private void addType(ManagedDeployment md, String type)
+   {
+      if(md.getTypes() == null)
+         md.setTypes(new HashSet<String>());
+      md.addType(type);
+   }
+
+   static class TypeVersion
+   {
+      private String type;
+      private Pattern versionPattern;
+      public TypeVersion(String type, Pattern versionPattern)
+      {
+         super();
+         this.type = type;
+         this.versionPattern = versionPattern;
+      }
+   }
+   public static void main(String[] args)
+   {
+      Pattern p = Pattern.compile("3.*");
+      Matcher m = p.matcher("3.0");
+      System.out.println("3.0 matches: "+m.matches());
+      m = p.matcher("3.1");
+      System.out.println("3.1 matches: "+m.matches());
+      m = p.matcher("3.x");
+      System.out.println("3.x matches: "+m.matches());
+      m = p.matcher("2.1");
+      System.out.println("2.1 matches: "+m.matches());
+
+      Pattern p2x = Pattern.compile("[1-2].*");
+      m = p2x.matcher("3.1");
+      System.out.println("3.1 is 2x: "+m.matches());
+      m = p2x.matcher("1.1");
+      System.out.println("1.1 is 2x: "+m.matches());
+      m = p2x.matcher("2.1");
+      System.out.println("2.1 is 2x: "+m.matches());
+   }
+}

Added: trunk/system/src/main/org/jboss/deployers/spi/management/KnownDeploymentTypes.java
===================================================================
--- trunk/system/src/main/org/jboss/deployers/spi/management/KnownDeploymentTypes.java	                        (rev 0)
+++ trunk/system/src/main/org/jboss/deployers/spi/management/KnownDeploymentTypes.java	2008-06-11 16:39:19 UTC (rev 74397)
@@ -0,0 +1,67 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt 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.deployers.spi.management;
+
+import org.jboss.managed.api.ManagedDeployment;
+
+/**
+ * Enum for the known deployment types.
+ * @see {@linkplain ManagedDeployment#getTypes()}
+ * 
+ * @author Scott.Stark at jboss.org
+ * @version $Revision:$
+ */
+public enum KnownDeploymentTypes
+{
+   JavaEEApplication("ear"),
+   JavaEEClientApplication("car"),
+   JavaEEEnterpriseBeans2x("ejb2x"),
+   JavaEEEnterpriseBeans3x("ejb3x"),
+   JavaEEWebApplication("war"),
+   JavaEEResourceAdaptor("rar"),
+   JavaEEPersistenceUnit("par"),
+   JBossServices("sar"),
+   MCBeans("beans"),
+   OSGIBundle("bundle"),
+   SpringApplication("spring"),
+   Unknown("*")
+   ;
+
+   /** The simple type string, usually used as the deployment archive suffix */
+   private final String type;
+
+   private KnownDeploymentTypes(String type)
+   {
+      this.type = type;
+   }
+
+   /**
+    * Get the simple deployment type string. This is usually used as the
+    * associated deployment archive suffix.
+    * 
+    * @return the simple deployment type string.
+    */
+   public String getType()
+   {
+      return type;
+   }
+}

Modified: trunk/system/src/main/org/jboss/profileservice/spi/DeploymentRepository.java
===================================================================
--- trunk/system/src/main/org/jboss/profileservice/spi/DeploymentRepository.java	2008-06-11 16:34:54 UTC (rev 74396)
+++ trunk/system/src/main/org/jboss/profileservice/spi/DeploymentRepository.java	2008-06-11 16:39:19 UTC (rev 74397)
@@ -52,7 +52,6 @@
 
    public Set<String> getDeploymentNames();
    public Set<String> getDeploymentNames(DeploymentPhase phase);
-   public Set<String> getDeploymentNamesForType(String type);
 
 
    /**

Modified: trunk/system/src/main/org/jboss/profileservice/spi/Profile.java
===================================================================
--- trunk/system/src/main/org/jboss/profileservice/spi/Profile.java	2008-06-11 16:34:54 UTC (rev 74396)
+++ trunk/system/src/main/org/jboss/profileservice/spi/Profile.java	2008-06-11 16:39:19 UTC (rev 74397)
@@ -74,15 +74,6 @@
    //public DeploymentInfo getDeploymentInfo(String name);
 
    /**
-    * Get the names of the deployment in the profile that have the
-    * given deployment type.
-    * 
-    * @param type - the deployment type
-    * @return the deployments names by type
-    */
-   Set<String> getDeploymentNamesForType(String type);
-
-   /**
     * Get the root for deployments of the given phase.
     * 
     * @param phase the deployment phase

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	2008-06-11 16:34:54 UTC (rev 74396)
+++ trunk/system/src/main/org/jboss/system/server/profile/repository/ProfileImpl.java	2008-06-11 16:39:19 UTC (rev 74397)
@@ -102,11 +102,6 @@
       return repository.getDeploymentNames(phase);
    }
 
-   public Set<String> getDeploymentNamesForType(String type)
-   {
-      return repository.getDeploymentNamesForType(type);
-   }
-
    public VirtualFile getRootFile(DeploymentPhase phase)
       throws Exception
    {

Modified: trunk/system-jmx/src/main/org/jboss/system/metadata/ServiceDeployment.java
===================================================================
--- trunk/system-jmx/src/main/org/jboss/system/metadata/ServiceDeployment.java	2008-06-11 16:34:54 UTC (rev 74396)
+++ trunk/system-jmx/src/main/org/jboss/system/metadata/ServiceDeployment.java	2008-06-11 16:39:19 UTC (rev 74397)
@@ -24,6 +24,7 @@
 import java.io.Serializable;
 import java.util.List;
 
+import org.jboss.managed.api.annotation.ManagementDeployment;
 import org.jboss.managed.api.annotation.ManagementObject;
 import org.jboss.managed.api.annotation.ManagementObjectID;
 import org.jboss.managed.api.annotation.ManagementProperty;
@@ -38,6 +39,7 @@
  * @version $Revision$
  */
 @ManagementObject
+ at ManagementDeployment(types={"sar"})
 public class ServiceDeployment
    implements Serializable
 {

Modified: trunk/testsuite/src/main/org/jboss/test/profileservice/test/DeployUnitTestCase.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/profileservice/test/DeployUnitTestCase.java	2008-06-11 16:34:54 UTC (rev 74396)
+++ trunk/testsuite/src/main/org/jboss/test/profileservice/test/DeployUnitTestCase.java	2008-06-11 16:39:19 UTC (rev 74397)
@@ -23,11 +23,13 @@
 
 import java.net.URL;
 
+import org.jboss.deployers.spi.management.ManagementView;
 import org.jboss.deployers.spi.management.deploy.DeploymentManager;
 import org.jboss.deployers.spi.management.deploy.DeploymentProgress;
 import org.jboss.deployers.spi.management.deploy.DeploymentStatus;
 import org.jboss.deployers.spi.management.deploy.ProgressEvent;
 import org.jboss.deployers.spi.management.deploy.ProgressListener;
+import org.jboss.managed.api.ManagedDeployment;
 import org.jboss.managed.api.ManagedDeployment.DeploymentPhase;
 
 /**
@@ -62,16 +64,16 @@
    public void testWarDeployment()
       throws Exception
    {
-      DeploymentManager mgtView = getDeploymentManager();
+      DeploymentManager deployMgr = getDeploymentManager();
       URL contentURL = super.getDeployURL("testWarDeployment.war");
-      mgtView.distribute("testWarDeployment.war", DeploymentPhase.APPLICATION, contentURL);
+      deployMgr.distribute("testWarDeployment.war", DeploymentPhase.APPLICATION, contentURL);
    }
    public void testEarDeployment()
       throws Exception
    {
-      DeploymentManager mgtView = getDeploymentManager();
+      DeploymentManager deployMgr = getDeploymentManager();
       URL contentURL = super.getDeployURL("testEarDeployment.ear");
-      mgtView.distribute("testEarDeployment.ear", DeploymentPhase.APPLICATION, contentURL);      
+      deployMgr.distribute("testEarDeployment.ear", DeploymentPhase.APPLICATION, contentURL);      
    }
    public void testMCBeansDeployment()
       throws Exception
@@ -79,8 +81,8 @@
       URL contentURL = super.getDeployURL("testMCBeansDeployment.beans");
 
       // Distribute the content
-      DeploymentManager mgtView = getDeploymentManager();
-      DeploymentProgress progress = mgtView.distribute("testMCBeansDeployment.beans", DeploymentPhase.APPLICATION, contentURL);
+      DeploymentManager deployMgr = getDeploymentManager();
+      DeploymentProgress progress = deployMgr.distribute("testMCBeansDeployment.beans", DeploymentPhase.APPLICATION, contentURL);
       progress.addProgressListener(this);
       progress.run();
       DeploymentStatus status = progress.getDeploymentStatus();
@@ -91,19 +93,28 @@
 
       // Now start the deployment
       String[] names = {"testMCBeansDeployment.beans"};
-      progress = mgtView.start(DeploymentPhase.APPLICATION, names);
+      progress = deployMgr.start(DeploymentPhase.APPLICATION, names);
       progress.addProgressListener(this);
       progress.run();
       status = progress.getDeploymentStatus();
       assertTrue("DeploymentStatus.isCompleted", status.isCompleted());
       assertTrue("DeploymentStatus.isRunning", status.isRunning());
-      assertFalse("DeploymentStatus.isFailed", status.isFailed());      
+      assertFalse("DeploymentStatus.isFailed", status.isFailed());
+      // Check for a 
+      ManagementView mgtView = super.getManagementView();
+      ManagedDeployment beans = mgtView.getDeployment("testMCBeansDeployment.beans", DeploymentPhase.APPLICATION);
+      assertNotNull(beans);
+      assertTrue(beans.getTypes().contains("beans"));
+
+      // Remove the deployment
+      deployMgr.undeploy(DeploymentPhase.APPLICATION, names);
+      
    }
    public void testSarDeployment()
       throws Exception
    {
-      DeploymentManager mgtView = getDeploymentManager();
+      DeploymentManager deployMgr = getDeploymentManager();
       URL contentURL = super.getDeployURL("testSarDeployment.sar");
-      mgtView.distribute("testSarDeployment.sar", DeploymentPhase.APPLICATION, contentURL);
+      deployMgr.distribute("testSarDeployment.sar", DeploymentPhase.APPLICATION, contentURL);
    }
 }

Modified: trunk/testsuite/src/main/org/jboss/test/profileservice/test/ProfileServiceUnitTestCase.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/profileservice/test/ProfileServiceUnitTestCase.java	2008-06-11 16:34:54 UTC (rev 74396)
+++ trunk/testsuite/src/main/org/jboss/test/profileservice/test/ProfileServiceUnitTestCase.java	2008-06-11 16:39:19 UTC (rev 74397)
@@ -34,6 +34,8 @@
 
 import junit.framework.Test;
 import junit.framework.TestSuite;
+
+import org.jboss.deployers.spi.management.KnownDeploymentTypes;
 import org.jboss.deployers.spi.management.ManagementView;
 import org.jboss.deployers.spi.management.KnownComponentTypes;
 import org.jboss.managed.api.ComponentType;
@@ -220,6 +222,71 @@
       assertTrue("Saw hsqldb-ds.xml in names", sawHsqldbDS);
    }
 
+   public void testWarDeploymentType()
+      throws Exception
+   {
+      ManagementView mgtView = getManagementView();
+      Set<String> names = mgtView.getDeploymentNamesForType(KnownDeploymentTypes.JavaEEWebApplication.getType());
+      log.info("war names: "+names);
+      assertTrue("names.size > 0 ", names.size() > 0);
+      boolean sawRootWar = false;
+      for (String name : names)
+      {
+         sawRootWar = name.endsWith("ROOT.war") || name.endsWith("ROOT.war/");
+         if (sawRootWar)
+            break;
+      }
+      assertTrue("Saw ROOT.war in names", sawRootWar);
+   }
+   public void testSarDeploymentType()
+      throws Exception
+   {
+      ManagementView mgtView = getManagementView();
+      Set<String> names = mgtView.getDeploymentNamesForType(KnownDeploymentTypes.JBossServices.getType());
+      log.info("sar names: "+names);
+      assertTrue("names.size > 0 ", names.size() > 0);
+      // To check for a jbossweb.sar
+      boolean sawJbosswebSar = false;
+      // To check for a transaction-service.xml
+      boolean sawTSService = false;
+      for (String name : names)
+      {
+         if(sawJbosswebSar == false)
+            sawJbosswebSar = name.endsWith("jbossweb.sar") || name.endsWith("jbossweb.sar/");
+         if(sawTSService == false)
+            sawTSService = name.endsWith("transaction-service.xml");
+      }
+      assertTrue("Saw jbossweb.sar in names", sawJbosswebSar);
+      assertTrue("Saw transaction-service.xml in names", sawTSService);
+   }
+
+   public void testMCBeansDeploymentType()
+      throws Exception
+   {
+      ManagementView mgtView = getManagementView();
+      Set<String> names = mgtView.getDeploymentNamesForType(KnownDeploymentTypes.MCBeans.getType());
+      log.info("beans names: "+names);
+      assertTrue("names.size > 0 ", names.size() > 0);
+      // To check for a jbossweb.deployer
+      boolean sawJbosswebDeployer = false;
+      // To check for a profileservice-beans.xml
+      boolean sawPSBeans = false;
+      // To check for a security-beans.xml
+      boolean sawSecurityBeans = false;
+      for (String name : names)
+      {
+         if(sawJbosswebDeployer == false)
+            sawJbosswebDeployer = name.endsWith("jbossweb.deployer") || name.endsWith("jbossweb.deployer/");
+         if(sawPSBeans == false)
+            sawPSBeans = name.endsWith("profileservice-beans.xml");
+         if(sawSecurityBeans == false)
+            sawSecurityBeans = name.endsWith("security-beans.xml");
+      }
+      assertTrue("Saw jbossweb.deployer in names", sawJbosswebDeployer);
+      assertTrue("Saw profileservice-beans.xml in names", sawPSBeans);
+      assertTrue("Saw security-beans.xml in names", sawSecurityBeans);
+   }
+
    /**
     * test api usage only
     * @throws Exception

Modified: trunk/tomcat/src/resources/war-deployers-beans.xml
===================================================================
--- trunk/tomcat/src/resources/war-deployers-beans.xml	2008-06-11 16:34:54 UTC (rev 74396)
+++ trunk/tomcat/src/resources/war-deployers-beans.xml	2008-06-11 16:39:19 UTC (rev 74397)
@@ -109,9 +109,23 @@
 
    <!-- The WebMetaData to service mbean deployer -->
    <bean name="WarDeployer" class="org.jboss.web.tomcat.service.deployers.TomcatDeployer">
+      <install bean="ManagedDeploymentCreator" method="addAttachmentType">
+         <parameter>
+            <value>org.jboss.metadata.web.jboss.JBossWebMetaData</value>
+         </parameter>
+         <parameter>
+            <value>war</value>
+         </parameter>
+      </install>
+      <uninstall bean="ManagedDeploymentCreator" method="removeAttachmentType">
+         <parameter>
+            <value>org.jboss.metadata.web.jboss.JBossWebMetaData</value>
+         </parameter>
+      </uninstall>
+
       <!-- Inject the MainDeployer for resolving cross deployment refs -->
       <property name="mainDeployer"><inject bean="MainDeployer" /></property>
-      <property name="type">war</property>
+
       <property name="relativeOrder">2003</property>
       <!-- You can configure a set of authenticators keyed by http-auth method
       used. This will apply the same set of authenticators across all web




More information about the jboss-cvs-commits mailing list