com.sdm.quasar.client.core.dialog
Class AbstractFeature

java.lang.Object
  extended bycom.sdm.quasar.client.core.dialog.AbstractFeature
All Implemented Interfaces:
Feature, SystemInfoProvider
Direct Known Subclasses:
AbstractCompositeFeature, AbstractControllerFeature, AbstractDialogCoreFeature, AbstractPresentationFeature, ActivationObjectionFeature, Ajax4jsfDialog, AutoCloseSessionFeature, BackReloadProblemDialog, BackReloadProblemHelloDialog, BookmarksDetailDialog, BookmarksDialog, BrowserWindowCompositeFeature, BrowserWindowFeature, CloseObjectionFeature, CommandBindingManagerDialog, CommandCallDialog, CommandCallDialogPresentation, CommandManagerFeature, ComplexDialogCore, ComplexDialogPresentation, ConfigurationDialog, ConverterValidatorDialog, DataBindingBeanDetailDialog, DataBindingBeanDialog, DataBindingManagerDialog, DataBindingManagerResultDialog, DataBindingMapDialog, DataBindingMapResultDialog, DataBindingSessionDialog, DataManagerDialog, DataManagerDialogPresentation, DataManagerFeature, DefaultSessionDataFeature, DependentWindow, DependentWindowDialog, DependentWindowDialog, DialogContextFeature, DialogCreationFeature, DialogInDialog, DialogResolverFeature, DoubleSubmitCheckerFeature, DoubleSubmitDialog, DoubleSubmitSingletonDialog, DynamicEmbeddingDialog, EmbeddedDetailDialog, EmbeddedListDialog, EmbeddedSearchDialog, ExceptionDialog, ExtendedLifeCycleDialog, FrameCompositeFeature, GenericDialog, HelloWorldDialog, HelloWorldDialog, HelloWorldPresentation, HelloWorldPresentationWithFrame, HtmlMessagePane, I18nDialog, ImageProviderFeature, KeywordResolverFeature, LoginDialog, MessageDialog, MethodCallDialog, MethodCallDialogPresentation, ModalDialog, ModalDialogDialog, ModalDialogFeature, NavigationDialog, NavigationFeature, NewPortalDialog, OptionDialogServiceFeature, ParameterDialog, ParameterDialogA, PortalDialog, PortalDialogActionFeature, PortalPresentation, ReactivationFeature, ResourceAccessFeature, RichFacesDialog, SessionResolverFeature, ShowcaseDialogCreationFeature, ShowcaseSessionFeature, SingletonMultitonDialog, SingletonMultitonOrdersDialog, StartDialog, StructuredDialog, StructuredDialogPresentation, SystemInfoDemoDialogFeature, SystemInfoDialogFeature, SystemInfoPanelFeature, SystemInfoTreeFeature, SystemSnapshotFeature, TabDialog, UnstructuredDialog, VisualRepresentationFeature, WelcomeDialog, WindowFeature

public abstract class AbstractFeature
extends java.lang.Object
implements Feature, SystemInfoProvider

Base implementation of Feature. This base class supports the dialog lifecycle by providing protected lifecycle-methods to be overwritten by subclasses (optional).

An AbstractFeature is initializes like this: Code in the constructor will be executed before the feature will be attached to the LifeCycle of a DialogControl (see Feature.attachDialogControl(DialogControl)). So access to getDialogControl() is forbidden (throws an IllegalStateException) and intialization should be limited to local set-up. Because of leazy intialization support, features can initialize very lazy access and resource allocation. This improves application speed, but requires more careful and robust implementation. To make initialization, that depends on other Features or dialog services, overwrite init(), where access to getDialogControl() is allowed.

If a concrete feature wants to take part on the dialog's lifecycle, it just needs to overwrite one of the lifecycle methods (prepare(), activate(), deactivate() and release()). In opposite to these lifecycle methods, a feature implementation must implement init(), to initialize the feature (see above) and install and register features and services, and dispose(), where the destruction code should uninstall and unregister the things registered in the init() method.

Note: Never(!) call any lifecycle-method directly! Lifecycle methods are subject to implement, not to call.

Note: Because of the lifecycle-concept, the dispose() method can be executed at any time and so should be implemented very robust.

AbstractFeature implements SystemInfoProvider, so just overwrite collectSystemInfo(SystemInfoNode, SystemInfoOptions) and the information provided at the given node will be displayed in the system overview dialog and dumped by a system snapshot. This helps understanding and finding errors in large applications!

Version:
1.0
Author:
Thomas Wolf

Constructor Summary
AbstractFeature()
          Creates a new AbstractFeature.
 
Method Summary
protected  void activate()
          Called when the dialog is activated.
 void attachDialogControl(DialogControl dialogControl)
          Attaches the lifecycle of the Feature to the lifecycle of the DialogControl given.
 void collectSystemInfo(SystemInfoNode root, SystemInfoOptions options)
          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. Subclasses should overwrite this method to append system informations
protected  void deactivate()
          Called when the dialog is deactivated.
protected abstract  void dispose()
          Called when the feature or dialog is disposed.
 void disposeFeature()
          Detaches the lifecycle of the Feature from the lifecycle of the DialogControl previouse given and disposes the feature.
protected  DialogControl getDialogControl()
           
protected abstract  void init()
          Called when the feature is initializing.
protected  boolean isInitialized()
          Returns true, iff this Feature instance is currently connected to a DialogControl and wether the init(), nor the dispose() methods are running.
protected  void prepare()
          Called when the dialog is prepared.
protected  void release()
          Called when the dialog is released.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractFeature

public AbstractFeature()
Creates a new AbstractFeature.

Note: After calling the constructor, it's important to call the features attachDialogControl(DialogControl) method (normally done by the DialogControl's reqireFeature() or installFeature() methods) to connect the feature to the lifecycle of that dialog. In this case the init() method of this feature will be called first (to enable initialization) and then - depending on the dialog's state - the other lifecycle methods will be called as necessary.

Method Detail

attachDialogControl

public final void attachDialogControl(DialogControl dialogControl)
Description copied from interface: Feature
Attaches the lifecycle of the Feature to the lifecycle of the DialogControl given. The feature must not be attached twice.

Note: This method has to be called after the feature was completely created.

Specified by:
attachDialogControl in interface Feature
See Also:
Feature.attachDialogControl(com.sdm.quasar.client.core.dialog.DialogControl)

isInitialized

protected boolean isInitialized()
Returns true, iff this Feature instance is currently connected to a DialogControl and wether the init(), nor the dispose() methods are running.


getDialogControl

protected final DialogControl getDialogControl()
Returns:
the dialog's access to the dialog environment

init

protected abstract void init()
Called when the feature is initializing. This is normally done, when the feature is connected to the lifecycle of the DialogControl installed to. To access the DialogControl use the getDialogControl() method.

Override this method to perform some action on initialization e.g. register public services.


dispose

protected abstract void dispose()
                         throws DisposeException
Called when the feature or dialog is disposed. Override this method to clean up resources and free memory when disposing.

Throws:
DisposeException

prepare

protected void prepare()
Called when the dialog is prepared. Override this method if you want to perform some action on LifeCycle.prepare(), e.g. gain resource and provide services for childs.

The default implementation in AbstractFeature does nothing.


activate

protected void activate()
Called when the dialog is activated. Override this method if you want to perform some action on LifeCycle.activate().

The default implementation in AbstractFeature does nothing.


deactivate

protected void deactivate()
Called when the dialog is deactivated. Override this method if you want to perform some action on LifeCycle.deactivate()().

The default implementation in AbstractFeature does nothing.


release

protected void release()
Called when the dialog is released. Override this method if you want to perform some action on LifeCycle.release()(), e.g. unregister services.

The default implementation in AbstractFeature does nothing.


collectSystemInfo

public void collectSystemInfo(SystemInfoNode root,
                              SystemInfoOptions options)
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. Subclasses should overwrite this method to append system informations

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)

disposeFeature

public final void disposeFeature()
                          throws DisposeException
Description copied from interface: Feature
Detaches the lifecycle of the Feature from the lifecycle of the DialogControl previouse given and disposes the feature. After calling this method must not be used again. Also attaching to a DialogControl is forbidden after calling this method.

Specified by:
disposeFeature in interface Feature
Throws:
DisposeException
See Also:
Disposable.dispose()