[jboss-cvs] JBossAS SVN: r74449 - in trunk: system/src/main/org/jboss/deployers/plugins/managed and 1 other directory.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Wed Jun 11 23:27:18 EDT 2008


Author: scott.stark at jboss.org
Date: 2008-06-11 23:27:18 -0400 (Wed, 11 Jun 2008)
New Revision: 74449

Modified:
   trunk/server/src/etc/deployers/ejb-deployer-beans.xml
   trunk/system/src/main/org/jboss/deployers/plugins/managed/TypedManagedDeploymentCreator.java
Log:
JBAS-5557, include version getter name

Modified: trunk/server/src/etc/deployers/ejb-deployer-beans.xml
===================================================================
--- trunk/server/src/etc/deployers/ejb-deployer-beans.xml	2008-06-12 02:00:51 UTC (rev 74448)
+++ trunk/server/src/etc/deployers/ejb-deployer-beans.xml	2008-06-12 03:27:18 UTC (rev 74449)
@@ -30,6 +30,9 @@
           <parameter>
              <value>[1-2].*</value>
           </parameter>
+          <parameter>
+             <value>getEjbVersion</value>
+          </parameter>
        </install>
        <uninstall bean="ManagedDeploymentCreator" method="removeVersionedAttachmentType">
           <parameter>

Modified: trunk/system/src/main/org/jboss/deployers/plugins/managed/TypedManagedDeploymentCreator.java
===================================================================
--- trunk/system/src/main/org/jboss/deployers/plugins/managed/TypedManagedDeploymentCreator.java	2008-06-12 02:00:51 UTC (rev 74448)
+++ trunk/system/src/main/org/jboss/deployers/plugins/managed/TypedManagedDeploymentCreator.java	2008-06-12 03:27:18 UTC (rev 74449)
@@ -70,9 +70,11 @@
          Map<String, ManagedObject> unitMOs,
          ManagedDeployment parent)
    {
+      if(unit.getSimpleName().startsWith("testEjb2xDeployment"))
+         log.info("Processing testEjb2xDeployment");
+
       DeploymentPhase phase = unit.getAttachment(DeploymentPhase.class);
       ManagementDeployment mdAnnotation = null;
-
       for(ManagedObject mo : unitMOs.values())
       {
          Map<String, Annotation> annotations = mo.getAnnotations();
@@ -128,18 +130,16 @@
             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);
-               }
+               String version = getVersion(attachment, tv.versionGetter);
+               if(version == null)
+                  continue;
+
+               Matcher m = tv.versionPattern.matcher(version);
+               if(m.matches())
+                  addType(md, tv.type);
             }
          }
       }
@@ -159,10 +159,15 @@
    public void addVersionedAttachmentType(Class attachmentType, String deploymentType,
          String versionPattern)
    {
+      addVersionedAttachmentType(attachmentType, deploymentType, versionPattern, "getVersion");
+   }
+   public void addVersionedAttachmentType(Class attachmentType, String deploymentType,
+         String versionPattern, String versionGetterName)
+   {
       Pattern p = Pattern.compile(versionPattern);
       log.debug("addVersionedAttachmentType, "+attachmentType+":"+deploymentType
             +", version: "+versionPattern);
-      TypeVersion tv = new TypeVersion(deploymentType, p);
+      TypeVersion tv = new TypeVersion(deploymentType, p, versionGetterName);
       List<TypeVersion> tvlist = attachmentToTypeVersionsMap.get(attachmentType);
       if(tvlist == null)
       {
@@ -197,17 +202,18 @@
    }
 
    /**
-    * Look for a String getVersion method using reflection
+    * Look for a String getterName method using reflection
     * @param attachment
+    * @param getterName - the method name to call to get the version
     * @return the attachment version if found, null otherwise
     */
-   private String getVersion(Object attachment)
+   private String getVersion(Object attachment, String getterName)
    {
       String version = null;
       try
       {
          Class[] parameterTypes = {};
-         Method getVersion = attachment.getClass().getMethod("getVersion", parameterTypes);
+         Method getVersion = attachment.getClass().getMethod(getterName, parameterTypes);
          Object[] args = {};
          version = (String) getVersion.invoke(attachment, args);
       }
@@ -229,11 +235,14 @@
    {
       private String type;
       private Pattern versionPattern;
-      public TypeVersion(String type, Pattern versionPattern)
+      private String versionGetter;
+
+      public TypeVersion(String type, Pattern versionPattern, String versionGetter)
       {
          super();
          this.type = type;
          this.versionPattern = versionPattern;
+         this.versionGetter = versionGetter;
       }
    }
    public static void main(String[] args)




More information about the jboss-cvs-commits mailing list