Skip to content

Commit

Permalink
WELD-812 simpler impl of an empty injection point
Browse files Browse the repository at this point in the history
  • Loading branch information
pmuir committed Jan 2, 2011
1 parent 7a83415 commit 8aba6cb
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 92 deletions.
Expand Up @@ -16,7 +16,6 @@
*/
package org.jboss.weld.bean.builtin;

import static org.jboss.weld.injection.SimpleInjectionPoint.EMPTY_INJECTION_POINT;
import static org.jboss.weld.logging.messages.BeanMessage.PROXY_REQUIRED;
import static org.jboss.weld.util.collections.Arrays2.asSet;
import static org.jboss.weld.util.reflection.Reflections.EMPTY_ANNOTATIONS;
Expand All @@ -40,6 +39,7 @@
import org.jboss.weld.Container;
import org.jboss.weld.exceptions.InvalidObjectException;
import org.jboss.weld.injection.CurrentInjectionPoint;
import org.jboss.weld.injection.EmptyInjectionPoint;
import org.jboss.weld.injection.ForwardingInjectionPoint;
import org.jboss.weld.manager.BeanManagerImpl;
import org.jboss.weld.resolution.ResolvableBuilder;
Expand Down Expand Up @@ -103,7 +103,7 @@ public static <I> Instance<I> of(InjectionPoint injectionPoint, CreationalContex

public static <I> Instance<I> of(Type type, Annotation[] qualifiers, CreationalContext<I> creationalContext, BeanManagerImpl beanManager)
{
return new InstanceImpl<I>(type, qualifiers, EMPTY_INJECTION_POINT, creationalContext, beanManager);
return new InstanceImpl<I>(type, qualifiers, EmptyInjectionPoint.INSTANCE, creationalContext, beanManager);
}

private InstanceImpl(Type type, Annotation[] qualifiers, InjectionPoint injectionPoint, CreationalContext<? super T> creationalContext, BeanManagerImpl beanManager)
Expand Down
Expand Up @@ -28,7 +28,7 @@
import org.jboss.weld.context.CreationalContextImpl;
import org.jboss.weld.context.WeldCreationalContext;
import org.jboss.weld.injection.CurrentInjectionPoint;
import org.jboss.weld.injection.SimpleInjectionPoint;
import org.jboss.weld.injection.EmptyInjectionPoint;
import org.jboss.weld.serialization.spi.ContextualStore;

/**
Expand Down Expand Up @@ -95,7 +95,7 @@ public T getInstance()
try
{
// Ensure that there is no injection point associated
container.services().get(CurrentInjectionPoint.class).push(SimpleInjectionPoint.EMPTY_INJECTION_POINT);
container.services().get(CurrentInjectionPoint.class).push(EmptyInjectionPoint.INSTANCE);
return context.get(bean, creationalContext);
}
finally
Expand Down
@@ -0,0 +1,58 @@
package org.jboss.weld.injection;

import java.io.Serializable;
import java.lang.annotation.Annotation;
import java.lang.reflect.Member;
import java.lang.reflect.Type;
import java.util.Collections;
import java.util.Set;

import javax.enterprise.inject.spi.Annotated;
import javax.enterprise.inject.spi.Bean;
import javax.enterprise.inject.spi.InjectionPoint;

public class EmptyInjectionPoint implements InjectionPoint, Serializable
{

private static final long serialVersionUID = -2041468540191211977L;

public static final InjectionPoint INSTANCE = new EmptyInjectionPoint();

private EmptyInjectionPoint() {}

public Type getType()
{
return Object.class;
}

public Set<Annotation> getQualifiers()
{
return Collections.emptySet();
}

public Bean<?> getBean()
{
return null;
}

public Member getMember()
{
return null;
}

public Annotated getAnnotated()
{
return null;
}

public boolean isDelegate()
{
return false;
}

public boolean isTransient()
{
return false;
}

}

This file was deleted.

0 comments on commit 8aba6cb

Please sign in to comment.