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/04/13 04:15:22 UTC
@Timeout in class inheritance is not handled well.
Currently, the code in openejb assume there's only 1 @Timeout annotated
method within a EJB. Actually, when there's multiple @timeout in the
class inheritance hierarchy.
The finder would return a method list the size of which is >1.
Following patch would use the @Timeout method in the bottom class where
@Timeout is defined.
org.apache.openejb.config.AnnotationDeployer.ProcessAnnotatedBeans.processCallbacks(Lifecycle,
AnnotationFinder)
{
.....
if (bean instanceof TimerConsumer) {
TimerConsumer timerConsumer = (TimerConsumer) bean;
if (timerConsumer.getTimeoutMethod() == null) {
List<Annotated<Method>> timeoutMethods =
annotationFinder.findMetaAnnotatedMethods(javax.ejb.Timeout.class);
//Validation Logic is moved to CheckCallback class.
- if(timeoutMethods.size() == 1){
- timerConsumer.setTimeoutMethod(new
NamedMethod(timeoutMethods.get(0).get()));
+ if(timeoutMethods.size() >= 1){
+ // only set the timeout method of child class
because
+ // the timeout method in child class will override
the timeout method in superclass
+ timerConsumer.setTimeoutMethod(new
NamedMethod(timeoutMethods.get(timeoutMethods.size()-1).get()));
}
}
}
....
}
Will open a JIRA later for this.
--
Shawn
Re: @Timeout in class inheritance is not handled well.
Posted by Shawn Jiang <ge...@gmail.com>.
Seems my git patch is not updated according to my workspace. refresh it to
the correct one, sort the methods before use it.
* @Timeout
*/
if (bean instanceof TimerConsumer) {
TimerConsumer timerConsumer = (TimerConsumer) bean;
if (timerConsumer.getTimeoutMethod() == null) {
- List<Annotated<Method>> timeoutMethods =
annotationFinder.findMetaAnnotatedMethods(javax.ejb.Timeout.class);
+ List<Annotated<Method>> timeoutMethods =
sortMethods(annotationFinder.findMetaAnnotatedMethods(javax.ejb.Timeout.class));
//Validation Logic is moved to CheckCallback class.
- if(timeoutMethods.size() == 1){
- timerConsumer.setTimeoutMethod(new
NamedMethod(timeoutMethods.get(0).get()));
+ if(timeoutMethods.size() >= 1){
+ // only set the timeout method of child class
because
+ // the timeout method in child class will override
the timeout method in super classes
+ timerConsumer.setTimeoutMethod(new
NamedMethod(timeoutMethods.get(timeoutMethods.size()-1).get()));
}
}
}
if (bean instanceof org.apache.openejb.jee.Session) {
On Wed, Apr 13, 2011 at 10:15 AM, Shawn Jiang <ge...@gmail.com> wrote:
> Currently, the code in openejb assume there's only 1 @Timeout annotated
> method within a EJB. Actually, when there's multiple @timeout in the
> class inheritance hierarchy.
> The finder would return a method list the size of which is >1.
> Following patch would use the @Timeout method in the bottom class where
> @Timeout is defined.
>
> org.apache.openejb.config.AnnotationDeployer.ProcessAnnotatedBeans.processCallbacks(Lifecycle,
> AnnotationFinder)
> {
>
> .....
>
> if (bean instanceof TimerConsumer) {
> TimerConsumer timerConsumer = (TimerConsumer) bean;
> if (timerConsumer.getTimeoutMethod() == null) {
> List<Annotated<Method>> timeoutMethods =
> annotationFinder.findMetaAnnotatedMethods(javax.ejb.Timeout.class);
> //Validation Logic is moved to CheckCallback class.
> - if(timeoutMethods.size() == 1){
> - timerConsumer.setTimeoutMethod(new
> NamedMethod(timeoutMethods.get(0).get()));
> + if(timeoutMethods.size() >= 1){
> + // only set the timeout method of child class
> because
> + // the timeout method in child class will override
> the timeout method in superclass
> + timerConsumer.setTimeoutMethod(new
> NamedMethod(timeoutMethods.get(timeoutMethods.size()-1).get()));
> }
> }
> }
>
> ....
>
> }
>
> Will open a JIRA later for this.
>
>
> --
> Shawn
>
--
Shawn