This repository was archived by the owner on Mar 30, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPlutoGrailsPlugin.groovy
76 lines (69 loc) · 2.85 KB
/
PlutoGrailsPlugin.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
69
70
71
72
73
74
75
76
import grails.util.GrailsUtil
import org.codehaus.grails.portlets.*
import org.codehaus.groovy.grails.commons.GrailsClass
import org.codehaus.groovy.grails.plugins.PluginMetaManager
import org.codehaus.groovy.grails.plugins.web.ControllersGrailsPlugin
import org.codehaus.groovy.grails.web.metaclass.BindDynamicMethod
import org.codehaus.groovy.grails.web.plugins.support.WebMetaUtils
import org.springframework.aop.framework.ProxyFactoryBean
import org.springframework.aop.target.HotSwappableTargetSource
import org.springframework.beans.factory.config.MethodInvokingFactoryBean
import org.springframework.context.ApplicationContext
import org.springframework.core.io.Resource
import org.springframework.web.context.request.RequestContextHolder as RCH
class PlutoGrailsPlugin {
// the plugin version
def version = "0.2"
// the version or versions of Grails the plugin is designed for
def grailsVersion = "1.1 > *"
// the other plugins this plugin depends on
def dependsOn = [portlets:"0.3 > * ", portletsPluto:"0.1 > * "]
// resources that are excluded from plugin packaging
def pluginExcludes = [
"grails-app/views/error.gsp"
]
def author = "Kenji Nakamura"
def authorEmail = "[email protected]"
def title = "Pluto runtime"
def description = '''\\
Launch Apache Pluto portal server with "run-app" command and deploy portlets
defined in the project.
'''
def watchedResources = ['file:./grails-app/portlets/**/*Portlet.groovy',
'file:./plugins/*/grails-app/portlets/**/*Portlet.groovy'
]
// URL to the plugin's documentation
def documentation = "http://grails.org/plugins/pluto"
def doWithSpring = {
}
def doWithApplicationContext = { applicationContext ->
}
def doWithWebDescriptor = {webXml ->
if (GrailsUtil.isDevelopmentEnv() && watchedResources.length > 0) {
log.info("Creating Pluto servlets for ${watchedResources.length} portlets...")
for (Resource portlet in watchedResources) {
def portletName = portlet.filename - 'Portlet.groovy'
servletElement + {
'servlet'
{
'servlet-name'(portletName)
'servlet-class'('org.apache.pluto.core.PortletServlet')
'init-param'
{
'param-name'('portlet-name')
'param-value'(portletName)
}
'load-on-startup'('1')
}
}
mappingElement + {
'servlet-mapping'
{
'servlet-name'(portletName)
'url-pattern'("/PlutoInvoker/${portletName}")
}
}
}
}
}
}