org.codehaus.groovy.grails.commons
Class ArtefactHandlerAdapter

java.lang.Object
  extended by org.codehaus.groovy.grails.commons.ArtefactHandlerAdapter
All Implemented Interfaces:
ArtefactHandler
Direct Known Subclasses:
BootstrapArtefactHandler, CodecArtefactHandler, ControllerArtefactHandler, DomainClassArtefactHandler, FiltersConfigArtefactHandler, ServiceArtefactHandler, TagLibArtefactHandler, UrlMappingsArtefactHandler

public class ArtefactHandlerAdapter
extends Object
implements ArtefactHandler

Author:
Marc Palmer (marc@anyware.co.uk)

Field Summary
protected  org.apache.commons.logging.Log log
           
 
Constructor Summary
ArtefactHandlerAdapter(String type, Class grailsClassType, Class grailsClassImpl, String artefactSuffix)
           
ArtefactHandlerAdapter(String type, Class grailsClassType, Class grailsClassImpl, String artefactSuffix, boolean allowAbstract)
           
 
Method Summary
 GrailsClass getArtefactForFeature(Object feature)
          Called 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()
 String getPluginName()
          Obtains the plugin name that deals with this artefact
 String getType()
          Implementations must return a name such as "Domain" to indicate the type of artefact they represent
 void initialize(ArtefactInfo artefacts)
          Sets up the relationships between the domain classes, this has to be done after the intial creation to avoid looping
 boolean isArtefact(Class aClass)
          This method will be 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.
 boolean isArtefactClass(Class clazz)
          Checks that class's name ends in the suffix specified for this handler.
 boolean isArtefactGrailsClass(GrailsClass artefactGrailsClass)
          Called to check if the specified GrailsClass is one managed by this artefact handler
 GrailsClass newArtefactClass(Class artefactClass)
          Creates new GrailsClass derived object using the type supplied in constructor.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

protected org.apache.commons.logging.Log log
Constructor Detail

ArtefactHandlerAdapter

public ArtefactHandlerAdapter(String type,
                              Class grailsClassType,
                              Class grailsClassImpl,
                              String artefactSuffix)

ArtefactHandlerAdapter

public ArtefactHandlerAdapter(String type,
                              Class grailsClassType,
                              Class grailsClassImpl,
                              String artefactSuffix,
                              boolean allowAbstract)
Method Detail

getPluginName

public String getPluginName()
Description copied from interface: ArtefactHandler
Obtains the plugin name that deals with this artefact

Specified by:
getPluginName in interface ArtefactHandler
Returns:
The plugin name or null if there isn't one

getType

public String getType()
Description copied from interface: ArtefactHandler

Implementations must return a name such as "Domain" to indicate the type of artefact they represent

Specified by:
getType in interface ArtefactHandler
Returns:
The aretfact type, as a String

isArtefact

public final boolean isArtefact(Class aClass)
Description copied from interface: ArtefactHandler

This method will be 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.

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:
isArtefact in interface ArtefactHandler
Parameters:
aClass - A class to test
Returns:
True if the class looks like one of your artefacts

isArtefactClass

public boolean isArtefactClass(Class clazz)

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

public GrailsClass newArtefactClass(Class artefactClass)

Creates new GrailsClass derived object using the type supplied in constructor. May not perform optimally but is a convenience.

Specified by:
newArtefactClass in interface ArtefactHandler
Parameters:
artefactClass - Creates a new artefact for the given class
Returns:
An instance of the GrailsClass interface representing the artefact

initialize

public void initialize(ArtefactInfo artefacts)
Sets up the relationships between the domain classes, this has to be done after the intial creation to avoid looping

Specified by:
initialize in interface ArtefactHandler
Parameters:
artefacts - The collection of artefact classes for this handler

getArtefactForFeature

public GrailsClass getArtefactForFeature(Object feature)
Description copied from interface: ArtefactHandler

Called 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:
getArtefactForFeature in interface ArtefactHandler
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

public boolean isArtefactGrailsClass(GrailsClass artefactGrailsClass)
Description copied from interface: ArtefactHandler

Called to check if the specified GrailsClass is one managed by this artefact handler

Specified by:
isArtefactGrailsClass in interface ArtefactHandler
Parameters:
artefactGrailsClass - A GrailsClass instance
Returns:
True if this handler manages the specified GrailsClass


Copyright (c) 2005-2009 The Grails project