Author: dallen6
Date: 2009-01-11 10:22:47 -0500 (Sun, 11 Jan 2009)
New Revision: 879
Modified:
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/SimpleBean.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/injection/InjectionPointProvider.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AbstractAnnotatedMember.java
Log:
Fixed some bugs related to the creation of InjectionPoint metadata beans.
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/SimpleBean.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/SimpleBean.java 2009-01-11
15:20:39 UTC (rev 878)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/SimpleBean.java 2009-01-11
15:22:47 UTC (rev 879)
@@ -289,14 +289,14 @@
InjectionPointProvider injectionPointProvider =
manager.getInjectionPointFactory();
for (AnnotatedField<?> injectableField : getInjectableFields())
{
- injectionPointProvider.pushInjectionPoint(injectableField);
+ injectionPointProvider.pushInjectionMember(injectableField);
try
{
injectableField.inject(instance, manager);
}
finally
{
- injectionPointProvider.popInjectionPoint();
+ injectionPointProvider.popInjectionMember();
}
}
}
Modified:
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/injection/InjectionPointProvider.java
===================================================================
---
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/injection/InjectionPointProvider.java 2009-01-11
15:20:39 UTC (rev 878)
+++
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/injection/InjectionPointProvider.java 2009-01-11
15:22:47 UTC (rev 879)
@@ -42,13 +42,15 @@
/**
* Pushes the current bean that is being instantiated onto a stack for later
- * use.
+ * use. This always pushes a null bean instance on the stack too which can
+ * later be replaced by a real instance.
*
* @param currentBean The bean being instantiated
*/
public void pushBean(Bean<?> currentBean)
{
beans.push(currentBean);
+ beanInstances.push(null);
}
/**
@@ -59,15 +61,25 @@
*/
public void pushInstance(Object currentInstance)
{
- beanInstances.push(currentInstance);
+ // Replace the null instance (from pushing the bean) with this one
+ // on the top of the stack.
+ if (beanInstances.peek() == null)
+ {
+ popInstance();
+ beanInstances.push(currentInstance);
+ }
+ else
+ {
+ throw new java.lang.IllegalStateException("More bean instances pushed than
there are beans");
+ }
}
/**
- * Pushes the current injection point being processed.
+ * Pushes the current injection point member being processed.
*
- * @param injectedMember The metadata for the injection point
+ * @param injectedMember The metadata for the injection point member
*/
- public void pushInjectionPoint(AnnotatedMember<?, ? extends Member>
injectedMember)
+ public void pushInjectionMember(AnnotatedMember<?, ? extends Member>
injectedMember)
{
injectionPoints.push(injectedMember);
}
@@ -78,6 +90,11 @@
*/
public void popBean()
{
+ if (!beanInstances.isEmpty() && beanInstances.size() == beans.size()
&& beanInstances.peek() == null)
+ {
+ // Pop the null instance since a real one was never pushed.
+ popInstance();
+ }
beans.pop();
}
@@ -94,7 +111,7 @@
* Pops the current injection point being processed. This should be called
* once the injection point is bound.
*/
- public void popInjectionPoint()
+ public void popInjectionMember()
{
injectionPoints.pop();
}
Modified:
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AbstractAnnotatedMember.java
===================================================================
---
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AbstractAnnotatedMember.java 2009-01-11
15:20:39 UTC (rev 878)
+++
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AbstractAnnotatedMember.java 2009-01-11
15:22:47 UTC (rev 879)
@@ -207,7 +207,7 @@
{
Object[] parameterValues = new Object[parameters.size()];
InjectionPointProvider injectionPointProvider =
manager.getInjectionPointFactory();
- injectionPointProvider.pushInjectionPoint(this);
+ injectionPointProvider.pushInjectionMember(this);
try
{
Iterator<AnnotatedParameter<Object>> iterator =
parameters.iterator();
@@ -226,7 +226,7 @@
}
finally
{
- injectionPointProvider.popInjectionPoint();
+ injectionPointProvider.popInjectionMember();
}
return parameterValues;
Show replies by date