public abstract class SimpleNode extends Object implements org.azyva.dragom.model.Node, org.azyva.dragom.model.MutableNode
Node and MutableNode.
Two type of SimpleNode's exist each represented by a different subclass:
| Modifier and Type | Class and Description |
|---|---|
protected static class |
SimpleNode.State
Defines the possible states in which the SimpleNode can be in.
|
| Modifier and Type | Field and Description |
|---|---|
protected boolean |
indMutable
Indicates if the SimpleNode is mutable, based on whether the
NodeConfig
provided is mutable. |
protected SimpleNode.State |
state |
| Modifier | Constructor and Description |
|---|---|
protected |
SimpleNode(org.azyva.dragom.model.config.NodeConfig nodeConfig,
SimpleClassificationNode simpleClassificationNodeParent)
Constructor for Node's other than the root SimpleClassificationNode when
creating a
Model from Config. |
protected |
SimpleNode(org.azyva.dragom.model.config.NodeConfig nodeConfig,
SimpleModel simpleModel)
Constructor for the root SimpleClassificationNode when creating a
Model
from Config. |
protected |
SimpleNode(SimpleModel simpleModel)
Constructor used when dynamically completing a
Model. |
| Modifier and Type | Method and Description |
|---|---|
protected void |
checkMutable()
Checks if the MutableNode is really mutable.
|
protected void |
checkNotDeleted()
Checks if the MutableNode is not deleted.
|
protected void |
cleanCaches(boolean indDelete)
Called when underlying
MutableConfig data have changed so that any
cache that could contain instantiated objects whose states are dependent on
this data is cleared. |
org.azyva.dragom.model.config.OptimisticLockHandle |
createOptimisticLockHandle(boolean indLock) |
void |
delete() |
protected void |
extractNodeConfigTransferObject(org.azyva.dragom.model.config.NodeConfigTransferObject nodeConfigTransferObject,
org.azyva.dragom.model.config.OptimisticLockHandle optimisticLockHandle)
Called by subclasses to extract the data from a
NodeConfigTransferObject and set
them within the configuration of the SimpleNode. |
org.azyva.dragom.model.ClassificationNode |
getClassificationNodeParent() |
List<String> |
getListPluginId(Class<? extends org.azyva.dragom.model.plugin.NodePlugin> classNodePlugin)
The order in which the plugin IDs are returned is as defined by the order of
the
PluginDefConfig within the underlying NodeConfig's. |
org.azyva.dragom.model.Model |
getModel() |
String |
getName()
If the SimpleNode was created from
Config, this is equivalent to
nodeConfig.getName. |
protected org.azyva.dragom.model.config.NodeConfig |
getNodeConfig() |
org.azyva.dragom.model.config.NodeConfigTransferObject |
getNodeConfigTransferObject(org.azyva.dragom.model.config.OptimisticLockHandle optimisticLockHandle) |
org.azyva.dragom.model.NodePath |
getNodePath() |
<NodePluginInterface extends org.azyva.dragom.model.plugin.NodePlugin> |
getNodePlugin(Class<NodePluginInterface> classNodePlugin,
String pluginId)
This method implements the logic to instantiate the NodePlugin either from
NodePluginFactory or by instantiating a class directly as a NodePlugin with
the current Node as the only constructor argument. |
String |
getProperty(String name)
See comment about initialization Properties in
SimpleModel. |
boolean |
isCreatedDynamically() |
boolean |
isDeleted() |
boolean |
isNew() |
boolean |
isNodePluginExists(Class<? extends org.azyva.dragom.model.plugin.NodePlugin> classNodePlugin,
String pluginId) |
boolean |
isOptimisticLockValid(org.azyva.dragom.model.config.OptimisticLockHandle optimisticLockHandle) |
void |
raiseNodeEvent(org.azyva.dragom.model.event.NodeEvent nodeEvent)
Raises a
NodeEvent. |
<NodeEventClass extends org.azyva.dragom.model.event.NodeEvent> |
registerListener(org.azyva.dragom.model.event.NodeEventListener<NodeEventClass> nodeEventListener,
boolean indChildrenAlso)
Registers a
NodeEventListener. |
String |
toString()
Returns the NodePath as a String representation.
|
protected boolean indMutable
NodeConfig
provided is mutable.protected SimpleNode.State state
protected SimpleNode(SimpleModel simpleModel)
Model.
This constructor is expected to be called by
SimpleClassificationNode.SimpleClassificationNode(SimpleModel) or
SimpleModule.SimpleModule(SimpleModel).
simpleModel - SimpleModel.protected SimpleNode(org.azyva.dragom.model.config.NodeConfig nodeConfig,
SimpleModel simpleModel)
Model
from Config.
If nodeConfig is a MutableNodeConfig and nodeConfig.isNew(), it means
we are creating a new MutableNode in a MutableModel with an
initially empty MutableNodeConfig.
Must not be used for SimpleNode's other than the root SimpleClassificationNode.
Use SimpleNode(NodeConfig, SimpleModel) for these SimpleNode's.
This constructor is expected to be called by
SimpleClassificationNode.SimpleClassificationNode(ClassificationNodeConfig, SimpleModel).
nodeConfig - NodeConfig.simpleModel - SimpleModel.protected SimpleNode(org.azyva.dragom.model.config.NodeConfig nodeConfig,
SimpleClassificationNode simpleClassificationNodeParent)
Model from Config.
If nodeConfig is a MutableNodeConfig and nodeConfig.isNew(), it means
we are creating a new MutableNode in a MutableModel with an
initially empty MutableNodeConfig.
Must not be used for the root SimpleClassificationNode. Use
SimpleNode(NodeConfig, SimpleModel) for the root
SimpleClassificationNode.
This constructor is expected to be called by
SimpleClassificationNode.SimpleClassificationNode(ClassificationNodeConfig, SimpleClassificationNode)
or SimpleModule.SimpleModule(ModuleConfig, SimpleClassificationNode).
nodeConfig - NodeConfig.simpleClassificationNodeParent - Parent SimpleClassificationNode.protected org.azyva.dragom.model.config.NodeConfig getNodeConfig()
public org.azyva.dragom.model.ClassificationNode getClassificationNodeParent()
getClassificationNodeParent in interface org.azyva.dragom.model.Nodepublic String getName()
Config, this is equivalent to
nodeConfig.getName. Otherwise, this is the name set when building the
SimpleNode.getName in interface org.azyva.dragom.model.Nodepublic org.azyva.dragom.model.Model getModel()
getModel in interface org.azyva.dragom.model.Nodepublic org.azyva.dragom.model.NodePath getNodePath()
getNodePath in interface org.azyva.dragom.model.Nodepublic String getProperty(String name)
SimpleModel. If the
property cannot be resolved from initialization properties, it will be
obtained from the Model according to below.
SimpleNode inheritance is considered. The value returned is that of the named property on the first SimpleNode that defines it while traversing the parent hierarchy of SimpleNode's starting with this Node.
If no SimpleNode in the parent hierarchy defines the property, null is returned.
If the first SimpleNode in the parent hierarchy that defines the property defines it as null (to avoid inheritance), null is also returned.
If the first SimpleNode in the parent hierarchy that defines the property
defines it only for that specific SimpleNode
(PropertyDefConfig.isOnlyThisNode() or setProperty(java.lang.String, java.lang.String, boolean) called with
indOnlyThisNode) and this first SimpleNode is not the one associated with this
SimpleNode, null is also returned.
If the value of a property as evaluated on the SimpleNode using the algorithm
above contains "$parent$", these parent references (generally there will be at
most one such reference) are replaced with the value of the same property
evaluated in the context of the SimpleNode that is the parent of the SimpleNode
that defined the property, or an empty string if null. This allows defining
cumulative properties, such as Maven properties. For example, if the root
SimpleNode defines "MAVEN_PROPERTIES=property1,property2" and a child
SimpleNode defines "MAVEN_PROPERTIES=$parent$,property3", the value of the
property MAVEN_PROPERTIES evaluated on the child SimpleNode is
"property1,property2,property3". See MavenBuilderPluginImpl for more
information about this specific example.
It is conceivable that eventually property values can contain expressions expressed in an embedded expression language such as Groovy. In that case this method would evaluate these expressions. These expressions would be evaluated in the context of this SimpleNode, but the SimpleNode on which the property value was actually defined would also be provided as a root object. This would provide for a very flexible and powerful inheritance mechanism that would subsume the functionality provided by parent references described above and much more.
Depending on how the SimpleNode was created, either from Config or
dynamically using ModelNodeBuilderFactory implemented by
SimpleModel, the property of a SimpleNode in the parent hierarchy may
come from the Config or may have been using setProperty.
getProperty in interface org.azyva.dragom.model.Nodename - Name of the property.public <NodePluginInterface extends org.azyva.dragom.model.plugin.NodePlugin> NodePluginInterface getNodePlugin(Class<NodePluginInterface> classNodePlugin, String pluginId)
NodePluginFactory or by instantiating a class directly as a NodePlugin with
the current Node as the only constructor argument.getNodePlugin in interface org.azyva.dragom.model.NodeclassNodePlugin - Class of the NodePlugin.pluginId - Plugin ID to distinguish between multiple instances of the same
NodePlugin.public boolean isNodePluginExists(Class<? extends org.azyva.dragom.model.plugin.NodePlugin> classNodePlugin, String pluginId)
isNodePluginExists in interface org.azyva.dragom.model.Nodepublic List<String> getListPluginId(Class<? extends org.azyva.dragom.model.plugin.NodePlugin> classNodePlugin)
PluginDefConfig within the underlying NodeConfig's. The
NodeConfig of the parents are considered while traversing the parent hierarchy
starting with this Node.getListPluginId in interface org.azyva.dragom.model.NodeclassNodePlugin - Class of the NodePlugin.public <NodeEventClass extends org.azyva.dragom.model.event.NodeEvent> void registerListener(org.azyva.dragom.model.event.NodeEventListener<NodeEventClass> nodeEventListener,
boolean indChildrenAlso)
NodeEventListener.
The NodeEventListener is registered within the SimpleNode, and thus within the
SimpleModel. It is also possible to register NodeEventListener's in the
ExecContext.
registerListener in interface org.azyva.dragom.model.NodenodeEventListener - NodeEventListener.indChildrenAlso - Indicates if NodeEvent raised on children should
be dispatched to the NodeEventListener.public void raiseNodeEvent(org.azyva.dragom.model.event.NodeEvent nodeEvent)
NodeEvent.
The NodeEvent is dispatched to all registered NodeEventListener's
interested in it.
NodeEventListener's registered in the ExecContext using
EventPlugin.registerListener(org.azyva.dragom.model.Node, org.azyva.dragom.model.event.NodeEventListener<NodeEventClass>, boolean, boolean) are also considered.
The NodeEvent sub-interface (ModuleEvent or ClassificationNodeEvent) must match the type of Node.
The NodeEvent must be dispatched on NodeEvent.getNode().
raiseNodeEvent in interface org.azyva.dragom.model.NodenodeEvent - NodeEvent.public boolean isCreatedDynamically()
isCreatedDynamically in interface org.azyva.dragom.model.Nodepublic boolean isNew()
isNew in interface org.azyva.dragom.model.MutableNodepublic org.azyva.dragom.model.config.OptimisticLockHandle createOptimisticLockHandle(boolean indLock)
createOptimisticLockHandle in interface org.azyva.dragom.model.MutableNodepublic boolean isOptimisticLockValid(org.azyva.dragom.model.config.OptimisticLockHandle optimisticLockHandle)
isOptimisticLockValid in interface org.azyva.dragom.model.MutableNodepublic org.azyva.dragom.model.config.NodeConfigTransferObject getNodeConfigTransferObject(org.azyva.dragom.model.config.OptimisticLockHandle optimisticLockHandle)
throws org.azyva.dragom.model.config.OptimisticLockException
getNodeConfigTransferObject in interface org.azyva.dragom.model.MutableNodeorg.azyva.dragom.model.config.OptimisticLockExceptionprotected void extractNodeConfigTransferObject(org.azyva.dragom.model.config.NodeConfigTransferObject nodeConfigTransferObject,
org.azyva.dragom.model.config.OptimisticLockHandle optimisticLockHandle)
throws org.azyva.dragom.model.config.OptimisticLockException,
org.azyva.dragom.model.config.DuplicateNodeException
NodeConfigTransferObject and set
them within the configuration of the SimpleNode.
Does most of the processing that
MutableNode.setNodeConfigTransferObject(org.azyva.dragom.model.config.NodeConfigTransferObject, org.azyva.dragom.model.config.OptimisticLockHandle) must do, except calling init
and setting the new state.
The reason for not directly implementing MutableNode.setNodeConfigValueTransferObject is that subclasses can have other tasks to perform.
If optimisticLockHandle is null, no optimistic lock is managed.
If optimisticLockHandle is not null, it must be locked
(OptimisticLockHandle.isLocked()) and its state must correspond to the
state of the data it represents, otherwise OptimisticLockException is
thrown. The state of the OptimisticLockHandle is updated to the new revision of
the SimpleNodeConfig.
nodeConfigTransferObject - NodeConfigTransferObject.optimisticLockHandle - OptimisticLockHandle.org.azyva.dragom.model.config.OptimisticLockException - When the underlying MutableNodeConfig
detects that the configuration data was changed since the call to
getNodeConfigTransferObject(org.azyva.dragom.model.config.OptimisticLockHandle).org.azyva.dragom.model.config.OptimisticLockException - Can be thrown only if optimisticLockHandle is
not null. This is a RuntimeException that may be of interest to
the caller.org.azyva.dragom.model.config.DuplicateNodeException - When the new configuration data would introduce
a duplicate MutableNode within the parent. This is a RuntimeException
that may be of interest to the caller.public void delete()
delete in interface org.azyva.dragom.model.MutableNodepublic boolean isDeleted()
isDeleted in interface org.azyva.dragom.model.MutableNodeprotected void checkNotDeleted()
Utility method to facilitate validating the SimpleNode is not deleted
at the beginning of other methods. Most methods must validate the SimpleNode
is not deleted. But some methods implicitly perform this validation by
verifying for specific states. In this case, calling this method is not
required.
protected void checkMutable()
protected void cleanCaches(boolean indDelete)
MutableConfig data have changed so that any
cache that could contain instantiated objects whose states are dependent on
this data is cleared. The current SimpleNode and its children are
traversed and the same method is called on all of them because of the
inheritance mechanisms implemented in Dragom.
Subclasses that manage such caches must override which method to add the appropriate behavior.
indDelete - Indicates to perform a full clean and put the MutableNode in
the State.DELETED to make it unusable.Copyright © 2015–2016 AZYVA INC.. All rights reserved.