Hi
On 10/04/13 13:52, Francesco Chicchiriccò wrote:
Hi all,
we had some discussion in the past about random errors with Java 7 and
the -Pjaxrs Maven profile.
Today I have updated CXF from 2.7.3 to 2.7.4 and most of such errors
seems to disappear (I've been executing some times -Pjaxrs with either
OpenJDK 7 and Oracle JDK 7 on different platforms).

Only two remain, in ConnInstanceTestITCase, when calling

connectorService.list(null)

This call is intentioned to be routed to
ConnectorServiceImpl.list(null), while instead it goes to
ConnectorService.readByResource(null): I guess that CXF gets confused by
the JAX-RS annotations on ConnectorService:

     @GET
     List<ConnInstanceTO>  list(@QueryParam("lang") String lang);

     @GET
     ConnInstanceTO readByResource(@MatrixParam("resourceName") String
resourceName);

with null param, in fact, there seems to be no way find the right match.

Indeed, optional parameters (query, matrix, headers) won't affect the selection of the method candidates, unless a custom resource comparator takes care of it

Why don't we have instead

     @GET
     @Path("{resourceName}")
     ConnInstanceTO readByResource(@PathParam("resourceName") String
resourceName);

? This should solve the issue, but I guess there is some best practice
here, so here's why I am asking.

This is definitely an option; if the optional parameters are preferred to be handled by multiple methods with the same matching path, then another option is to simply have say

@Context UriUnfo ui;
@GET Response m() {
  // check the available query parameters and handle as needed
  ui.getQueryParameters();
}

However, having the same path but expecting either Matrix or Query parameters drive the method selection makes it tricky; at least having either query or matrix parameters but not both types can help there

I'd probably go for having different path segments though

Cheers, Sergey

For the moment I have changed, in ConnInstanceTestITCase the calls above to

connectorService.list("")

and this makes the tests run smoothly.

Final remark: why "ConnectorService" (and derived) instead of
ConnInstanceService (and derived)? Connectors and ConnInstance (e.g.
connector instances) are distinct in Syncope.

Regards.



Reply via email to