Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Some way to disambiguate ambiguous resource methods on the server #803

Open
derekm opened this issue Oct 22, 2019 · 0 comments
Open

Some way to disambiguate ambiguous resource methods on the server #803

derekm opened this issue Oct 22, 2019 · 0 comments

Comments

@derekm
Copy link

derekm commented Oct 22, 2019

With Jersey's WebResourceFactory and MicroProfile's Rest Client, re-using the same JAX-RS-annotated interfaces on the client-side and the server-side is becoming more common.

When the server-side methods have arguments, it becomes convenient to overload those methods for the sake of the client-side, so that clients aren't forced to pass nulls when parameters are optional.

For example, on the client-side, I want this resource interface:

/**
 *  URI provides default behaviors associated with collections of entities.
 */
public interface CollectionResource<O extends ResourceObject, P extends ObjectParams> {

    /**
     * For some object type, retrieve the entire collection.
     * @return list of objects
     */
    @GET
    @Produces({MediaType.APPLICATION_JSON})
    default List<O> get() {
        return get(null);
    }

    /**
     * For some object type, retrieve the entire collection.
     * @param params parameters to filter the collection by
     * @return list of objects
     */
    @GET
    @Produces({MediaType.APPLICATION_JSON})
    List<O> get(@BeanParam P params);

    /**
     * For some object type, create an entry.
     * @param object object to create
     * @return created object
     */
    @POST
    @Consumes({MediaType.APPLICATION_JSON})
    @Produces({MediaType.APPLICATION_JSON})
    O post(O object);

}

but on the server-side I want this resource interfaces:

/**
 *  URI provides default behaviors associated with collections of entities.
 */
public interface CollectionResource<O extends ResourceObject, P extends ObjectParams> {

    /**
     * For some object type, retrieve the entire collection.
     * @param params parameters to filter the collection by
     * @return list of objects
     */
    @GET
    @Produces({MediaType.APPLICATION_JSON})
    List<O> get(@BeanParam P params);

    /**
     * For some object type, create an entry.
     * @param object object to create
     * @return created object
     */
    @POST
    @Consumes({MediaType.APPLICATION_JSON})
    @Produces({MediaType.APPLICATION_JSON})
    O post(O object);

}

Some way to re-use the 1st interface on both client- and server-sides while indicating to the server-side how to disambiguate the interface would be ideal.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant