Skip to content

Commit

Permalink
Fixed Java 6 compiler error and replaced the reflection on T to find …
Browse files Browse the repository at this point in the history
…the constructor.

git-svn-id: http://anonsvn.jboss.org/repos/weld/ri/trunk@213 1c488680-804c-0410-94cd-c6b725194a0e
  • Loading branch information
drallen committed Oct 31, 2008
1 parent 99577dd commit 6948406
Showing 1 changed file with 16 additions and 14 deletions.
Expand Up @@ -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;
Expand All @@ -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).
Expand All @@ -28,33 +31,32 @@ public class EventBeanModel<T> extends AbstractBeanModel<T, Field>
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;
Expand Down

0 comments on commit 6948406

Please sign in to comment.