[jboss-cvs] JBossAS SVN: r58492 - in trunk/server/src/main/org/jboss: deployment metadata

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Fri Nov 17 07:01:11 EST 2006


Author: alex.loubyansky at jboss.com
Date: 2006-11-17 07:01:07 -0500 (Fri, 17 Nov 2006)
New Revision: 58492

Modified:
   trunk/server/src/main/org/jboss/deployment/EjbJarObjectFactory.java
   trunk/server/src/main/org/jboss/metadata/MethodMetaData.java
Log:
fixed method metadata parsing

Modified: trunk/server/src/main/org/jboss/deployment/EjbJarObjectFactory.java
===================================================================
--- trunk/server/src/main/org/jboss/deployment/EjbJarObjectFactory.java	2006-11-17 11:12:42 UTC (rev 58491)
+++ trunk/server/src/main/org/jboss/deployment/EjbJarObjectFactory.java	2006-11-17 12:01:07 UTC (rev 58492)
@@ -22,6 +22,8 @@
 package org.jboss.deployment;
 
 
+import java.util.List;
+import java.util.ArrayList;
 import org.jboss.logging.Logger;
 import org.jboss.metadata.ApplicationMetaData;
 import org.jboss.metadata.DDObjectFactory;
@@ -279,21 +281,24 @@
       {
          return ad;
       }
-      else if(localName.equals("method-permission") ||
-         localName.equals("container-transaction"))
+      else if(localName.equals("method-permission"))
       {
-         return new MethodMetaData();
+         return new MethodPermission(ad);
       }
+      else if(localName.equals("container-transaction"))
+      {
+         return new ContainerTransaction();
+      }
+      else if(localName.equals("exclude-list"))
+      {
+         return ad;
+      }
       else if(localName.equals("method"))
       {
          MethodMetaData method = new MethodMetaData();
          method.setExcluded();
          return method;
       }
-      else if(localName.equals("exclude-list"))
-      {
-         return ad;
-      }
       else if(localName.equals("message-destination"))
       {
          MessageDestinationMetaData mdmd = new MessageDestinationMetaData();
@@ -341,6 +346,28 @@
       return null;
    }
 
+   public Object newChild(MethodPermission parent, UnmarshallingContext navigator,
+         String namespaceURI, String localName, Attributes attrs)
+   {
+      if(localName.equals("method"))
+      {
+         return new MethodMetaData();
+      }
+      return null;
+   }
+
+   public Object newChild(ContainerTransaction parent, UnmarshallingContext navigator,
+         String namespaceURI, String localName, Attributes attrs)
+   {
+      if(localName.equals("method"))
+      {
+         MethodMetaData method = new MethodMetaData();
+         parent.methods.add(method);
+         return method;
+      }
+      return null;
+   }
+
    public void addChild(ApplicationMetaData parent, EntityMetaData entity,
          UnmarshallingContext navigator, String namespaceURI, String localName)
    {
@@ -501,38 +528,30 @@
       }
    }
 
-   public void addChild(AssemblyDescriptor ad, MethodMetaData method,
-                        UnmarshallingContext ctx, String namespaceURI, String localName)
+   public void addChild(AssemblyDescriptor ad, MessageDestinationMetaData mdmd,
+         UnmarshallingContext ctx, String namespaceURI, String localName)
    {
-      if(method.getEjbName() == null)
-      {
-         throw new IllegalStateException("Method permission without ejb-name!");
-      }
+      ad.app.getAssemblyDescriptor().addMessageDestinationMetaData(mdmd); 
+   }
 
-      BeanMetaData bean = ad.app.getBeanByEjbName(method.getEjbName());
-      if(bean == null)
+   public void addChild(AssemblyDescriptor parent, ContainerTransaction child,
+         UnmarshallingContext ctx, String namespaceURI, String localName)
+   {
+      for(int i = 0; i < child.methods.size(); ++i)
       {
-         throw new IllegalStateException("Bean " + method.getEjbName() + " not found in the application.");
-      }
+         MethodMetaData method = (MethodMetaData)child.methods.get(i);
+         BeanMetaData bean = getBeanForMethod(parent, method);
 
-      if(method.isExcluded())
-      {
-         bean.addExcludedMethod(method);
-      }
-      else if(method.isUnchecked() || !method.getRoles().isEmpty())
-      {
-         bean.addPermissionMethod(method);
-      }
-      else
-      {
+         method.setTransactionType(child.transAttr);
          bean.addTransactionMethod(method);
       }
    }
-   
-   public void addChild(AssemblyDescriptor ad, MessageDestinationMetaData mdmd,
+
+   public void addChild(AssemblyDescriptor parent, MethodMetaData child,
          UnmarshallingContext ctx, String namespaceURI, String localName)
    {
-      ad.app.getAssemblyDescriptor().addMessageDestinationMetaData(mdmd); 
+      BeanMetaData bean = getBeanForMethod(parent, child);
+      bean.addExcludedMethod(child);
    }
 
    public void addChild(MessageDrivenMetaData parent, SecurityIdentityMetaData child,
@@ -589,6 +608,23 @@
       parent.addServiceReference(child);
    }
 
+   public void addChild(MethodPermission parent, MethodMetaData child,
+         UnmarshallingContext navigator, String namespaceURI, String localName)
+   {
+      BeanMetaData bean = getBeanForMethod(parent.ad, child);
+
+      if(parent.roles == null)
+      {
+         child.setUnchecked();
+      }
+      else
+      {
+         child.getRoles().addAll(parent.roles);
+      }
+
+      bean.addPermissionMethod(child);
+   }
+
    /**
     * Set text values of ejb-jar/* children
     * @param dd
@@ -877,18 +913,32 @@
       }
    }
 
-   public void setValue(MethodMetaData method,
+   public void setValue(MethodPermission method,
          UnmarshallingContext navigator, String namespaceURI, String localName,
          String value)
    {
-      // direct children
       if(localName.equals("role-name"))
       {
-         method.getRoles().add(value);
+         method.addRole(value);
       }
-      // method children
-      else if(localName.equals("ejb-name"))
+   }
+
+   public void setValue(ContainerTransaction parent,
+         UnmarshallingContext navigator, String namespaceURI, String localName,
+         String value)
+   {
+      if(localName.equals("trans-attribute"))
       {
+         parent.transAttr = MethodMetaData.getTransactionAttribute(value);
+      }
+   }
+
+   public void setValue(MethodMetaData method,
+         UnmarshallingContext navigator, String namespaceURI, String localName,
+         String value)
+   {
+      if(localName.equals("ejb-name"))
+      {
          method.setEjbName(value);
       }
       else if(localName.equals("method-intf"))
@@ -903,10 +953,6 @@
       {
          method.addParam(value);
       }
-      else if(localName.equals("trans-attribute"))
-      {
-         method.setTransactionType(value);
-      }
    }
 
    public void setValue(QueryMetaData query,
@@ -968,6 +1014,23 @@
       }
    }
 
+   // private
+
+   private BeanMetaData getBeanForMethod(AssemblyDescriptor parent, MethodMetaData child)
+   {
+      if(child.getEjbName() == null)
+      {
+         throw new IllegalStateException("Method permission without ejb-name!");
+      }
+
+      BeanMetaData bean = parent.app.getBeanByEjbName(child.getEjbName());
+      if(bean == null)
+      {
+         throw new IllegalStateException("Bean " + child.getEjbName() + " not found in the application.");
+      }
+      return bean;
+   }
+
    // inner
 
    public static class CMPFieldMetaData
@@ -984,4 +1047,30 @@
          this.app = app;
       }
    }
+
+   public static class MethodPermission
+   {
+      AssemblyDescriptor ad;
+      List roles;
+
+      public MethodPermission(AssemblyDescriptor ad)
+      {
+         this.ad = ad;
+      }
+
+      void addRole(String role)
+      {
+         if(roles == null)
+         {
+            roles = new ArrayList();
+         }
+         roles.add(role);
+      }
+   }
+
+   public static class ContainerTransaction
+   {
+      List methods = new ArrayList();
+      byte transAttr;
+   }
 }

Modified: trunk/server/src/main/org/jboss/metadata/MethodMetaData.java
===================================================================
--- trunk/server/src/main/org/jboss/metadata/MethodMetaData.java	2006-11-17 11:12:42 UTC (rev 58491)
+++ trunk/server/src/main/org/jboss/metadata/MethodMetaData.java	2006-11-17 12:01:07 UTC (rev 58492)
@@ -279,11 +279,6 @@
       transactionType = type;
    }
 
-   public void setTransactionType(String type)
-   {
-      transactionType = getTransactionAttribute(type);
-   }
-
    public Set getRoles()
    {
       return roles;




More information about the jboss-cvs-commits mailing list