Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [jersey-dev] Internal request with new UriInfo

Hi Jan,

OK let me try to explain.

Lets say Resource is constructed with UriInfo where
requestUri=https://localhost/some/path

But then I want to create another Resource and execute its methods as
if it was a completely new request, e.g.
requestUri=https://localhost/another/path

So the same UriInfo does not apply. Nor is this a sub-resource case.

On Mon, Oct 19, 2020 at 5:16 PM Jan Supol <jan.supol@xxxxxxxxxx> wrote:
>
> Hi,
>
> I am not sure I follow. Unless the resource is specified as a singleton
> (either by using the @Singleton annotation) or by
> Application.getSingletons(), the Resource classes are instantiated per
> request, so you should have the proper UriInfo.
>
> Note that you may also inject @Context UriInfo as a post method argument.
>
> Thanks,
>
> Jan
>
> On 19.10.2020 16:34, Martynas Jusevičius wrote:
> > Hi,
> >
> > say I have a resource class with a UriInfo constructor and a @POST method.
> >
> > How do I call post() on a new Resource with a new UriInfo with a
> > different requestUri?
> >
> > public class Resource
> > {
> >
> >      @Inject
> >      public Resource(UriInfo uriInfo)
> >      {
> >          ...
> >      }
> >
> >      @POST
> >      public post(Model model)
> >      {
> >          // use getUriInfo() here
> >          ...
> >          // forward POST -- how to construct UriInfo with an arbitrary
> > requestUri?
> >          new Resource(???).post(newModel);
> >          ...
> >      }
> >
> > }
> >
> >
> > Martynas
> > _______________________________________________
> > jersey-dev mailing list
> > jersey-dev@xxxxxxxxxxx
> > To unsubscribe from this list, visit https://urldefense.com/v3/__https://www.eclipse.org/mailman/listinfo/jersey-dev__;!!GqivPVa7Brio!Ll-NKpZ9Yae48eNnU-pgrlG-iFyaoR8gSuX7AC88OCuRiyVdKTD6GuxH4cVJ3nxa$
> _______________________________________________
> jersey-dev mailing list
> jersey-dev@xxxxxxxxxxx
> To unsubscribe from this list, visit https://www.eclipse.org/mailman/listinfo/jersey-dev


Back to the top