I have integrated groovy in my application using spring. My context looks like:
<lang:groovy id="myConfiguration"
script-source="classpath:MyGroovy.groovy"
refresh-check-delay="1000"/>
MyGroovy is an implementation of MyInterface. I was wondering how can I add more files in my classpath (also implementing the same interface) and to have more beans like the one above dynamically?
I would like to get something like:
<lang:groovy id="myConfiguration"
script-source="classpath:*.groovy"
refresh-check-delay="1000"/>
And later be able to use a list of implementations of MyInterface and sent it to another bean where I can go through the list and do stuff. My bean would like like:
<bean id="myProcessor"
class="com.package.processor.MyProcessor">
<constructor-arg>
<list value-type="com.package.processor.MyInterface">
<bean class="MyGroovy1"/>
<bean class="MyGroovy2"/>
<bean class="MyGroovy3"/>
</list>
</constructor-arg>
</bean>
Is this possible at all? I have just changed the first part and I already get Exceptions and haven't found in the documentation anything related to this topic.
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'myProcessor': Could not determine scripted object type for GroovyScriptFactory: script source locator [classpath:.groovy]; nested exception is java.io.FileNotFoundException: class path resource [.groovy] cannot be opened because it does not exist