import de.internetzky.grails.clamav.VirusValidator import de.internetzky.grails.clamav.VirusValidatorFactory import org.codehaus.groovy.grails.validation.ConstrainedProperty import org.codehaus.groovy.grails.commons.* class ClamavGrailsPlugin { def version = 0.1 def dependsOn = [:] def author = "Marc Guillemot" def description = ''' This plugin adds virus validation possibilities based on the Open Source anti-virus software ClamAv™. ''' def watchedResources = "file:./grails-app/conf/Config.groovy" def doWithSpring = { "clamAVService"(de.internetzky.grails.clamav.ClamAVService) "clamav.constraintFactory"(de.internetzky.grails.clamav.VirusValidatorFactory) { bean-> clamAvService = ref("clamAVService") bean.getBeanDefinition().setSingleton(true) } } def doWithApplicationContext = { applicationContext -> // TODO Implement post initialization spring config (optional) def virusValidatorFactory = applicationContext.getBean("clamav.constraintFactory") ConstrainedProperty.registerNewConstraint(VirusValidator.FREE_OF_VIRUS_CONSTRAINT, virusValidatorFactory) initService(applicationContext) } def doWithWebDescriptor = { xml -> // TODO Implement additions to web.xml (optional) } def doWithDynamicMethods = { ctx -> // TODO Implement registering dynamic methods to classes (optional) } def onChange = { event -> // TODO Implement code that is executed when this class plugin class is changed // the event contains: event.application and event.applicationContext objects } def onApplicationChange = { event -> // TODO Implement code that is executed when any class in a GrailsApplication changes // the event contain: event.source, event.application and event.applicationContext objects initService(event.ctx) } void initService(applicationContext) { def clamAvService = applicationContext.getBean("clamAVService") clamAvService.init(ApplicationHolder.getApplication().config['clamav']) } }