You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
The text was updated successfully, but these errors were encountered:
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
null
s when parameters are optional.For example, on the client-side, I want this resource interface:
but on the server-side I want this resource interfaces:
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.
The text was updated successfully, but these errors were encountered: