You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by souciance <so...@gmail.com> on 2016/08/11 13:21:04 UTC

PropertyInject in a standard class

Hello,

Does Camel's @PropertyInject annotation work in a standard java class? Say,
you want to define a utility class and you define some private variables and
use that annotation to inject some environment variables using
@PropertyInject("{{env:hostname}}"). Then you have some method as a public
interface in order to refer to them from outside the class. 

So far I only get null values. 

If I do the some injection from inside a RouteBuilder class it works.

Best
Souciance



--
View this message in context: http://camel.465427.n5.nabble.com/PropertyInject-in-a-standard-class-tp5786317.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: PropertyInject in a standard class

Posted by Claus Ibsen <cl...@gmail.com>.
The class/bean has to be created from the IoC framework you use such
as spring / cdi / guice / etc. Or standalone Camel.
If you create it manually using new XXX then there is no dependency injection.

On Thu, Aug 11, 2016 at 3:21 PM, souciance
<so...@gmail.com> wrote:
> Hello,
>
> Does Camel's @PropertyInject annotation work in a standard java class? Say,
> you want to define a utility class and you define some private variables and
> use that annotation to inject some environment variables using
> @PropertyInject("{{env:hostname}}"). Then you have some method as a public
> interface in order to refer to them from outside the class.
>
> So far I only get null values.
>
> If I do the some injection from inside a RouteBuilder class it works.
>
> Best
> Souciance
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/PropertyInject-in-a-standard-class-tp5786317.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-----------------
http://davsclaus.com @davsclaus
Camel in Action 2: https://www.manning.com/ibsen2