Author: gavin.king(a)jboss.com
Date: 2008-12-07 12:16:58 -0500 (Sun, 07 Dec 2008)
New Revision: 441
Modified:
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/AbstractClassBean.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bootstrap/Bootstrap.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/util/BeanFactory.java
Log:
scan for producer fields
Modified:
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/AbstractClassBean.java
===================================================================
---
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/AbstractClassBean.java 2008-12-07
17:14:53 UTC (rev 440)
+++
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/AbstractClassBean.java 2008-12-07
17:16:58 UTC (rev 441)
@@ -104,6 +104,17 @@
}
/**
+ * Returns the producer fields
+ *
+ * @return A set of producer fields. An empty set is returned if there are
+ * none present
+ */
+ public Set<AnnotatedField<Object>> getProducerFields()
+ {
+ return getAnnotatedItem().getAnnotatedFields(Produces.class);
+ }
+
+ /**
* Returns @Observer annotated fields.
*
* @return A set of observing fields. An empty set is returned if there are
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bootstrap/Bootstrap.java
===================================================================
---
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bootstrap/Bootstrap.java 2008-12-07
17:14:53 UTC (rev 440)
+++
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bootstrap/Bootstrap.java 2008-12-07
17:16:58 UTC (rev 441)
@@ -20,6 +20,7 @@
import static org.jboss.webbeans.util.BeanFactory.createEnterpriseBean;
import static org.jboss.webbeans.util.BeanFactory.createEventBean;
import static org.jboss.webbeans.util.BeanFactory.createObserver;
+import static org.jboss.webbeans.util.BeanFactory.createProducerFieldBean;
import static org.jboss.webbeans.util.BeanFactory.createProducerMethodBean;
import static org.jboss.webbeans.util.BeanFactory.createSimpleBean;
@@ -38,6 +39,7 @@
import org.jboss.webbeans.bean.AbstractBean;
import org.jboss.webbeans.bean.AbstractClassBean;
import org.jboss.webbeans.bean.EventBean;
+import org.jboss.webbeans.bean.ProducerFieldBean;
import org.jboss.webbeans.bean.ProducerMethodBean;
import org.jboss.webbeans.bindings.InitializedBinding;
import org.jboss.webbeans.bootstrap.spi.WebBeanDiscovery;
@@ -141,6 +143,12 @@
CurrentManager.rootManager().getResolver().addInjectionPoints(producerMethodBean.getInjectionPoints());
log.info("Web Bean: " + producerMethodBean);
}
+ for (AnnotatedField<Object> producerField : bean.getProducerFields())
+ {
+ ProducerFieldBean<?> producerFieldBean =
createProducerFieldBean(producerField, bean);
+ beans.add(producerFieldBean);
+ log.info("Web Bean: " + producerFieldBean);
+ }
for (AnnotatedField<Object> eventField : bean.getEventFields())
{
EventBean<?> eventBean = createEventBean(eventField);
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/util/BeanFactory.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/util/BeanFactory.java 2008-12-07
17:14:53 UTC (rev 440)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/util/BeanFactory.java 2008-12-07
17:16:58 UTC (rev 441)
@@ -17,12 +17,14 @@
package org.jboss.webbeans.util;
+import java.lang.reflect.Field;
import java.lang.reflect.Method;
import org.jboss.webbeans.CurrentManager;
import org.jboss.webbeans.bean.AbstractClassBean;
import org.jboss.webbeans.bean.EnterpriseBean;
import org.jboss.webbeans.bean.EventBean;
+import org.jboss.webbeans.bean.ProducerFieldBean;
import org.jboss.webbeans.bean.ProducerMethodBean;
import org.jboss.webbeans.bean.SimpleBean;
import org.jboss.webbeans.event.ObserverImpl;
@@ -75,6 +77,32 @@
}
/**
+ * Creates a producer field Web Bean
+ *
+ * @param <T> The type
+ * @param type The class
+ * @param field The underlying field
+ * @param declaringBean The declaring bean abstraction
+ * @return A producer Web Bean
+ */
+ public static <T> ProducerFieldBean<T>
createProducerFieldBean(Class<T> type, Field field, AbstractClassBean<?>
declaringBean)
+ {
+ return new ProducerFieldBean<T>(field, declaringBean,
CurrentManager.rootManager());
+ }
+
+ /**
+ * Creates a producer field Web Bean
+ *
+ * @param field The underlying method abstraction
+ * @param declaringBean The declaring bean abstraction
+ * @return A producer Web Bean
+ */
+ public static <T> ProducerFieldBean<T>
createProducerFieldBean(AnnotatedField<T> field, AbstractClassBean<?>
declaringBean)
+ {
+ return new ProducerFieldBean<T>(field, declaringBean,
CurrentManager.rootManager());
+ }
+
+ /**
* Creates a producer method Web Bean
*
* @param method The underlying method abstraction
Show replies by date