Skip to content

Commit

Permalink
WELD-546 Fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
drallen committed Jun 9, 2010
1 parent 8ed09be commit 6899a9e
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 4 deletions.
Expand Up @@ -25,6 +25,7 @@
import org.jboss.weld.Container;
import org.jboss.weld.exceptions.DefinitionException;
import org.jboss.weld.serialization.spi.ContextualStore;
import org.jboss.weld.util.Proxies.TypeInfo;

import com.google.common.base.Function;
import com.google.common.collect.MapMaker;
Expand Down Expand Up @@ -84,7 +85,8 @@ public ClientProxyProvider()
private static <T> T createClientProxy(Bean<T> bean, String id) throws RuntimeException
{
ContextBeanInstance<T> beanInstance = new ContextBeanInstance<T>(bean, id);
return new ProxyFactory<T>(bean.getBeanClass(), bean.getTypes()).create(beanInstance);
TypeInfo typeInfo = TypeInfo.of(bean.getTypes());
return new ProxyFactory<T>(typeInfo.getSuperClass(), bean.getTypes()).create(beanInstance);
}

/**
Expand Down
22 changes: 19 additions & 3 deletions impl/src/main/java/org/jboss/weld/bean/proxy/ProxyFactory.java
Expand Up @@ -82,7 +82,7 @@ public class ProxyFactory<T>
*
* @param proxiedBeanType the super-class for this proxy class
*/
public ProxyFactory(Class<?> proxiedBeanType, Set<Type> businessInterfaces)
public ProxyFactory(Class<?> proxiedBeanType, Set<? extends Type> businessInterfaces)
{
for (Type type : businessInterfaces)
{
Expand All @@ -94,7 +94,8 @@ public ProxyFactory(Class<?> proxiedBeanType, Set<Type> businessInterfaces)
addInterface(c);
}
}
Class<?> superClass = TypeInfo.of(businessInterfaces).getSuperClass();
TypeInfo typeInfo = TypeInfo.of(businessInterfaces);
Class<?> superClass = typeInfo.getSuperClass();
superClass = superClass == null ? Object.class : superClass;
if (superClass.equals(Object.class))
{
Expand All @@ -114,7 +115,22 @@ public ProxyFactory(Class<?> proxiedBeanType, Set<Type> businessInterfaces)
this.classPool = new ClassPool();
this.classPool.appendClassPath(new ClassloaderClassPath(classLoader));
addDefaultAdditionalInterfaces();
baseProxyName = proxiedBeanType.getName();
if (proxiedBeanType.equals(Object.class))
{
Class<?> superInterface = typeInfo.getSuperInterface();
if (superInterface == null)
{
throw new IllegalArgumentException("Proxied bean type cannot be java.lang.Object without an interface");
}
else
{
baseProxyName = superInterface.getName();
}
}
else
{
baseProxyName = proxiedBeanType.getName();
}
}

/**
Expand Down

0 comments on commit 6899a9e

Please sign in to comment.