Author: nickarls
Date: 2008-12-05 18:00:17 -0500 (Fri, 05 Dec 2008)
New Revision: 422
Modified:
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/EventBean.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bootstrap/Bootstrap.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/event/EventImpl.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/AnnotatedMethod.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/util/BeanFactory.java
ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/EventTest.java
Log:
minor manager singleton cleanups
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/EventBean.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/EventBean.java 2008-12-05
21:52:51 UTC (rev 421)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/EventBean.java 2008-12-05
23:00:17 UTC (rev 422)
@@ -25,7 +25,6 @@
import javax.webbeans.Event;
import javax.webbeans.Standard;
-import org.jboss.webbeans.ManagerImpl;
import org.jboss.webbeans.event.EventImpl;
import org.jboss.webbeans.introspector.AnnotatedField;
import org.jboss.webbeans.introspector.AnnotatedItem;
@@ -162,11 +161,12 @@
/**
* @see javax.webbeans.manager.Bean#create()
*/
+ @SuppressWarnings("unchecked")
@Override
public Event<T> create()
{
Class<T> eventType = (Class<T>)
annotatedItem.getType().getTypeParameters()[0].getClass();
- return new EventImpl<T>(ManagerImpl.instance(), eventType,
annotatedItem.getBindingTypesAsArray());
+ return new EventImpl<T>(eventType, annotatedItem.getBindingTypesAsArray());
}
}
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-05
21:52:51 UTC (rev 421)
+++
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bootstrap/Bootstrap.java 2008-12-05
23:00:17 UTC (rev 422)
@@ -126,13 +126,13 @@
ManagerImpl.instance().getResolver().addInjectionPoints(bean.getInjectionPoints());
for (AnnotatedMethod<Object> producerMethod : bean.getProducerMethods())
{
- ProducerMethodBean<?> producerMethodBean =
createProducerMethodBean(producerMethod.getType(), producerMethod, bean);
+ ProducerMethodBean<?> producerMethodBean =
createProducerMethodBean(producerMethod, bean);
beans.add(producerMethodBean);
ManagerImpl.instance().getResolver().addInjectionPoints(producerMethodBean.getInjectionPoints());
}
for (AnnotatedField<Object> eventField : bean.getEventFields())
{
- EventBean<?> eventBean = createEventBean(eventField.getType(),
eventField);
+ EventBean<?> eventBean = createEventBean(eventField);
beans.add(eventBean);
ManagerImpl.instance().getResolver().addInjectionPoints(eventBean.getInjectionPoints());
}
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/event/EventImpl.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/event/EventImpl.java 2008-12-05
21:52:51 UTC (rev 421)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/event/EventImpl.java 2008-12-05
23:00:17 UTC (rev 422)
@@ -39,27 +39,22 @@
* @param <T>
* @see javax.webbeans.Event
*/
-@Standard
-@Dependent
public class EventImpl<T> implements Event<T>
{
// The set of binding types
private final Set<? extends Annotation> bindingTypes;
// The event type
private final Class<T> eventType;
- // The Web Beans manager
- protected final ManagerImpl manager;
/**
* Constructor
*
* @param bindingTypes The binding types
*/
- public EventImpl(ManagerImpl manager, Class<T> eventType, Annotation...
bindingTypes)
+ public EventImpl(Class<T> eventType, Annotation... bindingTypes)
{
this.bindingTypes = getBindingTypes(bindingTypes);
this.eventType = eventType;
- this.manager = manager;
}
/**
@@ -68,8 +63,8 @@
* Removes @Observable from the list
*
* @param annotations The annotations to validate
- * @return A set of binding type annotations (minus @Observable, if it
- * was present)
+ * @return A set of binding type annotations (minus @Observable, if it was
+ * present)
*/
private static Set<Annotation> getBindingTypes(Annotation... annotations)
{
@@ -103,10 +98,12 @@
{
throw new IllegalArgumentException(annotation + " is not a binding
type");
}
- for (Annotation bindingAnnotation: this.bindingTypes) {
- if (bindingAnnotation.annotationType().equals(annotation.annotationType()))
{
+ for (Annotation bindingAnnotation : this.bindingTypes)
+ {
+ if (bindingAnnotation.annotationType().equals(annotation.annotationType()))
+ {
throw new DuplicateBindingTypeException(annotation + " is already
present in the bindings list");
- }
+ }
}
result.add(annotation);
}
@@ -123,7 +120,7 @@
{
Set<Annotation> bindingParameters = checkBindingTypes(bindingTypes);
bindingParameters.addAll(this.bindingTypes);
- manager.fireEvent(event, bindingParameters.toArray(new Annotation[0]));
+ ManagerImpl.instance().fireEvent(event, bindingParameters.toArray(new
Annotation[0]));
}
/**
@@ -136,7 +133,7 @@
{
Set<Annotation> bindingParameters = checkBindingTypes(bindingTypes);
bindingParameters.addAll(this.bindingTypes);
- manager.addObserver(observer, eventType, bindingParameters.toArray(new
Annotation[0]));
+ ManagerImpl.instance().addObserver(observer, eventType,
bindingParameters.toArray(new Annotation[0]));
}
-
+
}
Modified:
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/AnnotatedMethod.java
===================================================================
---
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/AnnotatedMethod.java 2008-12-05
21:52:51 UTC (rev 421)
+++
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/AnnotatedMethod.java 2008-12-05
23:00:17 UTC (rev 422)
@@ -60,7 +60,7 @@
* Invokes the observer method
*
* @param instance The instance to invoke
- * @param event the event object
+ * @param event the event object
* @return A reference to the instance
*/
public T invokeWithSpecialValue(Object instance, Class<? extends Annotation>
specialParam, Object specialVal);
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-05
21:52:51 UTC (rev 421)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/util/BeanFactory.java 2008-12-05
23:00:17 UTC (rev 422)
@@ -101,12 +101,11 @@
/**
* Creates a producer method Web Bean
*
- * @param type The type
* @param method The underlying method abstraction
* @param declaringBean The declaring bean abstraction
* @return A producer Web Bean
*/
- public static <T> ProducerMethodBean<T>
createProducerMethodBean(Class<T> type, AnnotatedMethod<T> method,
AbstractClassBean<?> declaringBean)
+ public static <T> ProducerMethodBean<T>
createProducerMethodBean(AnnotatedMethod<T> method, AbstractClassBean<?>
declaringBean)
{
return new ProducerMethodBean<T>(method, declaringBean);
}
@@ -114,13 +113,11 @@
/**
* Creates an event Web Bean
*
- * @param <T>
- * @param type The type
* @param field The observer field abstraction
* @param declaringBean The declaring bean abstraction
* @return An event Web Bean
*/
- public static <T> EventBean<T> createEventBean(Class<T> type,
AnnotatedField<T> field)
+ public static <T> EventBean<T> createEventBean(AnnotatedField<T>
field)
{
return new EventBean<T>(field);
}
Modified: ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/EventTest.java
===================================================================
--- ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/EventTest.java 2008-12-05
21:52:51 UTC (rev 421)
+++ ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/EventTest.java 2008-12-05
23:00:17 UTC (rev 422)
@@ -56,6 +56,7 @@
enabledDeploymentTypes.add(Standard.class);
enabledDeploymentTypes.add(AnotherDeploymentType.class);
manager = new MockManagerImpl();
+ MockManagerImpl.setInstance(manager);
manager.setEnabledDeploymentTypes(Standard.class, AnotherDeploymentType.class);
}
@@ -72,7 +73,7 @@
//Create a test annotation for the event and use it to construct the
//event object
Annotation[] annotations = new Annotation[] { new TameAnnotationLiteral() };
- EventImpl<DangerCall> eventComponent = new
EventImpl<DangerCall>(manager, DangerCall.class, annotations);
+ EventImpl<DangerCall> eventComponent = new
EventImpl<DangerCall>(DangerCall.class, annotations);
eventComponent.fire(anEvent, new SynchronousAnnotationLiteral());
assert anEvent.equals(manager.getEvent());
assert Reflections.annotationSetMatches(manager.getEventBindings(),
@@ -113,7 +114,7 @@
//Create a test annotation for the event and use it to construct the
//event object
Annotation[] annotations = new Annotation[] { new TameAnnotationLiteral() };
- EventImpl<DangerCall> eventComponent = new
EventImpl<DangerCall>(manager, DangerCall.class, annotations);
+ EventImpl<DangerCall> eventComponent = new
EventImpl<DangerCall>(DangerCall.class, annotations);
Observer<DangerCall> observer = new AnObserver<DangerCall>();
eventComponent.observe(observer, new SynchronousAnnotationLiteral());
assert manager.getObservedEventType().equals(DangerCall.class);