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