public class ModelFactoryHolder extends Object
ModelFactory.
Allows generic tools to be provided by Dragom or other third party that can be integrated as a client tool by providing a way for client tools to easily provide the ModelFactory to use. Tools provided by Dragom make use of this strategy.
Generally the ExecContextFactory implementation takes care of
initializing the Model using a ModelFactory.
DefaultExecContextFactory makes use of this class. Other
ExecContextFactory implementations should do the same.
Dragom attempts to remain as independent as possible from external frameworks whose use would have impacts on clients, such as Spring. But at the same time Dragom must not prevent the use of such frameworks. This class allows, but does not force, the ModelFactory to be set using a dependency injection framework such as Spring.
ModelFactoryHolder can also be used by tools without using a dependency injection framework. The ModelFactory can simply be set by bootstrapping code before invoking the tool.
The ModelFactory is simply held in a static variable.
Alternatively a Model can be set within this class, which is also held in a static variable. In this case a very simple ModelFactory is created that simply returns that Model. This provides even more flexibility when a dependency injection framework is used, allowing the Model itself to be provided in such a way. This works only when the Model is the same for all tool executions.
As a convenience, if no ModelFactory or Model is set, the class identified by
the org.azyva.dragom.DefaultModelFactory system property is used or
DefaultModelFactory if not specified.
Util.applyDragomSystemProperties() is called during initialization of this
class.
| Constructor and Description |
|---|
ModelFactoryHolder() |
| Modifier and Type | Method and Description |
|---|---|
static org.azyva.dragom.model.ModelFactory |
getModelFactory() |
static void |
setModel(org.azyva.dragom.model.Model model)
Sets the
Model. |
static void |
setModelFactory(org.azyva.dragom.model.ModelFactory modelFactory)
Sets the
ModelFactory. |
public static void setModelFactory(org.azyva.dragom.model.ModelFactory modelFactory)
ModelFactory.modelFactory - See description.public static void setModel(org.azyva.dragom.model.Model model)
Model.model - See description.public static org.azyva.dragom.model.ModelFactory getModelFactory()
ModelFactory set with setModelFactory(org.azyva.dragom.model.ModelFactory) or the default
ModelFactory if none has been set.Copyright © 2015–2016 AZYVA INC.. All rights reserved.