|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectau.gov.tas.dpiwe.mr.bean.NullBean
au.gov.tas.dpiwe.mr.bean.DebugBean
au.gov.tas.dpiwe.mr.test.ExampleBean
au.gov.tas.dpiwe.mr.test.MrExampleBean
public final class MrExampleBean
This is an implementation of the abstract ExampleBean class which wraps a ThinExampleBean with container-based persistence logic.
| 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 |
|---|
public static final boolean nullStringEqualsEmptyString
| Constructor Detail |
|---|
public MrExampleBean(Container container,
ThinExampleBean underlyingBean,
boolean cloned)
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.
public MrExampleBean(Container container,
ThinExampleBean underlyingBean)
container - the container to which the new bean object belongs.underlyingBean - the ThinExampleBean entity bean underlying
the new bean object.| Method Detail |
|---|
public Container getEnclosingContainer()
getEnclosingContainer in interface BeanWrapperpublic EntityBean getUnderlyingBean()
getUnderlyingBean in interface BeanWrapperpublic EJBLocalObject setUnderlyingBean(EntityBean bean)
setUnderlyingBean in interface BeanWrapperbean - the ThinExampleBean entity bean to wrap with this object.
public EJBLocalHome getEJBLocalHome()
throws EJBException
getEJBLocalHome in interface EJBLocalObjectEJBException - if something goes wrong.
public Object getPrimaryKey()
throws EJBException
getPrimaryKey in interface BeanWrappergetPrimaryKey in interface EJBLocalObjectEJBException - if something goes wrong.
public void simpleValidate()
throws EJBException
simpleValidate in interface SimpleValidatorsimpleValidate in class DebugBeanValidateException - if the data in this bean is
invalid under these checks.
EJBExceptionpublic boolean isPersistent()
isPersistent in interface ClientManagedLocalObjectNoSuchObjectLocalException - if the bean has been removed.
public Object ejbCreate(Object primaryKey)
throws CreateException,
EJBException
primaryKey - the primary key value for this bean.
CreateException - to object to the key value.
EJBException - something unexpected goes wrong.
public void ejbPostCreate(Object primaryKey)
throws CreateException,
EJBException
primaryKey - the primary key value for this bean.
CreateException - to object to the assignment of identity.
EJBException - something unexpected goes wrong.public Color getColour()
getColour in interface ExampleBeanObjectgetColour in class ExampleBeanNoSuchObjectLocalException - if the bean has been removed.public float getQuality()
getQuality in interface ExampleBeanObjectgetQuality in class ExampleBeanNoSuchObjectLocalException - if the bean has been removed.public String getShape()
getShape in interface ExampleBeanObjectgetShape in class ExampleBeanNoSuchObjectLocalException - if the bean has been removed.public void setColour(Color colour)
setColour in interface ExampleBeanObjectsetColour in class ExampleBeancolour - the new value for the colour property.
NoSuchObjectLocalException - if the bean has been removed.public void setQuality(float quality)
setQuality in interface ExampleBeanObjectsetQuality in class ExampleBeanquality - the new value for the quality property.
NoSuchObjectLocalException - if the bean has been removed.public void setShape(String shape)
setShape in interface ExampleBeanObjectsetShape in class ExampleBeanshape - the new value for the shape property.
NoSuchObjectLocalException - if the bean has been removed.
public void load()
throws EJBException
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.
load in interface ClientManagedLocalObjectEJBException - if something goes wrong.
public void loadSister()
throws EJBException
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.
loadSister in interface ClientManagedLocalObjectSisterException - 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.
public void store()
throws EJBException
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.
store in interface ClientManagedLocalObjectEJBException - if something goes wrong.
public void storeWithRelated()
throws EJBException
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.
storeWithRelated in interface ClientManagedLocalObjectEJBException - if something goes wrong.
public boolean isDirty()
throws NoSuchObjectLocalException
isDirty in interface ClientManagedLocalObjectisDirty in interface DirtyableNoSuchObjectLocalException - if the bean has been removed.
public void makeDirty()
throws NoSuchObjectLocalException
makeDirty in interface ClientManagedLocalObjectmakeDirty in interface DirtyableNoSuchObjectLocalException - if the bean has been removed.
public void scratch()
throws NoSuchObjectLocalException
scratch in interface DirtyableNoSuchObjectLocalExceptionDirtyable.polish()
public void polish()
throws NoSuchObjectLocalException
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.
polish in interface DirtyableNoSuchObjectLocalExceptionDirtyable.scratch()
public boolean areRelativesPersistent()
throws EJBException
areRelativesPersistent in interface ClientManagedLocalObjectNoSuchObjectLocalException - if the bean has been removed.
EJBException
public boolean isDummy()
throws NoSuchObjectLocalException
isDummy in interface ClientManagedLocalObjectNoSuchObjectLocalException - if the bean has been removed.
public void makeDummy()
throws NoSuchObjectLocalException
makeDummy in interface ClientManagedLocalObjectNoSuchObjectLocalException - if the bean has been removed.
public Object invokeOnServer(Method method,
Object[] parameters)
throws EJBException
invokeOnServer in interface ClientManagedLocalObjectmethod - the method to call.parameters - the parameters to pass to the method.
EJBException - if something goes wrong.
public void remove()
throws RemoveException,
EJBException
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.
remove in interface EJBLocalObjectRemoveException - if removal is disallowed.
EJBException - if something goes wrong.
public void removeUnrelated()
throws EJBException,
RemoveException
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.
removeUnrelated in interface ClientManagedLocalObjectEJBException - if something goes wrong.
RemoveException - if removal of one of the unrelated beans is
disallowed.public Map restoreUnrelated()
For internal use only, and not to be called by external clients.
restoreUnrelated in interface CloningUtilities
public void unrelateAllInFlatMap(Map relationshipUnrelatedTable)
throws EJBException
For internal use only, and not to be called by external clients.
unrelateAllInFlatMap in interface CloningUtilitiesrelationshipUnrelatedTable - a map describing the business objects
which are to be unrelated, where the entries are (relationship name,
unrelated object collection).
EJBException - if something goes wrong.
public void removeUnrelatedFromRelated()
throws EJBException,
RemoveException
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.
removeUnrelatedFromRelated in interface ClientManagedLocalObjectEJBException - if something goes wrong.
RemoveException - if removal of one of the unrelated beans is
disallowed.public Map restoreUnrelatedToRelated()
For internal use only, and not to be called by external clients.
restoreUnrelatedToRelated in interface CloningUtilities
public void unrelateAllInNestedMapFromRelated(Map relationshipParticipantUnrelatedTable)
throws EJBException
For internal use only, and not to be called by external clients.
unrelateAllInNestedMapFromRelated in interface CloningUtilitiesrelationshipParticipantUnrelatedTable - 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.
EJBException - if something goes wrong.
public boolean isIdentical(EJBLocalObject other)
throws EJBException
Bean objects are considered identical if their primary keys are equal.
isIdentical in interface EJBLocalObjectother - bean object to test for identity with the invoked bean object.
EJBException - Thrown when the method failed due to a
system-level failure.
public Object clone()
throws CloneNotSupportedException,
EJBException
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.)
clone in interface ClientManagedLocalObjectclone in class DebugBeanCloneNotSupportedException - if the
underlying "Thin" entity bean cannot be cloned.
EJBException - if something goes wrong.
EJBException - if something goes wrong.deepClone()
public Object deepClone()
throws CloneNotSupportedException,
EJBException
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...
deepClone in interface ClientManagedLocalObjectCloneNotSupportedException - if the underlying "Thin"
entity bean cannot be cloned.
EJBException - if something goes wrong.
public Object deeperClone()
throws CloneNotSupportedException,
EJBException
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...
deeperClone in interface ClientManagedLocalObjectCloneNotSupportedException
EJBExceptionClientManagedLocalObject.deepClone()
public boolean isCloned()
throws NoSuchObjectLocalException
isCloned in interface ClientManagedLocalObjectNoSuchObjectLocalException - if the bean has been removed.
public void markCloned()
throws NoSuchObjectLocalException
Cloned beans do not interact with caches until stored.
markCloned in interface ClientManagedLocalObjectNoSuchObjectLocalException - if the bean has been removed.
public boolean isShallow()
throws NoSuchObjectLocalException
isShallow in interface ClientManagedLocalObjectNoSuchObjectLocalException - if the bean has been removed.
public Object writeReplace()
throws ObjectStreamException
NotSerializableException - when one constituent bean is not
serializable.
ObjectStreamException - only NotSerializableException.
public void unrelateAll()
throws EJBException
unrelateAll in interface ClientManagedLocalObjectEJBExceptionpublic boolean lock()
lock in interface ClientManagedLocalObject
public void release()
throws EJBException
release in interface ClientManagedLocalObjectEJBException - if the lock is not held by this thread.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||