Reputation: 12528
First of all, is this possible?
Why, I am integrating some legacy java code into Grails and would like to use a grails mail plugin. The code sending the email is inside a java class. I don't to rename the file to .groovy since there are several hundred java files.
If this is possible, kindly post a sample code.
Thanks.
Upvotes: 1
Views: 1723
Reputation: 35951
Yes, you can. All Grails service/controllers/etc is a Spring beans. And you can configure it to pass mailer bean into any other bean. For example you can create 2 beans:
grails-app/conf/spring/resources.xml
. And after that you can use this bean from any other controller, service, etc.You can put your Java code into src/java
, or containing jar into lib
See http://www.grails.org/doc/1.3.x/guide/14.%20Grails%20and%20Spring.html for more information
Upvotes: 5
Reputation: 547
You can call any java code from groovy. Either put the class in src/java or add a jar containing the code to your classpath.
Upvotes: 0