at.spardat.xma.component
Class Component

java.lang.Object
  extended byat.spardat.xma.component.Component
All Implemented Interfaces:
Descriptive, Synchronization
Direct Known Subclasses:
ComponentClient, ComponentServer

public abstract class Component
extends java.lang.Object
implements Synchronization, Descriptive

This class implements the comon base for Components on the client side and on the server side. This is mostly the live-cycle-management of the PageModels.


Field Summary
protected  XMASession session_
          The session this component belongs to.
 
Constructor Summary
Component()
          This is a noop-constructor for test-purpose.
Component(XMASession session, boolean isStateless, boolean isAtServer)
          Constructor
 
Method Summary
 void commit()
          Calls commit on every page in this component.
 void describe(DNode n)
          describe puts all relevant information about this into the provided node.
protected  void externalizePageSet(java.util.HashSet pages, XmaOutput xo, boolean forceFull)
          Writes a set of pages to the output stream.
protected  void externalizeProperties(XmaOutput xo, boolean forceFull)
          Writes the property model to xout.
 short getId()
          Returns the id of this component.
abstract  java.lang.String getModelClass(short typeId)
          Gets the full classname for the given typeId of a page in the component.
 java.lang.String getName()
          Returns the short name of this component.
 int getNumPageModels()
          Gets the number of registered PageModels in this Component.
 Page getPageModel(short idPage)
          Gets the Page with the given ID.
 java.util.Iterator getPageModels()
          Gets an Iterator to iterate over all living PageModels.
protected  ComponentProperty[] getPropDes()
           
protected  ComponentProperty getPropDes(java.lang.String name)
          Gets the descriptor of a given property Only properties defined in the guidesigner for this component are found by this method.
 short getSCN()
          Returns the server change number.
 void incrementSCN()
          Increments the server change number.
protected  void internalizePageSet(XmaInput xi)
          Reads the information produces via externalizePageSet and applies the changes to the models.
protected  void internalizeProperties(XmaInput xi)
          Restores property model externalized via externalizeProperties.
 boolean isPageModelAlive(short idPageModel)
          Indicates if there exists an active Page with the given ID.
 boolean isStateless()
          Returns true if this Component is stateless.
 void model2props()
          Sets the properties from the values in the propModel.
 void props2model()
          modifies the propModel so that the value of the cell (i,0) equals the ith property of this component.
 void registerPageModel(Page model)
          Registers the given Page in the Component and assignes a unique ID to it.
protected  boolean removePageModel(short idPageModel)
          Removes a page model with a given id.
 void rollback()
          Calls rollback on every page in this component.
 void setId(short s)
          Sets the id of this component.
 void setSCN(short s)
          Sets the server change number.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface at.spardat.xma.mdl.Synchronization
externalize, internalize
 

Field Detail

session_

protected XMASession session_
The session this component belongs to. Never null.

Constructor Detail

Component

public Component(XMASession session,
                 boolean isStateless,
                 boolean isAtServer)
Constructor

Parameters:
session - the XMASession this component belongs to
isStateless - defines if this component is stateless
isAtServer - indicates if this component executes at the server side

Component

public Component()
This is a noop-constructor for test-purpose.

Method Detail

isStateless

public boolean isStateless()
Returns true if this Component is stateless. Stateless Components do not consume space at the server before and after a server side event.


registerPageModel

public void registerPageModel(Page model)
Registers the given Page in the Component and assignes a unique ID to it. A page must be registered at the time its models are created. After registration, the Page will be syncronized between client and server every time a serverEvent occures until the page is removed.

The assigned id is also stored in the page (via Page.setId()).

Parameters:
model - the Page to register.
Throws:
IllegalStateExecption - if the page is already registered.

getPageModel

public Page getPageModel(short idPage)
Gets the Page with the given ID. The Page exists, if it has been registered and not removed yet.

Parameters:
idPage - the ID of the desired Page.
Returns:
the Page with the given ID or null if there exists no Page for the given ID.

isPageModelAlive

public boolean isPageModelAlive(short idPageModel)
Indicates if there exists an active Page with the given ID. The Page is alive, if it has been registered and not removed yet.

Parameters:
idPageModel - the ID of the Page
Returns:
true if the Page with the given ID is alive false otherwise.

removePageModel

protected boolean removePageModel(short idPageModel)
Removes a page model with a given id. The model aspect of this page effectively is dead afterwards. The data stored in widget models on this page is lost.

Parameters:
idPageModel - the id of the model to remove
Returns:
true if successfully removed, false if there does not exist a page model with the provided id.

getNumPageModels

public int getNumPageModels()
Gets the number of registered PageModels in this Component.

Returns:
the number of PageModels registered but not removed yet.

getPageModels

public java.util.Iterator getPageModels()
Gets an Iterator to iterate over all living PageModels.

Returns:
an Iterator to iterate over all living PageModels.

getModelClass

public abstract java.lang.String getModelClass(short typeId)
Gets the full classname for the given typeId of a page in the component. This method will be implemented by the generated class for each component.

Parameters:
typeId - the unique typeId
Returns:
the full classname

externalizePageSet

protected void externalizePageSet(java.util.HashSet pages,
                                  XmaOutput xo,
                                  boolean forceFull)
                           throws java.io.IOException
Writes a set of pages to the output stream.

Parameters:
pages - the set of pages
xo - the output stream
forceFull - if true, all pages with all widget models are written. If false, only changed pages and within these pages only changed widget models are written.
Throws:
java.io.IOException

internalizePageSet

protected void internalizePageSet(XmaInput xi)
                           throws java.io.IOException,
                                  java.lang.ClassNotFoundException
Reads the information produces via externalizePageSet and applies the changes to the models.

This method requires that all pages whose information will be read out of the stream are already created.

Parameters:
xi - the object input stream
Throws:
java.io.IOException - on serialization errors
java.lang.ClassNotFoundException - on serialization errors

externalizeProperties

protected void externalizeProperties(XmaOutput xo,
                                     boolean forceFull)
                              throws java.io.IOException
Writes the property model to xout.

Parameters:
xo - output-stream
forceFull - ignore deltas
Throws:
java.io.IOException

props2model

public void props2model()
modifies the propModel so that the value of the cell (i,0) equals the ith property of this component.

This method must be called from outside the XMA-framework.


model2props

public void model2props()
Sets the properties from the values in the propModel. The setter of the property is not called if the value did not change. Warning: Setting the value of properties at the XMA client may trigger change-notifications and therefore may terminate with various runtime exceptions.

This method must not be called from outside the XMA-framework.


internalizeProperties

protected void internalizeProperties(XmaInput xi)
                              throws java.io.IOException,
                                     java.lang.ClassNotFoundException
Restores property model externalized via externalizeProperties.

Parameters:
xi - input stream
Throws:
java.io.IOException
java.lang.ClassNotFoundException

describe

public void describe(DNode n)
Description copied from interface: Descriptive
describe puts all relevant information about this into the provided node. The implementing method may construct subnodes of node.

Specified by:
describe in interface Descriptive
Parameters:
n - the node going to hold information about this.
See Also:
Descriptive.describe(at.spardat.xma.mdl.util.DNode)

toString

public java.lang.String toString()
See Also:
Object.toString()

getId

public short getId()
Returns the id of this component.


setId

public void setId(short s)
Sets the id of this component. This method must not be called from outside the XMA-framework.


getName

public java.lang.String getName()
Returns the short name of this component. The short name uniquely identifies a component type within an XMA application. Furthermore, the shortname equals the last component in the components fully qualified class name.


getSCN

public short getSCN()
Returns the server change number.


setSCN

public void setSCN(short s)
Sets the server change number.


incrementSCN

public void incrementSCN()
Increments the server change number.


commit

public void commit()
Calls commit on every page in this component. This method must not be called from outside the framework, nor overwritten.


rollback

public void rollback()
Calls rollback on every page in this component. This method must not be called from outside the framework, nor overwritten.


getPropDes

protected ComponentProperty[] getPropDes()
Returns:
the descriptors of all properties of this component. null if no properties are defined for the component in the guidesigner .

getPropDes

protected ComponentProperty getPropDes(java.lang.String name)
Gets the descriptor of a given property Only properties defined in the guidesigner for this component are found by this method.

Parameters:
name - the name of the property to find
Returns:
the descriptor of the property with the given name