com.sdm.quasar.client.core.data.impl
Class DefaultDataCore

java.lang.Object
  extended bycom.sdm.quasar.client.core.data.impl.DefaultDataCore
All Implemented Interfaces:
DataCore, Disposable, SystemInfoProvider

public final class DefaultDataCore
extends java.lang.Object
implements Disposable, DataCore, SystemInfoProvider

The core of a DataManagerComponent.

It registers the plug ins, administers the data structure and handles requests for data. This class should never be exposed to users or administrators of the DataManagerComponent.

When performing operations that need exclusive access to the DataCore you must synchronize on the Object returned by getSynchronizeObject().

TODO Für JSF Rel.: Threadsafe machen

Version:
1.0
Author:
Thomas Wolf, sd&m AG, Bernd Olleck, sd&m AG

Constructor Summary
DefaultDataCore()
          Constructor.
 
Method Summary
 NodeController addNode(Node node)
          Registers a node.
 void collectSystemInfo(SystemInfoNode root, SystemInfoOptions options)
          Builds the system information tree upon local information of the implementor.
 void dispose()
          Disposes the component.
 NodeController getNodeController(java.lang.String key)
          Returns the internal node with the given key
 java.util.Set getNodeKeys()
           
 DataManagerPlugIn getPlugIn(java.lang.Class plugInInterface)
          Returns the desired plug in implementation
 java.lang.Object getSynchronizeObject()
          When performing an operation on the DataCore that should must be exclusive you should synchronize on this Object.
 boolean hasNode(java.lang.String key)
          Tests whether a given node exists
 boolean hasPlugIn(java.lang.Class plugInInterface)
          Tests whether the plug in is registered with the data core
 void registerDataManagerPluginCallback(DataManagerPluginCallback callback)
           
 void registerPlugIn(java.lang.Class plugInInterface, AbstractDataManagerPlugIn plugIn)
          Registers a plug in with the DataManager.
 NodeController removeNode(java.lang.String key)
          Removes a node and all nodes that depend on it.
 void unregisterDataManagerPluginCallback(DataManagerPluginCallback callback)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultDataCore

public DefaultDataCore()
Constructor.

Method Detail

getSynchronizeObject

public java.lang.Object getSynchronizeObject()
Description copied from interface: DataCore
When performing an operation on the DataCore that should must be exclusive you should synchronize on this Object.

Specified by:
getSynchronizeObject in interface DataCore
Returns:
the Object to synchronize on when performing exclusive operations within the DataManager.
See Also:
DataCore.getSynchronizeObject()

hasNode

public boolean hasNode(java.lang.String key)
Description copied from interface: DataCore
Tests whether a given node exists

Specified by:
hasNode in interface DataCore
Parameters:
key - the key of the node
Returns:
true iff the node exists
See Also:
DataCore.hasNode(java.lang.String)

getNodeController

public NodeController getNodeController(java.lang.String key)
Description copied from interface: DataCore
Returns the internal node with the given key

Specified by:
getNodeController in interface DataCore
Parameters:
key - the key of the node
Returns:
the internal node with the given key
See Also:
DataCore.getNodeController(java.lang.String)

removeNode

public NodeController removeNode(java.lang.String key)
Removes a node and all nodes that depend on it.

Parameters:
key - the key of the node to remove
Returns:
the node that has been removed
Throws:
java.lang.IllegalArgumentException - if the given key is unknown

addNode

public NodeController addNode(Node node)
Registers a node.

Parameters:
node - the structure definition
Returns:
the node that has been added
Throws:
java.lang.IllegalArgumentException - if a node with the key is already known

getNodeKeys

public java.util.Set getNodeKeys()
Returns:
the set of the keys of all nodes.

registerPlugIn

public void registerPlugIn(java.lang.Class plugInInterface,
                           AbstractDataManagerPlugIn plugIn)
Registers a plug in with the DataManager. Plug ins are notified about changes in the data structure in the order they are registered here.

Note that this method may not be called after the first node definition.

Plug ins do not support inheritance in their interfaces, i.e. the call to DataManager.getPlugIn(Class) will only return the plug in implementation with the same interface that the plugin has been registered here. You may register a single plug in instance under multiple interfaces, but then the instance must be capable of dealing with multiple calls to DataManagerPlugIn.install(DataCore). Note that the AbstractDataManagerPlugIn is not capable to be registered multiple times.

Parameters:
plugInInterface - the interface defining the plugIns of the plug in, must extend DataManagerPlugIn.
plugIn - the implementation of the plug in, must implement the given interface
Throws:
java.lang.IllegalStateException - if there has already been a node configured

hasPlugIn

public boolean hasPlugIn(java.lang.Class plugInInterface)
Description copied from interface: DataCore
Tests whether the plug in is registered with the data core

Specified by:
hasPlugIn in interface DataCore
Parameters:
plugInInterface - the plug in interface
Returns:
true iff the plug in is available
See Also:
DataCore.hasPlugIn(java.lang.Class)

getPlugIn

public DataManagerPlugIn getPlugIn(java.lang.Class plugInInterface)
Description copied from interface: DataCore
Returns the desired plug in implementation

Specified by:
getPlugIn in interface DataCore
Parameters:
plugInInterface - the plug in interface
Returns:
the plug in implementation
See Also:
DataCore.getPlugIn(java.lang.Class)

dispose

public void dispose()
             throws DisposeException
Description copied from interface: Disposable
Disposes the component.

Important:
This method is called by an administrating component and must never be called directly.

The implementation should release any resources or objects allocated and any services registered. Furthermore, this method should be developed carefully to free a maximum of resources even when the system may have become unstable. In case of one or multiple errors, you should collect them in a DisposeException, continue with the execution, and throw it at the end of the method.

Note: The implementation must not return before the component is disposed. Any threads or asynchronous calls started must be completed before this method returns.

Specified by:
dispose in interface Disposable
Throws:
DisposeException - if there was one or more errors while disposing the component.

registerDataManagerPluginCallback

public void registerDataManagerPluginCallback(DataManagerPluginCallback callback)
Specified by:
registerDataManagerPluginCallback in interface DataCore
See Also:
DataCore.registerDataManagerPluginCallback(com.sdm.quasar.client.core.data.plugin.DataManagerPluginCallback)

unregisterDataManagerPluginCallback

public void unregisterDataManagerPluginCallback(DataManagerPluginCallback callback)
Specified by:
unregisterDataManagerPluginCallback in interface DataCore
See Also:
DataCore.unregisterDataManagerPluginCallback(com.sdm.quasar.client.core.data.plugin.DataManagerPluginCallback)

collectSystemInfo

public void collectSystemInfo(SystemInfoNode root,
                              SystemInfoOptions options)
Description copied from interface: SystemInfoProvider
Builds the system information tree upon local information of the implementor. The system information tree can be used within development by inspecting the system; so implementors should append their internal state (depending on the details settings within SystemInfoOptions). The information can be appended to the tree by adding new child SystemInformationNodes to the root node given using the SystemInfoNode.createChild(String) method and by setting information attributes the these nodes or the given root node.

Specified by:
collectSystemInfo in interface SystemInfoProvider
Parameters:
root - the SystemInfoNode to add information to (guaranteed to be not null)
options - contains additional options, that might influence the amount of information added to the tree (guaranteed to be not null)
See Also:
SystemInfoProvider.collectSystemInfo(com.sdm.quasar.client.core.common.sysinfo.SystemInfoNode, com.sdm.quasar.client.core.common.sysinfo.SystemInfoOptions)