Grails bean factory + method with parameters
Posted by admin - 20/10/11 at 11:10:14 pmclass MyObjectFactory { static final int TYPE_ONE = 1 static final int TYPE_TWO = 2 def produce(int type){ if (type == TYPE_ONE){ return ... // type one } if (type == TYPE_TWO){ return ... // type two } throw new IllegalArgumentException() } } ... beans { myObjectFactoryBean(MyObjectFactory) myObjectBean(myObjectFactoryBean:'produce'){bean-> bean.constructorArgs = [MyObjectFactory.TYPE_ONE ] } }
October 20, 2011 | In Grails | No Comments
No Comments yet »
RSS feed for comments on this post.
Leave a comment
Powered by WordPress with GimpStyle Theme design by Horacio Bella.
Entries and comments feeds.
Valid XHTML and CSS.