Author: dallen6
Date: 2010-04-28 11:14:25 -0400 (Wed, 28 Apr 2010)
New Revision: 6186
Modified:
core/trunk/impl/src/main/java/org/jboss/weld/bean/proxy/EnterpriseProxyFactory.java
core/trunk/impl/src/main/java/org/jboss/weld/bean/proxy/ProxyFactory.java
Log:
Changed constructor generation to use constructors from base class for all types of
proxies.
Modified:
core/trunk/impl/src/main/java/org/jboss/weld/bean/proxy/EnterpriseProxyFactory.java
===================================================================
---
core/trunk/impl/src/main/java/org/jboss/weld/bean/proxy/EnterpriseProxyFactory.java 2010-04-28
15:10:34 UTC (rev 6185)
+++
core/trunk/impl/src/main/java/org/jboss/weld/bean/proxy/EnterpriseProxyFactory.java 2010-04-28
15:14:25 UTC (rev 6186)
@@ -47,23 +47,6 @@
}
@Override
- protected void addConstructors(CtClass proxyClassType)
- {
- try
- {
- CtClass baseType = classPool.get(beanType.getName());
- for (CtConstructor constructor : baseType.getConstructors())
- {
-
proxyClassType.addConstructor(CtNewConstructor.make(constructor.getParameterTypes(),
constructor.getExceptionTypes(), proxyClassType));
- }
- }
- catch (Exception e)
- {
- throw new WeldException(e);
- }
- }
-
- @Override
protected String getProxyNameSuffix()
{
return PROXY_SUFFIX;
Modified: core/trunk/impl/src/main/java/org/jboss/weld/bean/proxy/ProxyFactory.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/bean/proxy/ProxyFactory.java 2010-04-28
15:10:34 UTC (rev 6185)
+++ core/trunk/impl/src/main/java/org/jboss/weld/bean/proxy/ProxyFactory.java 2010-04-28
15:14:25 UTC (rev 6186)
@@ -28,9 +28,9 @@
import java.util.ArrayList;
import java.util.Arrays;
-import javassist.CannotCompileException;
import javassist.ClassPool;
import javassist.CtClass;
+import javassist.CtConstructor;
import javassist.CtField;
import javassist.CtMethod;
import javassist.CtNewConstructor;
@@ -242,8 +242,8 @@
}
/**
- * Adds a public default constructor to the proxy class for ease of
- * instantiating it.
+ * Adds a constructor for the proxy for each constructor declared
+ * by the base bean type.
*
* @param proxyClassType the Javassist class for the proxy
*/
@@ -251,9 +251,20 @@
{
try
{
-
proxyClassType.addConstructor(CtNewConstructor.defaultConstructor(proxyClassType));
+ CtClass baseType = classPool.get(beanType.getName());
+ if (baseType.isInterface())
+ {
+
proxyClassType.addConstructor(CtNewConstructor.defaultConstructor(proxyClassType));
+ }
+ else
+ {
+ for (CtConstructor constructor : baseType.getConstructors())
+ {
+
proxyClassType.addConstructor(CtNewConstructor.make(constructor.getParameterTypes(),
constructor.getExceptionTypes(), proxyClassType));
+ }
+ }
}
- catch (CannotCompileException e)
+ catch (Exception e)
{
throw new WeldException(e);
}
Show replies by date