[webbeans-commits] Webbeans SVN: r213 - ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/model/bean.
webbeans-commits at lists.jboss.org
webbeans-commits at lists.jboss.org
Fri Oct 31 15:00:18 EDT 2008
Author: dallen6
Date: 2008-10-31 15:00:18 -0400 (Fri, 31 Oct 2008)
New Revision: 213
Modified:
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/model/bean/EventBeanModel.java
Log:
Fixed Java 6 compiler error and replaced the reflection on T to find the constructor.
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/model/bean/EventBeanModel.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/model/bean/EventBeanModel.java 2008-10-31 14:46:37 UTC (rev 212)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/model/bean/EventBeanModel.java 2008-10-31 19:00:18 UTC (rev 213)
@@ -2,6 +2,7 @@
import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
+import java.util.logging.Level;
import java.util.logging.Logger;
import javax.webbeans.Dependent;
@@ -14,6 +15,8 @@
import org.jboss.webbeans.introspector.SimpleAnnotatedField;
import org.jboss.webbeans.util.LoggerUtil;
+import com.sun.org.apache.xerces.internal.dom.events.EventImpl;
+
/**
* Web Beans bean meta model for the container instantiated, injectable,
* observable events (Section 7.4).
@@ -28,33 +31,32 @@
private String location;
private SimpleAnnotatedField<T> annotatedItem;
private SimpleAnnotatedField<T> xmlAnnotatedItem;
- private BeanConstructor<T> constructor;
+ private BeanConstructor<T> constructor;
public EventBeanModel(SimpleAnnotatedField<T> annotatedItem, SimpleAnnotatedField<T> xmlAnnotatedItem, ManagerImpl manager)
{
this.annotatedItem = annotatedItem;
this.xmlAnnotatedItem = xmlAnnotatedItem;
+ initConstructor();
this.init(manager);
}
- @Override
- protected void init(ManagerImpl container)
- {
- super.init(container);
- this.initConstructor();
- }
-
/**
- * Initializes the constructor field of this class.
+ * Caches the constructor for this type of bean to avoid future reflections during use.
*/
- protected void initConstructor()
+ @SuppressWarnings("unchecked")
+ private void initConstructor()
{
- // There should only be one constructor for the event implementation used here
- // TODO Probably don't need to use reflection as this is a container supplied class
- Constructor<T> classConstructor = this.annotatedItem.getType().getConstructors()[0];
- constructor = new SimpleConstructor<T>(classConstructor);
+ try
+ {
+ constructor = new SimpleConstructor<T>((Constructor<T>) EventImpl.class.getConstructor((Class[])null));
+ } catch (Exception e)
+ {
+ log.log(Level.SEVERE, "Unable to get constructor for build-in Event implementation", e);
+ }
}
+
public BeanConstructor<T> getConstructor()
{
return constructor;
More information about the weld-commits
mailing list