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
Object.metaClass.miau = {-> println "Miau!!!"} | |
"String".miau() | |
145.miau() |
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
public interface GroovyObject { | |
Object invokeMethod(String name, Object args); | |
Object getProperty(String property); | |
void setProperty(String property, Object newValue); | |
MetaClass getMetaClass(); | |
void setMetaClass(MetaClass metaClass); | |
} |
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 DemoController implements DatabaseExceptionHandler { | |
// todos os métodos de manipuação de exceção são definidos | |
// em DatabaseExceptionHandler serão adicionados | |
// nesta classe em tempo de execução | |
} |
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.demo | |
trait DatabaseExceptionHandler { | |
def handleSQLException(SQLException e) { | |
// manipular SQLException | |
} | |
def handleBatchUpdateException(BatchUpdateException e) { | |
// manipular BatchUpdateException | |
} | |
} |
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 demo | |
class DemoController { | |
def someAction() { | |
// do some work | |
} | |
def handleSQLException(SQLException e) { | |
render 'A SQLException Was Handled' | |
} | |
def handleBatchUpdateException(BatchUpdateException e) { | |
redirect controller: 'logging', action: 'batchProblem' |
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 ComponenteCustomizado implements WebAttributes { | |
def meuMetodo() { | |
println "params: " + params | |
} | |
} |
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
trait Controller implements ResponseRenderer, | |
ResponseRedirector, | |
RequestForwarder, | |
DataBinder, | |
WebAttributes, | |
ServletAttributes { | |
//... | |
} |
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 C implements A,B { | |
String exec() { A.super.exec() } | |
} |
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
trait A { | |
String exec() { 'A' } | |
} | |
trait B { | |
String exec() { 'B' } | |
} | |
class C implements A,B {} | |
def c = new C() | |
println c.exec() |
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
@Grapes( | |
@Grab(group='log4j', module='log4j', version='1.2.16') | |
) | |
import org.apache.commons.logging.LogFactory; | |
import org.apache.commons.logging.Log; | |
trait Loggable { | |
private Log logger | |
Log getLog() { | |
if( !logger ) | |
logger = LogFactory.getLog( this.getClass() ) |