public abstract class AbstractArtifactManager extends Object implements ArtifactManager
ArtifactManager
interface.Modifier and Type | Field and Description |
---|---|
protected static String |
ERROR_ARTIFACT_HANDLER_NULL |
EMPTY_GRIFFON_CLASS_LIST
Constructor and Description |
---|
AbstractArtifactManager() |
Modifier and Type | Method and Description |
---|---|
boolean |
canShutdown(GriffonApplication application)
Asks this handler if the application's shutdown sequence can proceed or not.
|
protected abstract Map<String,List<Class<? extends GriffonArtifact>>> |
doLoadArtifactMetadata() |
<A extends GriffonArtifact> |
findGriffonClass(A artifact)
Finds an artifact by class.
|
GriffonClass |
findGriffonClass(Class<? extends GriffonArtifact> clazz)
Finds an artifact by class.
|
GriffonClass |
findGriffonClass(Class<? extends GriffonArtifact> clazz,
String type)
Finds an artifact by class and type.
|
GriffonClass |
findGriffonClass(String fqClassName)
Finds an artifact by name.
|
GriffonClass |
findGriffonClass(String name,
String type)
Finds an artifact by name and type.
|
List<GriffonClass> |
getAllClasses()
Finds all artifact classes.
|
Set<String> |
getAllTypes()
Finds all supported artifact types.
|
protected Map<String,ArtifactHandler> |
getArtifactHandlers() |
List<GriffonClass> |
getClassesOfType(String type)
Finds all artifacts of an specific type.
|
protected boolean |
isArtifactTypeSupported(String type) |
protected <A extends GriffonArtifact> |
isClassOfType(String type,
Class<A> clazz) |
void |
loadArtifactMetadata(Injector<?> injector)
Reads the artifacts definitions file from the classpath.
|
<A extends GriffonArtifact> |
newInstance(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 |
onShutdown(GriffonApplication application)
Called when the shutdown sequence continues
|
void |
registerArtifactHandler(ArtifactHandler artifactHandler)
Registers an ArtifactHandler by type.
|
void |
unregisterArtifactHandler(ArtifactHandler artifactHandler)
Removes an ArtifactHandler by type.
|
protected static final String ERROR_ARTIFACT_HANDLER_NULL
@Nonnull protected Map<String,ArtifactHandler> getArtifactHandlers()
public final void loadArtifactMetadata(@Nonnull Injector<?> injector)
ArtifactManager
Should call initialize() on artifact handlers if there are any registered already.
loadArtifactMetadata
in interface ArtifactManager
@Nonnull public Set<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 Class<A> clazz)
ArtifactManager
newInstance
in interface ArtifactManager
clazz
- the Class for which an instance must be created@Nonnull protected abstract Map<String,List<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 ArtifactHandler@Nullable public GriffonClass findGriffonClass(@Nonnull String name, @Nonnull 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 Class<? extends GriffonArtifact> clazz, @Nonnull 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 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 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 List<GriffonClass> getClassesOfType(@Nonnull 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 List<GriffonClass> getAllClasses()
ArtifactManager
getAllClasses
in interface ArtifactManager
public boolean canShutdown(@Nonnull GriffonApplication application)
ShutdownHandler
Return false if the shutdown sequence must be aborted.
canShutdown
in interface ShutdownHandler
application
- the current running applicationpublic void onShutdown(@Nonnull GriffonApplication application)
ShutdownHandler
onShutdown
in interface ShutdownHandler
application
- the current running applicationprotected <A extends GriffonArtifact> boolean isClassOfType(@Nonnull String type, @Nonnull Class<A> clazz)