Browse files

Renamed plugin

  • Loading branch information...
1 parent 4787a72 commit 0496cf6c48086680e0681554450e3e9b5b1f6685 @deigote deigote committed Nov 30, 2012
View
71 GrailsSimplexMailPluginGrailsPlugin.groovy
@@ -1,71 +0,0 @@
-class GrailsSimplexMailPluginGrailsPlugin {
- // the plugin version
- def version = "0.1"
- // the version or versions of Grails the plugin is designed for
- def grailsVersion = "2.1 > *"
- // the other plugins this plugin depends on
- def dependsOn = [:]
- // resources that are excluded from plugin packaging
- def pluginExcludes = [
- "grails-app/views/error.gsp"
- ]
-
- // TODO Fill in these fields
- def title = "Grails Simplex Mail Plugin Plugin" // Headline display name of the plugin
- def author = "Your name"
- def authorEmail = ""
- def description = '''\
-Brief summary/description of the plugin.
-'''
-
- // URL to the plugin's documentation
- def documentation = "http://grails.org/plugin/grails-simplex-mail-plugin"
-
- // Extra (optional) plugin metadata
-
- // License: one of 'APACHE', 'GPL2', 'GPL3'
-// def license = "APACHE"
-
- // Details of company behind the plugin (if there is one)
-// def organization = [ name: "My Company", url: "http://www.my-company.com/" ]
-
- // Any additional developers beyond the author specified above.
-// def developers = [ [ name: "Joe Bloggs", email: "joe@bloggs.net" ]]
-
- // Location of the plugin's issue tracker.
-// def issueManagement = [ system: "JIRA", url: "http://jira.grails.org/browse/GPMYPLUGIN" ]
-
- // Online location of the plugin's browseable source code.
-// def scm = [ url: "http://svn.codehaus.org/grails-plugins/" ]
-
- def doWithWebDescriptor = { xml ->
- // TODO Implement additions to web.xml (optional), this event occurs before
- }
-
- def doWithSpring = {
- // TODO Implement runtime spring config (optional)
- }
-
- def doWithDynamicMethods = { ctx ->
- // TODO Implement registering dynamic methods to classes (optional)
- }
-
- def doWithApplicationContext = { applicationContext ->
- // TODO Implement post initialization spring config (optional)
- }
-
- def onChange = { event ->
- // TODO Implement code that is executed when any artefact that this plugin is
- // watching is modified and reloaded. The event contains: event.source,
- // event.application, event.manager, event.ctx, and event.plugin.
- }
-
- def onConfigChange = { event ->
- // TODO Implement code that is executed when the project configuration changes.
- // The event is the same as for 'onChange'.
- }
-
- def onShutdown = { event ->
- // TODO Implement code that is executed when the application shuts down (optional)
- }
-}
View
8 application.properties
@@ -1,9 +1,9 @@
#Grails Metadata file
-#Fri Oct 05 12:29:14 CEST 2012
+#Fri Nov 30 14:02:21 CET 2012
app.grails.version=2.1.1
-app.name=grails-simplex-mail-plugin
-plugins.asynchronous-mail=0.6
+app.name=simplex-mail
+plugins.asynchronous-mail=0.7
plugins.console=1.2
plugins.hibernate=2.1.1
-plugins.mail=1.0
+plugins.mail=1.0.1
plugins.quartz2=0.2.3
View
3 grails-app/conf/Config.groovy
@@ -22,3 +22,6 @@ log4j = {
warn 'org.mortbay.log'
}
+
+
+simplex.mail.config.files.paths = 'grails-app/conf/MailConfig.groovy'
View
89 grails-app/services/es/osoco/simplexmail/SimplexMailService.groovy
@@ -1,17 +1,36 @@
package es.osoco.simplexmail
-
-import java.util.Map;
+import org.codehaus.groovy.control.CompilerConfiguration
+import static es.osoco.simplexmail.MailPropertyType.*
class SimplexMailService {
def transactional = false
- def asynchronousMailService
+ def asynchronousMailService
+ def grailsApplication
- private sendEmail(toEmail, fromEmail, ccEmails, bccEmails, replyToEmail, emailSubject,
- emailBody, attachments) {
+ public loadMailConfig() {
+ println grailsApplication
+ println getResourceByPath(grailsApplication.config.simplex.mail.config.files.paths)
+
+ [grailsApplication.config.simplex.mail.config.files.paths].flatten().each { configFilePath ->
+ injectMailSendingMethods(
+ postProcessMailConfig(
+ buildGroovyShell().evaluate(getResourceByPath(configFilePath)?.text)
+ )
+ )
+ }
+ }
+
+ public sendEmail(emailProperties) {
+ println "INVOKED $emailProperties"
+ /*
+ asynchronousMailService.sendAsynchronousMail {
+ emailProperties.each { type, values -> with(types.configure(values) }
+ }*//*
asynchronousMailService.sendAsynchronousMail {
to toEmail
from fromEmail
+ cc ccEmails
bcc bccEmails
replyTo replyToEmail
subject emailSubject
@@ -20,6 +39,66 @@ class SimplexMailService {
attachment ->
attachBytes attachment.name, attachment.mimeType, attachment.content
}
+ }*/
+ }
+
+ private buildGroovyShell() {
+ new GroovyShell(
+ this.class.classLoader, new Binding(grailsApplication.config.toProperties()),
+ new CompilerConfiguration().with { compilerConfig ->
+ scriptBaseClass = SimplexMailBaseScript.class.name
+ compilerConfig
+ }
+ )
+ }
+
+ private injectMailSendingMethods(mailConfig) {
+ mailConfig.each { mail, props ->
+ this.metaClass."send${mail.capitalize()}" = { Map overwrittenProps = [:] ->
+ def effectiveProps = props + overwrittenProps
+ println "Sending email $mail with props $effectiveProps"
+ sendEmail(effectiveProps)
+ }
+ }
+ }
+
+ private getResourceByPath(path)
+ {
+ new File(new grails.util.BuildSettings().baseDir.path + "/" + path)
+ }
+
+ private postProcessMailConfig(mailConfig)
+ {
+ resolveAttachments(resolveInherits(mailConfig))
+ }
+
+ private resolveAttachments(mailConfig)
+ {
+ mailConfig.each { mailName, mailProps ->
+ mailProps[ATTACHMENTS] = mailProps[ATTACHMENTS]?.collect { getResourceByPath(it) }
+ }
+ mailConfig
+ }
+
+ private resolveInherits(mailConfig)
+ {
+ def resolve = { mailProps, stack ->
+ def inherits = mailProps.remove(INHERITS)?.getAt(0)
+ if (inherits)
+ {
+ if (inherits in stack) {
+ throw new CircularInheritanceException(stack)
+ }
+ else {
+ mailProps << call(mailConfig[inherits], stack << inherits)
+ }
+ }
+ else
+ {
+ mailProps
+ }
}
+ mailConfig.each { mailName, mailProps -> resolve(mailProps, [mailName]) }
+ mailConfig
}
}
View
BIN target/classes/BuildConfig.class
Binary file not shown.
View
BIN target/classes/Config.class
Binary file not shown.
View
BIN target/classes/DataSource.class
Binary file not shown.
View
BIN target/classes/GrailsSimplexMailPluginGrailsPlugin$_closure1.class
Binary file not shown.
View
BIN target/classes/GrailsSimplexMailPluginGrailsPlugin$_closure2.class
Binary file not shown.
View
BIN target/classes/GrailsSimplexMailPluginGrailsPlugin$_closure3.class
Binary file not shown.
View
BIN target/classes/GrailsSimplexMailPluginGrailsPlugin$_closure4.class
Binary file not shown.
View
BIN target/classes/GrailsSimplexMailPluginGrailsPlugin$_closure5.class
Binary file not shown.
View
BIN target/classes/GrailsSimplexMailPluginGrailsPlugin$_closure6.class
Binary file not shown.
View
BIN target/classes/GrailsSimplexMailPluginGrailsPlugin$_closure7.class
Binary file not shown.
View
BIN target/classes/GrailsSimplexMailPluginGrailsPlugin.class
Binary file not shown.
View
BIN target/classes/UrlMappings.class
Binary file not shown.
View
8 target/classes/application.properties
@@ -1,9 +1,9 @@
#Grails Metadata file
-#Fri Oct 05 12:29:14 CEST 2012
+#Fri Nov 30 14:02:21 CET 2012
app.grails.version=2.1.1
-app.name=grails-simplex-mail-plugin
-plugins.asynchronous-mail=0.6
+app.name=simplex-mail
+plugins.asynchronous-mail=0.7
plugins.console=1.2
plugins.hibernate=2.1.1
-plugins.mail=1.0
+plugins.mail=1.0.1
plugins.quartz2=0.2.3
View
BIN target/classes/es/osoco/simplexmail/SimplexMailService$_sendEmail_closure1.class
Binary file not shown.
View
BIN target/classes/es/osoco/simplexmail/SimplexMailService$_sendEmail_closure1_closure2.class
Binary file not shown.
View
BIN target/classes/es/osoco/simplexmail/SimplexMailService.class
Binary file not shown.
View
BIN target/classes/es/osoco/simplexmail/SimplexMailSlurperService.class
Binary file not shown.
View
5,930 target/stacktrace.log
9 additions, 5,921 deletions not shown because the diff is too large. Please use a local Git client to view these changes.
View
4 test/unit/es/osoco/simplexmail/SimplexMailServiceTests.groovy
@@ -1,7 +1,5 @@
package es.osoco.simplexmail
-
-
import grails.test.mixin.*
import org.junit.*
@@ -11,6 +9,8 @@ import org.junit.*
@TestFor(SimplexMailService)
class SimplexMailServiceTests {
+
+
void testSomething() {
fail "Implement me"
}

0 comments on commit 0496cf6

Please sign in to comment.