Skip to content

Commit

Permalink
WBRI-223
Browse files Browse the repository at this point in the history
git-svn-id: http://anonsvn.jboss.org/repos/weld/ri/trunk@2313 1c488680-804c-0410-94cd-c6b725194a0e
  • Loading branch information
pmuir committed Apr 6, 2009
1 parent 26ed2ff commit 42a5779
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 9 deletions.
Expand Up @@ -11,9 +11,13 @@

import org.jboss.webbeans.ManagerImpl;
import org.jboss.webbeans.context.DependentContext;
import org.jboss.webbeans.log.Log;
import org.jboss.webbeans.log.Logging;

public abstract class AbstractFacadeBean<T> extends AbstractStandardBean<T>
{

private static final Log log = Logging.getLog(AbstractFacadeBean.class);

protected AbstractFacadeBean(ManagerImpl manager)
{
Expand All @@ -25,16 +29,22 @@ public T create(CreationalContext<T> creationalContext)
try
{
DependentContext.INSTANCE.setActive(true);
//TODO Fix to use IP's manager rather than this bean's
InjectionPoint injectionPoint = this.getManager().getInjectionPoint();
Type genericType = injectionPoint.getType();
if (genericType instanceof ParameterizedType )
if (injectionPoint != null)
{
Type type = ((ParameterizedType) genericType).getActualTypeArguments()[0];
if (type instanceof Class)
Type genericType = injectionPoint.getType();
if (genericType instanceof ParameterizedType )
{
Class<?> clazz = Class.class.cast(type);
return newInstance(clazz, fixBindings(injectionPoint.getBindings()));
Type type = ((ParameterizedType) genericType).getActualTypeArguments()[0];
if (type instanceof Class)
{
Class<?> clazz = Class.class.cast(type);
return newInstance(clazz, fixBindings(injectionPoint.getBindings()));
}
else
{
throw new IllegalStateException("Must have concrete type argument " + injectionPoint);
}
}
else
{
Expand All @@ -43,9 +53,9 @@ public T create(CreationalContext<T> creationalContext)
}
else
{
throw new IllegalStateException("Must have concrete type argument " + injectionPoint);
log.warn("Dynamic lookup of " + toString() + " is not supported");
return null;
}

}
finally
{
Expand Down
@@ -0,0 +1,24 @@
package org.jboss.webbeans.test.unit.lookup;

import java.util.List;

import javax.inject.Instance;
import javax.inject.TypeLiteral;

import org.jboss.testharness.impl.packaging.Artifact;
import org.jboss.webbeans.literal.ObtainsLiteral;
import org.jboss.webbeans.test.unit.AbstractWebBeansTest;
import org.testng.annotations.Test;

@Artifact
public class LookupInstanceTest extends AbstractWebBeansTest
{


@Test
public void testLookupInstance() throws Exception
{
assert manager.getInstanceByType(new TypeLiteral<Instance<List<?>>>(){}, new ObtainsLiteral()) == null;
}

}

0 comments on commit 42a5779

Please sign in to comment.