1

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.

2 Answers 2

5

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:

  • mailerService - plain groovy/grails service, that sends mail
  • legacyCode - bean from legacy java code, configured as bean at 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

Sign up to request clarification or add additional context in comments.

Comments

0

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.