IBM Branch Transformation Toolkit Javadoc

com.ibm.btt.cha.ejb
Class CHAInstanceBean

java.lang.Object
  extended bycom.ibm.btt.cha.ejb.CHAInstanceBean
All Implemented Interfaces:
javax.ejb.EnterpriseBean, javax.ejb.EntityBean, java.io.Serializable
Direct Known Subclasses:
CHAInstanceForRootBean, CHAInstanceForSessionBean

public abstract class CHAInstanceBean
extends java.lang.Object
implements javax.ejb.EntityBean

Bean implementation class for Enterprise Bean: CHAInstance

See Also:
Serialized Form

Constructor Summary
CHAInstanceBean()
           
 
Method Summary
 void addElement(java.io.Serializable anElement)
          Adds an element to the Context
 void clearKeyedCollection()
          Clears the context (current level only) by destroying the current keyed collection associated and replacing it with a new one.
 void clearKeyedCollection(boolean keepKCollStatus, boolean clearOnlyValues)
          This method clears both the typed and non-typed elements in the context keyed collection.
 void ejbActivate()
          ejbActivate
 java.lang.String ejbCreate(java.lang.String instanceID)
          ejbCreate
 java.lang.String ejbCreate(java.lang.String instanceID, java.lang.String parentID, java.lang.String contextName, java.lang.String typeName, boolean isRoot, Context aContext)
          ejbCreate
 void ejbLoad()
          ejbLoad
 void ejbPassivate()
          ejbPassivate
 void ejbPostCreate(java.lang.String instanceID)
          ejbPostCreate
 void ejbPostCreate(java.lang.String instId, java.lang.String parentId, java.lang.String ctxName, java.lang.String typeName, boolean isRoot, Context aContext)
          ejbPostCreate (custom)
 void ejbRemove()
          ejbRemove
 void ejbStore()
          ejbStore
 Vector fields()
          Returns all the data fields, which are addressable from this context.
 void forChainTo(java.lang.String parentInstanceID)
          Chains this context to the context named specified by parentInstanceID.
 void forUnchain()
          Removes this context and all its children from the context tree.
 java.lang.String getAncestorByName(java.lang.String aContextName)
          Searches the context tree for an ancestor Context named aContextName and returns the first matching context.
abstract  byte[] getContext()
          Get accessor for persistent attribute: context
 java.lang.String getContextByType(java.lang.String aTypeName)
          Returns the instanceID of the first context that matches its type to aTypeName.
 java.io.Serializable getElementAt(java.lang.String aCompositeKey, boolean isReadOnly)
          Returns the element of its keyedCollection,or keyedCollections of the upper contexts which is located at aCompositeKey path.
 javax.ejb.EntityContext getEntityContext()
          getEntityContext
abstract  java.lang.String getInstanceID()
          Get accessor for persistent attribute: instanceID
abstract  boolean getIsRoot()
          Get accessor for persistent attribute: isRoot
 KeyedCollection getKeyedCollection()
          Returns the keyedCollection attribute.
 java.lang.String getLevel()
          We can define an attribute --level-- in dsectxt.xml file to indicate level of the context.
abstract  java.lang.String getName()
          Get accessor for persistent attribute: name
abstract  java.lang.String getParentID()
          Get accessor for persistent attribute: parentID
 Context getRealContext()
          Returns the _context.
 java.lang.String getTagName()
          Returns a String used by the externalizer.
abstract  java.lang.String getTypeName()
          Get accessor for persistent attribute: typeName
 boolean isAddToDynamicKColl()
          Returns the value of the addToDynamicKColl property.
 boolean isChained()
          return true/false based on the existence of a parent ID
 boolean isReadOnly()
          If the definition of this context in dsetxt.xml has the attribute readonly="true", this method will return true, otherwise, false is returned.
 DataElement removeAt(java.lang.String aCompositeKey)
          Removes aCompositeKey element of its keyedCollection.
 DataElement removeAtAnyLevel(java.lang.String aCompositeKey)
          Removes an element of its keyedCollection, or the keyedCollections in the upper contexts, located in the aCompositeKey path.
 void setAddToDynamicKColl(boolean newValue)
          Sets the value of the addToDynamicKColl property.
abstract  void setContext(byte[] newContext)
          Set accessor for persistent attribute: context
 void setEntityContext(javax.ejb.EntityContext ctx)
          setEntityContext
abstract  void setInstanceID(java.lang.String newInstanceID)
          Set accessor for persistent attribute: instanceID
abstract  void setIsRoot(boolean newIsRoot)
          Set accessor for persistent attribute: isRoot
 void setKCollDynamic(boolean aValue)
          Set the value to the attribute dynamic for the keyedCollection in this context.
 void setKeyedCollection(java.io.Serializable akeyedCollection)
          set the context's KeyedCollection.
abstract  void setName(java.lang.String newName)
          Set accessor for persistent attribute: name
abstract  void setParentID(java.lang.String newParentID)
          Set accessor for persistent attribute: parentID
 void setRealContext(Context context)
          Sets the _context.
abstract  void setTypeName(java.lang.String newTypeName)
          Set accessor for persistent attribute: typeName
 int setValueAt(SortedTable aSortedTable)
          The function is similiar to setValueAt(String, Object) except that set pairs of keys and values stored in aSortedTable via one method.
 void setValueAt(java.lang.String aKey, java.io.Serializable aValue)
          Adds a value to the Context Sets the value of the element of its keyedCollection, or keyedCollections of the upper contexts, located in the aCompositeKey path.
 Vector toStrings()
          Returns a visual representation of this context.
 int trySetElementAt(java.lang.String aCompositeKey, java.io.Serializable aValue)
          Set the value of the element of its keyedCollection, or keyedCollections of the upper contexts which is located at aCompositeKey path.
 void unsetEntityContext()
          unsetEntityContext
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CHAInstanceBean

public CHAInstanceBean()
Method Detail

setEntityContext

public void setEntityContext(javax.ejb.EntityContext ctx)
setEntityContext

Specified by:
setEntityContext in interface javax.ejb.EntityBean

getEntityContext

public javax.ejb.EntityContext getEntityContext()
getEntityContext


unsetEntityContext

public void unsetEntityContext()
unsetEntityContext

Specified by:
unsetEntityContext in interface javax.ejb.EntityBean

ejbCreate

public java.lang.String ejbCreate(java.lang.String instanceID)
                           throws javax.ejb.CreateException
ejbCreate

Throws:
javax.ejb.CreateException

ejbPostCreate

public void ejbPostCreate(java.lang.String instanceID)
                   throws javax.ejb.CreateException
ejbPostCreate

Throws:
javax.ejb.CreateException

ejbActivate

public void ejbActivate()
ejbActivate

Specified by:
ejbActivate in interface javax.ejb.EntityBean

ejbLoad

public void ejbLoad()
ejbLoad

Specified by:
ejbLoad in interface javax.ejb.EntityBean

ejbPassivate

public void ejbPassivate()
ejbPassivate

Specified by:
ejbPassivate in interface javax.ejb.EntityBean

ejbRemove

public void ejbRemove()
               throws javax.ejb.RemoveException
ejbRemove

Specified by:
ejbRemove in interface javax.ejb.EntityBean
Throws:
javax.ejb.RemoveException

ejbStore

public void ejbStore()
ejbStore

Specified by:
ejbStore in interface javax.ejb.EntityBean

getInstanceID

public abstract java.lang.String getInstanceID()
Get accessor for persistent attribute: instanceID


setInstanceID

public abstract void setInstanceID(java.lang.String newInstanceID)
Set accessor for persistent attribute: instanceID


getName

public abstract java.lang.String getName()
Get accessor for persistent attribute: name


setName

public abstract void setName(java.lang.String newName)
Set accessor for persistent attribute: name


getParentID

public abstract java.lang.String getParentID()
Get accessor for persistent attribute: parentID


setParentID

public abstract void setParentID(java.lang.String newParentID)
Set accessor for persistent attribute: parentID


getContext

public abstract byte[] getContext()
Get accessor for persistent attribute: context


setContext

public abstract void setContext(byte[] newContext)
Set accessor for persistent attribute: context


ejbCreate

public java.lang.String ejbCreate(java.lang.String instanceID,
                                  java.lang.String parentID,
                                  java.lang.String contextName,
                                  java.lang.String typeName,
                                  boolean isRoot,
                                  Context aContext)
                           throws javax.ejb.CreateException
ejbCreate

Throws:
javax.ejb.CreateException

ejbPostCreate

public void ejbPostCreate(java.lang.String instId,
                          java.lang.String parentId,
                          java.lang.String ctxName,
                          java.lang.String typeName,
                          boolean isRoot,
                          Context aContext)
ejbPostCreate (custom)


addElement

public void addElement(java.io.Serializable anElement)
                throws CHAException
Adds an element to the Context

Throws:
CHAException

forChainTo

public void forChainTo(java.lang.String parentInstanceID)
                throws CHAException
Chains this context to the context named specified by parentInstanceID. This method throws an CHAException if this context does not exist.

Throws:
CHAException

isChained

public boolean isChained()
                  throws CHAException
return true/false based on the existence of a parent ID

Throws:
CHAException

setAddToDynamicKColl

public void setAddToDynamicKColl(boolean newValue)
                          throws CHAException
Sets the value of the addToDynamicKColl property.

Parameters:
newValue - boolean The new value of the property.
Throws:
CHAException

setValueAt

public void setValueAt(java.lang.String aKey,
                       java.io.Serializable aValue)
                throws CHAException
Adds a value to the Context Sets the value of the element of its keyedCollection, or keyedCollections of the upper contexts, located in the aCompositeKey path. When the KeyedCollection of the Context is dynamic, this method has different behavior depending on value of addToDynamicKColl property. If addToDynamicKColl is false, this method first looks for the aCompositekey element in the hierarchy. If the method finds it, the method modifies its value. If the method does not find the element, the method creates it dynamically. When addToDynamicKColl is true, this method either creates a new element in the current context or overwrites the existing element without checking the existence of the element in upper contexts.

Throws:
CHAException

trySetElementAt

public int trySetElementAt(java.lang.String aCompositeKey,
                           java.io.Serializable aValue)
                    throws CHAException
Set the value of the element of its keyedCollection, or keyedCollections of the upper contexts which is located at aCompositeKey path. If the dataElement can be found in the current context or its upper contexts, set its value and return int 1. Otherwise, return -1 saying this dataElement does not exist.

Throws:
CHAException

getElementAt

public java.io.Serializable getElementAt(java.lang.String aCompositeKey,
                                         boolean isReadOnly)
                                  throws CHAException
Returns the element of its keyedCollection,or keyedCollections of the upper contexts which is located at aCompositeKey path.

Throws:
CHAException

setKeyedCollection

public void setKeyedCollection(java.io.Serializable akeyedCollection)
                        throws CHAException
set the context's KeyedCollection. Warning: parameter value can be large. Also any existing keyedCollection in the Context object is immediately replaced.

Throws:
CHAException

clearKeyedCollection

public void clearKeyedCollection()
                          throws CHAException
Clears the context (current level only) by destroying the current keyed collection associated and replacing it with a new one.

Throws:
CHAException

clearKeyedCollection

public void clearKeyedCollection(boolean keepKCollStatus,
                                 boolean clearOnlyValues)
                          throws CHAException
This method clears both the typed and non-typed elements in the context keyed collection. It can clear only the elements of the kColl and keep the kColl attributes. For the kColl elements it is possible to clear only the values or to clear all the attributes.

Parameters:
keepKCollStatus - boolean (false - clear also the context kColl attributes; true - keep the context kColl attributes and clear only the kColl data elements)
clearOnlyValues - boolean (false - clear all attributes of the context kColl data elements; true - clear only kColl data elements values)
Throws:
java.io.IOException - - If keepKCollStatus or clearOnlyValues are false and the keyed collection has not been defined in the generic data file or in the generic types file
CHAException

getRealContext

public Context getRealContext()
Returns the _context.

Returns:
com.ibm.btt.base.Context

setRealContext

public void setRealContext(Context context)
Sets the _context.


fields

public Vector fields()
              throws CHAException
Returns all the data fields, which are addressable from this context. This includes all the data fields of this context and the upper context.

Returns:
Vector
Throws:
CHAException

getKeyedCollection

public KeyedCollection getKeyedCollection()
                                   throws CHAException
Returns the keyedCollection attribute.

Throws:
CHAException

getAncestorByName

public java.lang.String getAncestorByName(java.lang.String aContextName)
                                   throws CHAException
Searches the context tree for an ancestor Context named aContextName and returns the first matching context.

Parameters:
aContextName - java.lang.String
Returns:
String instanceID
Throws:
CHAException

getContextByType

public java.lang.String getContextByType(java.lang.String aTypeName)
                                  throws CHAException
Returns the instanceID of the first context that matches its type to aTypeName.

Throws:
CHAException

isAddToDynamicKColl

public boolean isAddToDynamicKColl()
                            throws CHAException
Returns the value of the addToDynamicKColl property.

Returns:
boolean - The current value of addToDynamicKColl
Throws:
CHAException

toStrings

public Vector toStrings()
Returns a visual representation of this context.

Returns:
Vector

getTagName

public java.lang.String getTagName()
                            throws CHAException
Returns a String used by the externalizer.

Returns:
java.lang.String
Throws:
CHAException

forUnchain

public void forUnchain()
                throws CHAException
Removes this context and all its children from the context tree. Also maintains the consistency of the context tree.

Throws:
CHAException

setKCollDynamic

public void setKCollDynamic(boolean aValue)
                     throws CHAException
Set the value to the attribute dynamic for the keyedCollection in this context.

Parameters:
aValue -
Throws:
CHAException

removeAt

public DataElement removeAt(java.lang.String aCompositeKey)
                     throws CHAException
Removes aCompositeKey element of its keyedCollection.

Throws:
CHAException

removeAtAnyLevel

public DataElement removeAtAnyLevel(java.lang.String aCompositeKey)
                             throws CHAException
Removes an element of its keyedCollection, or the keyedCollections in the upper contexts, located in the aCompositeKey path.

Throws:
CHAException

setValueAt

public int setValueAt(SortedTable aSortedTable)
The function is similiar to setValueAt(String, Object) except that set pairs of keys and values stored in aSortedTable via one method. Behind this method, when this context is a distributed context, the pairs of keys and values stored in aSortedTable will be sent to CHA server a time, thus improving performance.

Parameters:
aSortedTable -
Returns:
int = 0 : success int = 1,2,...,n: a value is failed to set which is indicated by return int value. For example, if return value is 1, the first value in aSortedTable can not be set successfully. if return value is 2, the first value is set successfully, but the second value is failed to be set and subsequent pairs of the keys and values will not be set .

isReadOnly

public boolean isReadOnly()
                   throws CHAException
If the definition of this context in dsetxt.xml has the attribute readonly="true", this method will return true, otherwise, false is returned.

Returns:
boolean
Throws:
CHAException

getLevel

public java.lang.String getLevel()
                          throws CHAException
We can define an attribute --level-- in dsectxt.xml file to indicate level of the context. The context can be devided into three levels:root, session, normal.

Returns:
"root", "session", "normal". If this attribute is not difined, return null ;
Throws:
CHAException

getTypeName

public abstract java.lang.String getTypeName()
Get accessor for persistent attribute: typeName


setTypeName

public abstract void setTypeName(java.lang.String newTypeName)
Set accessor for persistent attribute: typeName


getIsRoot

public abstract boolean getIsRoot()
Get accessor for persistent attribute: isRoot


setIsRoot

public abstract void setIsRoot(boolean newIsRoot)
Set accessor for persistent attribute: isRoot


IBM Branch Transformation Toolkit Javadoc

(c) Copyright IBM Corporation 1998, 2005