This repository was archived by the owner on Jan 8, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDatanucleusJdoLdapGrailsPlugin.groovy
68 lines (61 loc) · 2.36 KB
/
DatanucleusJdoLdapGrailsPlugin.groovy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
class DatanucleusJdoLdapGrailsPlugin {
// the plugin version
def version = "0.1"
// the version or versions of Grails the plugin is designed for
def grailsVersion = "1.1.1 > *"
// the other plugins this plugin depends on
def dependsOn = [:]
// resources that are excluded from plugin packaging
def pluginExcludes = [
"grails-app/views/error.gsp"
]
def author = "Stefan Seelmann"
def title = "Grails DataNucleus JDO LDAP Plugin"
def description = '''\\
JDO persistence to an LDAP datastore using DataNucleus.
'''
// URL to the plugin's documentation
def documentation = ""
def doWithSpring = {
log.info "Configuring JDO PersistenceManager"
persistenceManagerFactory(org.springframework.beans.factory.config.MethodInvokingFactoryBean) {
targetClass = "javax.jdo.JDOHelper"
targetMethod = "getPersistenceManagerFactory"
arguments = ["jdo-ldap"]
}
persistenceManager(org.springframework.beans.factory.config.MethodInvokingFactoryBean) { bean ->
bean.scope = "request"
targetClass = "org.springframework.orm.jdo.PersistenceManagerFactoryUtils"
targetMethod = "getPersistenceManager"
arguments = [persistenceManagerFactory,false]
}
transactionManager(org.springframework.orm.jdo.JdoTransactionManager) {
persistenceManagerFactory = persistenceManagerFactory
}
transactionTemplate(org.springframework.transaction.support.TransactionTemplate) {
transactionManager = transactionManager
}
jdoTemplate(org.springframework.orm.jdo.JdoTemplate) {
persistenceManagerFactory = persistenceManagerFactory
}
if (manager?.hasGrailsPlugin("controllers")) {
openPersistenceManagerInViewInterceptor(org.springframework.orm.jdo.support.OpenPersistenceManagerInViewInterceptor) {
persistenceManagerFactory = persistenceManagerFactory
}
if(getSpringConfig().containsBean("grailsUrlHandlerMapping")) {
grailsUrlHandlerMapping.interceptors << openPersistenceManagerInViewInterceptor
}
}
}
def doWithDynamicMethods = { ctx ->
application.domainClasses.each { domainClass ->
domainClass.metaClass.static.list = {->
def persistenceManager = ctx.getBean("persistenceManager")
org.grails.plugins.jdo.JdoUtils.runInTransaction(persistenceManager) {
return persistenceManager.newQuery( domainClass.clazz ).execute()
}
}
}
}
}