Hi

Its likely because he creates the instance himself using the new
constructor. That does not do any IoC

def GroovyProc4 mybean = new GroovyProc4()

You would need to do the IoC yourself or let Camel create it using its injector

def GroovyProc4 mybean =
camelContext.getInjector().newInstance(GroovyProc4.class);



On Tue, May 5, 2015 at 4:34 PM, Henryk Konsek <hekon...@gmail.com> wrote:
> Hi,
>
> This is Spring? Can you send us the Maven example reproducing the issue?
>
> Cheers!
>
> wt., 5.05.2015 o 15:01 użytkownik bocamel <johnz...@gmail.com> napisał:
>
>> Because groovy script called by Camel cannot be debugged under IDE, I
>> created
>> my script as a hybrid so I can easily switch it between the bean mode and
>> script mode:
>> //==================
>> class GroovyProc4 {
>>         @BeanInject('myConfig')
>>         MyConfig myConfig
>>
>>         public void process(Exchange exchange) {
>>                 println(myConfig?.name)
>>         }
>> }
>>
>> def GroovyProc4 mybean = new GroovyProc4()
>> //mybean.myConfig = MyConfig.getInstanceFromRegistry(exchange.context,
>> "myConfig")
>> mybean.process(exchange)
>> //==================
>>
>> In the following route, I can choose to run the above processor as a script
>> or bean.
>>     <camel:route autoStartup="true">
>>         <camel:from uri="timer://test?period=10s"/>
>>          <camel:to uri="bean:groovyProc4" />
>>
>>     </camel:route>
>>
>> But when I ran it as a script, the @BeanInject in the class was ignored and
>> I would have to explicitly initialize the member property myConfig by
>> retrieving the value from Registry (in the commented out statement in the
>> script above).  Is this the expected behavior?   Thanks for any help!
>>
>>
>>
>>
>> --
>> View this message in context:
>> http://camel.465427.n5.nabble.com/BeanInject-ignored-in-Groovy-when-called-as-a-script-tp5766708.html
>> Sent from the Camel - Users mailing list archive at Nabble.com.
>>



-- 
Claus Ibsen
-----------------
Red Hat, Inc.
Email: cib...@redhat.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen
hawtio: http://hawt.io/
fabric8: http://fabric8.io/

Reply via email to