5.8.1 Evaluating Conventions - Reference Documentation
Authors: Andres Almiray
Version: 1.2.0
5.8.1 Evaluating Conventions
Every Griffon application exposes all information about its artifacts and addons via a pair of helper classesAddonManager
- used for all installed addonsArtifactManager
- used for all remaining artifacts
ArtifactManager
TheArtifactManager
class provides methods to evaluate the conventions within the project and internally stores references to all classes within a GriffonApplication using subclasses of GriffonClass class.A GriffonClass
represents a physical Griffon resources such as a controller or a service. For example to get all GriffonClass
instances you can call:app.artifactManager.allClasses.each { println it.name }
ArtifactManager
instance possesses that allow you to narrow the type of artifact you are interested in. For example if you only need to deal with controllers you can do:app.artifactManager.controllerClasses.each { println it.name }
get*Classes
- Retrieves all the classes for a particular artifact type. Exampleapp.artifactManager.getControllerClasses()
.*Classes
- Retrieves all the classes for a particular artifact type. Exampleapp.artifactManager.controllerClasses
.is*Class
- Returns true if the given class is of the given artifact type. Exampleapp.artifactManager.isControllerClass(ExampleController)
GriffonClass
interface itself provides a number of useful methods that allow you to further evaluate and work with the conventions. These include:
newInstance
- Creates a new instance of the enclosed class.getName
- Returns the logical name of the class in the application without the trailing convention part if applicablegetClazz
- Returns the artifact classgetType
- Returns the type of the artifact, i.e "controller"getTrailing
- Returns the suffix (if any) of the artifact, i.e "Controller"
AddonManager
TheAddonManager
class is responsible for holding references to all addons (which are of type griffon.core.GriffonAddon), as well as providing metainformation on each addon via an addon descriptor. The latter can be used to know at runtime the name and version of a particular addon, useful for building a dynamic About dialog for example.All addons have the same behavior which is explained in detail in the Addons section.