juneau-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From James Bognar <jamesbog...@apache.org>
Subject Re: Juneau + Springboot
Date Wed, 21 Nov 2018 16:58:02 GMT
I've added the following two methods to RestServlet:

   - setRestResourceResolver(RestResourceResolver)
   - getPath()

Now you can instantiate any subclass of RestServlet with the following code:

   @Bean
   public RootResources root(RestResourceResolver resolver) {
      return (RootResources)new
RootResources().setRestResourceResolver(resolver);
   }

   @Bean
   public ServletRegistrationBean<RootResources>
rootRegistration(RootResources root) {
      return new ServletRegistrationBean<>(root, CONTEXT_ROOT,
CONTEXT_ROOT+"/", CONTEXT_ROOT+"/"+root.getPath());
   }

On Wed, Nov 21, 2018 at 11:07 AM James Bognar <jamesbognar@apache.org>
wrote:

> Awesome work.
>
> I have some thoughts.
>
> In *@EnabledJuneauIntegration*, you define your root resource as:
>    *Class<? extends BasicRestServletJenaGroup> rootResources();*
> There's no reason why the root has to be a group.  It only needs to be
> anything that extends from *RestServlet*.  The groups are just
> specialized subclasses of a *RestServlet* that by default render a list
> of links to child resources defined via *@RestServlet(children)*.  See
> *BasicRestServletGroup* for what I mean.
> I suggest the following instead:
>   *Class<? extends RestServlet> resourceClass();*
>
> Perhaps you could add *@EnabledJuneauIntegration(path="...") *to identify
> the servlet path so that you can identify multiple resources?  And if not
> specified, you can default to *@RestResource(path)*?
>
> This code assumes your class will have a constructor that takes in a
> *RestResourceResolver*:
> loadConfig.rootResources().getDeclaredConstructor(RestResourceResolver.
> class).newInstance(resolver);
> This isn't likely to be true.  Most of the time there will only be a
> no-arg constructor (per servlet spec).
> I can add a *setRestResourceResolver(...)* method to the *RestServlet*
> class that can be called immediately following construction.  It should
> simplify this case.
> loadConfig.rootResources().
> newInstance().setRestResourceResolver(resolver);
> It will also eliminate the need to define a RestHook to register the
> resolver.
>
> On a side note, I may want to use the resolver to instantiate any of the
> types you can define on the *@RestResource* class (e.g. *@RestResource(callHandler,
> classpathResourceFinder, guards, ...)*) so that any of these can use
> injection.
>
> What currently isn't in place is console support.  i.e. what shows up on
> the command line when executing your jar file:
>    Running class 'RestMicroservice' using config file
> 'my-microservice.cfg'.
>    Server started on port 10000
>    List of available commands:
>       exit -- Shut down service
>       restart -- Restarts service
>       help -- Commands help
>    >
> You could get this essentially for free by subclassing and instantiating
> an instance of the *Microservice* class (e.g. *SpringBootMicroservice*).
> The *RestMicroservice* class extends this base class and adds Jetty
> support.  You could use it as an example of how to subclass this class and
> start/stop it.
>
> I think that's it for now.  Exciting stuff!
>
> On Tue, Nov 20, 2018 at 8:25 PM Marcelo Souza Vieira <
> marcelosouzav@gmail.com> wrote:
>
>> Hello guys.
>>
>> I am doing some tests to be able to work along with spring-boot.
>> I made some changes in the structure, I hope you are walking as you like.
>> One of the great features of spring-boot is to be very simple, with very
>> little code, so you can upload a server.
>> Thinking about this, I created the project "
>> *juneau-microservice-server-springboot*".
>> In it will stay the entire integration configuration, avoiding whoever is
>> doing the integration, need to make the settings manually.
>> I created the "*EnabledJuneauIntegration*" annotation to enable and
>> start the settings.
>>
>> I changed the project "*juneau-examples-rest-springboot*" to use this
>> new project.
>> So when someone else does the integration, just add the annotation in
>> this way.
>>
>> *@EnabledJuneauIntegration (rootResources = RootResources.class)*
>>
>> That all settings will work.
>>
>> I was able to go up and call an Juneau endpoint. You're giving me some
>> trouble, but I still see it.
>>
>> I'm taking a while, because I know little Juneau yet, so some
>> configuration mistakes, it takes a while to find.
>>
>> It turned out that my branch is getting big, because as I am testing
>> things, to see if everything is going to turn out, it will end up getting
>> big.
>> But I'm keeping the branch updated with the master in Juneau.
>>
>> If you want to take a look, it's on the link.
>>
>> *https://github.com/marcelosv/juneau/tree/dev-marcelo-v-spring
>> <https://github.com/marcelosv/juneau/tree/dev-marcelo-v-spring>*
>>
>> Marcelo Vieira
>>
>>

Mime
View raw message