au.gov.tas.dpiwe.mr.test
Class MrExampleBean

java.lang.Object
  extended by au.gov.tas.dpiwe.mr.bean.NullBean
      extended by au.gov.tas.dpiwe.mr.bean.DebugBean
          extended by au.gov.tas.dpiwe.mr.test.ExampleBean
              extended by au.gov.tas.dpiwe.mr.test.MrExampleBean
All Implemented Interfaces:
BeanWrapper, ClientManagedLocalObject, CloningUtilities, SimpleValidator, WrappedBean, ContainerChangeListener, ExampleBeanObject, Dirtyable, Serializable, EventListener, EJBLocalObject, EnterpriseBean, EntityBean

public final class MrExampleBean
extends ExampleBean
implements ExampleBeanObject, BeanWrapper, CloningUtilities

This is an implementation of the abstract ExampleBean class which wraps a ThinExampleBean with container-based persistence logic.

Version:
1.0.6.1
Author:
Kade Hansson, au.gov.tas.dpiwe.mr.tool.DeploymentTool
See Also:
Serialized Form

Field Summary
static boolean nullStringEqualsEmptyString
          For the purposes of keeping the dirty flag up to date, an empty string is considered equal to the null value.
 
Fields inherited from class au.gov.tas.dpiwe.mr.bean.DebugBean
context, type, wrapper
 
Constructor Summary
MrExampleBean(Container container, ThinExampleBean underlyingBean)
          Construct a new bean object.
MrExampleBean(Container container, ThinExampleBean underlyingBean, boolean cloned)
          Construct a new bean object.
 
Method Summary
 boolean areRelativesPersistent()
          Checks the direct and indirect relationships to determine whether they are all reflected in persistent storage.
 Object clone()
          Produces a shallow copy of this bean object.
 Object deepClone()
          Produces a deep copy of this bean object.
 Object deeperClone()
          Produces a deeper copy of this bean object than deepClone().
 Object ejbCreate(Object primaryKey)
          Informs a bean of the primary key identity it will be assigned.
 void ejbPostCreate(Object primaryKey)
          Informs a bean that it has been assigned identity.
 Color getColour()
          Accessor method for the colour property.
 EJBLocalHome getEJBLocalHome()
          Gets the home interface implementation instance for this bean object.
 Container getEnclosingContainer()
          Gets the container to which this bean object belongs.
 Object getPrimaryKey()
          Gets the primary key of this bean object.
 float getQuality()
          Accessor method for the quality property.
 String getShape()
          Accessor method for the shape property.
 EntityBean getUnderlyingBean()
          Gets the ThinExampleBean entity bean underlying this bean object.
 Object invokeOnServer(Method method, Object[] parameters)
          Executes a method of this bean on the server.
 boolean isCloned()
          Checks if this bean object is cloned.
 boolean isDirty()
          Checks whether this bean has been changed since it was last synchronized with persistent storage.
 boolean isDummy()
          Indicates that this bean is a placeholder and can never be synchronized with persistent storage.
 boolean isIdentical(EJBLocalObject other)
          Tests if a given bean object is identical to the invoked bean object.
 boolean isPersistent()
          Checks if this business object exists in persistent storage.
 boolean isShallow()
          Checks if this bean object is a shallow clone.
 void load()
          Loads a business object from persistent storage into this bean object.
 void loadSister()
          Loads a business object from persistent storage into this bean object while maintaining relationships across shallow clones.
 boolean lock()
          Attempts to acquire the mutual exclusion lock on this bean.
 void makeDirty()
          Flags that this bean is not synchronized with persistent storage.
 void makeDummy()
          Flags that this bean object is a placeholder for data only.
 void markCloned()
          Marks this bean as cloned.
 void polish()
          Compares the scratched bean to the polished bean and recalculates dirtiness.
 void release()
          Releases the mutual exclusion lock held for this bean.
 void remove()
          Removes the business object from persistent storage.
 void removeUnrelated()
          Removes business objects which have been explicitly unrelated from this business object from persistent storage.
 void removeUnrelatedFromRelated()
          Removes business objects which have been explicitly unrelated from the relatives and recently unrelated relatives of this business object from persistent storage.
 Map restoreUnrelated()
          Restores business objects which have been explicitly unrelated from this business object, effectively undoing any unrelator calls.
 Map restoreUnrelatedToRelated()
          Restores business objects which have been explicitly unrelated from the relatives of this business object, effectively undoing any unrelator calls to them.
 void scratch()
          Marks this bean for use as scratch space- as a scratched bean, if you will.
 void setColour(Color colour)
          Sets the value of the colour property.
 void setQuality(float quality)
          Sets the value of the quality property.
 void setShape(String shape)
          Sets the value of the shape property.
 EJBLocalObject setUnderlyingBean(EntityBean bean)
          Internal method which sets the ThinExampleBean entity bean underlying this bean object.
 void simpleValidate()
          Makes simple data validity checks for this bean based on the MetaData associated with the home.
 void store()
          Stores the business object in persistent storage if it has changed since it was last synchronized.
 void storeWithRelated()
          Stores the business object in persistent storage if it has changed since it was last synchronized, as well as any related objects changed since they were last synchronized.
 void unrelateAll()
          Removes all beans from one to zero or more relationships for which unrelate...() methods are defined.
 void unrelateAllInFlatMap(Map relationshipUnrelatedTable)
          Does a bulk removal of business objects from relationships.
 void unrelateAllInNestedMapFromRelated(Map relationshipParticipantUnrelatedTable)
          Does a bulk removal of business objects from the relationships of all business objects related to this one.
 Object writeReplace()
          Returns a new SerializableBeanObject with this bean as its underlyingObject.
 
Methods inherited from class au.gov.tas.dpiwe.mr.test.ExampleBean
businessMethod, ejbCreate, ejbPostCreate, validate
 
Methods inherited from class au.gov.tas.dpiwe.mr.bean.DebugBean
containerChanged, ejbActivate, ejbLoad, ejbPassivate, ejbRemove, ejbStore, getBeanObject, setEntityContext, unsetEntityContext
 
Methods inherited from class au.gov.tas.dpiwe.mr.bean.NullBean
throwEJBException
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface au.gov.tas.dpiwe.mr.test.ExampleBeanObject
businessMethod, validate
 
Methods inherited from interface javax.ejb.EntityBean
ejbActivate, ejbLoad, ejbPassivate, ejbRemove, ejbStore, setEntityContext, unsetEntityContext
 

Field Detail

nullStringEqualsEmptyString

public static final boolean nullStringEqualsEmptyString
For the purposes of keeping the dirty flag up to date, an empty string is considered equal to the null value.

See Also:
Constant Field Values
Constructor Detail

MrExampleBean

public MrExampleBean(Container container,
                     ThinExampleBean underlyingBean,
                     boolean cloned)
Construct a new bean object.

Parameters:
container - the container to which the new bean object belongs.
underlyingBean - the ThinExampleBean entity bean underlying the new bean object.
cloned - true to indicate that this bean is a clone.

MrExampleBean

public MrExampleBean(Container container,
                     ThinExampleBean underlyingBean)
Construct a new bean object.

Parameters:
container - the container to which the new bean object belongs.
underlyingBean - the ThinExampleBean entity bean underlying the new bean object.
Method Detail

getEnclosingContainer

public Container getEnclosingContainer()
Gets the container to which this bean object belongs.

Specified by:
getEnclosingContainer in interface BeanWrapper
Returns:
the container to which this bean object belongs.

getUnderlyingBean

public EntityBean getUnderlyingBean()
Gets the ThinExampleBean entity bean underlying this bean object.

Specified by:
getUnderlyingBean in interface BeanWrapper
Returns:
the ThinExampleBean entity bean underlying this bean object.

setUnderlyingBean

public EJBLocalObject setUnderlyingBean(EntityBean bean)
Internal method which sets the ThinExampleBean entity bean underlying this bean object.

Specified by:
setUnderlyingBean in interface BeanWrapper
Parameters:
bean - the ThinExampleBean entity bean to wrap with this object.
Returns:
this bean object.

getEJBLocalHome

public EJBLocalHome getEJBLocalHome()
                             throws EJBException
Gets the home interface implementation instance for this bean object.

Specified by:
getEJBLocalHome in interface EJBLocalObject
Returns:
the home interface implementation instance for this bean object.
Throws:
EJBException - if something goes wrong.

getPrimaryKey

public Object getPrimaryKey()
                     throws EJBException
Gets the primary key of this bean object.

Specified by:
getPrimaryKey in interface BeanWrapper
Specified by:
getPrimaryKey in interface EJBLocalObject
Returns:
the primary key of this bean object.
Throws:
EJBException - if something goes wrong.

simpleValidate

public void simpleValidate()
                    throws EJBException
Makes simple data validity checks for this bean based on the MetaData associated with the home.

Specified by:
simpleValidate in interface SimpleValidator
Overrides:
simpleValidate in class DebugBean
Throws:
ValidateException - if the data in this bean is invalid under these checks.
EJBException

isPersistent

public boolean isPersistent()
Checks if this business object exists in persistent storage.

Specified by:
isPersistent in interface ClientManagedLocalObject
Returns:
true if this business object exists in persistent storage, false otherwise.
Throws:
NoSuchObjectLocalException - if the bean has been removed.

ejbCreate

public Object ejbCreate(Object primaryKey)
                 throws CreateException,
                        EJBException
Informs a bean of the primary key identity it will be assigned. A Mr Architecture bean need not assign this value to the correct field.

Parameters:
primaryKey - the primary key value for this bean.
Returns:
the primary key value for this bean, or null.
Throws:
CreateException - to object to the key value.
EJBException - something unexpected goes wrong.

ejbPostCreate

public void ejbPostCreate(Object primaryKey)
                   throws CreateException,
                          EJBException
Informs a bean that it has been assigned identity.

Parameters:
primaryKey - the primary key value for this bean.
Throws:
CreateException - to object to the assignment of identity.
EJBException - something unexpected goes wrong.

getColour

public Color getColour()
Accessor method for the colour property.

Specified by:
getColour in interface ExampleBeanObject
Specified by:
getColour in class ExampleBean
Returns:
the current value of the colour property.
Throws:
NoSuchObjectLocalException - if the bean has been removed.

getQuality

public float getQuality()
Accessor method for the quality property.

Specified by:
getQuality in interface ExampleBeanObject
Specified by:
getQuality in class ExampleBean
Returns:
the current value of the quality property.
Throws:
NoSuchObjectLocalException - if the bean has been removed.

getShape

public String getShape()
Accessor method for the shape property.

Specified by:
getShape in interface ExampleBeanObject
Specified by:
getShape in class ExampleBean
Returns:
the current value of the shape property.
Throws:
NoSuchObjectLocalException - if the bean has been removed.

setColour

public void setColour(Color colour)
Sets the value of the colour property.

Specified by:
setColour in interface ExampleBeanObject
Specified by:
setColour in class ExampleBean
Parameters:
colour - the new value for the colour property.
Throws:
NoSuchObjectLocalException - if the bean has been removed.

setQuality

public void setQuality(float quality)
Sets the value of the quality property.

Specified by:
setQuality in interface ExampleBeanObject
Specified by:
setQuality in class ExampleBean
Parameters:
quality - the new value for the quality property.
Throws:
NoSuchObjectLocalException - if the bean has been removed.

setShape

public void setShape(String shape)
Sets the value of the shape property.

Specified by:
setShape in interface ExampleBeanObject
Specified by:
setShape in class ExampleBean
Parameters:
shape - the new value for the shape property.
Throws:
NoSuchObjectLocalException - if the bean has been removed.

load

public void load()
          throws EJBException
Loads a business object from persistent storage into this bean object.

If this bean belongs to the client container, this method takes the business object corresponding to this component interface and uses it as the parameter to a load command. The effect is to POST the command immediately to the CommandServlet, irrespective of whether a transaction is being managed on behalf of the calling thread by the enclosing container. The returned version of the entity bean is then immediately assigned as the business object behind this component interface and the previous version is discarded. If the current thread is involved in a transaction, these actions will only occur when the commit() method of the container is called.

If this bean belongs to the server container, a SQL SELECT query is formed to obtain the appropriate record from the database table corresponding to this bean. The entity bean is repopulated with the record data obtained.

Specified by:
load in interface ClientManagedLocalObject
Throws:
EJBException - if something goes wrong.

loadSister

public void loadSister()
                throws EJBException
Loads a business object from persistent storage into this bean object while maintaining relationships across shallow clones.

If this bean belongs to the client container, this method takes the business object corresponding to this component interface and uses it as the parameter to a load command. The effect is to POST the command immediately to the CommandServlet, irrespective of whether a transaction is being managed on behalf of the calling thread by the enclosing container. The returned version of the entity bean is then immediately assigned as the business object behind this component interface and the previous version is discarded. If the current thread is involved in a transaction, these actions will only occur when the commit() method of the container is called.

If this bean belongs to the server container, a SQL SELECT query is formed to obtain the appropriate record from the database table corresponding to this bean. The entity bean is repopulated with the record data obtained.

Specified by:
loadSister in interface ClientManagedLocalObject
Throws:
SisterException - The load took place, but the shared relationships among shallow clones may have been affected in an unexpected way. There are two cases: (a) this bean is the original, in which case only its relationships have been updated (usually undesirable- call loadSister() on a clone instead) or (b) this bean is a shallow clone, but the original bean object cannot be notified of its new relationships because it does not implement the WrappedBean interface (usually undesirable, and correctable by the bean developer) which facilitates communication between "Thin" entity beans and their bean object wrappers.
EJBException - if something else goes wrong.

store

public void store()
           throws EJBException
Stores the business object in persistent storage if it has changed since it was last synchronized.

If this bean belongs to the client container, this method takes the business object corresponding to this component interface and uses it as the parameter to a store command. If the current thread is not involved in a transaction, the effect is to POST the command immediately to the CommandServlet. The returned version is discarded, as it is assumed to contain no new state. If the current thread is involved in a transaction, these actions will only occur when the commit() method of the container is called.

If this bean belongs to the server container, a SQL INSERT or UPDATE query is formed to store the data from this bean in a database record corresponding to it. If the current thread is involved in a transaction, the UPDATE or INSERT query will only be executed when the commit() method of the container is called.

Specified by:
store in interface ClientManagedLocalObject
Throws:
EJBException - if something goes wrong.

storeWithRelated

public void storeWithRelated()
                      throws EJBException
Stores the business object in persistent storage if it has changed since it was last synchronized, as well as any related objects changed since they were last synchronized.

If this bean belongs to the client container, this method takes the business object corresponding to this component interface and uses it as the parameter to a store command. If the current thread is not involved in a transaction, the effect is to POST the command immediately to the CommandServlet. The returned version is discarded, as it is assumed to contain no new state. If the current thread is involved in a transaction, these actions will only occur when the commit() method of the container is called.

If this bean belongs to the server container, a SQL INSERT or UPDATE query is formed to store the data from this bean in a database record corresponding to it. If the current thread is involved in a transaction, the UPDATE or INSERT query will only be executed when the commit() method of the container is called.

Specified by:
storeWithRelated in interface ClientManagedLocalObject
Throws:
EJBException - if something goes wrong.

isDirty

public boolean isDirty()
                throws NoSuchObjectLocalException
Checks whether this bean has been changed since it was last synchronized with persistent storage.

Specified by:
isDirty in interface ClientManagedLocalObject
Specified by:
isDirty in interface Dirtyable
Returns:
true if this bean has been changed and not subsequently stored, false otherwise.
Throws:
NoSuchObjectLocalException - if the bean has been removed.

makeDirty

public void makeDirty()
               throws NoSuchObjectLocalException
Flags that this bean is not synchronized with persistent storage.

Specified by:
makeDirty in interface ClientManagedLocalObject
Specified by:
makeDirty in interface Dirtyable
Throws:
NoSuchObjectLocalException - if the bean has been removed.

scratch

public void scratch()
             throws NoSuchObjectLocalException
Marks this bean for use as scratch space- as a scratched bean, if you will. The data currently in the bean is retained for comparison purposes- this may be visualized as a polished bean.

Specified by:
scratch in interface Dirtyable
Throws:
NoSuchObjectLocalException
See Also:
Dirtyable.polish()

polish

public void polish()
            throws NoSuchObjectLocalException
Compares the scratched bean to the polished bean and recalculates dirtiness. The bean is no longer scratched, but still contains all the scratched data.

Polsihing a bean can only restore the dirty flag if it was changed between the scratch() and polish() calls, and only then if the polished bean is the same as the scratched bean. If the bean was dirty at scratch() time, this call can have no effect.

Specified by:
polish in interface Dirtyable
Throws:
NoSuchObjectLocalException
See Also:
Dirtyable.scratch()

areRelativesPersistent

public boolean areRelativesPersistent()
                               throws EJBException
Checks the direct and indirect relationships to determine whether they are all reflected in persistent storage.

Specified by:
areRelativesPersistent in interface ClientManagedLocalObject
Returns:
true if the relationships reflect persistent storage, false otherwise.
Throws:
NoSuchObjectLocalException - if the bean has been removed.
EJBException

isDummy

public boolean isDummy()
                throws NoSuchObjectLocalException
Indicates that this bean is a placeholder and can never be synchronized with persistent storage.

Specified by:
isDummy in interface ClientManagedLocalObject
Returns:
true if this bean cannot be stored, loaded or removed, false otherwise.
Throws:
NoSuchObjectLocalException - if the bean has been removed.

makeDummy

public void makeDummy()
               throws NoSuchObjectLocalException
Flags that this bean object is a placeholder for data only. It cannot be subsequently removed or synchronized with persistent storage.

Specified by:
makeDummy in interface ClientManagedLocalObject
Throws:
NoSuchObjectLocalException - if the bean has been removed.

invokeOnServer

public Object invokeOnServer(Method method,
                             Object[] parameters)
                      throws EJBException
Executes a method of this bean on the server.

Specified by:
invokeOnServer in interface ClientManagedLocalObject
Parameters:
method - the method to call.
parameters - the parameters to pass to the method.
Returns:
the result of the method call.
Throws:
EJBException - if something goes wrong.

remove

public void remove()
            throws RemoveException,
                   EJBException
Removes the business object from persistent storage.

If this bean belongs to the client container, this method takes the business object corresponding to this component interface and uses it as the parameter to a remove command. If the current thread is not involved in a transaction, the effect is to POST the command immediately to the CommandServlet. The returned version is returned to the pool and the previous version is discarded. If the current thread is involved in a transaction, these actions will only occur when the commit() method of the container is called.

If this bean belongs to the server container, a SQL DELETE query is formed to remove the database record corresponding to it. If the current thread is involved in a transaction, the DELETE query will only be executed when the commit() method of the container is called.

Specified by:
remove in interface EJBLocalObject
Throws:
RemoveException - if removal is disallowed.
EJBException - if something goes wrong.

removeUnrelated

public void removeUnrelated()
                     throws EJBException,
                            RemoveException
Removes business objects which have been explicitly unrelated from this business object from persistent storage.

If this bean belongs to the client container, this method takes each unrelated business object and uses each as the parameter to a remove command. If the current thread is not involved in a transaction, the effect is to POST the commands immediately to the CommandServlet. The returned version is returned to the pool and the previous version is discarded. If the current thread is involved in a transaction, these actions will only occur when the the commit() method of the container is called.

If this bean belongs to the server container, a SQL DELETE query is formed to remove the database records corresponding to each of the unrelated beans. If the current thread is involved in a transaction, each DELETE query will only be executed when the commit() method of the container is called.

Specified by:
removeUnrelated in interface ClientManagedLocalObject
Throws:
EJBException - if something goes wrong.
RemoveException - if removal of one of the unrelated beans is disallowed.

restoreUnrelated

public Map restoreUnrelated()
Restores business objects which have been explicitly unrelated from this business object, effectively undoing any unrelator calls.

For internal use only, and not to be called by external clients.

Specified by:
restoreUnrelated in interface CloningUtilities
Returns:
a map describing the business objects which have been rerelated, where the entries are (relationship name, unrelated object collection).

unrelateAllInFlatMap

public void unrelateAllInFlatMap(Map relationshipUnrelatedTable)
                          throws EJBException
Does a bulk removal of business objects from relationships.

For internal use only, and not to be called by external clients.

Specified by:
unrelateAllInFlatMap in interface CloningUtilities
Parameters:
relationshipUnrelatedTable - a map describing the business objects which are to be unrelated, where the entries are (relationship name, unrelated object collection).
Throws:
EJBException - if something goes wrong.

removeUnrelatedFromRelated

public void removeUnrelatedFromRelated()
                                throws EJBException,
                                       RemoveException
Removes business objects which have been explicitly unrelated from the relatives and recently unrelated relatives of this business object from persistent storage.

If this bean belongs to the client container, this method takes each unrelated business object and uses each as the parameter to a remove command. If the current thread is not involved in a transaction, the effect is to POST the commands immediately to the CommandServlet. The returned version is returned to the pool and the previous version is discarded. If the current thread is involved in a transaction, these actions will only occur when the the commit() method of the container is called.

If this bean belongs to the server container, a SQL DELETE query is formed to remove the database records corresponding to each of the unrelated beans. If the current thread is involved in a transaction, each DELETE query will only be executed when the commit() method of the container is called.

Specified by:
removeUnrelatedFromRelated in interface ClientManagedLocalObject
Throws:
EJBException - if something goes wrong.
RemoveException - if removal of one of the unrelated beans is disallowed.

restoreUnrelatedToRelated

public Map restoreUnrelatedToRelated()
Restores business objects which have been explicitly unrelated from the relatives of this business object, effectively undoing any unrelator calls to them.

For internal use only, and not to be called by external clients.

Specified by:
restoreUnrelatedToRelated in interface CloningUtilities
Returns:
a map describing the business objects which have been rerelated, where the entries are (relationship name, {(related bean object key, ({(relationship name, unrelated object collection)}, {entry}) )} ), where entry is another entry of this form.

unrelateAllInNestedMapFromRelated

public void unrelateAllInNestedMapFromRelated(Map relationshipParticipantUnrelatedTable)
                                       throws EJBException
Does a bulk removal of business objects from the relationships of all business objects related to this one.

For internal use only, and not to be called by external clients.

Specified by:
unrelateAllInNestedMapFromRelated in interface CloningUtilities
Parameters:
relationshipParticipantUnrelatedTable - a map describing the business objects which are to be unrelated, where the entries are (relationship name, {(related bean object key, ({(relationship name, unrelated object collection)}, {entry}) )} ), where entry is another entry of this form.
Throws:
EJBException - if something goes wrong.

isIdentical

public boolean isIdentical(EJBLocalObject other)
                    throws EJBException
Tests if a given bean object is identical to the invoked bean object.

Bean objects are considered identical if their primary keys are equal.

Specified by:
isIdentical in interface EJBLocalObject
Parameters:
other - bean object to test for identity with the invoked bean object.
Returns:
true if the given bean object is identical to the invoked bean object, false otherwise.
Throws:
EJBException - Thrown when the method failed due to a system-level failure.

clone

public Object clone()
             throws CloneNotSupportedException,
                    EJBException
Produces a shallow copy of this bean object.

A shallow clone shares all of its relationships with its sister. i.e. a change to a relationship in either sister will affect the relationship in the other. This semantic carries some time and space overhead in the initial clone operation and during relationship xetter calls.

The load() method updates persistent fields while preserving the relationships of all shallow clones. If the load() is called on the original, its relationships will be reset to reflect persistent storage, but these updated relationships will not be shared. On the other hand, load() invocations on shallow clones will have no effect on their own relationships or the shared ones. If these semantics are undesirable, use loadSister() instead of load(). loadSister() forces the shared relationships to be synchronized with persistent storage. (Note that loadSister() will throw an exception if invoked on an original- but only after loading has taken place- in order to indicate that its behaviour might not be what you expect.)

Specified by:
clone in interface ClientManagedLocalObject
Overrides:
clone in class DebugBean
Returns:
a shallow copy of this bean object.
Throws:
CloneNotSupportedException - if the underlying "Thin" entity bean cannot be cloned.
EJBException - if something goes wrong.
EJBException - if something goes wrong.
See Also:
deepClone()

deepClone

public Object deepClone()
                 throws CloneNotSupportedException,
                        EJBException
Produces a deep copy of this bean object.

The difference between this method and clone() is that all relationships and related beans are also cloned.

This implementation has the (possibly undesirable) side effect of restoring unrelated relatives to the original and the clone. If this not desirable, use the slightly slower deeperClone() instead.

It is important to note that only one of the resulting beans can be reliably stored if either bean has their relationships altered subsequent to this clone operation. If an attempt is made to store both, in the worst case an unpredictable amalgam of the relationships comprising the two beans will end up in persistent storage. At best the relationships as presented by the first (in the case where the second bean has no dirty relatives and no recently unrelated relatives beyond those for the first bean) or second bean will stand (in the case where the first bean has no dirty relatives and no recently unrelated relatives beyond those for the second bean.) Lying somewhere inbetween on the spectrum of unreliability are cases where the second update fails due to some synchronization failure or other. You have been warned...

Specified by:
deepClone in interface ClientManagedLocalObject
Returns:
a deep copy of this bean object.
Throws:
CloneNotSupportedException - if the underlying "Thin" entity bean cannot be cloned.
EJBException - if something goes wrong.

deeperClone

public Object deeperClone()
                   throws CloneNotSupportedException,
                          EJBException
Produces a deeper copy of this bean object than deepClone().

The difference between this method and deepClone() is that changed relationships are preserved in the original and the clone. This preservation semantic carries some time and space overhead.

It is important to note that only one of the resulting beans can be reliably stored if either bean has their relationships altered subsequent to this clone operation. If an attempt is made to store both, in the worst case an unpredictable amalgam of the relationships comprising the two beans will end up in persistent storage. At best the relationships as presented by the first (in the case where the second bean has no dirty relatives and no recently unrelated relatives beyond those for the first bean) or second bean will stand (in the case where the first bean has no dirty relatives and no recently unrelated relatives beyond those for the second bean.) Lying somewhere inbetween on the spectrum of unreliability are cases where the second update fails due to some synchronization failure or other. You have been warned...

Specified by:
deeperClone in interface ClientManagedLocalObject
Returns:
a deeper copy of this bean object.
Throws:
CloneNotSupportedException
EJBException
See Also:
ClientManagedLocalObject.deepClone()

isCloned

public boolean isCloned()
                 throws NoSuchObjectLocalException
Checks if this bean object is cloned.

Specified by:
isCloned in interface ClientManagedLocalObject
Returns:
true if this bean object is a clone, false otherwise.
Throws:
NoSuchObjectLocalException - if the bean has been removed.

markCloned

public void markCloned()
                throws NoSuchObjectLocalException
Marks this bean as cloned.

Cloned beans do not interact with caches until stored.

Specified by:
markCloned in interface ClientManagedLocalObject
Throws:
NoSuchObjectLocalException - if the bean has been removed.

isShallow

public boolean isShallow()
                  throws NoSuchObjectLocalException
Checks if this bean object is a shallow clone.

Specified by:
isShallow in interface ClientManagedLocalObject
Returns:
true if this bean object is a shallow clone, false otherwise.
Throws:
NoSuchObjectLocalException - if the bean has been removed.

writeReplace

public Object writeReplace()
                    throws ObjectStreamException
Returns a new SerializableBeanObject with this bean as its underlyingObject.

Returns:
a new SerializableBeanObject with this bean as its underlyingObject.
Throws:
NotSerializableException - when one constituent bean is not serializable.
ObjectStreamException - only NotSerializableException.

unrelateAll

public void unrelateAll()
                 throws EJBException
Removes all beans from one to zero or more relationships for which unrelate...() methods are defined.

Specified by:
unrelateAll in interface ClientManagedLocalObject
Throws:
EJBException

lock

public boolean lock()
Attempts to acquire the mutual exclusion lock on this bean.

Specified by:
lock in interface ClientManagedLocalObject
Returns:
true if the lock could be acquired, false otherwise.

release

public void release()
             throws EJBException
Releases the mutual exclusion lock held for this bean.

Specified by:
release in interface ClientManagedLocalObject
Throws:
EJBException - if the lock is not held by this thread.