|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.exolab.castor.persist.ClassMolder
public class ClassMolder
ClassMolder is a binder for one type of data object and its
Persistence
. For example, when ClassMolder is asked to load
an object, it acquires values from Persistence
and binds it
into an target object. It also resolves relations via
TransactionContext
and bind related object into an target object.
Beside loading, ClassMolder is also repsonsible for storing, removing, creating an object to and from a persistence storage, as well as reverting an object to previous state.
Each instance of ClassMolder deals with exactly one persistable type,
interacts with one instance of Persistent and belongs to one
LockEngine
.
Field Summary | |
---|---|
(package private) boolean |
_isKeyGenUsed
Is a key kenerator used for the base class? |
(package private) boolean |
resolversHaveBeenReset
|
Constructor Summary | |
---|---|
ClassMolder(DatingService ds,
MappingLoader loader,
LockEngine lock,
ClassDescriptor clsDesc,
Persistence persist)
Creates an instance of this class. |
Method Summary | |
---|---|
(package private) void |
addDependent(ClassMolder dep)
Mutator method to add a dependent ClassMolder |
(package private) void |
addExtendent(ClassMolder ext)
Mutator method to add a extent ClassMolder |
java.lang.Object |
create(TransactionContext tx,
OID oid,
DepositBox locker,
java.lang.Object object)
Create an object of the base class with specified identity into the persistence storage. |
void |
delete(TransactionContext tx,
OID oid)
Delete an object of the base type from the persistence storage. |
void |
expireCache(TransactionContext tx,
ObjectLock locker)
Inspect the fields stored in the object passed as an argument for contained objects. |
AccessMode |
getAccessMode(AccessMode txMode)
Get the effective accessMode of the the base type |
java.lang.Object |
getActualIdentity(java.lang.ClassLoader loader,
java.lang.Object o)
Get the identity from a object of the base type |
java.lang.Object |
getActualIdentity(TransactionContext tx,
java.lang.Object o)
Get the identity from a object of the base type |
int |
getCacheParam()
Return the preferred LRU cache capacity for caching object of this type |
java.lang.String |
getCacheType()
Return the preferred LRU cache mechanism for caching object of this type |
CallbackInterceptor |
getCallback()
Get the callback interceptor of the base type |
ClassMolder |
getDepends()
Get the depends class' ClassMolder |
ClassMolder |
getExtends()
Get the extends class' ClassMolder |
FieldMolder[] |
getFields()
Get the FieldMolder of the fields of the base type, except the identity fields. |
java.lang.Object |
getIdentity(TransactionContext tx,
java.lang.Object o)
Get the identity from a object of the base type If object isn't persistent and key generator is used, returns null |
FieldMolder[] |
getIds()
Get the FieldMolders of the identity fields |
java.lang.Class |
getJavaClass(java.lang.ClassLoader loader)
Get the base class of this ClassMolder given a ClassLoader |
LockEngine |
getLockEngine()
Get the LockEngine which this ClassMolder belongs to. |
java.lang.String |
getName()
Get the fully qualified name of the base type of this ClassMolder |
Persistence |
getPersistence()
Get the Persisetence of the base type |
int |
getPriority()
Determines the create priority of the data object class represented by this ClassMolder. |
boolean |
isAssignableFrom(java.lang.Class cls)
check if the current ClassModlder is assignable from the class
instance. |
boolean |
isDefaultIdentity(java.lang.Object identity)
Test if the specified identity is the default value of the type. |
boolean |
isDependent()
Return true if the base type of this ClassMolder is an dependent class. |
boolean |
isKeyGeneratorUsed()
Return true if a key generator is used for the base type of this ClassMolder |
boolean |
isKeyGenUsed()
Return true if a key generator is used for the base type of this ClassMolder |
java.lang.Object |
load(TransactionContext tx,
OID oid,
DepositBox locker,
ProposedObject proposedObject,
AccessMode suggestedAccessMode)
Load an object with specified identity from the persistent storage. |
java.lang.Object |
load(TransactionContext tx,
OID oid,
DepositBox locker,
ProposedObject proposedObject,
AccessMode suggestedAccessMode,
QueryResults results)
|
void |
markCreate(TransactionContext tx,
OID oid,
DepositBox locker,
java.lang.Object object)
Walk the object model and mark object that should be created. |
void |
markDelete(TransactionContext tx,
OID oid,
DepositBox locker,
java.lang.Object object)
Prepare to delete an object with the specified identity. |
java.lang.Object |
newInstance(java.lang.ClassLoader loader)
Return a new instance of the base class with the provided ClassLoader object |
boolean |
preStore(TransactionContext tx,
OID oid,
DepositBox locker,
java.lang.Object object,
int timeout)
Check the object for modification. |
boolean |
removeRelation(TransactionContext tx,
java.lang.Object object,
ClassMolder relatedMolder,
java.lang.Object relatedObject)
Remove the reference of a related object from an object of the base class. |
void |
resetResolvers()
|
void |
revertObject(TransactionContext tx,
OID oid,
DepositBox locker,
java.lang.Object object)
Revert the object back to the state of begining of the transaction If the object is loaded, it will be revert as it was loaded. |
(package private) void |
setDepends(ClassMolder dep)
Mutator method to set the depends ClassMolder |
(package private) void |
setExtends(ClassMolder ext)
Mutator method to set the extends ClassMolder |
void |
setFieldsNull(java.lang.Object object)
Set all persistence fields of object of the base type to null. |
void |
setIdentity(TransactionContext tx,
java.lang.Object object,
java.lang.Object identity)
Set the identity into an object |
void |
setPersistence(Persistence persist)
Mutator method to set the PersistenceEngine of |
void |
store(TransactionContext tx,
OID oid,
DepositBox locker,
java.lang.Object object)
Store a data object into the persistent storage of the base class of this ClassMolder. |
java.lang.String |
toString()
|
boolean |
update(TransactionContext tx,
OID oid,
DepositBox locker,
java.lang.Object object,
AccessMode suggestedAccessMode)
Update the object which loaded or created in the other transaction to the persistent storage. |
void |
updateCache(TransactionContext tx,
OID oid,
DepositBox locker,
java.lang.Object object)
Update the dirty checking cache. |
void |
writeLock(TransactionContext tx,
OID oid,
DepositBox locker,
java.lang.Object object)
Acquire a write lock on an object of the base type with the specified identity from the persistence storage. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
boolean _isKeyGenUsed
boolean resolversHaveBeenReset
Constructor Detail |
---|
ClassMolder(DatingService ds, MappingLoader loader, LockEngine lock, ClassDescriptor clsDesc, Persistence persist) throws java.lang.ClassNotFoundException, MappingException
ds
- is the helper class for resolving depends and extends relationship
among all the ClassMolder in the same LockEngine.loader
- the mapping loader.lock
- the lock engine.clsDesc
- the classDescriptor for the base class.persist
- the Persistence for the base class.
java.lang.ClassNotFoundException
- If a class cannot be loaded.
MappingException
- if an error occured with analysing the mapping information.Method Detail |
---|
public boolean removeRelation(TransactionContext tx, java.lang.Object object, ClassMolder relatedMolder, java.lang.Object relatedObject)
If the related object is PersistanceCapable, the field will be set null. If the related object is a Collection, then the related object will be removed from the Collection.
If any changed occured, transactionContext.markModified will be called, to indicate the object is modified.
It method will iterate thur all of the object's field and try to remove all the occurrence.
tx
- the TransactionContext of the transaction in actionobject
- the target object of the base type of this ClassMolderrelatedMolder
- the ClassMolder of the related object to be
removed from the objectrelatedObject
- the object to be removedpublic int getPriority()
public java.lang.Object load(TransactionContext tx, OID oid, DepositBox locker, ProposedObject proposedObject, AccessMode suggestedAccessMode) throws ObjectNotFoundException, PersistenceException
tx
- the TransactionContext in actionoid
- the object identity of the desired objectlocker
- the DepositBox
of the object which is used to
store the dirty checking cache of the object.suggestedAccessMode
- the acessMode for the object
ObjectNotFoundException
PersistenceException
public java.lang.Object load(TransactionContext tx, OID oid, DepositBox locker, ProposedObject proposedObject, AccessMode suggestedAccessMode, QueryResults results) throws ObjectNotFoundException, PersistenceException
ObjectNotFoundException
PersistenceException
public java.lang.Object create(TransactionContext tx, OID oid, DepositBox locker, java.lang.Object object) throws DuplicateIdentityException, PersistenceException
tx
- transaction in actionoid
- the object identity of the object to be created.locker
- the dirty checking cache of the objectobject
- the object to be created
DuplicateIdentityException
PersistenceException
public void markCreate(TransactionContext tx, OID oid, DepositBox locker, java.lang.Object object) throws DuplicateIdentityException, PersistenceException
tx
- transaction in actionoid
- the object identity of the object to be created.locker
- the dirty checking cache of the objectobject
- the object to be created
DuplicateIdentityException
PersistenceException
public boolean preStore(TransactionContext tx, OID oid, DepositBox locker, java.lang.Object object, int timeout) throws PersistenceException
tx
- transaction in actionoid
- the object identity of the objectlocker
- the dirty check cache for the objectobject
- the data object to be checkedtimeout
- timeout of updating the lock if needed
PersistenceException
public void store(TransactionContext tx, OID oid, DepositBox locker, java.lang.Object object) throws DuplicateIdentityException, PersistenceException, ObjectModifiedException, ObjectDeletedException
tx
- Transaction in actionoid
- the object identity of the stored objectlocker
- the dirty check cache of the objectobject
- the object to be stored
DuplicateIdentityException
PersistenceException
ObjectModifiedException
ObjectDeletedException
public boolean update(TransactionContext tx, OID oid, DepositBox locker, java.lang.Object object, AccessMode suggestedAccessMode) throws PersistenceException, ObjectModifiedException
tx
- Transaction in actionoid
- the object identity of the stored objectlocker
- the dirty check cache of the objectobject
- the object to be stored
PersistenceException
ObjectModifiedException
public void updateCache(TransactionContext tx, OID oid, DepositBox locker, java.lang.Object object)
tx
- - transaction in actionoid
- - object's identity of the target objectlocker
- - the dirty checking cache of the target objectobject
- - the target objectpublic void delete(TransactionContext tx, OID oid) throws PersistenceException
tx
- - transaction in actionoid
- - the object identity of the target object
PersistenceException
public void markDelete(TransactionContext tx, OID oid, DepositBox locker, java.lang.Object object) throws ObjectNotFoundException, PersistenceException
tx
- - transaction in actionoid
- - object's identity of the target objectlocker
- - the dirty checking cache of the target objectobject
- - the target object
ObjectNotFoundException
PersistenceException
public void revertObject(TransactionContext tx, OID oid, DepositBox locker, java.lang.Object object) throws PersistenceException
tx
- - transaction in actionoid
- - the object identity of the target objectlocker
- - the dirty checking cache of the target objectobject
- - the target object
PersistenceException
public void writeLock(TransactionContext tx, OID oid, DepositBox locker, java.lang.Object object) throws PersistenceException
tx
- - Transaction in actionoid
- - the object identity of the target objectlocker
- - the dirty checking cache of the objectobject
- - the target object
PersistenceException
public java.lang.Object newInstance(java.lang.ClassLoader loader) throws java.lang.InstantiationException, java.lang.IllegalAccessException, java.lang.ClassNotFoundException
loader
- the ClassLoader object to use to create a new object
java.lang.ClassNotFoundException
java.lang.IllegalAccessException
java.lang.InstantiationException
public AccessMode getAccessMode(AccessMode txMode)
txMode
- - the default transaction accessMode
public CallbackInterceptor getCallback()
public boolean isDefaultIdentity(java.lang.Object identity)
public java.lang.Object getIdentity(TransactionContext tx, java.lang.Object o)
tx
- the transaction contexto
- - object of the base type
public java.lang.Object getActualIdentity(TransactionContext tx, java.lang.Object o)
tx
- the transaction contexto
- - object of the base type
public java.lang.Object getActualIdentity(java.lang.ClassLoader loader, java.lang.Object o)
loader
- the current class loadero
- - object of the base type
public void setIdentity(TransactionContext tx, java.lang.Object object, java.lang.Object identity) throws PersistenceException
tx
- the transaction contextobject
- the object to set the identityidentity
- the new identity for the object
PersistenceException
public Persistence getPersistence()
public void setPersistence(Persistence persist)
public java.lang.Class getJavaClass(java.lang.ClassLoader loader)
loader
- the classloader
Class
instancepublic boolean isAssignableFrom(java.lang.Class cls)
class
instance.
cls
- the Class to check the assignation
public java.lang.String getName()
public FieldMolder[] getFields()
public FieldMolder[] getIds()
public ClassMolder getExtends()
public ClassMolder getDepends()
public LockEngine getLockEngine()
public java.lang.String getCacheType()
public int getCacheParam()
public boolean isDependent()
public void setFieldsNull(java.lang.Object object)
object
- - target objectvoid addExtendent(ClassMolder ext)
void addDependent(ClassMolder dep)
void setExtends(ClassMolder ext)
void setDepends(ClassMolder dep)
public java.lang.String toString()
toString
in class java.lang.Object
public boolean isKeyGenUsed()
public boolean isKeyGeneratorUsed()
public void expireCache(TransactionContext tx, ObjectLock locker) throws PersistenceException
tx
- The org.exolab.castor.persist.TransactionContext
locker
- The object that contains the fields to be inspected
PersistenceException
public void resetResolvers()
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |