Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [jaxrs-dev] Clarification regarding Application subclass instantiation

 

The JAX-RS 2.1 specification does not mandate that custom Application classes must be CDI-instantiable, which is a prerequisite for what you ask for.

>Actually, doesn't section 11.2.3 explicitly mandate this?  That an Application subclass must either be a singleton or in application scope?

 

11.2.3 is only effective IF the application author actively decides to support CDI. It does NOT that custom application MUST be CDI compliant at all. This section only lists forces that become effective once the application programmer WANTS CDI and the JAX-RS engine SUPPORTS CDI.

 

>Let's just talk about application scope: If my Application subclass is declared like this:

>@ApplicationScoped

>public MyApp extends Application { }

>…CDI is quite clear about what that means (without any reference to JAX-RS), and one of those things is that I must be able to do (for example):

>final Bean<?> applicationBean = >beanManager.resolve(beanManager.getBeans(Application.class));

>final Application app = beanManager.getReference(applicationBean, Application.class, >beanManager.createCreationalContext(applicationBean));

>In the interest of clarity, are you saying that section 11.2.3 says something different?

 

You mix up things. JAX-RS and CDI have been developed concurrently and are not 100% compatible as of now (that's why we want to change it starting with JAX-RS 2.3). The only thing you can rely on is the written, literal text of the JAX-RS specification as-is. You must not imply anything from another spec, in particular from CDI, as it might not work within a JAX-RS engine.

This is currently up to the application author to decide.

>Could you point to the specification language that I've missed that says that?  I'd like to learn more how section 11.2.3 doesn't cover this.

 

Read again the introduction to chaper 11.2. It literally says that that chapter adds requirements to the JAX-RS IMPLEMENTATION (i. e. the JAX-RS ENGINE). This implies that no application programmer is forced to use CDI. This implies that it is up to the application programmer to decide whether to even read sub-chapter 11.2.3.

 

Best,

Laird


Back to the top