Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Modifications needed for injection point metadata and fixes to tests;…
… integration code was thrown out due to conflicting design changes; all tests marked broken. git-svn-id: http://anonsvn.jboss.org/repos/weld/ri/trunk@809 1c488680-804c-0410-94cd-c6b725194a0e
- Loading branch information
Showing
5 changed files
with
152 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
124 changes: 124 additions & 0 deletions
124
webbeans-ri/src/main/java/org/jboss/webbeans/injection/InjectionPointFactory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,124 @@ | ||
/* | ||
* JBoss, Home of Professional Open Source | ||
* Copyright 2008, Red Hat Middleware LLC, and individual contributors | ||
* by the @authors tag. See the copyright.txt in the distribution for a | ||
* full listing of individual contributors. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.jboss.webbeans.injection; | ||
|
||
import java.lang.reflect.Member; | ||
import java.util.Stack; | ||
|
||
import javax.webbeans.InjectionPoint; | ||
import javax.webbeans.manager.Bean; | ||
|
||
import org.jboss.webbeans.introspector.jlr.AbstractAnnotatedMember; | ||
|
||
/** | ||
* Factory used to create the container provided implementation for the | ||
* InjectionPoint beans. This factory maintains a stack with the current bean | ||
* and instance being created so that this information is readily available for | ||
* construction of a new InjectionPoint bean. | ||
* | ||
* @author David Allen | ||
* | ||
*/ | ||
public class InjectionPointFactory | ||
{ | ||
private final Stack<Bean<?>> beans = new Stack<Bean<?>>(); | ||
private final Stack<Object> beanInstances = new Stack<Object>(); | ||
private final Stack<AbstractAnnotatedMember<?, ? extends Member>> injectionPoints = new Stack<AbstractAnnotatedMember<?, ? extends Member>>(); | ||
|
||
/** | ||
* Pushes the current bean that is being instantiated onto a stack for later | ||
* use. | ||
* | ||
* @param currentBean The bean being instantiated | ||
*/ | ||
public void pushBean(Bean<?> currentBean) | ||
{ | ||
beans.push(currentBean); | ||
} | ||
|
||
/** | ||
* Pushes the current bean instance that has been instantiated, but has not | ||
* yet had any injection points initialized. | ||
* | ||
* @param currentInstance The bean instance last instantiated | ||
*/ | ||
public void pushInstance(Object currentInstance) | ||
{ | ||
beanInstances.push(currentInstance); | ||
} | ||
|
||
/** | ||
* Pushes the current injection point being processed. | ||
* | ||
* @param injectedMember The metadata for the injection point | ||
*/ | ||
public void pushInjectionPoint(AbstractAnnotatedMember<?, ? extends Member> injectedMember) | ||
{ | ||
injectionPoints.push(injectedMember); | ||
} | ||
|
||
/** | ||
* Pops the bean and its current instance from the stack. This should be called | ||
* whenever all processing is complete for instantiating a bean. | ||
*/ | ||
public void popBeanAndInstance() | ||
{ | ||
beans.pop(); | ||
beanInstances.pop(); | ||
} | ||
|
||
/** | ||
* Pops the current injection point being processed. This should be called once | ||
* the injection point is bound. | ||
*/ | ||
public void popInjectionPoint() | ||
{ | ||
injectionPoints.pop(); | ||
} | ||
|
||
/** | ||
* Creates an InjectionPoint based on the current state of processing as | ||
* indicated by this factory's stack of injection points and related | ||
* information. | ||
* | ||
* @return a new injection point metadata object | ||
*/ | ||
public InjectionPoint newInstance() | ||
{ | ||
// When the injected member is a constructor, we are short one instance, | ||
// so the instance on the top of the stack is the bean instance | ||
// we want. Otherwise, it is the second to last instance same as | ||
// the bean stack. | ||
InjectionPoint injectionPoint = null; | ||
Bean<?> currentBean = beans.pop(); | ||
AbstractAnnotatedMember<?, ? extends Member> currentInjection = injectionPoints.pop(); | ||
if (beanInstances.size() < beans.size()) | ||
{ | ||
injectionPoint = new InjectionPointImpl(injectionPoints.peek(), beans.peek(), beanInstances.peek()); | ||
} | ||
else | ||
{ | ||
Object currentInstance = beanInstances.pop(); | ||
injectionPoint = new InjectionPointImpl(injectionPoints.peek(), beans.peek(), beanInstances.peek()); | ||
beanInstances.push(currentInstance); | ||
} | ||
beans.push(currentBean); | ||
injectionPoints.push(currentInjection); | ||
return injectionPoint; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters