This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Test { | |
void method1() { | |
println 'In method1' | |
} | |
void method1(String foo) { | |
println "In method1 with String param of $foo" | |
} | |
static method2(String foo) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def getRandomNumber() { | |
randomInt = new Random().nextInt(11) | |
} | |
def buildCell() { | |
"""${getRandomNumber()} <br> | |
+ ${getRandomNumber()} <br> | |
<hr width=40px> | |
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def init = { servletContext -> | |
if (["test", "ci", "functional"].contains(Environment.current.name)) { | |
// bring some environments down to bare database. 20120609160926 is the base migration script's ID | |
// limitation: if we add development to this list and run the app in IDEA, it orphans the java processes | |
executeCommand ("${getMigrationCommand()} --env=${Environment.current.name} version 20120609160926", new File("./db")) | |
executeCommand ("${getMigrationCommand()} --env=${Environment.current.name} up", new File("./db")) | |
} | |
// other init operations... | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package myapp | |
import org.apache.commons.logging.Log | |
import org.apache.commons.logging.LogFactory | |
import org.apache.log4j.MDC | |
class UsageTrackingFilters { | |
private static final Log LOG = LogFactory.getLog('usagetracking') | |
private static final String REQUEST_ID = "requestId" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<%@ page defaultCodec="none" %> | |
<div class="form-group ${formGroupClass ?: ''} <g:if test="${invalid}">has-error</g:if>"> | |
<label class="control-label ${labelClass ?: ''}" for="${property}">${label} <%=required ? "*" : ""%></label> | |
<input type="<%=type ?: "text" %>" name="${prefix ?: ''}${property}" id="${prefix ?: ''}${property}" value="${value}" <%=constraints.maxSize ? "maxlength=${constraints.maxSize}" : ""%> <%=readonly ? "readonly=readonly" : ""%> class="form-control <%= pageScope["class"] ?: '' %>" <%=placeholder ? "placeholder='$placeholder'" : ""%>/> | |
<g:if test="${helpText}"><span class="help-block">${helpText}</span></g:if> | |
<g:if test="${invalid}"><span class="help-block">${errors.join('<br>')}</span></g:if> | |
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def things = [ [a: 1], [a: 2] ] | |
things.collect { it.a } // returns [1, 2] | |
things*.a // returns [1, 2] | |
things.a // returns [1, 2] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def things = null | |
things.collect { it.a } // returns [] | |
things*.a // returns null | |
things.a // throws a NullPointerException |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.foo.util | |
import groovy.util.logging.Log4j | |
import org.apache.tomcat.jdbc.pool.ConnectionPool | |
import org.codehaus.groovy.grails.commons.GrailsApplication | |
@Log4j | |
class TomcatDatasourceUtil { | |
static void ensureCurrentDatasources(GrailsApplication application, List datasourceNames) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import groovy.json.JsonSlurper | |
dataSource { | |
// most properties are directly set | |
pooled = true | |
// ... | |
// the url is retrieved from etcd...make sure the etcd resource is properly protected | |
def jsonSlurper = new JsonSlurper() | |
def catalogUrlConfig = jsonSlurper.parseText(new URL("http://etcdlocation:2379/v2/keys/dataSource/url").text) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.foo.config | |
import com.foog.util.TomcatDatasourceUtil | |
import grails.plugins.rest.client.RestBuilder | |
import groovy.json.JsonSlurper | |
/** | |
* Application service to get and set values from a centralized remote configuration service. | |
*/ | |
class RemoteConfigService { |
OlderNewer