juneau-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Girish Vasmatkar <girish.vasmat...@hotwaxsystems.com>
Subject Re: Adding Resources Programmatically (No Annotations)
Date Fri, 05 Jun 2020 13:20:18 GMT
Hi James -

Thanks for the reply. Yes, I did look at the child and children methods.
What I am trying to figure out is if there is a generic way of defining
multiple children virtually (with different resource paths) and yet all the
requests be handled by a single class. Our project as a well defined
service oriented architecture defined.

POST /api/supplier/
GET /api/supplier/{id}
GET /api/supplier/{id}/contacts/{contactId}

I have above scenario in my mind where I already have various services
written (or can be written) to respond to the above three example resource
paths. I need to be able to dynamically add such resource paths (probably
picking from an XML API file) and then have a single generic child (one new
instance per request) that can cater to all such requests and decide
appropriately at the runtime (based on instance variable) which service to
call and return the response.

I am sorry if I am too verbose but this is the architecture I have in my
mind for our REST implementation and we want to use Juneau. Is there any
example of such programmatic resource creation?

Best Regards,

On Tue, Jun 2, 2020 at 5:58 PM James Bognar <jamesbognar@gmail.com> wrote:

> Hi Girish,
> The RestContextBuilder class can be accessed via a lifecycle hook:
> http://juneau.apache.org/site/apidocs-8.1.3/overview-summary.html#juneau-rest-server.Instantiation.LifecycleHooks
> From there you can add it via either the child() or children() methods:
> http://juneau.apache.org/site/apidocs-8.1.3/org/apache/juneau/rest/RestContextBuilder.html#child-java.lang.String-java.lang.Object-
> On Mon, Jun 1, 2020 at 3:37 PM Girish Vasmatkar
> <girish.vasmatkar@hotwaxsystems.com> wrote:
> >
> > Hi All,
> >
> > I am evaluating Juneau as one of the possible REST implementations.
> While I am able to define resources using @Rest annotation, I am looking
> for something that enables me to add new resources
> dynamically/programmatically.
> >
> > For example, the @Rest annotation defines children property that I will
> not be knowing until runtime. I am trying to have an XML configuration file
> containing all resources and methods details and I would like to consume
> that XML at boot up time and have Juneau configure these resources
> programmatically.
> >
> > I looked at RestContextBuilder but could not find how I can use it to
> register resources and methods dynamically.
> >
> > Best Regards,
> > Girish

View raw message