|
|
|
Jarosław Lewandowski
|
Some javascript/style in this post has been disabled (why?)
Hi,I found some issue with Atmosphere and Jersey integration. In my code resources are EJBs. Some of these resources are returned as sub resources from root resource and as spec says the annotations are discovered in the runtime. So my beans have business interfaces defined and to allow jersey to discover all it's annotations they are included in such interfaces e.g. @Stateless public class SystemResourceBean implements SystemResource { @Override public String status() { .... } } public interface SystemResource { @GET public String status(); } and root resource @Stateless public class RootResource { } Unfortunately when methods of this interface are annotated with Atmosphere annotations (like @Suspend etc.) they have no effect. After some investigation I found in Jersey code that the class com.sun.jersey.core.reflection.AnnotatedMethod uses all annotation of class if it is simple POJO (including Atmosphere's ones) and tries to merge annotations from super classes and all interfaces. Due to this fragment of code: private static Annotation[] mergeMethodAnnotations(Method m, Method am) { List<Annotation> al = asList(m.getAnnotations()); for (Annotation a : am.getAnnotations()) { if (isMethodAnnotation(a)) al.add(a); } return al.toArray(new Annotation[0]); } only annotations passing isMethodAnnotation(...) check are added to the result, which means that only @Path, @Produces, @Consumes and any other annotations annotated by @HttpMethod are merged from interfaces.. and obviously annotations like @Suspend are discarded... In my opinion is it kind of inconsistency in treating POJO's annotations and their interfaces in different way... Lack of this annotation in method specification of resource causes that org.atmosphere.core.AtmosphereFilter is not able to work properly :( So my question is: does anybody know about this issue? If not, then should I rise it in Atmosphere or in Jersey project? I know that workaround for this is to use no-interface Session Beans only... but this is not a solution for me :( Regards Jaro |
|
Jarosław Lewandowski
|
Hi,
I found some issue with Atmosphere and Jersey integration. In my code resources are EJBs. Some of these resources are returned as sub resources from root resource and as spec says the annotations are discovered in the runtime. So my beans have business interfaces defined and to allow jersey to discover all it's annotations they are included in such interfaces e.g. @Stateless public class SystemResourceBean implements SystemResource { @Override public String status() { .... } } public interface SystemResource { @GET public String status(); } and in root resource: @Stateless public class RootResource { @EJB private SystemResource systemResource; @Path("system") SystemResource system() { return systemResource; } } Unfortunately when methods of this interface are annotated with Atmosphere annotations (like @Suspend etc.) they have no effect. After some investigation I found in Jersey code that the class com.sun.jersey.core.reflection.AnnotatedMethod uses all annotation of class if it is simple POJO (including Atmosphere's ones) and tries to merge annotations from super classes and all interfaces. Due to this fragment of code: private static Annotation[] mergeMethodAnnotations(Method m, Method am) { List<Annotation> al = asList(m.getAnnotations()); for (Annotation a : am.getAnnotations()) { if (isMethodAnnotation(a)) al.add(a); } return al.toArray(new Annotation[0]); } only annotations passing isMethodAnnotation(...) check are added to the result, which means that only @Path, @Produces, @Consumes and any other annotations annotated by @HttpMethod are merged from interfaces.. and obviously annotations like @Suspend are discarded... In my opinion is it kind of inconsistency in treating POJO's annotations and their interfaces in different way... Lack of this annotation in method specification of resource causes that org.atmosphere.core.AtmosphereFilter is not able to work properly :( So my question is: does anybody know about this issue? If not, then should I rise it in Atmosphere or in Jersey project? I know that workaround for this is to use no-interface Session Beans only... but this is not a solution for me :( Regards Jaro --------------------------------------------------------------------- To unsubscribe, e-mail: [hidden email] For additional commands, e-mail: [hidden email] |
|||||||||||||||||||
|
Jeanfrancois Arcand
|
In reply to this post
by Jarosław Lewandowski
Salut,
Jaros?aw Lewandowski wrote: > Hi, > > I found some issue with Atmosphere and Jersey integration. In my code > resources are EJBs. Some of these resources are returned as sub > resources from root resource and as spec says the annotations are > discovered in the runtime. So my beans have business interfaces defined > and to allow jersey to discover all it's annotations they are included > in such interfaces e.g. > > @Stateless > public class SystemResourceBean implements SystemResource { > > @Override > public String status() { > .... > } > } > > public interface SystemResource { > @GET > public String status(); > } > > and root resource > > @Stateless > public class RootResource { > } > > Unfortunately when methods of this interface are annotated with > Atmosphere annotations (like @Suspend etc.) they have no effect. After > some investigation I found in Jersey code that the > class com.sun.jersey.core.reflection.AnnotatedMethod uses all annotation > of class if it is simple POJO (including Atmosphere's ones) and tries to > merge annotations from super classes and all interfaces. Due to this > fragment of code: > > private static Annotation[] mergeMethodAnnotations(Method m, Method am) { > List<Annotation> al = asList(m.getAnnotations()); > for (Annotation a : am.getAnnotations()) { > if (isMethodAnnotation(a)) > al.add(a); > } > > > > return al.toArray(new Annotation[0]); > } > > only annotations passing isMethodAnnotation(...) check are added to the > result, which means that only @Path, @Produces, @Consumes and any other > annotations annotated by @HttpMethod are merged from interfaces.. and > obviously annotations like @Suspend are discarded... In my opinion is it > kind of inconsistency in treating POJO's annotations and their > interfaces in different way... Lack of this annotation in method > specification of resource causes that > org.atmosphere.core.AtmosphereFilter is not able to work properly :( First, Great analysis. > > So my question is: does anybody know about this issue? If not, then > should I rise it in Atmosphere or in Jersey project? This is a new issue. I'm cc-ing the Jersey's dev list but I suspect the issue is with Atmosphere and how I defines those annotations. Let me look at how Jersey defines its annotation and see if I can comes with a solution. Meanwhile if someone of the Jersey list knows the solution, let me know :-) > I know that workaround for this is to use no-interface Session Beans > only... but this is not a solution for me :( Sure let's try to find a solution and include it in the upcoming 0.4 release. Thanks -- Jeanfrancois > > Regards > Jaro --------------------------------------------------------------------- To unsubscribe, e-mail: [hidden email] For additional commands, e-mail: [hidden email] |
|||||||||||||||||||
|
Paul Sandoz
|
Hi,
It is not an issue with Atmosphere. Jaro, could you log an issue with Jersey? Jersey is being unduly restrictive when merging the annotations. It should be safe to merge any annotations from the JAX-RS identified method as long as those annotations do not already exist on the overriding/implementing method. Same goes for the annotations declared on the parameters. Unfortunately there is no standard behavior specified for annotation inheritance for methods and method parameters. So each spec/framework does its own thing. Thanks, Paul. On Oct 14, 2009, at 2:02 AM, Jeanfrancois Arcand wrote: > Salut, > > Jaros?aw Lewandowski wrote: >> Hi, >> I found some issue with Atmosphere and Jersey integration. In my >> code resources are EJBs. Some of these resources are returned as >> sub resources from root resource and as spec says the annotations >> are discovered in the runtime. So my beans have business interfaces >> defined and to allow jersey to discover all it's annotations they >> are included in such interfaces e.g. >> @Stateless >> public class SystemResourceBean implements SystemResource { >> @Override >> public String status() { >> .... >> } >> } >> public interface SystemResource { >> @GET >> public String status(); >> } >> and root resource >> @Stateless >> public class RootResource { >> } >> Unfortunately when methods of this interface are annotated with >> Atmosphere annotations (like @Suspend etc.) they have no effect. >> After some investigation I found in Jersey code that the class >> com.sun.jersey.core.reflection.AnnotatedMethod uses all annotation >> of class if it is simple POJO (including Atmosphere's ones) and >> tries to merge annotations from super classes and all interfaces. >> Due to this fragment of code: >> private static Annotation[] mergeMethodAnnotations(Method m, Method >> am) { >> List<Annotation> al = asList(m.getAnnotations()); >> for (Annotation a : am.getAnnotations()) { >> if (isMethodAnnotation(a)) >> al.add(a); >> } >> return al.toArray(new Annotation[0]); >> } >> only annotations passing isMethodAnnotation(...) check are added to >> the result, which means that only @Path, @Produces, @Consumes and >> any other annotations annotated by @HttpMethod are merged from >> interfaces.. and obviously annotations like @Suspend are >> discarded... In my opinion is it kind of inconsistency in treating >> POJO's annotations and their interfaces in different way... Lack of >> this annotation in method specification of resource causes that >> org.atmosphere.core.AtmosphereFilter is not able to work properly :( > > First, Great analysis. > >> So my question is: does anybody know about this issue? If not, then >> should I rise it in Atmosphere or in Jersey project? > > This is a new issue. I'm cc-ing the Jersey's dev list but I suspect > the issue is with Atmosphere and how I defines those annotations. > Let me look at how Jersey defines its annotation and see if I can > comes with a solution. Meanwhile if someone of the Jersey list knows > the solution, let me know :-) > > >> I know that workaround for this is to use no-interface Session >> Beans only... but this is not a solution for me :( > > Sure let's try to find a solution and include it in the upcoming 0.4 > release. > > Thanks > > -- Jeanfrancois > > >> Regards >> Jaro > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [hidden email] > For additional commands, e-mail: [hidden email] > --------------------------------------------------------------------- To unsubscribe, e-mail: [hidden email] For additional commands, e-mail: [hidden email] |
|||||||||||||||||||
|
Jarosław Lewandowski
|
Some javascript/style in this post has been disabled (why?)
Hi,Regards JL On 14 Oct 2009, at 10:28, Paul Sandoz wrote:
|
|||||||||||||||||||
|
Paul Sandoz
|
Some javascript/style in this post has been disabled (why?)
On Oct 14, 2009, at 11:50 AM, Jarosław Lewandowski wrote: Paul.
|
|||||||||||||||||||
|
Paul Sandoz
|
In reply to this post
by Jarosław Lewandowski
Some javascript/style in this post has been disabled (why?)
On Oct 14, 2009, at 11:50 AM, Jarosław Lewandowski wrote: Paul.
|
|||||||||||||||||||
|
Jeanfrancois Arcand
|
Paul Sandoz wrote: > > On Oct 14, 2009, at 11:50 AM, Jarosław Lewandowski wrote: > >> Hi, >> >> Submitted: https://jersey.dev.java.net/issues/show_bug.cgi?id=385 >> > > Fixed, Wow that was fast! Thanks Paul, I've bumped Jersey version to 1.1.4-ea-SNAPSHOT so the fix will make its way in 0.4 -- Jeanfrancois > Paul. > >> Regards >> JL >> >> On 14 Oct 2009, at 10:28, Paul Sandoz wrote: >> >>> Hi, >>> >>> It is not an issue with Atmosphere. Jaro, could you log an issue with >>> Jersey? >>> >>> Jersey is being unduly restrictive when merging the annotations. It >>> should be safe to merge any annotations from the JAX-RS identified >>> method as long as those annotations do not already exist on the >>> overriding/implementing method. Same goes for the annotations >>> declared on the parameters. >>> >>> Unfortunately there is no standard behavior specified for annotation >>> inheritance for methods and method parameters. So each spec/framework >>> does its own thing. >>> >>> Thanks, >>> Paul. >>> >>> On Oct 14, 2009, at 2:02 AM, Jeanfrancois Arcand wrote: >>> >>>> Salut, >>>> >>>> Jaros?aw Lewandowski wrote: >>>>> Hi, >>>>> I found some issue with Atmosphere and Jersey integration. In my >>>>> code resources are EJBs. Some of these resources are returned as >>>>> sub resources from root resource and as spec says the annotations >>>>> are discovered in the runtime. So my beans have business interfaces >>>>> defined and to allow jersey to discover all it's annotations they >>>>> are included in such interfaces e.g. >>>>> @Stateless >>>>> public class SystemResourceBean implements SystemResource { >>>>> @Override >>>>> public String status() { >>>>> .... >>>>> } >>>>> } >>>>> public interface SystemResource { >>>>> @GET >>>>> public String status(); >>>>> } >>>>> and root resource >>>>> @Stateless >>>>> public class RootResource { >>>>> } >>>>> Unfortunately when methods of this interface are annotated with >>>>> Atmosphere annotations (like @Suspend etc.) they have no effect. >>>>> After some investigation I found in Jersey code that the class >>>>> com.sun.jersey.core.reflection.AnnotatedMethod uses all annotation >>>>> of class if it is simple POJO (including Atmosphere's ones) and >>>>> tries to merge annotations from super classes and all interfaces. >>>>> Due to this fragment of code: >>>>> private static Annotation[] mergeMethodAnnotations(Method m, Method >>>>> am) { >>>>> List<Annotation> al = asList(m.getAnnotations()); >>>>> for (Annotation a : am.getAnnotations()) { >>>>> if (isMethodAnnotation(a)) >>>>> al.add(a); >>>>> } >>>>> return al.toArray(new Annotation[0]); >>>>> } >>>>> only annotations passing isMethodAnnotation(...) check are added to >>>>> the result, which means that only @Path, @Produces, @Consumes and >>>>> any other annotations annotated by @HttpMethod are merged from >>>>> interfaces.. and obviously annotations like @Suspend are >>>>> discarded... In my opinion is it kind of inconsistency in treating >>>>> POJO's annotations and their interfaces in different way... Lack of >>>>> this annotation in method specification of resource causes that >>>>> org.atmosphere.core.AtmosphereFilter is not able to work properly :( >>>> >>>> First, Great analysis. >>>> >>>>> So my question is: does anybody know about this issue? If not, then >>>>> should I rise it in Atmosphere or in Jersey project? >>>> >>>> This is a new issue. I'm cc-ing the Jersey's dev list but I suspect >>>> the issue is with Atmosphere and how I defines those annotations. >>>> Let me look at how Jersey defines its annotation and see if I can >>>> comes with a solution. Meanwhile if someone of the Jersey list knows >>>> the solution, let me know :-) >>>> >>>> >>>>> I know that workaround for this is to use no-interface Session >>>>> Beans only... but this is not a solution for me :( >>>> >>>> Sure let's try to find a solution and include it in the upcoming 0.4 >>>> release. >>>> >>>> Thanks >>>> >>>> -- Jeanfrancois >>>> >>>> >>>>> Regards >>>>> Jaro >>>> >>>> --------------------------------------------------------------------- >>>> To unsubscribe, e-mail: [hidden email] >>>> <mailto:[hidden email]> >>>> For additional commands, e-mail: [hidden email] >>>> <mailto:[hidden email]> >>>> >>> >>> >>> --------------------------------------------------------------------- >>> To unsubscribe, e-mail: [hidden email] >>> <mailto:[hidden email]> >>> For additional commands, e-mail: [hidden email] >>> <mailto:[hidden email]> >>> >> > --------------------------------------------------------------------- To unsubscribe, e-mail: [hidden email] For additional commands, e-mail: [hidden email] |
|||||||||||||||||||
| Free Embeddable Forum Powered by Nabble | Help |