import org.lilie.services.eliot.applications.textes.datastore.EliotFileDataStore
import org.lilie.services.eliot.applications.verrou.ApplicationVerrouGestionnaire
import org.codehaus.groovy.grails.commons.GrailsApplication
+import net.bull.javamelody.MonitoringFilter
+import net.bull.javamelody.SessionListener
+import org.lilie.services.eliot.utils.EliotDataSourceBeanPostProcessor
+import org.lilie.services.eliot.utils.JavaMelodySpringPlugin
+
-import org.springframework.core.annotation.AnnotationUtils
-import org.springframework.jmx.export.MBeanExporter
-import org.springframework.jmx.export.annotation.AnnotationJmxAttributeSource
-import org.springframework.jmx.export.annotation.ManagedResource
-import org.springframework.jmx.export.assembler.MetadataMBeanInfoAssembler
-import org.springframework.jmx.export.assembler.MethodExclusionMBeanInfoAssembler
-import org.springframework.jmx.export.naming.MetadataNamingStrategy
-import org.springframework.jmx.support.MBeanServerFactoryBean
class EliotAppPluginGrailsPlugin {
def doWithSpring = {
- // adding the mbean server configuration and export with mbeanserver ref... no exports
+ // adding the mbean server configuration and export with mbeanserver ref... no exports
mbeanServer(org.springframework.jmx.support.MBeanServerFactoryBean) {
locateExistingServerIfPossible = true
}
}
}
}
+
+ if (ConfigurationHolder?.config?.javamelody?.spring?.actif) {
+
+ xmlns aop: "http://www.springframework.org/schema/aop"
+
+ javaMelodySpringPlugin(JavaMelodySpringPlugin)
+
+ aop {
+ config("proxy-target-class": true) {
+ pointcut(
+ id: "interceptorPointcut",
+ expression: ConfigurationHolder?.config?.javamelody?.spring?.pointcutExpression
+ )
+ advisor(
+ 'pointcut-ref': "interceptorPointcut",
+ 'advice-ref': "javaMelodySpringPlugin"
+ )
+
+ }
+ }
+ }
+
+ eliotDataSourceBeanPostProcessor(EliotDataSourceBeanPostProcessor)
+
+
+
+
}
def doWithApplicationContext = {ApplicationContext applicationContext ->
def doWithWebDescriptor = {xml ->
+ def confJavaMelody = ConfigurationHolder?.config?.javamelody
+
+ if (!confJavaMelody?.actif) {
+ return
+ }
+
+ def contextParam = xml.'context-param'
+
+ contextParam[contextParam.size() - 1] + {
+ 'filter' {
+ 'filter-name'('monitoring')
+ 'filter-class'(MonitoringFilter.name)
+
+ confJavaMelody?.each {
+ String nom = it.key
+ String valeur = it.value
+
+ if (nom == 'compteurs') {
+ nom = 'displayed-counters'
+ }
+
+ 'init-param' {
+ 'param-name'(nom)
+ 'param-value'(valeur)
+ }
+ }
+ }
+ }
+
+ findMappingLocation.delegate = delegate
+ def mappingLocation = findMappingLocation(xml)
+
+ mappingLocation + {
+ 'filter-mapping' {
+ 'filter-name'('monitoring')
+ 'url-pattern'('/*')
+ }
+ }
+
+ def filterMapping = xml.'filter-mapping'
+ filterMapping[filterMapping.size() - 1] + {
+
+ 'listener' {
+ 'listener-class'(SessionListener.name)
+ }
+ }
+
+
}
+ private findMappingLocation = {xml ->
+
+ // recherche la position du mapping dans le fichier de config tomcat
+ def mappingLocation = xml.'filter-mapping'.find { it.'filter-name'.text() == 'charEncodingFilter' }
+ if (mappingLocation) {
+ return mappingLocation
+ }
+
+ int i = 0
+ int siteMeshIndex = -1
+ xml.'filter-mapping'.each {
+ if (it.'filter-name'.text().equalsIgnoreCase('sitemesh')) {
+ siteMeshIndex = i
+ }
+ i++
+ }
+ if (siteMeshIndex > 0) {
+ return xml.'filter-mapping'[siteMeshIndex - 1]
+ }
+
+ if (siteMeshIndex == 0 || xml.'filter-mapping'.size() == 0) {
+ def filters = xml.'filter'
+ return filters[filters.size() - 1]
+ }
+
+ def filters = xml.'filter'
+ return filters[filters.size() - 1]
+
+ }
+
+
def doWithDynamicMethods = {ctx ->
- // Implement registering dynamic methods to classes (optional)
}
def onChange = {event ->
app.config.putAll(config.merge(app.config))
}
+
}