You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Bernard Ligny <be...@gmail.com> on 2017/03/29 13:58:44 UTC

Why do we have we to specify a context for @PropertyInject ?

I am using Camel-CDI features in a war with multiple camel contexts
(initialised via a factory), all of them sharing the same set of Camel
components (initialised via a factory):


In a route being part of a particular context, I want to inject properties
(coming from my property file):


This is working fine...as soon as i specify a context on the
@PropertyInject.
I do not understand why the context addition is necessary as:
- the context is already set on the route builder 
- my properties component is shared across all contexts (cfr
@ApplicationScoped) 





--
View this message in context: http://camel.465427.n5.nabble.com/Why-do-we-have-we-to-specify-a-context-for-PropertyInject-tp5796699.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Why do we have we to specify a context for @PropertyInject ?

Posted by Antonin Stefanutti <an...@stefanutti.fr>.
Hi Bernard,

Specifying the context attribute for @PropertyInject is currently necessary when dealing with multiple Camel contexts so that the bean post processing can resolve the Camel context to use. If it is not specified, then the default (following CDI semantic, that is with the @Default qualifier) Camel context is resolved.

There is no further logic nor convention beyond that context attribute. I guess this is the way other DI frameworks handle bean post processing as well to support Camel annotations (which all have that context attribute).

That being said, we could add more sensible convention to the default behaviour, like when processing beans of type CamelContextAware, or BuilderSupport in you case, for which a Camel context may have been set already.

I would suggest you create a ticket in JIRA to track that enhancement.

Antonin

> On 29 Mar 2017, at 15:58, Bernard Ligny <be...@gmail.com> wrote:
> 
> I am using Camel-CDI features in a war with multiple camel contexts
> (initialised via a factory), all of them sharing the same set of Camel
> components (initialised via a factory):
> 
> 
> In a route being part of a particular context, I want to inject properties
> (coming from my property file):
> 
> 
> This is working fine...as soon as i specify a context on the
> @PropertyInject.
> I do not understand why the context addition is necessary as:
> - the context is already set on the route builder 
> - my properties component is shared across all contexts (cfr
> @ApplicationScoped) 
> 
> 
> 
> 
> 
> --
> View this message in context: http://camel.465427.n5.nabble.com/Why-do-we-have-we-to-specify-a-context-for-PropertyInject-tp5796699.html
> Sent from the Camel - Users mailing list archive at Nabble.com.


Re: Why do we have to specify a context for @PropertyInject ?

Posted by Antonin Stefanutti <an...@stefanutti.fr>.
Thanks for the detailed report. That makes sense to contextualize the default context based on @ContextName.

Antonin

> On 30 Mar 2017, at 18:27, Bernard Ligny <be...@gmail.com> wrote:
> 
> Improvement issue created:
> https://issues.apache.org/jira/browse/CAMEL-11097
> 
> 
> 
> --
> View this message in context: http://camel.465427.n5.nabble.com/Why-do-we-have-to-specify-a-context-for-PropertyInject-tp5796699p5796750.html
> Sent from the Camel - Users mailing list archive at Nabble.com.


Re: Why do we have to specify a context for @PropertyInject ?

Posted by Bernard Ligny <be...@gmail.com>.
Improvement issue created:
https://issues.apache.org/jira/browse/CAMEL-11097



--
View this message in context: http://camel.465427.n5.nabble.com/Why-do-we-have-to-specify-a-context-for-PropertyInject-tp5796699p5796750.html
Sent from the Camel - Users mailing list archive at Nabble.com.