1919
2020import org .apache .openejb .ApplicationException ;
2121import org .apache .openejb .BeanContext ;
22+ import org .apache .openejb .ContainerType ;
2223import org .apache .openejb .InterfaceType ;
2324import org .apache .openejb .InvalidateReferenceException ;
2425import org .apache .openejb .OpenEJBException ;
3536import javax .ejb .EJBAccessException ;
3637import javax .ejb .EJBLocalObject ;
3738import javax .ejb .EJBObject ;
39+ import javax .ejb .Remove ;
3840import java .io .ObjectStreamException ;
3941import java .lang .reflect .Method ;
4042import java .rmi .AccessException ;
@@ -75,7 +77,7 @@ public Object _invoke(final Object p, final Class interfce, final Method m, fina
7577 if (logger .isDebugEnabled ()) {
7678 logger .debug ("EjbObjectProxyHandler: invoking method " + methodName + " on " + deploymentID + " with identity " + primaryKey );
7779 }
78- Integer operation = dispatchTable . get ( methodName );
80+ Integer operation = getMappedOperation ( m );
7981 if (operation != null ) {
8082 if (operation == 3 ) {
8183 if (m .getParameterTypes ()[0 ] != EJBObject .class && m .getParameterTypes ()[0 ] != EJBLocalObject .class ) {
@@ -85,7 +87,12 @@ public Object _invoke(final Object p, final Class interfce, final Method m, fina
8587 operation = m .getParameterTypes ().length == 0 ? operation : null ;
8688 }
8789 }
88- if (operation == null || !interfaceType .isComponent ()) {
90+
91+
92+ boolean isComponentOperation = operation != null && interfaceType .isComponent ();
93+ boolean isRemoveOperation = dispatchTable .get ("remove" ).equals (operation ) && ContainerType .STATEFUL .equals (this .container .getContainerType ());
94+
95+ if (!isComponentOperation && !isRemoveOperation ) {
8996 retValue = businessMethod (interfce , m , a , p );
9097 } else {
9198 switch (operation ) {
@@ -174,6 +181,14 @@ public Object _invoke(final Object p, final Class interfce, final Method m, fina
174181 }
175182 }
176183
184+ private static Integer getMappedOperation (final Method m ) {
185+ Integer opCode = dispatchTable .get (m .getName ());
186+ if (opCode == null && m .getDeclaredAnnotation (Remove .class ) != null ) {
187+ opCode = dispatchTable .get ("remove" );
188+ }
189+ return opCode ;
190+ }
191+
177192 protected Object getEJBHome (final Method method , final Object [] args , final Object proxy ) throws Throwable {
178193 checkAuthorization (method );
179194 return getBeanContext ().getEJBHome ();
0 commit comments