at.spardat.xma.component
Class ComponentServer

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

public abstract class ComponentServer
extends Component

Representation of a server side component


Field Summary
 
Fields inherited from class at.spardat.xma.component.Component
session_
 
Constructor Summary
ComponentServer()
          This constructor is for test-purpose.
ComponentServer(XMASessionServer session, boolean isStateless, short id)
          Constructor.
 
Method Summary
 void cleanUpAfterServerEvent()
          Removes all stateless pages from this component.
 java.lang.Throwable convertToBaseException(java.lang.Throwable detail)
          This method is always called when an Exception occurred in a server side RPC implementation.
 void dispose()
          Destroys this component and deregisters it with the session.
 int estimateMemory()
          Estimates the number of bytes this object consumes in memory.
 void executeRemoteCall(RemoteCall call, RemoteReply reply, PageServer targetPage, java.lang.reflect.Method targetMethod)
          This method is called for every server side event on a page in this component or on the component itself.
protected  void executeRemoteCallImpl(RemoteCall call, RemoteReply reply, PageServer targetPage, java.lang.reflect.Method targetMethod)
          See executeRemoteCall(at.spardat.xma.rpc.RemoteCall, at.spardat.xma.rpc.RemoteReply, at.spardat.xma.page.PageServer, java.lang.reflect.Method).
 void externalize(XmaOutput xo, boolean forceFull)
          This method produces the delta of the server model changes cumulated in the course of executing a server side event.
 XMASessionServer getSession()
          Returns the Session this belongs to (you can rely on the returned object not to be null).
 void internalize(XmaInput in)
          This is the partner operation of ComponentClient.externalize(at.spardat.xma.serializer.XmaOutput, boolean).
 PageServer newPageModel(short typeId)
          Constructs a page for a given type id
 void registerServerPage(PageServer page, short id)
          Registers a Page with the Component where the caller provides an id.
protected  boolean removePageModel(short idPageModel)
          Removes a page model with a given id.
 
Methods inherited from class at.spardat.xma.component.Component
commit, describe, externalizePageSet, externalizeProperties, getId, getModelClass, getName, getNumPageModels, getPageModel, getPageModels, getPropDes, getPropDes, getSCN, incrementSCN, internalizePageSet, internalizeProperties, isPageModelAlive, isStateless, model2props, props2model, registerPageModel, rollback, setId, setSCN, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ComponentServer

public ComponentServer(XMASessionServer session,
                       boolean isStateless,
                       short id)
Constructor. Registers this with the session.

Parameters:
session - the session this component will belong to.
isStateless - defines whether this component is stateless or not.
id - the id of the component as transmitted from the client.

ComponentServer

public ComponentServer()
This constructor is for test-purpose. It is not intended to be called from other classes except JUnit-Tests.

Method Detail

dispose

public void dispose()
Destroys this component and deregisters it with the session.


externalize

public void externalize(XmaOutput xo,
                        boolean forceFull)
                 throws java.io.IOException
This method produces the delta of the server model changes cumulated in the course of executing a server side event. This information will be read by ComponentClient.internalize(at.spardat.xma.serializer.XmaInput).

The forceFull parameter is ignored since we always produce deltas.

Parameters:
xo - the serialization destination
forceFull - if true, the complete state is written and deltas are ignored.
Throws:
java.io.IOException - on serialization errors
See Also:
Synchronization.externalize(at.spardat.xma.serializer.XmaOutput, boolean)

internalize

public void internalize(XmaInput in)
                 throws java.io.IOException,
                        java.lang.ClassNotFoundException
This is the partner operation of ComponentClient.externalize(at.spardat.xma.serializer.XmaOutput, boolean). The output stream produces in externalize is processed and applied here to make this server side component look like the client side component.

Parameters:
in - the XMAObjectInput. If a XMAObjectInputChangeListener is set in the object in, it will be notified after applying changes read from in.
Throws:
java.lang.ClassNotFoundException - on serialization errors
java.io.IOException - on serialization errors
See Also:
Synchronization.internalize(at.spardat.xma.serializer.XmaInput)

getSession

public XMASessionServer getSession()
Returns the Session this belongs to (you can rely on the returned object not to be null).


executeRemoteCall

public void executeRemoteCall(RemoteCall call,
                              RemoteReply reply,
                              PageServer targetPage,
                              java.lang.reflect.Method targetMethod)
This method is called for every server side event on a page in this component or on the component itself. The default implementation is to call the method executeRemoteCallImpl, which actually calls the right method in the page or component. You may overwrite this method in order to correct things like error handling or other stuff you want to do generically at the component level.

Warning: This method must not be called from outside the framework. It may just be overwritten.

Parameters:
call - the RemoteCall objects as sent from the client.
reply - the RemoteReply object that will sent back to the client.
targetPage - if the RemoteCall has been launched in a page, this page is the server page, that will execute the call. If the RemoteCall has been launched from a component, targetPage is null.
targetMethod - the executing method of the page or component.

executeRemoteCallImpl

protected void executeRemoteCallImpl(RemoteCall call,
                                     RemoteReply reply,
                                     PageServer targetPage,
                                     java.lang.reflect.Method targetMethod)
See executeRemoteCall(at.spardat.xma.rpc.RemoteCall, at.spardat.xma.rpc.RemoteReply, at.spardat.xma.page.PageServer, java.lang.reflect.Method). This method must not be called or overwritten outside the framework.


convertToBaseException

public java.lang.Throwable convertToBaseException(java.lang.Throwable detail)
This method is always called when an Exception occurred in a server side RPC implementation. The default behauvior is that the argument is simply returned. This method can be overridden to implement project specific Exception type handling. Typically these are conversions from an Exception (as it was thrown) to a BaseException (with the possible additional setting of a code or a message etc.) The Exception returned by this method will be handeled by the XMA framework. A BaseException is transfered to the client, others are converted to a SysException and then transfered.

Parameters:
detail - the Exception to convert
Returns:
a converted Exception, it really only makes sense to convert to a BaseException.
Since:
version_number

cleanUpAfterServerEvent

public void cleanUpAfterServerEvent()
Removes all stateless pages from this component.

This method must not be called from outside the framework. It also must not be overwritten.


estimateMemory

public int estimateMemory()
Estimates the number of bytes this object consumes in memory.


newPageModel

public PageServer newPageModel(short typeId)
Constructs a page for a given type id


registerServerPage

public void registerServerPage(PageServer page,
                               short id)
Registers a Page with the Component where the caller provides an id. Is used at the server, when pages are transmitted from the client where the server knows the id.

Parameters:
page - the Page to register.
id - the id to assign
Throws:
java.lang.IllegalStateException - a page with the given id is already registered.

removePageModel

protected boolean removePageModel(short idPageModel)
Removes a page model with a given id. Extends the superclass-remove by deleting the parent child relationship.

Overrides:
removePageModel in class Component
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.