Re: [DISCUSS] ConnectorService, Java 7 and @MatrixParam
FYI, I have opened SYNCOPE-358 for this. Regards. -- Francesco Chicchiriccò ASF Member, Apache Syncope PMC chair, Apache Cocoon PMC Member http://people.apache.org/~ilgrosso/
RE: [DISCUSS] ConnectorService, Java 7 and @MatrixParam
Hi Francesco, 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). Cool! 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 ListConnInstanceTO 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. 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. For the moment I have changed, in ConnInstanceTestITCase the calls above to connectorService.list() and this makes the tests run smoothly. Currently CXF method selection is extended by org.apache.syncope.core.rest.utils.QueryResourceInfoComperator. This comparator additionally analyses Query and Matrix parameters to select a correct method. I do not exactly remember the reason why it was done this way. However I tend to use classic path selection for readByResource() as well. Resource name is reasonable path parameter. Final remark: why ConnectorService (and derived) instead of ConnInstanceService (and derived)? Connectors and ConnInstance (e.g. connector instances) are distinct in Syncope. Not sure ... the name seems to be ConnectorService from beginning. Will ping Jan regarding it. Regards, Andrei. Regards. -- Francesco Chicchiriccò ASF Member, Apache Syncope PMC chair, Apache Cocoon PMC Member http://people.apache.org/~ilgrosso/
Re: [DISCUSS] ConnectorService, Java 7 and @MatrixParam
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 ListConnInstanceTO 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.