Sebastian,
UriInfo should already be injectable using @Context.
— Santiago
> On Feb 1, 2016, at 3:56 PM, Sebastian Daschner <java_at_sebastian-daschner.de> wrote:
>
> Hi experts,
>
> Thanks for the work done so far.
>
> We had the case in projects that we wanted to construct URIs based on
> UriInfo without wanting to pass the current UriInfo into other
> (dedicated helper) classes.
>
> Do you think it's feasible to enable the request scoped UriInfo (plus
> maybe others) for CDI injection, in order to decouple potential URI
> construction classes from the JAX-RS resources?
>
> So something like follows would be possible (to call the method from any
> component):
>
> public class BookstoreUriBuilder {
>
> @Inject
> UriInfo uriInfo;
>
> public URI forBook(Book book) {
> return uriInfo.getBaseUriBuilder()
> .path(BooksResource.class)
> .path(BooksResource.class, "getBook")
> .build(book.getId());
> }
>
> }
>
> WDYT?
>
> Cheers,
> Sebastian