Annotation Interface WebClient
The @WebClient
annotation indicates Web client stub interface.
It must be set on an interface which specifies Web route stub pointing to resources exposed by an HTTP server. The uri()
attribute identifies the destination to which HTTP requests will be
sent, it must be a valid service URI. The Web compiler generates a bean implementing the Web client stub, the Web client stub interface can then be injected in a module to consume HTTP resources.
Web routes are declared as methods annotated with @Webroute
.
For instance, the following example will result in the generation of a BookClient
bean which allows to list or get book resources exposed at http://host:8080/book
.
@Webclient( uri = "http://host:8080/book" )
public interface BookClient {
@WebRoute
List<Book> getList();
@WebRoute( path = "/{id}" )
Book get(@PathParam String id)
}
- Since:
- 1.12
- Author:
- Jeremy Kuhn
-
Required Element Summary
-
Optional Element Summary
Modifier and TypeOptional ElementDescriptionIndicates a name identifying the Web client bean in the module, defaults to the name of the class.Indicates the visibility of the Web client bean in the module.
-
Element Details
-
name
String nameIndicates a name identifying the Web client bean in the module, defaults to the name of the class.
- Returns:
- A name
- Default:
""
-
uri
String uriThe destination URI.
The destination URI must be a valid service URI as defined by
ServiceID
: it must be absolute (i.e. have a scheme), if it is not opaque it must have an authority component and the path component must be absolute.- Returns:
- the destination URI
-
visibility
Bean.Visibility visibilityIndicates the visibility of the Web client bean in the module.
- Returns:
- The bean's visibility
- Default:
PUBLIC
-