18.10.2 Adding Your Own Artefact Types 3.1.10

See the light - agile, industrial strength, rapid web application development made easy

(Quick Reference) # 18.10.2 Adding Your Own Artefact Types - Reference Documentation Authors: Graeme Rocher, Peter Ledbrook, Marc Palmer, Jeff Brown, Luke Daley, Burt Beckwith, Lari Hotari Version: 3.1.10 ## 18.10.2 Adding Your Own Artefact Types Plugins can easily provide their own artefacts so that they can easily find out what implementations are available and take part in reloading. All you need to do is create an `ArtefactHandler` implementation and register it in your main plugin class:
    class MyGrailsPlugin {
        def artefacts = [ org.somewhere.MyArtefactHandler ]
        …
    }
The `artefacts` list can contain either handler classes (as above) or instances of handlers. So, what does an artefact handler look like? Well, put simply it is an implementation of the ArtefactHandler interface. To make life a bit easier, there is a skeleton implementation that can readily be extended: ArtefactHandlerAdapter. In addition to the handler itself, every new artefact needs a corresponding wrapper class that implements GrailsClass. Again, skeleton implementations are available such as AbstractInjectableGrailsClass, which is particularly useful as it turns your artefact into a Spring bean that is auto-wired, just like controllers and services. The best way to understand how both the handler and wrapper classes work is to look at the Quartz plugin: GrailsJobClass DefaultGrailsJobClass JobArtefactHandler Another example is the Shiro plugin which adds a realm artefact. | Quick Reference (hide)