Skip to content

Commit

Permalink
fix for GRAILS-1954 "Lazy load support for shell"
Browse files Browse the repository at this point in the history
  • Loading branch information
graemerocher committed Jan 26, 2010
1 parent ebcf804 commit 395c3ec
Showing 1 changed file with 5 additions and 20 deletions.
25 changes: 5 additions & 20 deletions grails/scripts/Shell.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -42,26 +42,11 @@ target(shell:"The shell implementation target") {
b.ctx = appCtx
b.grailsApplication = grailsApp

def original = Groovysh.metaClass.getMetaMethod("execute", [String] as Object[])
Groovysh.metaClass.execute = { String line ->
try {
def listeners = appCtx.getBeansOfType(PersistenceContextInterceptor)
listeners.each { k,v ->
v.init()
}

original.invoke(delegate, line)
listeners.each { k,v ->
v.flush()
}
}
finally {
listeners.each { k,v ->
v.destroy()
}
}
}


def listeners = appCtx.getBeansOfType(PersistenceContextInterceptor)
listeners?.each { key, listener ->
listener.init()
}
def shell = new Groovysh(classLoader,b, new IO(System.in, System.out, System.err))
shell.run([] as String[])
}

0 comments on commit 395c3ec

Please sign in to comment.