[jboss-cvs] JBossAS SVN: r75968 - in projects/microcontainer/trunk/aop-mc-int/src: main/org/jboss/aop/microcontainer/beans/metadata and 2 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Thu Jul 17 13:50:12 EDT 2008


Author: kabir.khan at jboss.com
Date: 2008-07-17 13:50:12 -0400 (Thu, 17 Jul 2008)
New Revision: 75968

Added:
   projects/microcontainer/trunk/aop-mc-int/src/resources/tests/org/jboss/test/microcontainer/beans/test/DomainParentAopTestCase.xml
   projects/microcontainer/trunk/aop-mc-int/src/resources/tests/org/jboss/test/microcontainer/beans/test/DomainParentBeansTestCase.xml
   projects/microcontainer/trunk/aop-mc-int/src/resources/tests/org/jboss/test/microcontainer/beans/test/DomainParentDeploymentTestCase.xml
   projects/microcontainer/trunk/aop-mc-int/src/tests/org/jboss/test/microcontainer/beans/test/DomainParentAopTestCase.java
   projects/microcontainer/trunk/aop-mc-int/src/tests/org/jboss/test/microcontainer/beans/test/DomainParentBeansTestCase.java
   projects/microcontainer/trunk/aop-mc-int/src/tests/org/jboss/test/microcontainer/beans/test/DomainParentDeploymentTestCase.java
   projects/microcontainer/trunk/aop-mc-int/src/tests/org/jboss/test/microcontainer/beans/test/DomainParentTest.java
Modified:
   projects/microcontainer/trunk/aop-mc-int/src/main/org/jboss/aop/microcontainer/beans/AOPDomain.java
   projects/microcontainer/trunk/aop-mc-int/src/main/org/jboss/aop/microcontainer/beans/metadata/DomainBeanMetaDataFactory.java
Log:
[JBMICROCONT-315] JBossXB for aspect domain did not set the parentFirst, extends, inheritBindings and inheritDefinitions attributes

Modified: projects/microcontainer/trunk/aop-mc-int/src/main/org/jboss/aop/microcontainer/beans/AOPDomain.java
===================================================================
--- projects/microcontainer/trunk/aop-mc-int/src/main/org/jboss/aop/microcontainer/beans/AOPDomain.java	2008-07-17 17:46:15 UTC (rev 75967)
+++ projects/microcontainer/trunk/aop-mc-int/src/main/org/jboss/aop/microcontainer/beans/AOPDomain.java	2008-07-17 17:50:12 UTC (rev 75968)
@@ -36,7 +36,7 @@
    boolean parentFirst=false;
    boolean inheritDefinitions=true;
    boolean inheritBindings=false;
-   String extendz;
+   AOPDomain parent;
    DomainDefinition definition;
 
    public AspectManager getManager()
@@ -89,14 +89,14 @@
       this.inheritBindings = inheritBindings;
    }
 
-   public String getExtends()
+   public AOPDomain getParent()
    {
-      return extendz;
+      return parent;
    }
 
-   public void setExtends(String extendz)
+   public void setParent(AOPDomain parent)
    {
-      this.extendz = extendz;
+      this.parent = parent;
    }
 
    public AspectManager getDomain()
@@ -107,14 +107,9 @@
    public void start()
    {
       AspectManager parent = manager;
-      if (extendz != null)
+      if (this.parent != null)
       {
-         DomainDefinition parentDef = manager.getContainer(extendz);
-         if (parentDef == null)
-         {
-            throw new RuntimeException("unable to find parent Domain: " + extendz);
-         }
-         parent = parentDef.getManager();
+         parent = this.parent.getDomain();
       }
          
       definition = new DomainDefinition(name, parent, parentFirst, inheritDefinitions, inheritBindings);

Modified: projects/microcontainer/trunk/aop-mc-int/src/main/org/jboss/aop/microcontainer/beans/metadata/DomainBeanMetaDataFactory.java
===================================================================
--- projects/microcontainer/trunk/aop-mc-int/src/main/org/jboss/aop/microcontainer/beans/metadata/DomainBeanMetaDataFactory.java	2008-07-17 17:46:15 UTC (rev 75967)
+++ projects/microcontainer/trunk/aop-mc-int/src/main/org/jboss/aop/microcontainer/beans/metadata/DomainBeanMetaDataFactory.java	2008-07-17 17:50:12 UTC (rev 75968)
@@ -25,6 +25,7 @@
 import java.util.List;
 
 import javax.xml.bind.annotation.XmlAnyElement;
+import javax.xml.bind.annotation.XmlAttribute;
 import javax.xml.bind.annotation.XmlElement;
 import javax.xml.bind.annotation.XmlElements;
 import javax.xml.bind.annotation.XmlNsForm;
@@ -35,6 +36,7 @@
 import org.jboss.aop.microcontainer.beans.AOPDomain;
 import org.jboss.beans.metadata.spi.BeanMetaData;
 import org.jboss.beans.metadata.spi.BeanMetaDataFactory;
+import org.jboss.beans.metadata.spi.ValueMetaData;
 import org.jboss.beans.metadata.spi.builder.BeanMetaDataBuilder;
 import org.jboss.xb.annotations.JBossXmlSchema;
 
@@ -50,37 +52,64 @@
 public class DomainBeanMetaDataFactory extends AspectManagerAwareBeanMetaDataFactory
 {
    private static final long serialVersionUID = 1L;
-   String parentFirst;
-   String inheritDefinitions;
-   String inheritBindings;
+   
+   //Same defaults as org.jboss.aop.Domain
+   Boolean parentFirst;
+   Boolean inheritDefinitions = true;
+   Boolean inheritBindings;
    String extendz;
-   
+
    List<BeanMetaDataFactory> childBeans;
    
    public DomainBeanMetaDataFactory()
    {
    }
+   
 
-   public void setParentFirst(String parentFirst)
+   @XmlAttribute(name="parentFirst")
+   public void setParentFirst(boolean parentFirst)
    {
       this.parentFirst = parentFirst;
    }
+   
+   public boolean getParentFirst()
+   {
+      return parentFirst;
+   }
 
-   public void setInheritDefinitions(String inheritDefinitions)
+   @XmlAttribute(name="inheritDefinitions")
+   public void setInheritDefinitions(boolean  inheritDefinitions)
    {
       this.inheritDefinitions = inheritDefinitions;
    }
 
-   public void setInheritBindings(String inheritBindings)
+   public boolean getInheritDefinitions()
    {
+      return inheritDefinitions;
+   }
+
+   @XmlAttribute(name="inheritBindings")
+   public void setInheritBindings(boolean  inheritBindings)
+   {
       this.inheritBindings = inheritBindings;
    }
 
+   public boolean getInheritBindings()
+   {
+      return inheritBindings;
+   }
+
+   @XmlAttribute
    public void setExtends(String extendz)
    {
       this.extendz = extendz;
    }
 
+   public String getExtends()
+   {
+      return extendz;
+   }
+
    @XmlElements
    ({
       @XmlElement(name="annotation", type=AnnotationOverrideBeanMetaDataFactory.class),
@@ -128,7 +157,7 @@
       
       BeanMetaDataBuilder domainBuilder = BeanMetaDataBuilder.createBuilder(getName(), AOPDomain.class.getName());
       domainBuilder.addPropertyMetaData("name", getName());
-      
+    
       if (parentFirst != null)
       {
          domainBuilder.addPropertyMetaData("parentFirst", parentFirst);
@@ -143,8 +172,10 @@
       }
       if (extendz != null)
       {
-         domainBuilder.addPropertyMetaData("extends", extendz);
+         ValueMetaData value = domainBuilder.createInject(extendz);
+         domainBuilder.addPropertyMetaData("parent", value);
       }
+      
       setAspectManagerProperty(domainBuilder);
       result.add(domainBuilder.getBeanMetaData());
       

Added: projects/microcontainer/trunk/aop-mc-int/src/resources/tests/org/jboss/test/microcontainer/beans/test/DomainParentAopTestCase.xml
===================================================================
--- projects/microcontainer/trunk/aop-mc-int/src/resources/tests/org/jboss/test/microcontainer/beans/test/DomainParentAopTestCase.xml	                        (rev 0)
+++ projects/microcontainer/trunk/aop-mc-int/src/resources/tests/org/jboss/test/microcontainer/beans/test/DomainParentAopTestCase.xml	2008-07-17 17:50:12 UTC (rev 75968)
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<aop xmlns="urn:jboss:aop-beans:1.0">
+
+   <bean name="AspectManager" class="org.jboss.aop.AspectManager">
+      <constructor factoryClass="org.jboss.aop.AspectManager" factoryMethod="instance"/>
+   </bean>
+
+   <domain name="Level1" parentFirst="true" inheritDefinitions="true" inheritBindings="true">
+      <annotation xmlns="urn:jboss:aop-beans:1.0" expr="class(org.jboss.test.microcontainer.beans.POJO)" invisible="false">
+         @org.jboss.test.microcontainer.beans.Annotation1
+      </annotation>
+      <metadata-loader tag="custom" class="org.jboss.test.microcontainer.beans.TestMetaDataLoader"/>
+   </domain>
+
+   <domain name="Level2ParentFirst" parentFirst="true" inheritDefinitions="true" inheritBindings="true" extends="Level1">
+      <annotation xmlns="urn:jboss:aop-beans:1.0" expr="class(org.jboss.test.microcontainer.beans.POJO)" invisible="false">
+         @org.jboss.test.microcontainer.beans.Annotation2
+      </annotation>
+   </domain>
+   
+   <domain name="Level2ParentLast" parentFirst="false" inheritDefinitions="true" inheritBindings="true" extends="Level1">
+      <annotation xmlns="urn:jboss:aop-beans:1.0" expr="class(org.jboss.test.microcontainer.beans.POJO)" invisible="false">
+         @org.jboss.test.microcontainer.beans.Annotation2
+      </annotation>
+   </domain>
+
+   <domain name="Level2Nada" parentFirst="false" inheritDefinitions="false" inheritBindings="false" extends="Level1">
+   </domain>
+</aop>

Added: projects/microcontainer/trunk/aop-mc-int/src/resources/tests/org/jboss/test/microcontainer/beans/test/DomainParentBeansTestCase.xml
===================================================================
--- projects/microcontainer/trunk/aop-mc-int/src/resources/tests/org/jboss/test/microcontainer/beans/test/DomainParentBeansTestCase.xml	                        (rev 0)
+++ projects/microcontainer/trunk/aop-mc-int/src/resources/tests/org/jboss/test/microcontainer/beans/test/DomainParentBeansTestCase.xml	2008-07-17 17:50:12 UTC (rev 75968)
@@ -0,0 +1,72 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<deployment xmlns="urn:jboss:bean-deployer:2.0">
+
+   <bean name="AspectManager" class="org.jboss.aop.AspectManager">
+      <constructor factoryClass="org.jboss.aop.AspectManager" factoryMethod="instance"/>
+   </bean>
+
+   <bean name="Level1" class="org.jboss.aop.microcontainer.beans.AOPDomain">
+      <property name="name">Level1</property>
+      <property name="manager"><inject bean="AspectManager"/></property>
+      <property name="parentFirst">true</property>   
+      <property name="inheritDefinitions">true</property>   
+      <property name="inheritBindings">true</property>   
+   </bean>
+
+   <bean name="Annotation1" class="org.jboss.aop.microcontainer.beans.AnnotationOverride">
+      <property name="manager"><inject bean="Level1" property="domain"/></property>
+      <property name="expr">class(org.jboss.test.microcontainer.beans.POJO)</property>
+      <property name="annotation">@org.jboss.test.microcontainer.beans.Annotation1</property>
+      <property name="invisible">false</property>
+   </bean>
+   
+   <bean name="custom$loader" class="org.jboss.aop.microcontainer.beans.ClassMetaDataLoader">
+      <property name="manager"><inject bean="Level1" property="domain"/></property>
+      <property name="tag">custom</property>
+      <property name="className">org.jboss.test.microcontainer.beans.TestMetaDataLoader</property>
+   </bean>
+   
+
+   <bean name="Level2ParentFirst" class="org.jboss.aop.microcontainer.beans.AOPDomain">
+      <property name="name">Level2ParentFirst</property>
+      <property name="manager"><inject bean="AspectManager"/></property>
+      <property name="parent"><inject bean="Level1"/></property>
+      <property name="parentFirst">true</property>   
+      <property name="inheritDefinitions">true</property>   
+      <property name="inheritBindings">true</property>   
+   </bean>
+
+   <bean name="Annotation2First" class="org.jboss.aop.microcontainer.beans.AnnotationOverride">
+      <property name="manager"><inject bean="Level2ParentFirst" property="domain"/></property>
+      <property name="expr">class(org.jboss.test.microcontainer.beans.POJO)</property>
+      <property name="annotation">@org.jboss.test.microcontainer.beans.Annotation2</property>
+      <property name="invisible">false</property>
+   </bean>
+   
+
+   <bean name="Level2ParentLast" class="org.jboss.aop.microcontainer.beans.AOPDomain">
+      <property name="name">Level2ParentLast</property>
+      <property name="manager"><inject bean="AspectManager"/></property>
+      <property name="parent"><inject bean="Level1"/></property>
+      <property name="parentFirst">false</property>   
+      <property name="inheritDefinitions">true</property>   
+      <property name="inheritBindings">true</property>   
+   </bean>
+
+   <bean name="Annotation2Last" class="org.jboss.aop.microcontainer.beans.AnnotationOverride">
+      <property name="manager"><inject bean="Level2ParentLast" property="domain"/></property>
+      <property name="expr">class(org.jboss.test.microcontainer.beans.POJO)</property>
+      <property name="annotation">@org.jboss.test.microcontainer.beans.Annotation2</property>
+      <property name="invisible">false</property>
+   </bean>
+   
+   <bean name="Level2Nada" class="org.jboss.aop.microcontainer.beans.AOPDomain">
+      <property name="name">Level2Nada</property>
+      <property name="manager"><inject bean="AspectManager"/></property>
+      <property name="parent"><inject bean="Level1"/></property>
+      <property name="parentFirst">false</property>   
+      <property name="inheritDefinitions">false</property>   
+      <property name="inheritBindings">false</property>   
+   </bean>
+</deployment>

Added: projects/microcontainer/trunk/aop-mc-int/src/resources/tests/org/jboss/test/microcontainer/beans/test/DomainParentDeploymentTestCase.xml
===================================================================
--- projects/microcontainer/trunk/aop-mc-int/src/resources/tests/org/jboss/test/microcontainer/beans/test/DomainParentDeploymentTestCase.xml	                        (rev 0)
+++ projects/microcontainer/trunk/aop-mc-int/src/resources/tests/org/jboss/test/microcontainer/beans/test/DomainParentDeploymentTestCase.xml	2008-07-17 17:50:12 UTC (rev 75968)
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<deployment xmlns="urn:jboss:bean-deployer:2.0">
+
+   <bean name="AspectManager" class="org.jboss.aop.AspectManager">
+      <constructor factoryClass="org.jboss.aop.AspectManager" factoryMethod="instance"/>
+   </bean>
+
+   <domain xmlns="urn:jboss:aop-beans:1.0" name="Level1" parentFirst="true" inheritDefinitions="true" inheritBindings="true">
+      <annotation xmlns="urn:jboss:aop-beans:1.0" expr="class(org.jboss.test.microcontainer.beans.POJO)" invisible="false">
+         @org.jboss.test.microcontainer.beans.Annotation1
+      </annotation>
+      <metadata-loader tag="custom" class="org.jboss.test.microcontainer.beans.TestMetaDataLoader"/>
+   </domain>
+
+   <domain xmlns="urn:jboss:aop-beans:1.0" name="Level2ParentFirst" parentFirst="true" inheritDefinitions="true" inheritBindings="true" extends="Level1">
+      <annotation xmlns="urn:jboss:aop-beans:1.0" expr="class(org.jboss.test.microcontainer.beans.POJO)" invisible="false">
+         @org.jboss.test.microcontainer.beans.Annotation2
+      </annotation>
+   </domain>
+   
+   <domain xmlns="urn:jboss:aop-beans:1.0" name="Level2ParentLast" parentFirst="false" inheritDefinitions="true" inheritBindings="true" extends="Level1">
+      <annotation xmlns="urn:jboss:aop-beans:1.0" expr="class(org.jboss.test.microcontainer.beans.POJO)" invisible="false">
+         @org.jboss.test.microcontainer.beans.Annotation2
+      </annotation>
+   </domain>
+
+   <domain xmlns="urn:jboss:aop-beans:1.0" name="Level2Nada" parentFirst="false" inheritDefinitions="false" inheritBindings="false" extends="Level1">
+   </domain>
+</deployment>

Added: projects/microcontainer/trunk/aop-mc-int/src/tests/org/jboss/test/microcontainer/beans/test/DomainParentAopTestCase.java
===================================================================
--- projects/microcontainer/trunk/aop-mc-int/src/tests/org/jboss/test/microcontainer/beans/test/DomainParentAopTestCase.java	                        (rev 0)
+++ projects/microcontainer/trunk/aop-mc-int/src/tests/org/jboss/test/microcontainer/beans/test/DomainParentAopTestCase.java	2008-07-17 17:50:12 UTC (rev 75968)
@@ -0,0 +1,44 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, 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.test.microcontainer.beans.test;
+
+import junit.framework.Test;
+
+/**
+ * 
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class DomainParentAopTestCase extends DomainParentTest
+{
+
+   public DomainParentAopTestCase(String name)
+   {
+      super(name);
+   }
+
+   public static Test suite()
+   {
+      return suite(DomainParentAopTestCase.class);
+   }
+
+}

Added: projects/microcontainer/trunk/aop-mc-int/src/tests/org/jboss/test/microcontainer/beans/test/DomainParentBeansTestCase.java
===================================================================
--- projects/microcontainer/trunk/aop-mc-int/src/tests/org/jboss/test/microcontainer/beans/test/DomainParentBeansTestCase.java	                        (rev 0)
+++ projects/microcontainer/trunk/aop-mc-int/src/tests/org/jboss/test/microcontainer/beans/test/DomainParentBeansTestCase.java	2008-07-17 17:50:12 UTC (rev 75968)
@@ -0,0 +1,48 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, 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.test.microcontainer.beans.test;
+
+import org.jboss.aop.AspectManager;
+import org.jboss.aop.Domain;
+import org.jboss.aop.microcontainer.beans.AOPDomain;
+
+import junit.framework.Test;
+
+/**
+ * 
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class DomainParentBeansTestCase extends DomainParentTest
+{
+
+   public DomainParentBeansTestCase(String name)
+   {
+      super(name);
+   }
+
+   public static Test suite()
+   {
+      return suite(DomainParentBeansTestCase.class);
+   }
+
+}

Added: projects/microcontainer/trunk/aop-mc-int/src/tests/org/jboss/test/microcontainer/beans/test/DomainParentDeploymentTestCase.java
===================================================================
--- projects/microcontainer/trunk/aop-mc-int/src/tests/org/jboss/test/microcontainer/beans/test/DomainParentDeploymentTestCase.java	                        (rev 0)
+++ projects/microcontainer/trunk/aop-mc-int/src/tests/org/jboss/test/microcontainer/beans/test/DomainParentDeploymentTestCase.java	2008-07-17 17:50:12 UTC (rev 75968)
@@ -0,0 +1,44 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, 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.test.microcontainer.beans.test;
+
+import junit.framework.Test;
+
+/**
+ * 
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class DomainParentDeploymentTestCase extends DomainParentTest
+{
+
+   public DomainParentDeploymentTestCase(String name)
+   {
+      super(name);
+   }
+
+   public static Test suite()
+   {
+      return suite(DomainParentDeploymentTestCase.class);
+   }
+
+}

Added: projects/microcontainer/trunk/aop-mc-int/src/tests/org/jboss/test/microcontainer/beans/test/DomainParentTest.java
===================================================================
--- projects/microcontainer/trunk/aop-mc-int/src/tests/org/jboss/test/microcontainer/beans/test/DomainParentTest.java	                        (rev 0)
+++ projects/microcontainer/trunk/aop-mc-int/src/tests/org/jboss/test/microcontainer/beans/test/DomainParentTest.java	2008-07-17 17:50:12 UTC (rev 75968)
@@ -0,0 +1,109 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, 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.test.microcontainer.beans.test;
+
+import java.util.List;
+import java.util.Map;
+
+import org.jboss.aop.AspectManager;
+import org.jboss.aop.Domain;
+import org.jboss.aop.introduction.AnnotationIntroduction;
+import org.jboss.aop.metadata.ClassMetaDataLoader;
+import org.jboss.aop.microcontainer.beans.AOPDomain;
+
+
+/**
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public abstract class DomainParentTest extends DomainProxyTest
+{
+   public DomainParentTest(String name)
+   {
+      super(name);
+   }
+
+   public void testDomainWithParentInheritance()
+   {
+      Domain parentFirst = getDomainAndCheck("Level2ParentFirst", true, true, true);
+      List<AnnotationIntroduction> overridesFirst = parentFirst.getAnnotationOverrides();
+      assertEquals(2, overridesFirst.size());
+      
+      assertNotNull(parentFirst.getClassMetaDataLoaders());
+      assertEquals(1, parentFirst.getClassMetaDataLoaders().size());
+
+      Domain parentLast = getDomainAndCheck("Level2ParentLast", true, true, false);
+      List<AnnotationIntroduction> overridesLast = parentLast.getAnnotationOverrides();
+      assertEquals(2, overridesLast.size());
+
+      assertNotNull(parentLast.getClassMetaDataLoaders());
+      assertEquals(1, parentLast.getClassMetaDataLoaders().size());
+      
+      assertEquals(overridesFirst.get(0).getOriginalAnnotationExpr(), overridesLast.get(1).getOriginalAnnotationExpr());
+      assertEquals(overridesFirst.get(1).getOriginalAnnotationExpr(), overridesLast.get(0).getOriginalAnnotationExpr());
+   }
+   
+   public void testDomainWithNoInheritanceFromParent()
+   {
+      Domain level2 = getDomainAndCheck("Level2Nada", false, false, false);
+      List<AnnotationIntroduction> overrides = level2.getAnnotationOverrides();
+      assertEquals(0, overrides.size());
+
+      Map<String, ClassMetaDataLoader> loaders = level2.getClassMetaDataLoaders();
+      assertEquals(0, loaders.size());
+}
+   
+   private Domain getDomainAndCheck(String name, boolean inheritBindings, boolean inheritDefinitions, boolean isParentFirst)
+   {
+      Domain level1 = (Domain)getDomain("Level1");
+      checkLevel1Domain(null, level1);
+
+      Domain level2 = (Domain)getDomain(name);
+      checkDomain(level1, level2, name, inheritBindings, inheritDefinitions, isParentFirst);
+      return level2;
+   }
+   
+   private void checkLevel1Domain(AspectManager parent, Domain domain)
+   {
+      checkDomain(parent, domain, "Level1", true, true, true);
+   }
+   
+   private void checkDomain(AspectManager parent, Domain domain, String name, boolean inheritBindings, boolean inheritDefinitions, boolean isParentFirst)
+   {
+      AOPDomain bean = (AOPDomain)getBean(name);
+      assertSame(domain, bean.getDomain());
+
+      assertEquals(inheritBindings, bean.isInheritBindings());
+      assertEquals(inheritDefinitions, bean.isInheritDefinitions());
+      assertEquals(isParentFirst, bean.isParentFirst());
+      
+      if (parent == null)
+      {
+         assertNull(bean.getParent());
+      }
+      else
+      {
+         assertSame(parent, bean.getParent().getDomain());
+      }
+   }
+}




More information about the jboss-cvs-commits mailing list