You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomee.apache.org by Shawn Jiang <ge...@gmail.com> on 2011/06/02 11:16:45 UTC
Lost method info if the local and remote interface are in a type hierarchy
I found that in following case:
public interface LocalIF {
void doSomething();
}
public interface RemoteIF extends LocalIF {
}
@Stateless()
@Remote(RemoteIF.class)
@Local(LocalIF.class)
public class EJB implements LocalIF,RemoteIF {
public void doSomething() {
...
}
}
We are using following method to map the methods in interface to the impl
method in EJB. *intrface.getMethods() *will always return method* LocalIF*
*.doSomething()* for both RemoteIF and LocalIF.
----------------------------------------------------------------------------------------------------
org.apache.openejb.BeanContext.mapObjectInterface(Class intrface) {
Method [] interfaceMethods =* intrface.getMethods();*
for (Method method : interfaceMethods) {
Class declaringClass = method.getDeclaringClass();
if (declaringClass == EJBObject.class || declaringClass ==
EJBLocalObject.class) {
continue;
}
try {
Method beanMethod = beanClass.getMethod(method.getName(),
method.getParameterTypes());
mapMethods(method, beanMethod);
} catch (NoSuchMethodException nsme) {
throw new RuntimeException("Invalid method [" + method + "].
Not declared by " + beanClass.getName() + " class");
}
}
}
---------------------------------------------------------------------------------------------------------------
That means, we lost RemoteIF method mapping info here. Users can't
define different transctions for the same EJB mothed in different invoking
context(remote or Local). The client side code lose the ability to obtain
the EJB method through the RemoteIF.
Can anyone shed some lights on how to fix this without changing the
methodMap data api in BeanContext ?
--
Shawn
Re: Lost method info if the local and remote interface are in a type hierarchy
Posted by David Blevins <da...@gmail.com>.
On Jun 2, 2011, at 4:43 PM, David Blevins wrote:
> Definitely not popular, but it doesn't need to be to be part of the TCK :) It was never tested before and we never supported it. Specifically we only supported it legacy 2.x Home/Remote LocalHome/Local views.
>
> There was a TODO in this area of the code and the transaction attributes are not using the MethodContext yet. I've been hacking on it all day and have something close to working.
Fixed. Was a bit of a bear to fix as we were loosing that info at several stages. The deploy side could use some clean up (can do that post certify), but the runtime impact was kept small.
-David
>
> On Jun 2, 2011, at 2:37 AM, Shawn Jiang wrote:
>
>> Thanks, I know it's not wired from the code, but The interface type
>> hierarchy is a very popular EJB programing practice. Suppose the user
>> wants to customize the transaction for doSomething method.
>>
>> <container-transaction>
>> <method>
>> <ejb-name>EJB</ejb-name>
>> <method-intf>Remote</method-intf>
>> <method-name>doSomething</method-name>
>> </method>
>> <trans-attribute>Required</trans-attribute>
>> </container-transaction>
>> <container-transaction>
>> <method>
>> <ejb-name>EJB</ejb-name>
>> <method-intf>Local</method-intf>
>> <method-name>doSomething</method-name>
>> </method>
>> <trans-attribute>Mandatory</trans-attribute>
>> </container-transaction>
>>
>> See, there's no enough options in DD about where the method was defined in
>> the inteface hierarchy.
>>
>> On Thu, Jun 2, 2011 at 5:27 PM, Romain Manni-Bucau <rm...@gmail.com>wrote:
>>
>>> did you try re-defining doSomething() in remoteif?
>>>
>>> because the behavior you are describing is not weird for me. doSomething
>>> belongs to LocalIf not RemoteIF.
>>>
>>> - Romain
>>>
>>> 2011/6/2 Shawn Jiang <ge...@gmail.com>
>>>
>>>> I found that in following case:
>>>>
>>>> public interface LocalIF {
>>>>
>>>> void doSomething();
>>>>
>>>> }
>>>>
>>>> public interface RemoteIF extends LocalIF {
>>>>
>>>> }
>>>>
>>>> @Stateless()
>>>> @Remote(RemoteIF.class)
>>>> @Local(LocalIF.class)
>>>> public class EJB implements LocalIF,RemoteIF {
>>>>
>>>> public void doSomething() {
>>>> ...
>>>> }
>>>>
>>>> }
>>>>
>>>> We are using following method to map the methods in interface to the impl
>>>> method in EJB. *intrface.getMethods() *will always return method*
>>>> LocalIF*
>>>> *.doSomething()* for both RemoteIF and LocalIF.
>>>>
>>>>
>>>>
>>> ----------------------------------------------------------------------------------------------------
>>>> org.apache.openejb.BeanContext.mapObjectInterface(Class intrface) {
>>>>
>>>> Method [] interfaceMethods =* intrface.getMethods();*
>>>>
>>>> for (Method method : interfaceMethods) {
>>>> Class declaringClass = method.getDeclaringClass();
>>>> if (declaringClass == EJBObject.class || declaringClass ==
>>>> EJBLocalObject.class) {
>>>> continue;
>>>> }
>>>> try {
>>>> Method beanMethod = beanClass.getMethod(method.getName(),
>>>> method.getParameterTypes());
>>>> mapMethods(method, beanMethod);
>>>> } catch (NoSuchMethodException nsme) {
>>>> throw new RuntimeException("Invalid method [" + method +
>>> "].
>>>> Not declared by " + beanClass.getName() + " class");
>>>> }
>>>> }
>>>>
>>>> }
>>>>
>>>>
>>> ---------------------------------------------------------------------------------------------------------------
>>>>
>>>> That means, we lost RemoteIF method mapping info here. Users can't
>>>> define different transctions for the same EJB mothed in different
>>> invoking
>>>> context(remote or Local). The client side code lose the ability to
>>>> obtain
>>>> the EJB method through the RemoteIF.
>>>>
>>>> Can anyone shed some lights on how to fix this without changing the
>>>> methodMap data api in BeanContext ?
>>>>
>>>> --
>>>> Shawn
>>>>
>>>
>>
>>
>>
>> --
>> Shawn
>
Re: Lost method info if the local and remote interface are in a type hierarchy
Posted by David Blevins <da...@gmail.com>.
Definitely not popular, but it doesn't need to be to be part of the TCK :) It was never tested before and we never supported it. Specifically we only supported it legacy 2.x Home/Remote LocalHome/Local views.
There was a TODO in this area of the code and the transaction attributes are not using the MethodContext yet. I've been hacking on it all day and have something close to working.
-David
On Jun 2, 2011, at 2:37 AM, Shawn Jiang wrote:
> Thanks, I know it's not wired from the code, but The interface type
> hierarchy is a very popular EJB programing practice. Suppose the user
> wants to customize the transaction for doSomething method.
>
> <container-transaction>
> <method>
> <ejb-name>EJB</ejb-name>
> <method-intf>Remote</method-intf>
> <method-name>doSomething</method-name>
> </method>
> <trans-attribute>Required</trans-attribute>
> </container-transaction>
> <container-transaction>
> <method>
> <ejb-name>EJB</ejb-name>
> <method-intf>Local</method-intf>
> <method-name>doSomething</method-name>
> </method>
> <trans-attribute>Mandatory</trans-attribute>
> </container-transaction>
>
> See, there's no enough options in DD about where the method was defined in
> the inteface hierarchy.
>
> On Thu, Jun 2, 2011 at 5:27 PM, Romain Manni-Bucau <rm...@gmail.com>wrote:
>
>> did you try re-defining doSomething() in remoteif?
>>
>> because the behavior you are describing is not weird for me. doSomething
>> belongs to LocalIf not RemoteIF.
>>
>> - Romain
>>
>> 2011/6/2 Shawn Jiang <ge...@gmail.com>
>>
>>> I found that in following case:
>>>
>>> public interface LocalIF {
>>>
>>> void doSomething();
>>>
>>> }
>>>
>>> public interface RemoteIF extends LocalIF {
>>>
>>> }
>>>
>>> @Stateless()
>>> @Remote(RemoteIF.class)
>>> @Local(LocalIF.class)
>>> public class EJB implements LocalIF,RemoteIF {
>>>
>>> public void doSomething() {
>>> ...
>>> }
>>>
>>> }
>>>
>>> We are using following method to map the methods in interface to the impl
>>> method in EJB. *intrface.getMethods() *will always return method*
>>> LocalIF*
>>> *.doSomething()* for both RemoteIF and LocalIF.
>>>
>>>
>>>
>> ----------------------------------------------------------------------------------------------------
>>> org.apache.openejb.BeanContext.mapObjectInterface(Class intrface) {
>>>
>>> Method [] interfaceMethods =* intrface.getMethods();*
>>>
>>> for (Method method : interfaceMethods) {
>>> Class declaringClass = method.getDeclaringClass();
>>> if (declaringClass == EJBObject.class || declaringClass ==
>>> EJBLocalObject.class) {
>>> continue;
>>> }
>>> try {
>>> Method beanMethod = beanClass.getMethod(method.getName(),
>>> method.getParameterTypes());
>>> mapMethods(method, beanMethod);
>>> } catch (NoSuchMethodException nsme) {
>>> throw new RuntimeException("Invalid method [" + method +
>> "].
>>> Not declared by " + beanClass.getName() + " class");
>>> }
>>> }
>>>
>>> }
>>>
>>>
>> ---------------------------------------------------------------------------------------------------------------
>>>
>>> That means, we lost RemoteIF method mapping info here. Users can't
>>> define different transctions for the same EJB mothed in different
>> invoking
>>> context(remote or Local). The client side code lose the ability to
>>> obtain
>>> the EJB method through the RemoteIF.
>>>
>>> Can anyone shed some lights on how to fix this without changing the
>>> methodMap data api in BeanContext ?
>>>
>>> --
>>> Shawn
>>>
>>
>
>
>
> --
> Shawn
Re: Lost method info if the local and remote interface are in a type hierarchy
Posted by Romain Manni-Bucau <rm...@gmail.com>.
IMHO the remote interface has to be a copy of the local interface if you
want to do it. I don't know how does other container, do you know? I don't
think we can create Method object "by default" in java so the API has to
change if you want to manage it.
- ROmain
2011/6/2 Shawn Jiang <ge...@gmail.com>
> Thanks, I know it's not wired from the code, but The interface type
> hierarchy is a very popular EJB programing practice. Suppose the user
> wants to customize the transaction for doSomething method.
>
> <container-transaction>
> <method>
> <ejb-name>EJB</ejb-name>
> <method-intf>Remote</method-intf>
> <method-name>doSomething</method-name>
> </method>
> <trans-attribute>Required</trans-attribute>
> </container-transaction>
> <container-transaction>
> <method>
> <ejb-name>EJB</ejb-name>
> <method-intf>Local</method-intf>
> <method-name>doSomething</method-name>
> </method>
> <trans-attribute>Mandatory</trans-attribute>
> </container-transaction>
>
> See, there's no enough options in DD about where the method was defined in
> the inteface hierarchy.
>
> On Thu, Jun 2, 2011 at 5:27 PM, Romain Manni-Bucau <rmannibucau@gmail.com
> >wrote:
>
> > did you try re-defining doSomething() in remoteif?
> >
> > because the behavior you are describing is not weird for me. doSomething
> > belongs to LocalIf not RemoteIF.
> >
> > - Romain
> >
> > 2011/6/2 Shawn Jiang <ge...@gmail.com>
> >
> > > I found that in following case:
> > >
> > > public interface LocalIF {
> > >
> > > void doSomething();
> > >
> > > }
> > >
> > > public interface RemoteIF extends LocalIF {
> > >
> > > }
> > >
> > > @Stateless()
> > > @Remote(RemoteIF.class)
> > > @Local(LocalIF.class)
> > > public class EJB implements LocalIF,RemoteIF {
> > >
> > > public void doSomething() {
> > > ...
> > > }
> > >
> > > }
> > >
> > > We are using following method to map the methods in interface to the
> impl
> > > method in EJB. *intrface.getMethods() *will always return method*
> > > LocalIF*
> > > *.doSomething()* for both RemoteIF and LocalIF.
> > >
> > >
> > >
> >
> ----------------------------------------------------------------------------------------------------
> > > org.apache.openejb.BeanContext.mapObjectInterface(Class intrface) {
> > >
> > > Method [] interfaceMethods =* intrface.getMethods();*
> > >
> > > for (Method method : interfaceMethods) {
> > > Class declaringClass = method.getDeclaringClass();
> > > if (declaringClass == EJBObject.class || declaringClass ==
> > > EJBLocalObject.class) {
> > > continue;
> > > }
> > > try {
> > > Method beanMethod =
> beanClass.getMethod(method.getName(),
> > > method.getParameterTypes());
> > > mapMethods(method, beanMethod);
> > > } catch (NoSuchMethodException nsme) {
> > > throw new RuntimeException("Invalid method [" + method +
> > "].
> > > Not declared by " + beanClass.getName() + " class");
> > > }
> > > }
> > >
> > > }
> > >
> > >
> >
> ---------------------------------------------------------------------------------------------------------------
> > >
> > > That means, we lost RemoteIF method mapping info here. Users can't
> > > define different transctions for the same EJB mothed in different
> > invoking
> > > context(remote or Local). The client side code lose the ability to
> > > obtain
> > > the EJB method through the RemoteIF.
> > >
> > > Can anyone shed some lights on how to fix this without changing the
> > > methodMap data api in BeanContext ?
> > >
> > > --
> > > Shawn
> > >
> >
>
>
>
> --
> Shawn
>
Re: Lost method info if the local and remote interface are in a type hierarchy
Posted by Shawn Jiang <ge...@gmail.com>.
Thanks, I know it's not wired from the code, but The interface type
hierarchy is a very popular EJB programing practice. Suppose the user
wants to customize the transaction for doSomething method.
<container-transaction>
<method>
<ejb-name>EJB</ejb-name>
<method-intf>Remote</method-intf>
<method-name>doSomething</method-name>
</method>
<trans-attribute>Required</trans-attribute>
</container-transaction>
<container-transaction>
<method>
<ejb-name>EJB</ejb-name>
<method-intf>Local</method-intf>
<method-name>doSomething</method-name>
</method>
<trans-attribute>Mandatory</trans-attribute>
</container-transaction>
See, there's no enough options in DD about where the method was defined in
the inteface hierarchy.
On Thu, Jun 2, 2011 at 5:27 PM, Romain Manni-Bucau <rm...@gmail.com>wrote:
> did you try re-defining doSomething() in remoteif?
>
> because the behavior you are describing is not weird for me. doSomething
> belongs to LocalIf not RemoteIF.
>
> - Romain
>
> 2011/6/2 Shawn Jiang <ge...@gmail.com>
>
> > I found that in following case:
> >
> > public interface LocalIF {
> >
> > void doSomething();
> >
> > }
> >
> > public interface RemoteIF extends LocalIF {
> >
> > }
> >
> > @Stateless()
> > @Remote(RemoteIF.class)
> > @Local(LocalIF.class)
> > public class EJB implements LocalIF,RemoteIF {
> >
> > public void doSomething() {
> > ...
> > }
> >
> > }
> >
> > We are using following method to map the methods in interface to the impl
> > method in EJB. *intrface.getMethods() *will always return method*
> > LocalIF*
> > *.doSomething()* for both RemoteIF and LocalIF.
> >
> >
> >
> ----------------------------------------------------------------------------------------------------
> > org.apache.openejb.BeanContext.mapObjectInterface(Class intrface) {
> >
> > Method [] interfaceMethods =* intrface.getMethods();*
> >
> > for (Method method : interfaceMethods) {
> > Class declaringClass = method.getDeclaringClass();
> > if (declaringClass == EJBObject.class || declaringClass ==
> > EJBLocalObject.class) {
> > continue;
> > }
> > try {
> > Method beanMethod = beanClass.getMethod(method.getName(),
> > method.getParameterTypes());
> > mapMethods(method, beanMethod);
> > } catch (NoSuchMethodException nsme) {
> > throw new RuntimeException("Invalid method [" + method +
> "].
> > Not declared by " + beanClass.getName() + " class");
> > }
> > }
> >
> > }
> >
> >
> ---------------------------------------------------------------------------------------------------------------
> >
> > That means, we lost RemoteIF method mapping info here. Users can't
> > define different transctions for the same EJB mothed in different
> invoking
> > context(remote or Local). The client side code lose the ability to
> > obtain
> > the EJB method through the RemoteIF.
> >
> > Can anyone shed some lights on how to fix this without changing the
> > methodMap data api in BeanContext ?
> >
> > --
> > Shawn
> >
>
--
Shawn
Re: Lost method info if the local and remote interface are in a type hierarchy
Posted by Romain Manni-Bucau <rm...@gmail.com>.
did you try re-defining doSomething() in remoteif?
because the behavior you are describing is not weird for me. doSomething
belongs to LocalIf not RemoteIF.
- Romain
2011/6/2 Shawn Jiang <ge...@gmail.com>
> I found that in following case:
>
> public interface LocalIF {
>
> void doSomething();
>
> }
>
> public interface RemoteIF extends LocalIF {
>
> }
>
> @Stateless()
> @Remote(RemoteIF.class)
> @Local(LocalIF.class)
> public class EJB implements LocalIF,RemoteIF {
>
> public void doSomething() {
> ...
> }
>
> }
>
> We are using following method to map the methods in interface to the impl
> method in EJB. *intrface.getMethods() *will always return method*
> LocalIF*
> *.doSomething()* for both RemoteIF and LocalIF.
>
>
> ----------------------------------------------------------------------------------------------------
> org.apache.openejb.BeanContext.mapObjectInterface(Class intrface) {
>
> Method [] interfaceMethods =* intrface.getMethods();*
>
> for (Method method : interfaceMethods) {
> Class declaringClass = method.getDeclaringClass();
> if (declaringClass == EJBObject.class || declaringClass ==
> EJBLocalObject.class) {
> continue;
> }
> try {
> Method beanMethod = beanClass.getMethod(method.getName(),
> method.getParameterTypes());
> mapMethods(method, beanMethod);
> } catch (NoSuchMethodException nsme) {
> throw new RuntimeException("Invalid method [" + method + "].
> Not declared by " + beanClass.getName() + " class");
> }
> }
>
> }
>
> ---------------------------------------------------------------------------------------------------------------
>
> That means, we lost RemoteIF method mapping info here. Users can't
> define different transctions for the same EJB mothed in different invoking
> context(remote or Local). The client side code lose the ability to
> obtain
> the EJB method through the RemoteIF.
>
> Can anyone shed some lights on how to fix this without changing the
> methodMap data api in BeanContext ?
>
> --
> Shawn
>