Author: swd847
Date: 2010-03-05 15:37:57 -0500 (Fri, 05 Mar 2010)
New Revision: 6010
Modified:
extensions/trunk/core/src/main/java/org/jboss/weld/extensions/beans/BeanLifecycle.java
extensions/trunk/core/src/main/java/org/jboss/weld/extensions/beans/CustomBean.java
extensions/trunk/core/src/main/java/org/jboss/weld/extensions/util/annotated/NewAnnotatedType.java
Log:
Fixed a bug with NewAnnotatedType where you could not annotate non-public members
Modified:
extensions/trunk/core/src/main/java/org/jboss/weld/extensions/beans/BeanLifecycle.java
===================================================================
---
extensions/trunk/core/src/main/java/org/jboss/weld/extensions/beans/BeanLifecycle.java 2010-03-05
14:32:12 UTC (rev 6009)
+++
extensions/trunk/core/src/main/java/org/jboss/weld/extensions/beans/BeanLifecycle.java 2010-03-05
20:37:57 UTC (rev 6010)
@@ -2,6 +2,13 @@
import javax.enterprise.context.spi.CreationalContext;
+/**
+ * Hanlder for the create/destroy methods of CustomBean
+ *
+ * @author stuart
+ *
+ * @param <T>
+ */
public interface BeanLifecycle<T>
{
public T create(CustomBean<T> bean, CreationalContext<T> arg0);
Modified:
extensions/trunk/core/src/main/java/org/jboss/weld/extensions/beans/CustomBean.java
===================================================================
---
extensions/trunk/core/src/main/java/org/jboss/weld/extensions/beans/CustomBean.java 2010-03-05
14:32:12 UTC (rev 6009)
+++
extensions/trunk/core/src/main/java/org/jboss/weld/extensions/beans/CustomBean.java 2010-03-05
20:37:57 UTC (rev 6010)
@@ -11,6 +11,13 @@
import javax.enterprise.inject.spi.InjectionPoint;
import javax.enterprise.inject.spi.InjectionTarget;
+/**
+ * An immutable bean.
+ *
+ * @author stuart
+ *
+ * @param <T>
+ */
public class CustomBean<T> implements Bean<T>
{
final Class<?> beanClass;
Modified:
extensions/trunk/core/src/main/java/org/jboss/weld/extensions/util/annotated/NewAnnotatedType.java
===================================================================
---
extensions/trunk/core/src/main/java/org/jboss/weld/extensions/util/annotated/NewAnnotatedType.java 2010-03-05
14:32:12 UTC (rev 6009)
+++
extensions/trunk/core/src/main/java/org/jboss/weld/extensions/util/annotated/NewAnnotatedType.java 2010-03-05
20:37:57 UTC (rev 6010)
@@ -7,6 +7,7 @@
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
+import java.util.Map.Entry;
import javax.enterprise.inject.spi.AnnotatedConstructor;
import javax.enterprise.inject.spi.AnnotatedField;
@@ -29,28 +30,64 @@
private final Class<X> javaClass;
+ /**
+ * We make sure that there is a NewAnnotatedMember for every public
+ * method/field/constructor
+ *
+ * If annotation have been added to other methods as well we add them to
+ *
+ */
NewAnnotatedType(Class<X> clazz, AnnotationStore typeAnnotations, Map<Field,
AnnotationStore> fieldAnnotations, Map<Method, AnnotationStore>
methodAnnotations, Map<Method, Map<Integer, AnnotationStore>>
methodParameterAnnotations, Map<Constructor<X>, AnnotationStore>
constructorAnnotations, Map<Constructor<X>, Map<Integer,
AnnotationStore>> constructorParameterAnnotations)
{
super(clazz, typeAnnotations);
this.javaClass = clazz;
this.constructors = new HashSet<AnnotatedConstructor<X>>();
+ Set<Constructor<?>> cset = new HashSet<Constructor<?>>();
+ Set<Method> mset = new HashSet<Method>();
+ Set<Field> fset = new HashSet<Field>();
for (Constructor<?> c : clazz.getConstructors())
{
NewAnnotatedConstructor<X> nc = new NewAnnotatedConstructor<X>(this,
c, constructorAnnotations.get(c), constructorParameterAnnotations.get(c));
constructors.add(nc);
+ cset.add(c);
}
+ for (Entry<Constructor<X>, AnnotationStore> c :
constructorAnnotations.entrySet())
+ {
+ if (!cset.contains(c.getKey()))
+ {
+ NewAnnotatedConstructor<X> nc = new
NewAnnotatedConstructor<X>(this, c.getKey(), c.getValue(),
constructorParameterAnnotations.get(c.getKey()));
+ constructors.add(nc);
+ }
+ }
this.methods = new HashSet<AnnotatedMethod<? super X>>();
for (Method m : clazz.getMethods())
{
NewAnnotatedMethod<X> met = new NewAnnotatedMethod<X>(this, m,
methodAnnotations.get(m), methodParameterAnnotations.get(m));
methods.add(met);
+ mset.add(m);
}
+ for (Entry<Method, AnnotationStore> c : methodAnnotations.entrySet())
+ {
+ if (!mset.contains(c.getKey()))
+ {
+ NewAnnotatedMethod<X> nc = new NewAnnotatedMethod<X>(this,
c.getKey(), c.getValue(), methodParameterAnnotations.get(c.getKey()));
+ methods.add(nc);
+ }
+ }
this.fields = new HashSet<AnnotatedField<? super X>>();
for (Field f : clazz.getFields())
{
NewAnnotatedField<X> b = new NewAnnotatedField<X>(this, f,
fieldAnnotations.get(f));
fields.add(b);
+ fset.add(f);
}
+ for (Entry<Field, AnnotationStore> e : fieldAnnotations.entrySet())
+ {
+ if (fset.contains(e.getKey()))
+ {
+ fields.add(new NewAnnotatedField<X>(this, e.getKey(), e.getValue()));
+ }
+ }
}
public Set<AnnotatedConstructor<X>> getConstructors()
Show replies by date