Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [osgi-users] JAX-RS Whiteboard question

JAX-RS natively expects to re-create resources on every request, so unless you know very well the behaviour and have _no_ context (i.e. request, session) based injections into your resources _only_ then can you avoid PROTOTYPE scope.

- Ray

On Thu, Jan 7, 2021 at 4:50 AM Fauth Dirk (XC-ECO/ESM1) <Dirk.Fauth@xxxxxxxxxxxx> wrote:

Hi all,

 

New year -> new mailing list -> new question. 😊

 

I wish everyone on this mailing list a happy and healthy new year!

 

I’m currently writing the blog post about JAX-RS Whiteboard as promised last year. There is one question that came up where I am not sure about the answer. In the specification all JAX-RS Whiteboard Resource examples are configured with PROTOTYPE scope. In chapter 151.4.2 JAX-RS Whiteboard Resource Lifecycle it is explained that stateless services can also be registered as singletons (which is more common in OSGi). If the JAX-RS Whiteboard Resource service has a state (e.g. a JAX-RS context value in a field) it should be PROTOTYPE scope to get a new instance for each request.

 

All examples in the specification are stateless, so my question is, is there a reason/best practice to create all JAX-RS Whiteboard Resource services with PROTOTYPE scope?

 

Mit freundlichen Grüßen / Best regards

Dirk Fauth


Cross-Domain Computing Solutions, Cross Automotive Platforms - System, Software and Tools Engineering Engineering Software Methods and Tools1 (XC-ECO/ESM1)
Robert Bosch GmbH | Postfach 30 02 40 | 70442 Stuttgart | GERMANY |
www.bosch.com
Tel.
+49 711 811-57819 | Telefax +49 711 811 | Dirk.Fauth@xxxxxxxxxxxx

Sitz: Stuttgart, Registergericht: Amtsgericht Stuttgart, HRB 14000;
Aufsichtsratsvorsitzender: Franz Fehrenbach; Geschäftsführung: Dr. Volkmar Denner,
Prof. Dr. Stefan Asenkerschbaumer, Filiz Albrecht, Dr. Michael Bolle, Dr. Christian Fischer,
Dr. Stefan Hartung, Dr. Markus Heyn, Harald Kröger, Rolf Najork, Uwe Raschke

_______________________________________________
osgi-users mailing list
osgi-users@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/osgi-users


--
Raymond Augé (@rotty3000)
Senior Software Architect Liferay, Inc. (@Liferay)
OSGi Fellow

Back to the top