Skip to content

Commit

Permalink
Add ability to require a proxy
Browse files Browse the repository at this point in the history
  • Loading branch information
pmuir committed Nov 3, 2009
1 parent d6be8cb commit 5f92bcf
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 2 deletions.
19 changes: 18 additions & 1 deletion impl/src/main/java/org/jboss/weld/BeanManagerImpl.java
Expand Up @@ -60,6 +60,7 @@
import org.jboss.weld.bean.DecoratorImpl;
import org.jboss.weld.bean.InterceptorImpl;
import org.jboss.weld.bean.NewBean;
import org.jboss.weld.bean.RIBean;
import org.jboss.weld.bean.SessionBean;
import org.jboss.weld.bean.builtin.AbstractBuiltInBean;
import org.jboss.weld.bean.builtin.ExtensionBean;
Expand Down Expand Up @@ -911,7 +912,7 @@ public Object getReference(Bean<?> bean, CreationalContext<?> creationalContext)
{
creationalContext = ((WeldCreationalContext<?>) creationalContext).getCreationalContext(bean);
}
if (getServices().get(MetaAnnotationStore.class).getScopeModel(bean.getScope()).isNormal())
if (isProxyRequired(bean))
{
if (creationalContext != null || getContext(bean.getScope()).get(bean) != null)
{
Expand All @@ -927,6 +928,22 @@ public Object getReference(Bean<?> bean, CreationalContext<?> creationalContext)
return getContext(bean.getScope()).get((Contextual) bean, creationalContext);
}
}

private boolean isProxyRequired(Bean<?> bean)
{
if (getServices().get(MetaAnnotationStore.class).getScopeModel(bean.getScope()).isNormal())
{
return true;
}
else if (bean instanceof RIBean<?>)
{
return ((RIBean<?>) bean).isProxyRequired();
}
else
{
return false;
}
}

public Object getReference(Bean<?> bean, Type beanType, CreationalContext<?> creationalContext)
{
Expand Down
5 changes: 5 additions & 0 deletions impl/src/main/java/org/jboss/weld/bean/RIBean.java
Expand Up @@ -72,6 +72,11 @@ public boolean isDependent()

public abstract boolean isProxyable();

public boolean isProxyRequired()
{
return false;
}

public abstract boolean isPrimitive();

public abstract Set<WeldInjectionPoint<?, ?>> getAnnotatedInjectionPoints();
Expand Down
Expand Up @@ -108,7 +108,12 @@ public boolean isAlternative()
@Override
public boolean isProxyable()
{
return false;
return true;
}

public boolean isProxyRequired()
{
return true;
}

@Override
Expand Down

0 comments on commit 5f92bcf

Please sign in to comment.