com.sdm.quasar.client.core.dialog.impl
Class DefaultDialogManager

java.lang.Object
  extended bycom.sdm.quasar.client.core.dialog.impl.DefaultDialogManager
All Implemented Interfaces:
DialogManager, Disposable, LifeCycleListenerSupport

public class DefaultDialogManager
extends java.lang.Object
implements DialogManager

A default implementation of DialogManager.

Version:
1.$Revision$
Author:
Thomas Wolf

Constructor Summary
DefaultDialogManager(ID rootId, HierarchyManager hierarchyManager, DialogServiceManager serviceManager)
          Constructor.
 
Method Summary
 void addLifeCycleListener(LifeCycleListener listener)
          Registers an observer of the life cycle of dialogs.
 boolean canCreateDialog(java.lang.String dialogId)
          Tests, whether the dialog with the given id can be created by this dialog manager.
 void collectSystemInfo(ID id, SystemInfoNode root, SystemInfoOptions options)
          Builds the system information tree upon local information of the implementor about the dialog with the ID given.
 DialogInstance createDialog(java.lang.String dialogId, DialogInstanceId lifeCycleParentDiid, java.lang.Object context)
          Creates a dependent dialog.
 DialogInstance createRootDialog(DialogInstanceId rootDialogInstanceId, java.lang.Object context)
          Creates the root dialog instance.
 DialogInstanceId createRootDialogInstanceId()
          Creates a root dialog id.
 void dispose()
          Disposes the component.
 void disposeDialog(DialogInstanceId diid)
          Disposes a dialog by calling com.sdm.quasar.client.comp.dlgdef.Dialog#dispose().
 DialogExceptionHandler getDialogExceptionHandler()
           
 LifeCycleState getLifeCycleState(ID id)
          Returns a LifeCycleState for the given id.
protected  java.lang.String getNextInstanceId()
          Returns the next instance-number to use for the specified dialog.
 boolean hasDialog(DialogInstanceId diid)
          Tests, whether a dialog with a given instance id exists.
 void removeLifeCycleListener(LifeCycleListener listener)
          Unregisters an observer of the life cycle of dialogs.
protected  DialogInstanceId reserveId(java.lang.String dialogId)
          Reserves a DialogInstanceId for a dialog that will be created later using #createDialogInternal(DialogInstanceId, DialogServiceManager, Object).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultDialogManager

public DefaultDialogManager(ID rootId,
                            HierarchyManager hierarchyManager,
                            DialogServiceManager serviceManager)
Constructor.

Parameters:
rootId - the root id for independent dialogs (e.g. session id)
hierarchyManager - the HierarchyManager for the dialog hierarchy
serviceManager - the DialogServiceManager to register services
Method Detail

getLifeCycleState

public LifeCycleState getLifeCycleState(ID id)
Description copied from interface: DialogManager
Returns a LifeCycleState for the given id. If the id is a known dialog instance id, the returned state is equal to the state of the acssociated dialog instance. Additionally this method assures, that for any other id given, a valid LifeCycleState is returned.

Specified by:
getLifeCycleState in interface DialogManager
Parameters:
id - the id to get a LifeCycleState for
Returns:
the LifeCycleState for the id
See Also:
DialogManager.getLifeCycleState(ID)

canCreateDialog

public boolean canCreateDialog(java.lang.String dialogId)
Description copied from interface: DialogManager
Tests, whether the dialog with the given id can be created by this dialog manager.

Specified by:
canCreateDialog in interface DialogManager
Parameters:
dialogId - the id of the dialog
Returns:
true, iff the dialog can be created
See Also:
com.sdm.quasar.client.core.dialog.DialogManager#canCreateDialog(java.lang.String)

createRootDialogInstanceId

public DialogInstanceId createRootDialogInstanceId()
Description copied from interface: DialogManager
Creates a root dialog id.

Note: This is the first step in creating a root dialog node. A call to #createRootDialog(DialogInstanceId, DialogServiceManager, Object) should follow to finish creation of a root dialog.

Specified by:
createRootDialogInstanceId in interface DialogManager
Returns:
the DialogInstanceId for the root dialog, that will be created later by calling #createRootDialog(DialogInstanceId, DialogServiceManager, Object).
See Also:
DialogManager.createRootDialogInstanceId()

createRootDialog

public DialogInstance createRootDialog(DialogInstanceId rootDialogInstanceId,
                                       java.lang.Object context)
                                throws DialogException
Description copied from interface: DialogManager
Creates the root dialog instance.

Note: This is the second step in creating a root dialog node. The given rootDialogInstanceId must already exist. To create a root id use #createRootDialogInstanceId(String) in advance.

It uses the given dialog id and the context object. Based on the dialog id additional configuration may be used.

Specified by:
createRootDialog in interface DialogManager
Parameters:
context - the dialog context object, used as initialization parameter by the dialog
Throws:
DialogException - if the dialog could not be created due to an error in configuration or dialog implementation.
See Also:
DialogManager.createRootDialog(com.sdm.quasar.client.core.dialog.DialogInstanceId, java.lang.Object)

createDialog

public DialogInstance createDialog(java.lang.String dialogId,
                                   DialogInstanceId lifeCycleParentDiid,
                                   java.lang.Object context)
                            throws DialogException
Description copied from interface: DialogManager
Creates a dependent dialog. The dialog will be created and added to the hierarchy as a child to the given parent dialog.

The dialog will be disposed automatically before its parent dialog is disposed.

Specified by:
createDialog in interface DialogManager
Parameters:
dialogId - the id of the dialog to be created
lifeCycleParentDiid - the dialog instance id of the parent
context - the dialog context object, used as initialization parameter by the dialog
Returns:
the instance id of the new dialog
Throws:
DialogException - if the dialog could not be created due to an error in configuration or dialog implementation.
See Also:
DialogManager.createDialog(java.lang.String, com.sdm.quasar.client.core.dialog.DialogInstanceId, java.lang.Object)

disposeDialog

public void disposeDialog(DialogInstanceId diid)
Description copied from interface: DialogManager
Disposes a dialog by calling com.sdm.quasar.client.comp.dlgdef.Dialog#dispose().

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

Specified by:
disposeDialog in interface DialogManager
Parameters:
diid - diid the dialog instance id of the dialog to be disposed
See Also:
com.sdm.quasar.client.comp.dlgdef.mgmt.DialogManager#disposeDialog(com.sdm.quasar.client.comp.dlgdef.DialogInstanceId)

hasDialog

public boolean hasDialog(DialogInstanceId diid)
Description copied from interface: DialogManager
Tests, whether a dialog with a given instance id exists.

Specified by:
hasDialog in interface DialogManager
Parameters:
diid - diid the dialog instance id to be tested
Returns:
true, iff the dialog exists
See Also:
com.sdm.quasar.client.comp.dlgdef.mgmt.DialogManager#hasDialog(com.sdm.quasar.client.comp.dlgdef.DialogInstanceId)

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.
See Also:
Disposable.dispose()

getDialogExceptionHandler

public DialogExceptionHandler getDialogExceptionHandler()
Returns:
the DialogExceptionHandler used

reserveId

protected DialogInstanceId reserveId(java.lang.String dialogId)
Reserves a DialogInstanceId for a dialog that will be created later using #createDialogInternal(DialogInstanceId, DialogServiceManager, Object).

A dialog with such a preliminary instance id is not considered a known dialog, i.e. DialogManager.hasDialog(DialogInstanceId) will return false until #createDialogInternal(DialogInstanceId, DialogServiceManager, Object) is called.

Parameters:
dialogId - the id of the dialog to be created
Returns:
the dialog instance id

getNextInstanceId

protected java.lang.String getNextInstanceId()
Returns the next instance-number to use for the specified dialog.

Returns:
the instance-number

addLifeCycleListener

public void addLifeCycleListener(LifeCycleListener listener)
Description copied from interface: LifeCycleListenerSupport
Registers an observer of the life cycle of dialogs. The order of the registration of observers are preserved. The observers are notified in reverse order.

Specified by:
addLifeCycleListener in interface LifeCycleListenerSupport
Parameters:
listener - the listener to add
See Also:
com.sdm.quasar.client.comp.dlgdef.mgmt.TechnicalDialogLifeCycleObservable#addDialogLifeCycleListener(com.sdm.quasar.client.comp.dlgdef.mgmt.TechnicalDialogLifeCycleListener)

removeLifeCycleListener

public void removeLifeCycleListener(LifeCycleListener listener)
Description copied from interface: LifeCycleListenerSupport
Unregisters an observer of the life cycle of dialogs.

Specified by:
removeLifeCycleListener in interface LifeCycleListenerSupport
Parameters:
listener - the listener to remove
See Also:
com.sdm.quasar.client.comp.dlgdef.mgmt.TechnicalDialogLifeCycleObservable#removeDialogLifeCycleListener(com.sdm.quasar.client.comp.dlgdef.mgmt.TechnicalDialogLifeCycleListener)

collectSystemInfo

public void collectSystemInfo(ID id,
                              SystemInfoNode root,
                              SystemInfoOptions options)
Description copied from interface: DialogManager
Builds the system information tree upon local information of the implementor about the dialog with the ID given.

Specified by:
collectSystemInfo in interface DialogManager
Parameters:
id - the ID to append system information to the node given
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:
DialogManager.collectSystemInfo(com.sdm.quasar.client.core.common.ID, com.sdm.quasar.client.core.common.sysinfo.SystemInfoNode, com.sdm.quasar.client.core.common.sysinfo.SystemInfoOptions)