[jboss-cvs] JBossAS SVN: r67134 - in projects/microcontainer/trunk/aop-mc-int/src: resources/tests/org/jboss/test/microcontainer/beans2/test and 2 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Thu Nov 15 09:39:12 EST 2007
Author: kabir.khan at jboss.com
Date: 2007-11-15 09:39:12 -0500 (Thu, 15 Nov 2007)
New Revision: 67134
Added:
projects/microcontainer/trunk/aop-mc-int/src/main/org/jboss/aop/microcontainer/beans2/ClassMetaData.java
projects/microcontainer/trunk/aop-mc-int/src/main/org/jboss/aop/microcontainer/beans2/ClassMetaDataLoader.java
projects/microcontainer/trunk/aop-mc-int/src/main/org/jboss/aop/microcontainer/beans2/SecurityActions.java
projects/microcontainer/trunk/aop-mc-int/src/resources/tests/org/jboss/test/microcontainer/beans2/test/ClassMetaDataBeansTestCase.xml
projects/microcontainer/trunk/aop-mc-int/src/resources/tests/org/jboss/test/microcontainer/beans2/test/ClassMetaDataLoaderBeansTestCase.xml
projects/microcontainer/trunk/aop-mc-int/src/resources/tests/org/jboss/test/microcontainer/beans2/test/TESTS.txt
projects/microcontainer/trunk/aop-mc-int/src/tests/org/jboss/test/microcontainer/beans2/TestClassMetaDataAspect.java
projects/microcontainer/trunk/aop-mc-int/src/tests/org/jboss/test/microcontainer/beans2/TestMetaDataBinding.java
projects/microcontainer/trunk/aop-mc-int/src/tests/org/jboss/test/microcontainer/beans2/TestMetaDataLoader.java
projects/microcontainer/trunk/aop-mc-int/src/tests/org/jboss/test/microcontainer/beans2/test/ClassMetaDataBeansTestCase.java
projects/microcontainer/trunk/aop-mc-int/src/tests/org/jboss/test/microcontainer/beans2/test/ClassMetaDataLoaderBeansTestCase.java
Log:
Add underlying beans to support CLassMetaData in -aop.xml style in -beans.xml
This will all be moved around, I just wanted to commit before I start doing that
Added: projects/microcontainer/trunk/aop-mc-int/src/main/org/jboss/aop/microcontainer/beans2/ClassMetaData.java
===================================================================
--- projects/microcontainer/trunk/aop-mc-int/src/main/org/jboss/aop/microcontainer/beans2/ClassMetaData.java (rev 0)
+++ projects/microcontainer/trunk/aop-mc-int/src/main/org/jboss/aop/microcontainer/beans2/ClassMetaData.java 2007-11-15 14:39:12 UTC (rev 67134)
@@ -0,0 +1,122 @@
+/*
+* 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.aop.microcontainer.beans2;
+
+import org.jboss.aop.AspectManager;
+import org.jboss.aop.metadata.ClassMetaDataBinding;
+import org.jboss.aop.metadata.ClassMetaDataLoader;
+import org.jboss.util.id.GUID;
+import org.w3c.dom.Element;
+
+/**
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class ClassMetaData
+{
+ AspectManager manager;
+ String name = GUID.asString();
+
+ //Should we read these from the element instead?
+ String tag;
+ String className;
+
+ Element element;
+
+ public AspectManager getManager()
+ {
+ return manager;
+ }
+
+ public void setManager(AspectManager manager)
+ {
+ this.manager = manager;
+ }
+
+ public String getName()
+ {
+ return name;
+ }
+
+ public void setName(String name)
+ {
+ this.name = name;
+ }
+
+ public String getTag()
+ {
+ return tag;
+ }
+
+ public void setTag(String tag)
+ {
+ this.tag = tag;
+ }
+
+ public String getClassName()
+ {
+ return className;
+ }
+
+ public void setClassName(String className)
+ {
+ this.className = className;
+ }
+
+ public Element getElement()
+ {
+ return element;
+ }
+
+ public void setElement(Element element)
+ {
+ this.element = element;
+ }
+
+ public void start()
+ {
+ if (manager == null)
+ throw new IllegalArgumentException("Null manager");
+ if (tag == null)
+ throw new IllegalArgumentException("Null tag");
+ if (className == null)
+ throw new IllegalArgumentException("Null className");
+
+ ClassMetaDataLoader loader = manager.findClassMetaDataLoader(tag);
+ try
+ {
+ ClassMetaDataBinding data = loader.importMetaData(element, name, tag, className);
+ manager.addClassMetaData(data);
+ }
+ catch (Exception e)
+ {
+ // AutoGenerated
+ throw new RuntimeException(e);
+ }
+ }
+
+ public void stop()
+ {
+ manager.removeClassMetaData(name);
+ }
+}
Added: projects/microcontainer/trunk/aop-mc-int/src/main/org/jboss/aop/microcontainer/beans2/ClassMetaDataLoader.java
===================================================================
--- projects/microcontainer/trunk/aop-mc-int/src/main/org/jboss/aop/microcontainer/beans2/ClassMetaDataLoader.java (rev 0)
+++ projects/microcontainer/trunk/aop-mc-int/src/main/org/jboss/aop/microcontainer/beans2/ClassMetaDataLoader.java 2007-11-15 14:39:12 UTC (rev 67134)
@@ -0,0 +1,95 @@
+/*
+* 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.aop.microcontainer.beans2;
+
+import org.jboss.aop.AspectManager;
+
+/**
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class ClassMetaDataLoader
+{
+ AspectManager manager;
+ String tag;
+ String className;
+
+ public AspectManager getManager()
+ {
+ return manager;
+ }
+
+ public void setManager(AspectManager manager)
+ {
+ this.manager = manager;
+ }
+
+ public String getTag()
+ {
+ return tag;
+ }
+
+ public void setTag(String tag)
+ {
+ this.tag = tag;
+ }
+
+ public String getClassName()
+ {
+ return className;
+ }
+
+ public void setClassName(String className)
+ {
+ this.className = className;
+ }
+
+ public void start()
+ {
+ if (manager == null)
+ throw new IllegalArgumentException("Null manager");
+ if (tag == null)
+ throw new IllegalArgumentException("Null tag");
+ if (className == null)
+ throw new IllegalArgumentException("Null className");
+
+ try
+ {
+ //FIXME Probably need to use something else
+ ClassLoader cl = SecurityActions.getContextClassLoader();
+ Class clazz = cl.loadClass(className);
+ org.jboss.aop.metadata.ClassMetaDataLoader loader = (org.jboss.aop.metadata.ClassMetaDataLoader)clazz.newInstance();
+
+ manager.addClassMetaDataLoader(tag, loader);
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeException(e);
+ }
+ }
+
+ public void stop()
+ {
+ manager.removeClassMetaDataLoader(tag);
+ }
+}
Added: projects/microcontainer/trunk/aop-mc-int/src/main/org/jboss/aop/microcontainer/beans2/SecurityActions.java
===================================================================
--- projects/microcontainer/trunk/aop-mc-int/src/main/org/jboss/aop/microcontainer/beans2/SecurityActions.java (rev 0)
+++ projects/microcontainer/trunk/aop-mc-int/src/main/org/jboss/aop/microcontainer/beans2/SecurityActions.java 2007-11-15 14:39:12 UTC (rev 67134)
@@ -0,0 +1,63 @@
+/*
+* 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.aop.microcontainer.beans2;
+
+/**
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+class SecurityActions
+{
+ private interface GetContextClassLoaderAction
+ {
+ ClassLoader getContextClassLoader();
+
+ GetContextClassLoaderAction PRIVILEGED = new GetContextClassLoaderAction() {
+
+ public ClassLoader getContextClassLoader()
+ {
+ return null;
+ }
+ };
+
+ GetContextClassLoaderAction NOT_PRIVILEGED = new GetContextClassLoaderAction() {
+
+ public ClassLoader getContextClassLoader()
+ {
+ return Thread.currentThread().getContextClassLoader();
+ }
+ };
+ }
+
+ public static ClassLoader getContextClassLoader()
+ {
+ if (System.getSecurityManager() == null)
+ {
+ return GetContextClassLoaderAction.NOT_PRIVILEGED.getContextClassLoader();
+ }
+ else
+ {
+ return GetContextClassLoaderAction.PRIVILEGED.getContextClassLoader();
+ }
+ }
+}
Added: projects/microcontainer/trunk/aop-mc-int/src/resources/tests/org/jboss/test/microcontainer/beans2/test/ClassMetaDataBeansTestCase.xml
===================================================================
--- projects/microcontainer/trunk/aop-mc-int/src/resources/tests/org/jboss/test/microcontainer/beans2/test/ClassMetaDataBeansTestCase.xml (rev 0)
+++ projects/microcontainer/trunk/aop-mc-int/src/resources/tests/org/jboss/test/microcontainer/beans2/test/ClassMetaDataBeansTestCase.xml 2007-11-15 14:39:12 UTC (rev 67134)
@@ -0,0 +1,54 @@
+<?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="ClassMetaData" class="org.jboss.aop.microcontainer.beans2.ClassMetaData">
+ <property name="manager"><inject bean="AspectManager"/></property>
+ <property name="tag">SomeTag</property>
+ <property name="className">org.jboss.test.microcontainer.beans2.POJO</property>
+ <property name="element">
+ <![CDATA[
+ <metadata>
+ <constructor expr="POJO()">
+ <data>ctor</data>
+ </constructor>
+ <method expr="int *(..)">
+ <data>method1</data>
+ </method>
+ <method expr="void *()">
+ <data>method2</data>
+ </method>
+ </metadata>
+ ]]>
+ </property>
+ </bean>
+
+ <beanfactory name="Factory$org.jboss.test.microcontainer.beans2.TestClassMetaDataAspect" class="org.jboss.test.microcontainer.beans2.TestClassMetaDataAspect"/>
+
+ <bean name="org.jboss.test.microcontainer.beans2.TestClassMetaDataAspect" class="org.jboss.aop.microcontainer.beans2.Aspect">
+ <property name="advice"><inject bean="Factory$org.jboss.test.microcontainer.beans2.TestClassMetaDataAspect"/></property>
+ <property name="manager"><inject bean="AspectManager"/></property>
+ </bean>
+
+ <bean name="TestAspectBinding" class="org.jboss.aop.microcontainer.beans2.AspectBinding">
+ <property name="pointcut">execution(org.jboss.test.microcontainer.beans2.POJO->new(..)) OR execution(* org.jboss.test.microcontainer.beans2.POJO->*(..))</property>
+ <property name="manager"><inject bean="AspectManager"/></property>
+ <property name="advices">
+ <list>
+ <bean name="TestAspectBinding1$" class="org.jboss.aop.microcontainer.beans2.InterceptorEntry">
+ <property name="manager"><inject bean="AspectManager"/></property>
+ <property name="aspect"><inject bean="org.jboss.test.microcontainer.beans2.TestClassMetaDataAspect"/></property>
+ <property name="aspectMethod">advice</property>
+ <property name="aspectBinding"><inject bean="TestAspectBinding" state="Instantiated"/></property>
+ </bean>
+ </list>
+ </property>
+ </bean>
+
+ <bean name="Bean" class="org.jboss.test.microcontainer.beans2.POJO"/>
+
+</deployment>
Added: projects/microcontainer/trunk/aop-mc-int/src/resources/tests/org/jboss/test/microcontainer/beans2/test/ClassMetaDataLoaderBeansTestCase.xml
===================================================================
--- projects/microcontainer/trunk/aop-mc-int/src/resources/tests/org/jboss/test/microcontainer/beans2/test/ClassMetaDataLoaderBeansTestCase.xml (rev 0)
+++ projects/microcontainer/trunk/aop-mc-int/src/resources/tests/org/jboss/test/microcontainer/beans2/test/ClassMetaDataLoaderBeansTestCase.xml 2007-11-15 14:39:12 UTC (rev 67134)
@@ -0,0 +1,52 @@
+<?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="custom$loader" class="org.jboss.aop.microcontainer.beans2.ClassMetaDataLoader">
+ <property name="manager"><inject bean="AspectManager"/></property>
+ <property name="tag">custom</property>
+ <property name="className">org.jboss.test.microcontainer.beans2.TestMetaDataLoader</property>
+ </bean>
+
+ <bean name="ClassMetaData" class="org.jboss.aop.microcontainer.beans2.ClassMetaData">
+ <property name="manager"><inject bean="AspectManager"/></property>
+ <property name="tag">custom</property>
+ <property name="className">org.jboss.test.microcontainer.beans2.POJO</property>
+ <property name="element">
+ <![CDATA[
+ <metadata>
+ <data>custom1</data>
+ </metadata>
+ ]]>
+ </property>
+ </bean>
+
+ <beanfactory name="Factory$org.jboss.test.microcontainer.beans2.TestClassMetaDataAspect" class="org.jboss.test.microcontainer.beans2.TestClassMetaDataAspect"/>
+
+ <bean name="org.jboss.test.microcontainer.beans2.TestClassMetaDataAspect" class="org.jboss.aop.microcontainer.beans2.Aspect">
+ <property name="advice"><inject bean="Factory$org.jboss.test.microcontainer.beans2.TestClassMetaDataAspect"/></property>
+ <property name="manager"><inject bean="AspectManager"/></property>
+ </bean>
+
+ <bean name="TestAspectBinding" class="org.jboss.aop.microcontainer.beans2.AspectBinding">
+ <property name="pointcut">execution(org.jboss.test.microcontainer.beans2.POJO->new(..)) OR execution(* org.jboss.test.microcontainer.beans2.POJO->*(..))</property>
+ <property name="manager"><inject bean="AspectManager"/></property>
+ <property name="advices">
+ <list>
+ <bean name="TestAspectBinding1$" class="org.jboss.aop.microcontainer.beans2.InterceptorEntry">
+ <property name="manager"><inject bean="AspectManager"/></property>
+ <property name="aspect"><inject bean="org.jboss.test.microcontainer.beans2.TestClassMetaDataAspect"/></property>
+ <property name="aspectMethod">advice</property>
+ <property name="aspectBinding"><inject bean="TestAspectBinding" state="Instantiated"/></property>
+ </bean>
+ </list>
+ </property>
+ </bean>
+
+ <bean name="Bean" class="org.jboss.test.microcontainer.beans2.POJO"/>
+
+</deployment>
Added: projects/microcontainer/trunk/aop-mc-int/src/resources/tests/org/jboss/test/microcontainer/beans2/test/TESTS.txt
===================================================================
--- projects/microcontainer/trunk/aop-mc-int/src/resources/tests/org/jboss/test/microcontainer/beans2/test/TESTS.txt (rev 0)
+++ projects/microcontainer/trunk/aop-mc-int/src/resources/tests/org/jboss/test/microcontainer/beans2/test/TESTS.txt 2007-11-15 14:39:12 UTC (rev 67134)
@@ -0,0 +1,66 @@
+*aspect/advice
+AspectSimpleBeansTestCase
+
+*interceptor
+InterceptorSimpleBeansTestCase
+
+*interceptor w/ dependency
+InterceptorWithDependencyBeansTestCase
+InterceptorWithDependencyBeansDifferentOrderTestCase
+
+*aspect/advice with dependency
+AspectWithDependencyBeansTestCase
+AspectWithDependencyBeansDifferentOrderTestCase
+
+*multiple aspects/interceptors
+MultipleAdviceBeansTestCase.java
+
+*multiple aspects/interceptors w/ dependency
+MultipleAdvicesWithSingleDependencyBeansTestCase
+MultipleAdvicesWithSingleDependencyBeansDifferentOrderTestCase
+MultipleAdvicesWithMultipleDependencyBeansTestCase
+MultipleAdvicesWithMultipleDependencyBeansDifferentOrderTestCase
+
+
+*interceptor/aspect factory
+AspectFactorySimpleBeansTestCase
+InterceptorFactorySimpleBeansTestCase
+
+* scoped aspects/interceptors (PER_CLASS, PER_VM etc.)
+ScopedAspectBeansTestCase *** SOME PROBLEMS WITH testPerClassJoinPoint() if any of the other tests are enabled?!?!?!
+
+*interceptor/aspect factory with dependency
+
+
+*named aspects/interceptors
+NonStandardNameAspectBeansTestCase
+*** Should maybe do one for beans with depenencies as well
+
+*cflow in bindings
+CFlowBeansTestCase
+
+*aspects/interceptors with attributes
+*** Need tests for the "magically" inserted advisor, instance advisor etc.
+
+*interceptor stacks
+StackBeansTestCase
+MultipleStackBeansTestCase
+
+*interceptor stacks where entries have dependencies
+StackWithSingleDependencyBeansTestCase
+StackWithSingleDependencyBeansDifferentOrderTestCase
+StackWithMultipleDependencyBeansTestCase
+StackWithMultipleDependencyBeansDifferentOrderTestCase
+
+*binding deployed seperately from aspect definition
+
+*domains
+
+*annotation overrides
+AnnotationOverrideBeansTestCase
+
+*typedefs
+TypeDefBeansTestCase
+
+*Named pointcuts
+NamedPointcutBeansTestCase
\ No newline at end of file
Added: projects/microcontainer/trunk/aop-mc-int/src/tests/org/jboss/test/microcontainer/beans2/TestClassMetaDataAspect.java
===================================================================
--- projects/microcontainer/trunk/aop-mc-int/src/tests/org/jboss/test/microcontainer/beans2/TestClassMetaDataAspect.java (rev 0)
+++ projects/microcontainer/trunk/aop-mc-int/src/tests/org/jboss/test/microcontainer/beans2/TestClassMetaDataAspect.java 2007-11-15 14:39:12 UTC (rev 67134)
@@ -0,0 +1,43 @@
+/*
+* 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.beans2;
+
+import org.jboss.aop.joinpoint.Invocation;
+
+/**
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class TestClassMetaDataAspect
+{
+ public static boolean invoked;
+ public static String last;
+
+ public Object advice(Invocation inv) throws Throwable
+ {
+ Interceptions.add(this);
+ invoked = true;
+ last = (String)inv.getMetaData("SomeTag", "data");
+ return inv.invokeNext();
+ }
+}
Added: projects/microcontainer/trunk/aop-mc-int/src/tests/org/jboss/test/microcontainer/beans2/TestMetaDataBinding.java
===================================================================
--- projects/microcontainer/trunk/aop-mc-int/src/tests/org/jboss/test/microcontainer/beans2/TestMetaDataBinding.java (rev 0)
+++ projects/microcontainer/trunk/aop-mc-int/src/tests/org/jboss/test/microcontainer/beans2/TestMetaDataBinding.java 2007-11-15 14:39:12 UTC (rev 67134)
@@ -0,0 +1,53 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., and individual contributors as indicated
+* 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.test.microcontainer.beans2;
+
+import org.jboss.aop.metadata.ClassMetaDataBinding;
+import org.jboss.aop.metadata.ClassMetaDataLoader;
+
+/**
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision$
+ */
+public class TestMetaDataBinding extends ClassMetaDataBinding
+{
+ String data;
+
+ public TestMetaDataBinding(ClassMetaDataLoader loader, String name, String tag, String exp)
+ {
+ super(loader, name, tag, exp);
+ }
+
+ public String getData()
+ {
+ return data;
+ }
+
+ public void setData(String data)
+ {
+ this.data = data;
+ }
+
+
+
+}
Added: projects/microcontainer/trunk/aop-mc-int/src/tests/org/jboss/test/microcontainer/beans2/TestMetaDataLoader.java
===================================================================
--- projects/microcontainer/trunk/aop-mc-int/src/tests/org/jboss/test/microcontainer/beans2/TestMetaDataLoader.java (rev 0)
+++ projects/microcontainer/trunk/aop-mc-int/src/tests/org/jboss/test/microcontainer/beans2/TestMetaDataLoader.java 2007-11-15 14:39:12 UTC (rev 67134)
@@ -0,0 +1,80 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., and individual contributors as indicated
+* 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.test.microcontainer.beans2;
+
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+
+import javassist.CtConstructor;
+import javassist.CtField;
+import javassist.CtMethod;
+
+import org.jboss.aop.Advisor;
+import org.jboss.aop.metadata.ClassMetaDataBinding;
+import org.jboss.aop.metadata.ClassMetaDataLoader;
+import org.jboss.aop.util.XmlHelper;
+import org.w3c.dom.Element;
+
+/**
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision$
+ */
+public class TestMetaDataLoader implements ClassMetaDataLoader
+{
+ public ClassMetaDataBinding importMetaData(Element element, String name, String tag, String classExpr) throws Exception
+ {
+ TestMetaDataBinding data = new TestMetaDataBinding(this, name, tag, classExpr);
+ String value = XmlHelper.getOptionalChildContent(element, "data");
+ data.setData(value);
+
+ return data;
+ }
+
+ public void bind(Advisor advisor, ClassMetaDataBinding data, CtMethod[] methods, CtField[] fields, CtConstructor[] constructors) throws Exception
+ {
+ for (int i = 0 ; i < methods.length ; i++)
+ {
+ advisor.getMethodMetaData().addMethodMetaData(methods[i], "SomeTag", "data", "M" + ((TestMetaDataBinding)data).getData());
+ }
+ for (int i = 0 ; i < constructors.length ; i++)
+ {
+ advisor.getConstructorMetaData().addConstructorMetaData(constructors[i], "SomeTag", "data", "C" + ((TestMetaDataBinding)data).getData());
+ }
+ }
+
+ public void bind(Advisor advisor, ClassMetaDataBinding data, Method[] methods, Field[] fields, Constructor[] constructors) throws Exception
+ {
+ for (int i = 0 ; i < methods.length ; i++)
+ {
+ advisor.getMethodMetaData().addMethodMetaData(methods[i], "SomeTag", "data", "M" + ((TestMetaDataBinding)data).getData());
+ }
+ for (int i = 0 ; i < constructors.length ; i++)
+ {
+ advisor.getConstructorMetaData().addConstructorMetaData(constructors[i], "SomeTag", "data", "C" + ((TestMetaDataBinding)data).getData());
+ }
+ }
+
+
+
+}
Added: projects/microcontainer/trunk/aop-mc-int/src/tests/org/jboss/test/microcontainer/beans2/test/ClassMetaDataBeansTestCase.java
===================================================================
--- projects/microcontainer/trunk/aop-mc-int/src/tests/org/jboss/test/microcontainer/beans2/test/ClassMetaDataBeansTestCase.java (rev 0)
+++ projects/microcontainer/trunk/aop-mc-int/src/tests/org/jboss/test/microcontainer/beans2/test/ClassMetaDataBeansTestCase.java 2007-11-15 14:39:12 UTC (rev 67134)
@@ -0,0 +1,67 @@
+/*
+* 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.beans2.test;
+
+import junit.framework.Test;
+
+import org.jboss.aop.microcontainer.junit.AOPMicrocontainerTest;
+import org.jboss.test.microcontainer.beans2.POJO;
+import org.jboss.test.microcontainer.beans2.TestClassMetaDataAspect;
+
+/**
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class ClassMetaDataBeansTestCase extends AOPMicrocontainerTest
+{
+ public void testMetaData() throws Exception
+ {
+ POJO pojo = (POJO)getBean("Bean");
+ assertNotNull(pojo);
+
+ assertTrue(TestClassMetaDataAspect.invoked);
+ assertEquals("ctor", TestClassMetaDataAspect.last);
+
+ TestClassMetaDataAspect.invoked = false;
+ TestClassMetaDataAspect.last = null;
+ pojo.method(2);
+ assertTrue(TestClassMetaDataAspect.invoked);
+ assertEquals("method1", TestClassMetaDataAspect.last);
+
+ TestClassMetaDataAspect.invoked = false;
+ TestClassMetaDataAspect.last = null;
+ pojo.method();
+ assertTrue(TestClassMetaDataAspect.invoked);
+ assertEquals("method2", TestClassMetaDataAspect.last);
+ }
+
+ public static Test suite()
+ {
+ return suite(ClassMetaDataBeansTestCase.class);
+ }
+
+ public ClassMetaDataBeansTestCase(String test)
+ {
+ super(test);
+ }
+}
Added: projects/microcontainer/trunk/aop-mc-int/src/tests/org/jboss/test/microcontainer/beans2/test/ClassMetaDataLoaderBeansTestCase.java
===================================================================
--- projects/microcontainer/trunk/aop-mc-int/src/tests/org/jboss/test/microcontainer/beans2/test/ClassMetaDataLoaderBeansTestCase.java (rev 0)
+++ projects/microcontainer/trunk/aop-mc-int/src/tests/org/jboss/test/microcontainer/beans2/test/ClassMetaDataLoaderBeansTestCase.java 2007-11-15 14:39:12 UTC (rev 67134)
@@ -0,0 +1,67 @@
+/*
+* 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.beans2.test;
+
+import junit.framework.Test;
+
+import org.jboss.aop.microcontainer.junit.AOPMicrocontainerTest;
+import org.jboss.test.microcontainer.beans2.POJO;
+import org.jboss.test.microcontainer.beans2.TestClassMetaDataAspect;
+
+/**
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class ClassMetaDataLoaderBeansTestCase extends AOPMicrocontainerTest
+{
+ public void testMetaData() throws Exception
+ {
+ POJO pojo = (POJO)getBean("Bean");
+ assertNotNull(pojo);
+
+ assertTrue(TestClassMetaDataAspect.invoked);
+ assertEquals("Ccustom1", TestClassMetaDataAspect.last);
+
+ TestClassMetaDataAspect.invoked = false;
+ TestClassMetaDataAspect.last = null;
+ pojo.method(2);
+ assertTrue(TestClassMetaDataAspect.invoked);
+ assertEquals("Mcustom1", TestClassMetaDataAspect.last);
+
+ TestClassMetaDataAspect.invoked = false;
+ TestClassMetaDataAspect.last = null;
+ pojo.method();
+ assertTrue(TestClassMetaDataAspect.invoked);
+ assertEquals("Mcustom1", TestClassMetaDataAspect.last);
+ }
+
+ public static Test suite()
+ {
+ return suite(ClassMetaDataLoaderBeansTestCase.class);
+ }
+
+ public ClassMetaDataLoaderBeansTestCase(String test)
+ {
+ super(test);
+ }
+}
More information about the jboss-cvs-commits
mailing list