|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.hydrateframework.ObjectContext
public class ObjectContext
An object context represents a single self-consistent representation of a business model. In order to stay self-consistent, the context manages a set of object indexes that help to guarantee object uniqueness and to resolve objects found in the database that refer to objects already in memory. The context also orchestrates blocking where an attempt is made to resolve a reference where the target object has not yet been loaded from the database.
Nested Class Summary | |
---|---|
static class |
ObjectContext.IndexEntry
This class stores an entry in an index.when it needs to be passed to the outside world. |
Field Summary | |
---|---|
protected java.util.Map<ObjectCollection,java.util.Set<ObjectRelationshipFactory.RelationshipMap>> |
m_mtms
A Map holding a list of changes to be made to a many-to-many relationship. |
Constructor Summary | |
---|---|
ObjectContext(boolean isReadWrite)
Construct a new object context. |
Method Summary | |
---|---|
ObjectIndex |
addIndex(ObjectIndex newIdx)
Add an index to the context |
void |
addLoadErrorHandler(ObjectLoadErrorHandler handler)
|
void |
addToIndex(ObjectKey key,
java.lang.Object obj)
Add a business object to alternate key indexes that it is not already a part of. |
void |
blockOn(java.lang.Object instOrCls,
java.lang.String mbr,
boolean add)
This call is used to request that the infrastructure block on requests for a particular object member on a particular class. |
void |
clearAll()
|
boolean |
clearLoadErrorHandler(ObjectLoadErrorHandler handler)
|
void |
constructed(java.lang.Object o)
This method is called by a model object on construction and allows the context to take any special required action on object creation. |
java.io.PrintStream |
dumpIndexes(java.io.PrintStream out)
This diagnostic function prints out a list of indexes and their contents. |
ObjectAccessEventHandler |
getAccessEventHandler(java.lang.Class cls)
|
java.lang.Class |
getBusinessClass(java.lang.Object o)
Returns the interface that represents the most-derived class that is part of the current object model that this object supports. |
static ObjectContext |
getDefaultContext(java.lang.Class familyClass)
|
ObjectFactory |
getFactory(java.lang.Class cls)
Return a factory for creating objects of the specified |
java.util.Set<ObjectRelationshipFactory.RelationshipMap> |
getMTM(ObjectCollection coll,
boolean forSave)
|
java.util.List |
getObjectsAsList(java.lang.Class obj,
java.lang.Class keyCls)
Return the objects in a list - dh |
ObjectRelationshipFactory |
getRelationshipFactory(java.lang.String name)
Return the factory for creating the link between objects with a many-to-many relationship. |
RequestContext |
getRequestContext()
|
java.lang.Object |
handleClassMismatch(java.lang.Object existing,
java.lang.Class newClass,
ObjectKey newKey)
|
boolean |
isDirty(java.lang.Object o)
|
boolean |
isForSave()
Determine if changes are to be saved in the database. |
java.util.Iterator |
iterateObjects(java.lang.Class obj,
java.lang.Class keyCls)
returns an iterator for a particular class of object. |
java.util.Iterator |
iterateObjects(java.lang.Class obj,
java.lang.Class keyCls,
boolean concurrent)
Iterate through objects in an index. |
void |
needKeyNow(java.lang.Object obj)
This may be needed during batch inserts where a key is required for an object that has been inserted, but whose batch has not yet run. |
java.lang.Object |
removeObject(ObjectKey key)
Drop an object from an index. |
java.lang.Object |
resolveKey(ObjectKey key)
Try to find a business object given its primary key. |
java.lang.Object |
resolveKeyTo(ObjectKey key,
java.lang.Class toCls)
Try to find a business object given its primary key. |
void |
saveAll()
Save all changed objects in the context. |
void |
setAccessEventHandler(java.lang.Class<?> cls,
ObjectAccessEventHandler hnd)
|
static void |
setDefaultContext(ObjectContext ctx)
|
ObjectFactory |
setFactory(java.lang.Class cls,
ObjectFactory fact)
Establish the factory to be used to create a particular object type. |
void |
setNeedsUpdate(HydrateObject o,
boolean needsUpdate)
|
void |
setObjectOrder(java.lang.Class[] classes)
Provide a dependency ordering for the objects in the model. |
ObjectRelationshipFactory |
setRelationshipFactory(java.lang.String name,
ObjectRelationshipFactory fact)
Establish the factory to be used to create a link between objects |
void |
setRequestContext(RequestContext rc)
Establish the request context for this object context. |
void |
setUpdateStrategy(int strategy,
int batchSize)
Establish the update strategy to be used in the database. |
HydrateObject |
tempProxy(java.lang.Object o)
Provides a temporary proxy for a non-hydrate object. |
java.lang.Object |
tryResolveKey(ObjectKey key)
Try to find a business object given its primary key. |
boolean |
waitForPopulation(java.lang.Object what,
HydrateObject obj,
java.lang.String mbr)
Block the current thread waiting for the population of a particular business object attribute or collection. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected java.util.Map<ObjectCollection,java.util.Set<ObjectRelationshipFactory.RelationshipMap>> m_mtms
Constructor Detail |
---|
public ObjectContext(boolean isReadWrite)
isReadWrite
- true if updates to objects in the context will be saved
in the database.Method Detail |
---|
public static ObjectContext getDefaultContext(java.lang.Class familyClass)
public static void setDefaultContext(ObjectContext ctx)
public void addLoadErrorHandler(ObjectLoadErrorHandler handler)
public boolean clearLoadErrorHandler(ObjectLoadErrorHandler handler)
public java.lang.Object handleClassMismatch(java.lang.Object existing, java.lang.Class newClass, ObjectKey newKey) throws SaveException
SaveException
public java.lang.Class getBusinessClass(java.lang.Object o)
setObjectOrder(java.lang.Class[])
having been called which happens automatically on a call to
<FamilyName>.configureContext(ctx)
o
- The object whose class is to be known
public HydrateObject tempProxy(java.lang.Object o)
o
- The object for which a proxy is required.
public void constructed(java.lang.Object o)
o
- the object that was just constructed.public java.util.Set<ObjectRelationshipFactory.RelationshipMap> getMTM(ObjectCollection coll, boolean forSave)
public void setNeedsUpdate(HydrateObject o, boolean needsUpdate)
public void setObjectOrder(java.lang.Class[] classes)
classes
- the ordered list of classes.public void setRequestContext(RequestContext rc)
rc
- the request contextpublic ObjectFactory getFactory(java.lang.Class cls)
cls
- the class (interface) for which a factory is to be returned.
public ObjectFactory setFactory(java.lang.Class cls, ObjectFactory fact)
cls
- the class (interface) for which the factory is to be set.fact
- the factory class.
public ObjectRelationshipFactory getRelationshipFactory(java.lang.String name)
name
- the name of the relationship.
public ObjectRelationshipFactory setRelationshipFactory(java.lang.String name, ObjectRelationshipFactory fact)
name
- the name of the relationship to which the factory applies.fact
- the factory object.
public void blockOn(java.lang.Object instOrCls, java.lang.String mbr, boolean add)
instOrCls
- this object is an instance of the business on whose member
to block or, alternatively the class object that represents the implemented
business interface for which blocking should occur for all instances.mbr
- the name of the member to block on. This name should be one of the
strings defined in the business object interface to represent object members.add
- true to add the block, false to remove it.public RequestContext getRequestContext()
public boolean isForSave()
public void clearAll()
public boolean isDirty(java.lang.Object o)
public void saveAll() throws SaveException
SaveException
- if there was a problem with the savepublic void needKeyNow(java.lang.Object obj)
obj
- the object that needs a key.public void setUpdateStrategy(int strategy, int batchSize)
strategy
- The strategy is one or more of the NamedParameterStatement.STRATEGY_...
flags. You may boolean or (|) multiple flags together.batchSize
- the size of the batch. A batch size of other than one automatically
sets the NamedParameterStatement.STRATEGY_BATCH
flagpublic ObjectIndex addIndex(ObjectIndex newIdx)
newIdx
- the index to add
public java.io.PrintStream dumpIndexes(java.io.PrintStream out)
out
- the stream to output data to.
public java.util.Iterator iterateObjects(java.lang.Class obj, java.lang.Class keyCls)
public java.util.List getObjectsAsList(java.lang.Class obj, java.lang.Class keyCls)
obj
- keyCls
-
public java.util.Iterator iterateObjects(java.lang.Class obj, java.lang.Class keyCls, boolean concurrent)
obj
- the class of object that we want to iterate.keyCls
- the class of the key that indicates the index to iterate.concurrent
- true if the iteration needs to be isolated from concurrent
changes to the list (from another thread).
public void addToIndex(ObjectKey key, java.lang.Object obj)
obj
- the object to be added to indexes in this contextpublic java.lang.Object removeObject(ObjectKey key)
key
- the key that is being used to index the object. The index
from which the object is removed is specific to this key.
public java.lang.Object tryResolveKey(ObjectKey key)
key
- the primary key of the business object.
public java.lang.Object resolveKey(ObjectKey key) throws NotLoadedException
key
- the primary key of the business object.
NotLoadedException
- if the object could not be found.public java.lang.Object resolveKeyTo(ObjectKey key, java.lang.Class toCls) throws NotLoadedException
key
- the primary key of the business object.
NotLoadedException
- if the object could not be found.public void setAccessEventHandler(java.lang.Class<?> cls, ObjectAccessEventHandler hnd)
public ObjectAccessEventHandler getAccessEventHandler(java.lang.Class cls)
public boolean waitForPopulation(java.lang.Object what, HydrateObject obj, java.lang.String mbr)
what
- the thing that we are waiting for.obj
- the business object instance whose attribute we are waiting to
be populated.mbr
- the name of the attribute within the business object.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |