Class ArtefactHandlerAdapter
- All Implemented Interfaces:
ArtefactHandler
- Direct Known Subclasses:
ControllerArtefactHandler,DomainClassArtefactHandler,ServiceArtefactHandler,UrlMappingsArtefactHandler
ArtefactHandler interface- Since:
- 1.0
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionArtefactHandlerAdapter(String type, Class<? extends GrailsClass> grailsClassType, Class<?> grailsClassImpl, String artefactSuffix) ArtefactHandlerAdapter(String type, Class<? extends GrailsClass> grailsClassType, Class<?> grailsClassImpl, String artefactSuffix, boolean allowAbstract) -
Method Summary
Modifier and TypeMethodDescriptiongetArtefactForFeature(Object feature) Called to retrieve an artefact relating to some other key for example a URI or tag nameObtains the plugin name that deals with this artefact.getType()Implementations must return a name such as "Domain" to indicate the type of artefact they represent.voidinitialize(ArtefactInfo artefacts) Sets up the relationships between the domain classes, this has to be done after the intial creation to avoid looping.final booleanisArtefact(Class aClass) Called by the GrailsApplication whenever it needs to know if a given class is considered to be the kind of artefact represented by this handler.booleanisArtefact(org.codehaus.groovy.ast.ClassNode classNode) Default implementation ofArtefactHandler.isArtefact(org.codehaus.groovy.ast.ClassNode)which returns true if the ClassNode passes theisArtefactResource(org.grails.io.support.Resource)method and the name of the ClassNode ends with theartefactSuffixbooleanisArtefactClass(Class clazz) Checks that class's name ends in the suffix specified for this handler.booleanisArtefactGrailsClass(GrailsClass artefactGrailsClass) Called to check if the specified GrailsClass is one managed by this artefact handlerprotected booleanisArtefactResource(org.grails.io.support.Resource resource) Subclasses can override to narrow down whether the given resource is an artefact of this type.protected booleanisValidArtefactClassNode(org.codehaus.groovy.ast.ClassNode classNode, int modifiers) newArtefactClass(Class artefactClass) Creates new GrailsClass derived object using the type supplied in constructor.
-
Field Details
-
type
-
grailsClassType
-
grailsClassImpl
-
allowAbstract
protected boolean allowAbstract -
artefactSuffix
-
-
Constructor Details
-
ArtefactHandlerAdapter
public ArtefactHandlerAdapter(String type, Class<? extends GrailsClass> grailsClassType, Class<?> grailsClassImpl, String artefactSuffix) -
ArtefactHandlerAdapter
public ArtefactHandlerAdapter(String type, Class<? extends GrailsClass> grailsClassType, Class<?> grailsClassImpl, String artefactSuffix, boolean allowAbstract)
-
-
Method Details
-
getPluginName
Description copied from interface:ArtefactHandlerObtains the plugin name that deals with this artefact.- Specified by:
getPluginNamein interfaceArtefactHandler- Returns:
- The plugin name or null if there isn't one
-
getType
Description copied from interface:ArtefactHandlerImplementations must return a name such as "Domain" to indicate the type of artefact they represent.- Specified by:
getTypein interfaceArtefactHandler- Returns:
- The aretfact type, as a String
-
isArtefact
public boolean isArtefact(org.codehaus.groovy.ast.ClassNode classNode) Default implementation ofArtefactHandler.isArtefact(org.codehaus.groovy.ast.ClassNode)which returns true if the ClassNode passes theisArtefactResource(org.grails.io.support.Resource)method and the name of the ClassNode ends with theartefactSuffix- Specified by:
isArtefactin interfaceArtefactHandler- Parameters:
classNode- The ClassNode instance- Returns:
- True if the ClassNode is an artefact of this type
-
isValidArtefactClassNode
protected boolean isValidArtefactClassNode(org.codehaus.groovy.ast.ClassNode classNode, int modifiers) -
isArtefactResource
Subclasses can override to narrow down whether the given resource is an artefact of this type. The default is to consider all files under "grails-app" to be a resource- Parameters:
resource- The resource- Returns:
- True if it is a Grails artefact
- Throws:
IOException
-
isArtefact
Description copied from interface:ArtefactHandlerCalled by the GrailsApplication whenever it needs to know if a given class is considered to be the kind of artefact represented by this handler.
Typically you will check the name of the class and some other properties to see if it is of the correct artefact type
- Specified by:
isArtefactin interfaceArtefactHandler- Parameters:
aClass- A class to test- Returns:
- true if the class looks like one of your artefacts
-
isArtefactClass
Checks that class's name ends in the suffix specified for this handler.
Override for more complex criteria
- Parameters:
clazz- The class to check- Returns:
- true if it is an artefact of this type
-
newArtefactClass
Creates new GrailsClass derived object using the type supplied in constructor. May not perform optimally but is a convenience.
- Specified by:
newArtefactClassin interfaceArtefactHandler- Parameters:
artefactClass- Creates a new artefact for the given class- Returns:
- An instance of the GrailsClass interface representing the artefact
-
initialize
Sets up the relationships between the domain classes, this has to be done after the intial creation to avoid looping.- Specified by:
initializein interfaceArtefactHandler- Parameters:
artefacts- The collection of artefact classes for this handler
-
getArtefactForFeature
Description copied from interface:ArtefactHandlerCalled to retrieve an artefact relating to some other key for example a URI or tag name
Handlers are responsible for caching the appropriate information using the data passed to them in calls to initialize()
- Specified by:
getArtefactForFeaturein interfaceArtefactHandler- Parameters:
feature- Any object that acts as a key- Returns:
- A matching artefact GrailsClass or null if there is no match for this feature ID
-
isArtefactGrailsClass
Description copied from interface:ArtefactHandlerCalled to check if the specified GrailsClass is one managed by this artefact handler
- Specified by:
isArtefactGrailsClassin interfaceArtefactHandler- Parameters:
artefactGrailsClass- A GrailsClass instance- Returns:
- true if this handler manages the specified GrailsClass
-