[jboss-cvs] JBossAS SVN: r74873 - in projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata: plugins/builder and 1 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Fri Jun 20 07:56:34 EDT 2008
Author: alesj
Date: 2008-06-20 07:56:34 -0400 (Fri, 20 Jun 2008)
New Revision: 74873
Added:
projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/DirectAnnotationMetaData.java
Modified:
projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/builder/BeanMetaDataBuilderImpl.java
projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/spi/builder/BeanMetaDataBuilder.java
Log:
Allow direct annotation addition to bean metadata.
Copied: projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/DirectAnnotationMetaData.java (from rev 74253, projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/AbstractAnnotationMetaData.java)
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/DirectAnnotationMetaData.java (rev 0)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/DirectAnnotationMetaData.java 2008-06-20 11:56:34 UTC (rev 74873)
@@ -0,0 +1,108 @@
+/*
+* 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.beans.metadata.plugins;
+
+import java.io.Serializable;
+import java.lang.annotation.Annotation;
+import java.util.Iterator;
+import javax.xml.bind.annotation.XmlTransient;
+
+import org.jboss.beans.metadata.spi.AnnotationMetaData;
+import org.jboss.beans.metadata.spi.MetaDataVisitor;
+import org.jboss.beans.metadata.spi.MetaDataVisitorNode;
+import org.jboss.util.JBossObject;
+import org.jboss.util.JBossStringBuilder;
+
+/**
+ * Metadata for an annotation.
+ *
+ * @author <a href="ales.justin at jboss.com">Ales Justin</a>
+ */
+public class DirectAnnotationMetaData extends JBossObject implements AnnotationMetaData, Serializable
+{
+ private static final long serialVersionUID = 1L;
+
+ private Annotation annotation;
+
+ public DirectAnnotationMetaData(Annotation annotation)
+ {
+ if (annotation == null)
+ throw new IllegalArgumentException("Null annotation");
+
+ this.annotation = annotation;
+ }
+
+ @XmlTransient
+ public Annotation getAnnotationInstance()
+ {
+ return annotation;
+ }
+
+ public Annotation getAnnotationInstance(ClassLoader cl)
+ {
+ return annotation;
+ }
+
+ public void initialVisit(MetaDataVisitor visitor)
+ {
+ visitor.initialVisit(this);
+ }
+
+ public void describeVisit(MetaDataVisitor vistor)
+ {
+ vistor.describeVisit(this);
+ }
+
+ public Iterator<? extends MetaDataVisitorNode> getChildren()
+ {
+ return null;
+ }
+
+ public void toString(JBossStringBuilder buffer)
+ {
+ buffer.append("annotationr=").append(annotation);
+ }
+
+ public void toShortString(JBossStringBuilder buffer)
+ {
+ buffer.append(annotation);
+ }
+
+ protected int getHashCode()
+ {
+ return annotation.hashCode();
+ }
+
+ public boolean equals(Object object)
+ {
+ if (object == null || object instanceof DirectAnnotationMetaData == false)
+ return false;
+
+ DirectAnnotationMetaData damd = (DirectAnnotationMetaData)object;
+ return annotation.equals(damd.annotation);
+ }
+
+ public DirectAnnotationMetaData clone()
+ {
+ return (DirectAnnotationMetaData)super.clone();
+ }
+}
\ No newline at end of file
Modified: projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/builder/BeanMetaDataBuilderImpl.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/builder/BeanMetaDataBuilderImpl.java 2008-06-20 11:26:12 UTC (rev 74872)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/builder/BeanMetaDataBuilderImpl.java 2008-06-20 11:56:34 UTC (rev 74873)
@@ -27,6 +27,7 @@
import java.util.List;
import java.util.Map;
import java.util.Set;
+import java.lang.annotation.Annotation;
import org.jboss.beans.info.spi.BeanAccessMode;
import org.jboss.beans.metadata.plugins.AbstractArrayMetaData;
@@ -48,6 +49,7 @@
import org.jboss.beans.metadata.plugins.StringValueMetaData;
import org.jboss.beans.metadata.plugins.ThisValueMetaData;
import org.jboss.beans.metadata.plugins.AbstractAnnotationMetaData;
+import org.jboss.beans.metadata.plugins.DirectAnnotationMetaData;
import org.jboss.beans.metadata.spi.BeanMetaData;
import org.jboss.beans.metadata.spi.ClassLoaderMetaData;
import org.jboss.beans.metadata.spi.DemandMetaData;
@@ -313,6 +315,17 @@
* Create annotation metadata.
*
* @param annotation the string annotation
+ * @return the annotation metadata
+ */
+ protected AnnotationMetaData createAnnotationMetaData(Annotation annotation)
+ {
+ return new DirectAnnotationMetaData(annotation);
+ }
+
+ /**
+ * Create annotation metadata.
+ *
+ * @param annotation the string annotation
* @param replace the replace flag
* @return the annotation metadata
*/
@@ -362,6 +375,14 @@
return this;
}
+ public BeanMetaDataBuilder addAnnotation(Annotation annotation)
+ {
+ Set<AnnotationMetaData> annotations = getAnnotations();
+ AnnotationMetaData amd = createAnnotationMetaData(annotation);
+ annotations.add(amd);
+ return this;
+ }
+
public BeanMetaDataBuilder addAnnotation(String annotation, boolean replace)
{
Set<AnnotationMetaData> annotations = getAnnotations();
Modified: projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/spi/builder/BeanMetaDataBuilder.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/spi/builder/BeanMetaDataBuilder.java 2008-06-20 11:26:12 UTC (rev 74872)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/spi/builder/BeanMetaDataBuilder.java 2008-06-20 11:56:34 UTC (rev 74873)
@@ -21,21 +21,22 @@
*/
package org.jboss.beans.metadata.spi.builder;
+import java.lang.annotation.Annotation;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.Set;
+import org.jboss.beans.info.spi.BeanAccessMode;
+import org.jboss.beans.metadata.api.model.AutowireType;
import org.jboss.beans.metadata.plugins.AbstractBeanMetaData;
import org.jboss.beans.metadata.plugins.builder.BeanMetaDataBuilderFactory;
import org.jboss.beans.metadata.spi.BeanMetaData;
import org.jboss.beans.metadata.spi.ClassLoaderMetaData;
import org.jboss.beans.metadata.spi.ValueMetaData;
-import org.jboss.beans.metadata.api.model.AutowireType;
-import org.jboss.beans.info.spi.BeanAccessMode;
+import org.jboss.dependency.spi.Cardinality;
import org.jboss.dependency.spi.ControllerMode;
import org.jboss.dependency.spi.ControllerState;
-import org.jboss.dependency.spi.Cardinality;
import org.jboss.dependency.spi.ErrorHandlingMode;
/**
@@ -144,6 +145,14 @@
* Add annotation.
*
* @param annotation the annotation
+ * @return the builder
+ */
+ public abstract BeanMetaDataBuilder addAnnotation(Annotation annotation);
+
+ /**
+ * Add annotation.
+ *
+ * @param annotation the annotation
* @param replace the replace flag
* @return the builder
*/
More information about the jboss-cvs-commits
mailing list