public abstract class AbstractArtifactManager extends java.lang.Object implements ArtifactManager
ArtifactManager
interface.Modifier and Type | Field and Description |
---|---|
protected static java.lang.String |
ERROR_ARTIFACT_HANDLER_NULL |
EMPTY_GRIFFON_CLASS_LIST
Constructor and Description |
---|
AbstractArtifactManager() |
Modifier and Type | Method and Description |
---|---|
protected abstract java.util.Map<java.lang.String,java.util.List<java.lang.Class<? extends GriffonArtifact>>> |
doLoadArtifactMetadata() |
<A extends GriffonArtifact> |
findGriffonClass(A artifact)
Finds an artifact by class.
|
GriffonClass |
findGriffonClass(java.lang.Class<? extends GriffonArtifact> clazz)
Finds an artifact by class.
|
GriffonClass |
findGriffonClass(java.lang.Class<? extends GriffonArtifact> clazz,
java.lang.String type)
Finds an artifact by class and type.
|
GriffonClass |
findGriffonClass(java.lang.String fqClassName)
Finds an artifact by name.
|
GriffonClass |
findGriffonClass(java.lang.String name,
java.lang.String type)
Finds an artifact by name and type.
|
java.util.List<GriffonClass> |
getAllClasses()
Finds all artifact classes.
|
java.util.Set<java.lang.String> |
getAllTypes()
Finds all supported artifact types.
|
protected java.util.Map<java.lang.String,ArtifactHandler> |
getArtifactHandlers() |
java.util.List<GriffonClass> |
getClassesOfType(java.lang.String type)
Finds all artifacts of an specific type.
|
protected boolean |
isArtifactTypeSupported(java.lang.String type) |
protected <A extends GriffonArtifact> |
isClassOfType(java.lang.String type,
java.lang.Class<A> clazz) |
void |
loadArtifactMetadata()
Reads the artifacts definitions file from the classpath.
|
<A extends GriffonArtifact> |
newInstance(java.lang.Class<A> clazz)
Creates a new instance of the specified class and type.
Triggers the ApplicationEvent.NEW_INSTANCE with the following parameters clazz - the Class of the object instance -> the object that was created |
<A extends GriffonArtifact> |
newInstance(GriffonClass griffonClass)
Creates a new instance of the specified class and type.
Triggers the ApplicationEvent.NEW_INSTANCE with the following parameters clazz - the Class of the object instance -> the object that was created |
void |
registerArtifactHandler(ArtifactHandler artifactHandler)
Registers an ArtifactHandler by type.
|
void |
unregisterArtifactHandler(ArtifactHandler artifactHandler)
Removes an ArtifactHandler by type.
|
protected static final java.lang.String ERROR_ARTIFACT_HANDLER_NULL
@Nonnull protected java.util.Map<java.lang.String,ArtifactHandler> getArtifactHandlers()
public final void loadArtifactMetadata()
ArtifactManager
Should call initialize() on artifact handlers if there are any registered already.
loadArtifactMetadata
in interface ArtifactManager
@Nonnull public java.util.Set<java.lang.String> getAllTypes()
ArtifactManager
getAllTypes
in interface ArtifactManager
@Nonnull public <A extends GriffonArtifact> A newInstance(@Nonnull GriffonClass griffonClass)
ArtifactManager
newInstance
in interface ArtifactManager
griffonClass
- the GriffonClass for which an instance must be created@Nonnull public <A extends GriffonArtifact> A newInstance(@Nonnull java.lang.Class<A> clazz)
ArtifactManager
newInstance
in interface ArtifactManager
clazz
- the Class for which an instance must be created@Nonnull protected abstract java.util.Map<java.lang.String,java.util.List<java.lang.Class<? extends GriffonArtifact>>> doLoadArtifactMetadata()
public void registerArtifactHandler(@Nonnull ArtifactHandler artifactHandler)
ArtifactManager
Should call initialize() on the handler.
registerArtifactHandler
in interface ArtifactManager
artifactHandler
- an ArtifactHandlerpublic void unregisterArtifactHandler(@Nonnull ArtifactHandler artifactHandler)
ArtifactManager
unregisterArtifactHandler
in interface ArtifactManager
artifactHandler
- an ArtifactHandlerprotected boolean isArtifactTypeSupported(@Nonnull java.lang.String type)
@Nullable public GriffonClass findGriffonClass(@Nonnull java.lang.String name, @Nonnull java.lang.String type)
ArtifactManager
Example: findGriffonClass("Book", "controller") will return an artifact class that describes BookController.
findGriffonClass
in interface ArtifactManager
name
- the name of the artifact, e.g. 'Book'type
- the type of the artifact, e.g. 'controller'@Nullable public GriffonClass findGriffonClass(@Nonnull java.lang.Class<? extends GriffonArtifact> clazz, @Nonnull java.lang.String type)
ArtifactManager
Example: findGriffonClass(BookController, "controller") will return an artifact class that describes BookController.
findGriffonClass
in interface ArtifactManager
clazz
- the name of the artifact, e.g. com.acme.BookControllertype
- the type of the artifact, e.g. 'controller'@Nullable public <A extends GriffonArtifact> GriffonClass findGriffonClass(@Nonnull A artifact)
ArtifactManager
Example: findGriffonClass(aBookControllerInstance) will return an artifact class that describes BookController.
findGriffonClass
in interface ArtifactManager
artifact
- an artifact instance@Nullable public GriffonClass findGriffonClass(@Nonnull java.lang.Class<? extends GriffonArtifact> clazz)
ArtifactManager
Example: findGriffonClass(BookController) will return an artifact class that describes BookController.
findGriffonClass
in interface ArtifactManager
clazz
- a Class instance@Nullable public GriffonClass findGriffonClass(@Nonnull java.lang.String fqClassName)
ArtifactManager
Example: findGriffonClass("BookController") will return an artifact class that describes BookController.
findGriffonClass
in interface ArtifactManager
fqClassName
- full qualified class name@Nonnull public java.util.List<GriffonClass> getClassesOfType(@Nonnull java.lang.String type)
ArtifactManager
Example: getClassesOfType("controller") will return all artifact classes that describe controllers.
getClassesOfType
in interface ArtifactManager
type
- an artifact type, e.g. 'controller'@Nonnull public java.util.List<GriffonClass> getAllClasses()
ArtifactManager
getAllClasses
in interface ArtifactManager
protected <A extends GriffonArtifact> boolean isClassOfType(@Nonnull java.lang.String type, @Nonnull java.lang.Class<A> clazz)