chabapok
chabapok

Reputation: 952

How to invoke bean method from spring groovy-based configuration file?

How to invoke method from spring configuration groovy-based file? I know about MethodInvokingFactoryBean, but i want more simple way.

My bean:

public class Foo{
    public void func(String prm1, int prm2){
       System.out.println("Func called with "+prm1+","+prm2);
    }
}

My beans.groovy:

beans {
    myCoolBean(Foo){
        //how to invoke func method?
        func('a', 5) //not working
    }
}

Upvotes: 2

Views: 416

Answers (1)

Andrew Inzer
Andrew Inzer

Reputation: 48

You can do this:

beans {
    myCoolBean(Foo)
    myCoolBeanCall(myCoolBean: 'func', 'a', 5)
}

Upvotes: 1

Related Questions