Author: pete.muir(a)jboss.org
Date: 2009-06-04 13:22:52 -0400 (Thu, 04 Jun 2009)
New Revision: 2764
Added:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/inheritance/specialization/simple/broken/noextend3/SpecializingClassExtendsNonSimpleBeanTest.java
Removed:
ri/trunk/impl/src/main/java/org/jboss/webbeans/mock/
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/inheritance/specialization/simple/broken/noextend3/SpecializingClassExtendsNonSimpleBean.java
Modified:
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/EnterpriseBean.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/proxy/ClientProxyMethodHandler.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/proxy/EnterpriseBeanProxyMethodHandler.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/ejb/InternalEjbDescriptor.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/ConstructorSignature.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/MethodSignature.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/jlr/MethodSignatureImpl.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/enterprise/remove/SessionScopedSessionBean.java
Log:
WBRI-265
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/EnterpriseBean.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/EnterpriseBean.java 2009-06-04
17:20:38 UTC (rev 2763)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/EnterpriseBean.java 2009-06-04
17:22:52 UTC (rev 2764)
@@ -352,7 +352,7 @@
return ejbDescriptor;
}
- public boolean canCallRemoveMethods()
+ public boolean isClientCanCallRemoveMethods()
{
return getEjbDescriptor().isStateful() && isDependent();
}
Modified:
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/proxy/ClientProxyMethodHandler.java
===================================================================
---
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/proxy/ClientProxyMethodHandler.java 2009-06-04
17:20:38 UTC (rev 2763)
+++
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/proxy/ClientProxyMethodHandler.java 2009-06-04
17:22:52 UTC (rev 2764)
@@ -17,6 +17,7 @@
package org.jboss.webbeans.bean.proxy;
import java.io.Serializable;
+import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import javassist.util.proxy.MethodHandler;
@@ -93,9 +94,16 @@
bean = manager.getBeans().get(beanIndex);
}
Object proxiedInstance = getProxiedInstance(bean);
- Object returnValue = Reflections.lookupMethod(proxiedMethod,
proxiedInstance).invoke(proxiedInstance, args);
- log.trace("Executed method " + proxiedMethod + " on " +
proxiedInstance + " with parameters " + args + " and got return value
" + returnValue);
- return returnValue;
+ try
+ {
+ Object returnValue = Reflections.lookupMethod(proxiedMethod,
proxiedInstance).invoke(proxiedInstance, args);
+ log.trace("Executed method " + proxiedMethod + " on " +
proxiedInstance + " with parameters " + args + " and got return value
" + returnValue);
+ return returnValue;
+ }
+ catch (InvocationTargetException e)
+ {
+ throw e.getCause();
+ }
}
private <T> T getProxiedInstance(Bean<T> bean)
Modified:
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/proxy/EnterpriseBeanProxyMethodHandler.java
===================================================================
---
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/proxy/EnterpriseBeanProxyMethodHandler.java 2009-06-04
17:20:38 UTC (rev 2763)
+++
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/proxy/EnterpriseBeanProxyMethodHandler.java 2009-06-04
17:22:52 UTC (rev 2764)
@@ -17,11 +17,14 @@
package org.jboss.webbeans.bean.proxy;
import java.lang.reflect.Method;
+import java.util.Collection;
import javassist.util.proxy.MethodHandler;
import org.jboss.webbeans.bean.EnterpriseBean;
import org.jboss.webbeans.ejb.api.SessionObjectReference;
+import org.jboss.webbeans.introspector.MethodSignature;
+import org.jboss.webbeans.introspector.jlr.MethodSignatureImpl;
import org.jboss.webbeans.log.Log;
import org.jboss.webbeans.log.Logging;
import org.jboss.webbeans.util.Reflections;
@@ -56,9 +59,12 @@
enterpriseBean.set(bean);
}
- final SessionObjectReference reference;
- final Class<?> objectInterface;
- boolean destroyed;
+ private final SessionObjectReference reference;
+ private final Class<?> objectInterface;
+ private final Collection<MethodSignature> removeMethodSignatures;
+ private final boolean clientCanCallRemoveMethods;
+
+ private boolean destroyed;
/**
* Constructor
@@ -71,6 +77,8 @@
{
this.destroyed = false;
this.objectInterface = bean.getEjbDescriptor().getObjectInterface();
+ this.removeMethodSignatures = bean.getEjbDescriptor().getRemoveMethodSignatures();
+ this.clientCanCallRemoveMethods = bean.isClientCanCallRemoveMethods();
try
{
setEnterpriseBean(bean);
@@ -131,6 +139,16 @@
return null;
}
+ if (!clientCanCallRemoveMethods)
+ {
+ // TODO we can certainly optimize this search algorithm!
+ MethodSignature methodSignature = new MethodSignatureImpl(method);
+ if (removeMethodSignatures.contains(methodSignature))
+ {
+ throw new UnsupportedOperationException("Cannot call EJB remove method
directly on non-dependent scoped bean " + method );
+ }
+ }
+
Class<?> businessInterface = method.getDeclaringClass();
if (businessInterface.equals(Object.class))
{
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/ejb/InternalEjbDescriptor.java
===================================================================
---
ri/trunk/impl/src/main/java/org/jboss/webbeans/ejb/InternalEjbDescriptor.java 2009-06-04
17:20:38 UTC (rev 2763)
+++
ri/trunk/impl/src/main/java/org/jboss/webbeans/ejb/InternalEjbDescriptor.java 2009-06-04
17:22:52 UTC (rev 2764)
@@ -16,10 +16,15 @@
*/
package org.jboss.webbeans.ejb;
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.Collection;
import java.util.Iterator;
import org.jboss.webbeans.ejb.spi.BusinessInterfaceDescriptor;
import org.jboss.webbeans.ejb.spi.EjbDescriptor;
+import org.jboss.webbeans.introspector.MethodSignature;
+import org.jboss.webbeans.introspector.jlr.MethodSignatureImpl;
/**
* More powerful version of {@link EjbDescriptor} that exposes Maps for some
@@ -34,6 +39,7 @@
private final Class<?> objectInterface;
private final EjbDescriptor<T> delegate;
+ private final Collection<MethodSignature> removeMethodSignatures;
public InternalEjbDescriptor(EjbDescriptor<T> ejbDescriptor)
{
@@ -47,6 +53,11 @@
{
this.objectInterface = null;
}
+ removeMethodSignatures = new ArrayList<MethodSignature>();
+ for (Method method : delegate.getRemoveMethods())
+ {
+ removeMethodSignatures.add(new MethodSignatureImpl(method));
+ }
}
@Override
@@ -60,4 +71,9 @@
return objectInterface;
}
+ public Collection<MethodSignature> getRemoveMethodSignatures()
+ {
+ return removeMethodSignatures;
+ }
+
}
Modified:
ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/ConstructorSignature.java
===================================================================
---
ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/ConstructorSignature.java 2009-06-04
17:20:38 UTC (rev 2763)
+++
ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/ConstructorSignature.java 2009-06-04
17:22:52 UTC (rev 2764)
@@ -16,7 +16,9 @@
*/
package org.jboss.webbeans.introspector;
-public interface ConstructorSignature
+import java.io.Serializable;
+
+public interface ConstructorSignature extends Serializable
{
public String[] getParameterTypes();
Modified:
ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/MethodSignature.java
===================================================================
---
ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/MethodSignature.java 2009-06-04
17:20:38 UTC (rev 2763)
+++
ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/MethodSignature.java 2009-06-04
17:22:52 UTC (rev 2764)
@@ -16,7 +16,9 @@
*/
package org.jboss.webbeans.introspector;
-public interface MethodSignature
+import java.io.Serializable;
+
+public interface MethodSignature extends Serializable
{
public String getMethodName();
Modified:
ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/jlr/MethodSignatureImpl.java
===================================================================
---
ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/jlr/MethodSignatureImpl.java 2009-06-04
17:20:38 UTC (rev 2763)
+++
ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/jlr/MethodSignatureImpl.java 2009-06-04
17:22:52 UTC (rev 2764)
@@ -16,6 +16,7 @@
*/
package org.jboss.webbeans.introspector.jlr;
+import java.lang.reflect.Method;
import java.util.Arrays;
import org.jboss.webbeans.introspector.AnnotatedMethod;
@@ -24,6 +25,8 @@
public class MethodSignatureImpl implements MethodSignature
{
+ private static final long serialVersionUID = 870948075030895317L;
+
private final String methodName;
private final String[] parameterTypes;
@@ -35,6 +38,16 @@
{
parameterTypes[i] = method.getParameters().get(i).getRawType().getName();
}
+ }
+
+ public MethodSignatureImpl(Method method)
+ {
+ this.methodName = method.getName();
+ this.parameterTypes = new String[method.getParameterTypes().length];
+ for (int i = 0; i < method.getParameterTypes().length; i++)
+ {
+ parameterTypes[i] = method.getParameterTypes()[i].getName();
+ }
}
Modified:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/enterprise/remove/SessionScopedSessionBean.java
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/enterprise/remove/SessionScopedSessionBean.java 2009-06-04
17:20:38 UTC (rev 2763)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/enterprise/remove/SessionScopedSessionBean.java 2009-06-04
17:22:52 UTC (rev 2764)
@@ -1,5 +1,6 @@
package org.jboss.jsr299.tck.tests.implementation.enterprise.remove;
+import javax.ejb.Remove;
import javax.ejb.Stateful;
import javax.enterprise.context.SessionScoped;
@@ -7,7 +8,8 @@
@SessionScoped
public class SessionScopedSessionBean implements SessionScopedSessionInterface
{
-
+
+ @Remove
public void remove()
{
}
Deleted:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/inheritance/specialization/simple/broken/noextend3/SpecializingClassExtendsNonSimpleBean.java
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/inheritance/specialization/simple/broken/noextend3/SpecializingClassExtendsNonSimpleBean.java 2009-06-04
17:20:38 UTC (rev 2763)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/inheritance/specialization/simple/broken/noextend3/SpecializingClassExtendsNonSimpleBean.java 2009-06-04
17:22:52 UTC (rev 2764)
@@ -1,22 +0,0 @@
-package org.jboss.jsr299.tck.tests.inheritance.specialization.simple.broken.noextend3;
-
-import javax.inject.DefinitionException;
-
-import org.hibernate.tck.annotations.SpecAssertion;
-import org.jboss.jsr299.tck.AbstractJSR299Test;
-import org.jboss.testharness.impl.packaging.Artifact;
-import org.jboss.testharness.impl.packaging.ExpectedDeploymentException;
-import org.testng.annotations.Test;
-
-@Artifact
-(a)ExpectedDeploymentException(DefinitionException.class)
-public class SpecializingClassExtendsNonSimpleBean extends AbstractJSR299Test
-{
- @Test(groups = { "specialization", "ri-broken" })
- @SpecAssertion(section = "3.2.7", id = "d")
- public void testSpecializingClassExtendsNonSimpleBean()
- {
- assert false;
- }
-
-}
Copied:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/inheritance/specialization/simple/broken/noextend3/SpecializingClassExtendsNonSimpleBeanTest.java
(from rev 2749,
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/inheritance/specialization/simple/broken/noextend3/SpecializingClassExtendsNonSimpleBean.java)
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/inheritance/specialization/simple/broken/noextend3/SpecializingClassExtendsNonSimpleBeanTest.java
(rev 0)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/inheritance/specialization/simple/broken/noextend3/SpecializingClassExtendsNonSimpleBeanTest.java 2009-06-04
17:22:52 UTC (rev 2764)
@@ -0,0 +1,22 @@
+package org.jboss.jsr299.tck.tests.inheritance.specialization.simple.broken.noextend3;
+
+import javax.inject.DefinitionException;
+
+import org.hibernate.tck.annotations.SpecAssertion;
+import org.jboss.jsr299.tck.AbstractJSR299Test;
+import org.jboss.testharness.impl.packaging.Artifact;
+import org.jboss.testharness.impl.packaging.ExpectedDeploymentException;
+import org.testng.annotations.Test;
+
+@Artifact
+(a)ExpectedDeploymentException(DefinitionException.class)
+public class SpecializingClassExtendsNonSimpleBeanTest extends AbstractJSR299Test
+{
+ @Test(groups = { "specialization", "ri-broken" })
+ @SpecAssertion(section = "3.2.7", id = "d")
+ public void testSpecializingClassExtendsNonSimpleBean()
+ {
+ assert false;
+ }
+
+}
Property changes on:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/inheritance/specialization/simple/broken/noextend3/SpecializingClassExtendsNonSimpleBeanTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain