Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

fixes for GPPLATFORMCORE-30 , GPPLATFORMCORE-34, github/5

  • Loading branch information...
commit b019a5e784635f72f4d8ffb238e4deb88c597b69 1 parent d8a94f9
@smaldini smaldini authored
View
2  PlatformCoreGrailsPlugin.groovy
@@ -24,7 +24,7 @@ import org.grails.plugin.platform.events.registry.DefaultEventsRegistry
class PlatformCoreGrailsPlugin {
// the plugin version
- def version = "1.0.RC3"
+ def version = "1.0.RC4"
// the version or versions of Grails the plugin is designed for
def grailsVersion = "1.3 > *"
View
2  application.properties
@@ -1,5 +1,5 @@
#Grails Metadata file
-#Mon Jan 14 12:18:49 GMT 2013
+#Tue Jan 15 17:19:01 GMT 2013
app.grails.version=2.2.0
app.name=PlatformCore
plugins.rest-client-builder=1.0.2
View
3  grails-app/conf/BuildConfig.groovy
@@ -49,7 +49,8 @@ grails.project.dependency.resolution = {
}
test(":spock:0.7") {
- exclude "spock-grails-support"
+ //exclude "spock-grails-support"
+ export = false
}
}
}
View
6 grails-app/conf/TestEvents.groovy
@@ -18,6 +18,8 @@
//import org.grails.plugin.platform.test.Book
events = {
- //sampleHello namespace:'lal', onReply: { println 'joy' }
- beforeInsert
+
+ sampleHello namespace:'platformCore', filter:{
+ true
+ }
}
View
6 src/groovy/org/grails/plugin/platform/conventions/DSLEvaluator.groovy
@@ -26,10 +26,8 @@ class DSLEvaluator {
final log = LoggerFactory.getLogger(DSLEvaluator)
- def grailsApplication
-
- List<DSLCommand> evaluate(Closure c) {
- def builder = new StandardDSLBuilder()
+ List<DSLCommand> evaluate(Closure c, grailsApplication = null) {
+ def builder = new StandardDSLBuilder(grailsApplication: grailsApplication)
builder.build(c)
}
}
View
24 src/groovy/org/grails/plugin/platform/conventions/DSLGetValueCommand.groovy
@@ -0,0 +1,24 @@
+/* Copyright 2011-2012 the original author or authors:
+ *
+ * Marc Palmer (marc@grailsrocks.com)
+ * Stéphane Maldini (smaldini@vmware.com)
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.grails.plugin.platform.conventions
+
+/**
+ * Encapsulate a DSL command that sets a property value
+ */
+class DSLGetValueCommand extends DSLCommand {
+}
View
3  src/groovy/org/grails/plugin/platform/conventions/StandardDSLBuilder.groovy
@@ -33,10 +33,11 @@ import org.slf4j.LoggerFactory
class StandardDSLBuilder {
final log = LoggerFactory.getLogger(StandardDSLBuilder)
+ def grailsApplication
List<DSLCommand> build(Closure c, args = null) {
List<DSLCommand> results = []
- def delegateBuilder = new StandardDSLDelegate(results)
+ def delegateBuilder = new StandardDSLDelegate(results, grailsApplication)
c.delegate = delegateBuilder
c.resolveStrategy = Closure.DELEGATE_FIRST
if (args) {
View
54 src/groovy/org/grails/plugin/platform/conventions/StandardDSLDelegate.groovy
@@ -17,6 +17,7 @@
*/
package org.grails.plugin.platform.conventions
+import org.codehaus.groovy.grails.commons.GrailsApplication
import org.slf4j.LoggerFactory
/**
@@ -24,15 +25,17 @@ import org.slf4j.LoggerFactory
* method calls and property access, with child nodes for methods taking a closure
*/
class StandardDSLDelegate {
-
+
final __log = LoggerFactory.getLogger(StandardDSLDelegate)
-
+
private List<DSLCommand> __results
-
- StandardDSLDelegate(List<DSLCommand> results) {
+ private GrailsApplication grailsApplication
+
+ StandardDSLDelegate(List<DSLCommand> results, GrailsApplication grailsApplication) {
this.__results = results
+ this.grailsApplication = grailsApplication
}
-
+
private __newBlock(String name, args, Closure body) {
DSLCommand cmd
if (this.@__log.debugEnabled) {
@@ -44,46 +47,61 @@ class StandardDSLDelegate {
cmd = new DSLBlockCommand(name: name, arguments: args ?: [])
}
List<DSLCommand> results = []
- def nestedDelegate = new StandardDSLDelegate(results)
+ def nestedDelegate = new StandardDSLDelegate(results, grailsApplication)
body.resolveStrategy = Closure.DELEGATE_FIRST
body.delegate = nestedDelegate
body()
cmd.children = results
- return cmd
+ return cmd
}
-
+
def methodMissing(String name, args) {
DSLCommand command
-
+
if (args) {
if (args.size() == 1) {
if (args[0] instanceof Map) {
- command = new DSLNamedArgsCallCommand(name: name, arguments:args[0])
- } else if (args[0] instanceof Closure){
+ command = new DSLNamedArgsCallCommand(name: name, arguments: args[0])
+ } else if (args[0] instanceof Closure) {
command = __newBlock(name, null, args[0])
} else {
- command = new DSLSetValueCommand(name: name, value:args[0])
+ command = new DSLSetValueCommand(name: name, value: args[0])
}
} else {
if (args[-1] instanceof Closure) {
- command = __newBlock(name, args[0..args.size()-2], args[-1])
+ command = __newBlock(name, args[0..args.size() - 2], args[-1])
} else {
- command = new DSLCallCommand(name: name, arguments:args)
+ command = new DSLCallCommand(name: name, arguments: args)
}
}
} else {
- command = new DSLCallCommand(name: name, arguments:[])
+ command = new DSLCallCommand(name: name, arguments: [])
}
-
+
if (command) {
this.@__results << command
} else {
throw new IllegalArgumentException('Standard DSL Builder does not understand a call to [$name] with [${args}]')
}
}
-
+
def propertyMissing(String name, value) {
- this.@__results << new DSLSetValueCommand(name: name, value:value)
+ this.@__results << new DSLSetValueCommand(name: name, value: value)
value
}
+
+ def propertyMissing(String name) {
+ if (grailsApplication) {
+ switch (name) {
+ case 'grailsApplication': return grailsApplication
+ break
+ case 'ctx': return grailsApplication.mainContext
+ break
+ case 'config': return grailsApplication.config
+ break
+ }
+ }
+
+ this.@__results << new DSLGetValueCommand(name: name)
+ }
}
View
12 src/groovy/org/grails/plugin/platform/events/EventsImpl.groovy
@@ -254,22 +254,22 @@ class EventsImpl implements Events {
}
void registerEvents(Closure dsl) {
- List<DSLCommand> commands = new DSLEvaluator().evaluate(dsl)
+ List<DSLCommand> commands = new DSLEvaluator().evaluate(dsl,grailsApplication)
String definingPlugin = PluginUtils.getNameOfDefiningPlugin(grailsApplication.mainContext, dsl)
parseDSL(commands, definingPlugin)
}
void loadDSL(Class dslClass) {
Script dslInstance = dslClass.newInstance() as Script
- dslInstance.binding.setVariable("grailsApplication", grailsApplication)
- dslInstance.binding.setVariable("ctx", grailsApplication.mainContext)
- dslInstance.binding.setVariable("config", grailsApplication.config)
+ dslInstance.binding["grailsApplication"] = grailsApplication
+ dslInstance.binding["ctx"] = grailsApplication.mainContext
+ dslInstance.binding["config"] = grailsApplication.config
dslInstance.run()
- def dsl = dslInstance.binding.hasProperty('events') ? dslInstance.binding.getVariable('events') as Closure : null
+ def dsl = dslInstance.binding['events'] ? dslInstance.binding['events'] as Closure : null
if (dsl) {
registerEvents(dsl)
} else {
- log.warn "Tried to load events data from artefact [${artefact.clazz}] but no 'events' value was found in the script"
+ log.warn "Tried to load events data from artefact [${dslClass}] but no 'events' value was found in the script"
}
}
View
2  src/groovy/org/grails/plugin/platform/navigation/NavigationImpl.groovy
@@ -277,7 +277,7 @@ class NavigationImpl implements Navigation {
}
void registerNavigation(Closure dsl) {
- List<DSLCommand> commands = new DSLEvaluator().evaluate(dsl)
+ List<DSLCommand> commands = new DSLEvaluator().evaluate(dsl, grailsApplication)
String definingPlugin = PluginUtils.getNameOfDefiningPlugin(grailsApplication.mainContext, dsl)
parseDSL(commands, null, definingPlugin)
updateCaches()
View
2  src/java/org/grails/plugin/platform/events/ListenerId.java
@@ -63,7 +63,7 @@ public ListenerId(String namespace, String topic, String className, String metho
this.methodName = methodName;
this.hashCode = hashCode;
this.namespace = namespace;
- if (topic != null && !topic.isEmpty()) {
+ if (topic != null && !topic.equals("")) {
this.topic = topic;
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.