Skip to content

Commit

Permalink
Shortcut for AbstractBean proxybility (proxibility? proxyability? pro…
Browse files Browse the repository at this point in the history
…xiability?) tests

Temporary(?) fix for injection point checks with two producer beans

git-svn-id: http://anonsvn.jboss.org/repos/weld/ri/trunk@977 1c488680-804c-0410-94cd-c6b725194a0e
  • Loading branch information
nickarls committed Jan 15, 2009
1 parent 8c6f3c4 commit 32d128e
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 1 deletion.
Expand Up @@ -46,6 +46,7 @@
import org.jboss.webbeans.log.LogProvider;
import org.jboss.webbeans.log.Logging;
import org.jboss.webbeans.model.MergedStereotypes;
import org.jboss.webbeans.util.Proxies;
import org.jboss.webbeans.util.Reflections;

/**
Expand All @@ -62,6 +63,8 @@ public abstract class AbstractBean<T, E> extends Bean<T>
@SuppressWarnings("unchecked")
private static Set<Class<?>> STANDARD_WEB_BEAN_CLASSES = new HashSet<Class<?>>(Arrays.asList(Event.class, ManagerImpl.class));

private boolean proxyable;

/**
* Helper class for getting deployment type
*
Expand Down Expand Up @@ -137,6 +140,7 @@ protected void init()
checkDeploymentType();
initScopeType();
initTypes();
proxyable = Proxies.apiTypesAreProxyable(getTypes());
}

/**
Expand Down Expand Up @@ -541,4 +545,9 @@ public String toString()
{
return "AbstractBean " + getName();
}

public boolean isProxyable()
{
return proxyable;
}
}
Expand Up @@ -165,6 +165,10 @@ protected void checkReturnValue(T instance)
throw new IllegalProductException("Producers cannot declare passivating scope and return a non-serializable class");
}
InjectionPointImpl injectionPoint = (InjectionPointImpl) manager.getInjectionPointProvider().getCurrentInjectionPoint();
if (injectionPoint == null)
{
return;
}
if (dependent && Reflections.isPassivatingBean(injectionPoint.getBean()))
{
if (injectionPoint.isField())
Expand Down
22 changes: 21 additions & 1 deletion webbeans-ri/src/main/java/org/jboss/webbeans/util/Proxies.java
Expand Up @@ -9,6 +9,8 @@

import javax.webbeans.manager.Bean;

import org.jboss.webbeans.bean.AbstractBean;

public class Proxies
{

Expand Down Expand Up @@ -150,7 +152,25 @@ else if (Reflections.isArrayType(clazz))
*/
public static boolean isBeanProxyable(Bean<?> bean)
{
for (Type apiType : bean.getTypes())
if (bean instanceof AbstractBean)
{
return ((AbstractBean<?, ?>) bean).isProxyable();
}
else
{
return apiTypesAreProxyable(bean.getTypes());
}
}

/**
* Indicates if a set of types are all proxyable
*
* @param types The types to test
* @return True if proxyable, false otherwise
*/
public static boolean apiTypesAreProxyable(Set<Type> types)
{
for (Type apiType : types)
{
if (Object.class.equals(apiType))
{
Expand Down

0 comments on commit 32d128e

Please sign in to comment.