[jboss-cvs] JBossAS SVN: r63565 - in projects/microcontainer/trunk: kernel/src/resources/tests/org/jboss/test/kernel/deployment/xml/test and 1 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Tue Jun 19 02:12:08 EDT 2007
Author: alesj
Date: 2007-06-19 02:12:07 -0400 (Tue, 19 Jun 2007)
New Revision: 63565
Added:
projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/deployment/xml/test/DeploymentWithAnnotations.xml
Modified:
projects/microcontainer/trunk/docs/gettingstarted/src/docbkx/en/modules/basics.xml
projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/deployment/xml/test/DeploymentTestCase.java
Log:
Docs annotations, Deployment with annotations.
Modified: projects/microcontainer/trunk/docs/gettingstarted/src/docbkx/en/modules/basics.xml
===================================================================
--- projects/microcontainer/trunk/docs/gettingstarted/src/docbkx/en/modules/basics.xml 2007-06-18 22:32:47 UTC (rev 63564)
+++ projects/microcontainer/trunk/docs/gettingstarted/src/docbkx/en/modules/basics.xml 2007-06-19 06:12:07 UTC (rev 63565)
@@ -978,6 +978,63 @@
</section>
<section>
+ <title>Annotations</title>
+
+ <para>With the new Microcontainer 2.0 we've added support for annotations via XML. Meaning you can have annotation
+ support even in Java 1.4 and before, depending on the retrowowen Microcontainer project.
+ Each annotation is set per bean instance and you can set annotations on the following types:
+ <itemizedlist>
+ <listitem>deployment (all beans inherit this annotations)</listitem>
+ <listitem>bean</listitem>
+ <listitem>constructor</listitem>
+ <listitem>lifecycle</listitem>
+ <listitem>install / uninstall</listitem>
+ <listitem>callback</listitem>
+ <listitem>annotated value</listitem>
+ </itemizedlist>
+ </para>
+
+ <programlisting>
+ <deployment name="SimpleDeployment" xmlns="urn:jboss:bean-deployer:2.0">
+
+ <annotation>@org.jboss.test.kernel.deployment.xml.support.Annotation1</annotation>
+ <annotation>@org.jboss.test.kernel.deployment.xml.support.AnnotationWithAttributes(clazz=java.lang.Integer.class, integer=100, str="Annotations are nice")</annotation>
+
+ <bean name="bn1" class="org.jboss.test.Example1">
+ <annotation>@org.jboss.test.kernel.deployment.xml.support.Annotation2</annotation>
+ <annotation>@org.jboss.test.kernel.deployment.xml.support.Annotation3</annotation>
+ </bean>
+
+ <bean name="bn2" class="org.jboss.test.Example2">
+ <constructor>
+ <annotation>@org.jboss.test.kernel.deployment.xml.support.Annotation3</annotation>
+ </constructor>
+ </bean>
+
+ <bean name="bn3" class="org.jboss.test.Example3">
+ <install method="someMethod">
+ <annotation>@org.jboss.test.kernel.deployment.xml.support.Annotation1</annotation>
+ </install>
+ </bean>
+
+ <bean name="bn4" class="org.jboss.test.Example4">
+ <create>
+ <annotation>@org.jboss.test.kernel.deployment.xml.support.Annotation1</annotation>
+ </create>
+ </bean>
+
+ <bean name="bn5" class="org.jboss.test.Example5">
+ <property name="PropertyName">
+ <annotation>@org.jboss.test.kernel.deployment.xml.support.Annotation1</annotation>
+ <value>123</value>
+ </property>
+ </bean>
+
+ </deployment>
+ </programlisting>
+ </section>
+
+ <section>
<title>Alias</title>
<para>Mostly bean will have one unique name, but sometimes it is useful to be able to have an extra name.
Added: projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/deployment/xml/test/DeploymentWithAnnotations.xml
===================================================================
--- projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/deployment/xml/test/DeploymentWithAnnotations.xml (rev 0)
+++ projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/deployment/xml/test/DeploymentWithAnnotations.xml 2007-06-19 06:12:07 UTC (rev 63565)
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<deployment name="SimpleDeployment" xmlns="urn:jboss:bean-deployer:2.0">
+
+ <annotation>@org.jboss.test.kernel.deployment.xml.support.Annotation1</annotation>
+ <annotation>@org.jboss.test.kernel.deployment.xml.support.AnnotationWithAttributes(clazz=java.lang.Integer.class, integer=100, str="Annotations are nice")</annotation>
+
+</deployment>
Modified: projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/deployment/xml/test/DeploymentTestCase.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/deployment/xml/test/DeploymentTestCase.java 2007-06-18 22:32:47 UTC (rev 63564)
+++ projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/deployment/xml/test/DeploymentTestCase.java 2007-06-19 06:12:07 UTC (rev 63565)
@@ -23,17 +23,22 @@
import java.util.List;
import java.util.Set;
+import java.util.ArrayList;
+import java.lang.annotation.Annotation;
import junit.framework.Test;
import org.jboss.beans.metadata.plugins.factory.GenericBeanFactory;
import org.jboss.beans.metadata.spi.BeanMetaData;
import org.jboss.beans.metadata.spi.BeanMetaDataFactory;
import org.jboss.beans.metadata.spi.LifecycleMetaData;
+import org.jboss.beans.metadata.spi.AnnotationMetaData;
import org.jboss.dependency.spi.ControllerMode;
import org.jboss.kernel.plugins.deployment.AbstractKernelDeployment;
import org.jboss.test.kernel.deployment.xml.support.TestBeanMetaDataFactory;
import org.jboss.test.kernel.deployment.xml.support.TestBeanMetaDataFactory1;
import org.jboss.test.kernel.deployment.xml.support.TestBeanMetaDataFactory2;
+import org.jboss.test.kernel.deployment.xml.support.Annotation1;
+import org.jboss.test.kernel.deployment.xml.support.AnnotationWithAttributes;
/**
* DeploymentTestCase.
@@ -293,6 +298,29 @@
assertEquals("SecondAlias", sndAliases.iterator().next());
}
+ public void testDeploymentWithAnnotations() throws Exception
+ {
+ AbstractKernelDeployment deployment = unmarshalDeployment("DeploymentWithAnnotations.xml");
+ Set<AnnotationMetaData> annotations = deployment.getAnnotations();
+ assertNotNull(annotations);
+ assertEquals(2, annotations.size());
+ List<AnnotationMetaData> annotationList = new ArrayList<AnnotationMetaData>(annotations);
+ Annotation ann = annotationList.get(0).getAnnotationInstance();
+ assertNotNull(ann);
+ assertEquals(Annotation1.class.getName(), ann.annotationType().getName());
+ ann = annotationList.get(1).getAnnotationInstance();
+ assertNotNull(ann);
+ assertEquals(AnnotationWithAttributes.class.getName(), ann.annotationType().getName());
+ assertTrue(ann instanceof AnnotationWithAttributes);
+ AnnotationWithAttributes ann1 = (AnnotationWithAttributes)ann;
+ assertNotNull(ann1.clazz());
+ assertEquals(Integer.class, ann1.clazz());
+ assertNotNull(ann1.integer());
+ assertEquals(100, ann1.integer());
+ assertNotNull(ann1.str());
+ assertEquals("Annotations are nice", ann1.str());
+ }
+
public static Test suite()
{
return suite(DeploymentTestCase.class);
More information about the jboss-cvs-commits
mailing list