Interface IArtifactCreator
-
- All Known Implementing Classes:
DefaultFileArtifactCreator,DefaultFolderArtifactCreator,DefaultJavaFileArtifactCreator,DefaultXmlFileArtifactCreator,VtlFileArtifactCreator
public interface IArtifactCreatorDescribes creator instances which know how to translate real world objects into artifact instances. Implementations must fulfill the following contract:handlesArtifact(Class, Object)is called to figure out whether a creator is able to handle a certain artifact under given class-based restrictions. Typically, more specific creators are asked later than more generic ones, but more specific creators (according to inheritance relationships) are considered first for creation. An implementation which answerstruemust be able to create the queried artifact.createArtifactInstance(Object, ArtifactModel)actually creates an instance for the previously queried object. However, no information shall be stored nor there is a guarantee thatcreateArtifactInstance(Object, ArtifactModel)will be called (dependent on the other registered creators). As stated above, ifhandlesArtifact(Class, Object)answers withtrue,createArtifactInstance(Object, ArtifactModel)must be able to perform the creation for the given object.
- Author:
- Holger Eichelberger
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringDEFAULT_PATTERNA pseudo token denoting the implemented configuration (value "*").
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description voidconfigure(java.util.Properties properties, java.util.List<Message> messages)Configures its own reaction according to a set of properties.IArtifactcreateArtifactInstance(java.lang.Object real, ArtifactModel model)Returns the artifact instance forreal.java.lang.Class<? extends IArtifact>getArtifactClass()The class of the artifact being created.booleanhandlesArtifact(java.lang.Class<? extends IArtifact> kind, java.lang.Object real)Returns whether this creator handles this type of artifact.
-
-
-
Field Detail
-
DEFAULT_PATTERN
static final java.lang.String DEFAULT_PATTERN
A pseudo token denoting the implemented configuration (value "*").- See Also:
- Constant Field Values
-
-
Method Detail
-
handlesArtifact
boolean handlesArtifact(java.lang.Class<? extends IArtifact> kind, java.lang.Object real)
Returns whether this creator handles this type of artifact.- Parameters:
kind- the kind of artifact in terms of a class (typically the top-level interfaces)real- the real world object- Returns:
trueif it can handle the artifact,falseelse
-
createArtifactInstance
IArtifact createArtifactInstance(java.lang.Object real, ArtifactModel model) throws VilException
Returns the artifact instance forreal.- Parameters:
real- the real world objectmodel- the artifact model to create the artifact within- Returns:
- the instance or null if
realcannot be handled - Throws:
VilException- in case that any instance creation problem occurs
-
configure
void configure(java.util.Properties properties, java.util.List<Message> messages)Configures its own reaction according to a set of properties. Each artifact creator may look for a property with its own single name and read a comma separated list of regular file path patterns for its configuration. If empty, the artifact creator shall be disabled. IfDEFAULT_PATTERNis contained, then the default implementation shall be called, otherwise only the configured entries shall be considered. A creator shall not modify the givenproperties(exceptions may apply).- Parameters:
properties- the properties to configure onmessages- configuration messages (to be modified as a side effect)
-
getArtifactClass
java.lang.Class<? extends IArtifact> getArtifactClass()
The class of the artifact being created. Do not override this method for an existing creator if you plan to just replace an existing artifact! In that case subclass the respective creator and override onlycreateArtifactInstance(Object, ArtifactModel).- Returns:
- the class of the artifact being created
-
-