You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@openwebbeans.apache.org by Helge Waastad <he...@waastad.org> on 2018/03/23 11:31:55 UTC
Meecrowave and singletons
Hi,
Just trying to figure out a couple of things with meecrowave.
ex:
rootresource has:
@Override
public Set<Object> getSingletons() {
return Stream.of(new UserService()).collect(Collectors.toSet());
}
@Path("users")
public class UserService {
@GET
public Response get() {
....return somthing..
}
}
in tomee 7 it will contruct the UserService once.
In meecrowave twice...
/hw
--
Helge Waastad
- The Undelstad Cup Champion 2017
Re: Meecrowave and singletons
Posted by Helge Waastad <he...@waastad.org>.
Hi,so I read the "Custom Configuration" in cxf/cdi1.1 and rather
inject UserService (dependent) into getSingletons, I guess is what's
needed.
/hw
fr., 23.03.2018 kl. 14.35 +0100, skrev Romain Manni-Bucau:
> Hi,
> yes in org.apache.cxf.cdi.JAXRSCdiResourceExtension#load
> and org.apache.cxf.jaxrs.utils.ResourceUtils#createApplication. You
> should probably always return the same instance of singletons since
> getSingletons/getClasses *can* be called N times.
>
> Romain Manni-Bucau
> @rmannibucau | Blog | Old Blog | Github | LinkedIn | Book
>
> 2018-03-23 12:31 GMT+01:00 Helge Waastad <he...@waastad.org>:
> > Hi,
> > Just trying to figure out a couple of things with meecrowave.
> >
> > ex:
> > rootresource has:
> > @Override
> > public Set<Object> getSingletons() {
> > return Stream.of(new
> > UserService()).collect(Collectors.toSet());
> > }
> >
> > @Path("users")
> > public class UserService {
> > @GET
> > public Response get() {
> > ....return somthing..
> > }
> > }
> >
> > in tomee 7 it will contruct the UserService once.
> > In meecrowave twice...
> >
> > /hw
> >
> > --
> > Helge Waastad
> > - The Undelstad Cup Champion 2017
--
Helge Waastad
- The Undelstad Cup Champion 2017
Re: Meecrowave and singletons
Posted by "John D. Ament" <jo...@apache.org>.
So the idea here would be to not look up a CDI bean for a resource if its
declared in the singletons? That would be a pretty straight forward change
in CXF.
John
On Fri, Mar 23, 2018 at 9:35 AM Romain Manni-Bucau <rm...@gmail.com>
wrote:
> Hi,
>
> yes in org.apache.cxf.cdi.JAXRSCdiResourceExtension#load
> and org.apache.cxf.jaxrs.utils.ResourceUtils#createApplication. You should
> probably always return the same instance of singletons since
> getSingletons/getClasses *can* be called N times.
>
>
> Romain Manni-Bucau
> @rmannibucau <https://twitter.com/rmannibucau> | Blog
> <https://rmannibucau.metawerx.net/> | Old Blog
> <http://rmannibucau.wordpress.com> | Github
> <https://github.com/rmannibucau> | LinkedIn
> <https://www.linkedin.com/in/rmannibucau> | Book
> <https://www.packtpub.com/application-development/java-ee-8-high-performance>
>
> 2018-03-23 12:31 GMT+01:00 Helge Waastad <he...@waastad.org>:
>
>> Hi,
>> Just trying to figure out a couple of things with meecrowave.
>>
>> ex:
>> rootresource has:
>> @Override
>> public Set<Object> getSingletons() {
>> return Stream.of(new UserService()).collect(Collectors.toSet());
>> }
>>
>> @Path("users")
>> public class UserService {
>> @GET
>> public Response get() {
>> ....return somthing..
>> }
>> }
>>
>> in tomee 7 it will contruct the UserService once.
>> In meecrowave twice...
>>
>> /hw
>>
>> --
>>
>> Helge Waastad
>> - The Undelstad Cup Champion 2017
>>
>
>
Re: Meecrowave and singletons
Posted by Romain Manni-Bucau <rm...@gmail.com>.
Hi,
yes in org.apache.cxf.cdi.JAXRSCdiResourceExtension#load
and org.apache.cxf.jaxrs.utils.ResourceUtils#createApplication. You should
probably always return the same instance of singletons since
getSingletons/getClasses *can* be called N times.
Romain Manni-Bucau
@rmannibucau <https://twitter.com/rmannibucau> | Blog
<https://rmannibucau.metawerx.net/> | Old Blog
<http://rmannibucau.wordpress.com> | Github <https://github.com/rmannibucau> |
LinkedIn <https://www.linkedin.com/in/rmannibucau> | Book
<https://www.packtpub.com/application-development/java-ee-8-high-performance>
2018-03-23 12:31 GMT+01:00 Helge Waastad <he...@waastad.org>:
> Hi,
> Just trying to figure out a couple of things with meecrowave.
>
> ex:
> rootresource has:
> @Override
> public Set<Object> getSingletons() {
> return Stream.of(new UserService()).collect(Collectors.toSet());
> }
>
> @Path("users")
> public class UserService {
> @GET
> public Response get() {
> ....return somthing..
> }
> }
>
> in tomee 7 it will contruct the UserService once.
> In meecrowave twice...
>
> /hw
>
> --
>
> Helge Waastad
> - The Undelstad Cup Champion 2017
>