public class MutableDataSource extends java.lang.Object implements DataSource, MemoryHandler
// declare the datasource
MutableDataSource ds=null;
try
{
// create a datasource
ds = new MutableDataSource(...);
// use the datasource
...
}
finally
{
// release the datasource inside the finally block
if (ds != null) ds.dispose();
// the datasource cannot be used any longer
}
MemoryHandler.Cost
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
ATTRIBUTE_MODE
the mode
|
static java.lang.String |
ENV_DEFAULT_VALIDATE_PARALLEL
Should the validate in parallel be enabled by default
|
static java.lang.String |
ENV_VALIDATE_PARALLEL_SIZE
the number of objects before we parallel the validate
|
static java.lang.String |
MODE_BULK_LOAD
the bulk load
|
static java.lang.String |
NEXT_NUMBER_ROWID
Next number identifier for ROWID
|
static java.lang.String |
NEXT_NUMBER_TRANSACTION
Next number identifier for TRANSACTION
|
protected Login |
sudoLogin
the login this data source was created with
|
Constructor and Description |
---|
MutableDataSource(DataSource ds)
A valid login is required to create a mutableDataSource
All database requests will be limited by the ACLs associated
with Login's access group.
|
MutableDataSource(Login login)
A valid login is required to create a mutableDataSource
All database requests will be limited by the ACLs associated
with Login's access group.
|
MutableDataSource(Login login,
Login realLogin)
A valid login is required to create a mutableDataSource
All database requests will be limited by the ACLs associated
with Login's access group.
|
MutableDataSource(Session session)
A valid login is required to create a mutableDataSource
All database requests will be limited by the ACLs associated
with Login's access group.
|
Modifier and Type | Method and Description |
---|---|
void |
abort()
abort the datasource and remove any locks.
|
void |
addJournalHint(DBClass dbClass,
long rowUID)
add to the journal Hint
|
boolean |
changeThreadMode(ThreadCop.MODE mode)
change the thread mode for this object
|
void |
clearSavePoint(java.lang.String id) |
DBObject |
create(DBClass dbClass)
Creates a new DBObject of a particular type
|
DBObject |
create(DBClass dbClass,
FldParams params)
Creates a new DBObject of a particular type
|
DBObject |
create(GlobalId classGid)
Creates a new DBObject of a particular type
|
DBObject |
create(java.lang.String className)
Creates a new DBObject of a particular type
|
boolean |
disableParallelValidation(boolean flag) |
void |
dispose()
dispose of this MutableDataSource clear to tables and make sure we can't use this MutableDataSource after calling this method
THREAD SAFE: This method is designed to be safe to be called from external threads.
|
DBObject |
duplicate(DBObject orig)
Creates a new DBObject of the same class type and copies all the fields.
|
void |
excludeFromGroup(ContactGroup group)
exclude the current user from the group.
|
void |
excludeFromGroup(ContactGroup group,
Person person)
exclude the contact from the group
|
DBClass |
findDBClass(GlobalId classId)
Find a DBClass by it's global id.
|
DBClass |
findDBClass(java.lang.String className)
Finds the DBClass by name
THREAD SAFE: Just calling the VirtualDB version of find class which is thread safe.
|
DBClassAbstract |
findDBClassAbstract(GlobalId classId)
Find a DBClass by it's global id.
|
DBClassAbstract |
findDBClassAbstract(java.lang.String className)
Finds the DBClass by name
THREAD SAFE: Just calling the VirtualDB version of find class which is thread safe.
|
DBObject |
findKey(GlobalId valueId,
GlobalId classId)
Find a DBObject via it's value global ID and class global ID
|
DBObject |
findKey(GlobalId id,
java.lang.String defName)
Finds a new DBObject by its value id and the class name
|
DBObject |
findKey(GlobalKey gKey)
Finds a new DBObject by its primary key
THREAD SAFE: Multi-Threaded access allowed.
|
DBObject |
findKey(java.lang.String value,
java.lang.String defName)
find a key
|
DBObject |
findRow(long rowId,
DBClassConcrete def,
Hint hint)
Finds a DBObject by it's rowId
THREAD SAFE: Multi-Threaded access allowed.
|
long |
forceToDB(java.lang.String message)
Repeatedly try to write this job to the database.
|
long |
freeMemory(double percentage)
Free memory at this level and below.
|
java.lang.Object |
getAttribute(java.lang.String name)
Gets a general purpose attribute
|
java.lang.Object |
getCacheObject(java.lang.String key)
return a cached object
|
MemoryHandler.Cost |
getCost()
The cost level for this MemoryHandler.
|
DataSource |
getCurrentDataSource()
get the current datasource, if from VurtualDB then the thread local version
|
VirtualDB |
getDataBase()
Returns the VirtualDB for this MutableDataSource.
|
DataSource |
getDataBaseReadOnly()
Returns itself.
|
long |
getEstimatedSize()
The estimated size of data held by this memory handler
|
Globals |
getGlobalObject()
Get the globals object
|
DBResult |
getInwardLinkage(DBClass sourceClass,
DBField sourceField,
DBObject target,
HintField hint)
If this is an incoming link and the base object is new
then don't check the database for records as there
will not/should not be any records.
|
HintData |
getJournalHint(DBClass dbClass)
get the journal hint
|
long |
getLastAccessed()
The last time this memory handle was accessed
|
Login |
getLogin()
Returns the Login for this MutableDataSource.
|
DBQueryHandler |
getQueryHandler(DBClass searchClass)
Makes a Query handler for simple virtual db.
|
DataBase |
getRawReadDB()
Deprecated.
|
DataBase |
getRawWriteDB()
Returns the physical WRITE database for this datasource
|
Login |
getRealLogin()
The real login
THREAD SAFE: Multi-Threaded- We will allow Multi-Thread access to this method as it doesn't cause any real harm.
|
Session |
getSession()
Get the current session
|
java.util.TimeZone |
getTimeZone()
Returns the login which created this MutableDataSource's current timeZone.
|
Person |
getUser()
Returns the User for this MutableDataSource.
|
boolean |
hasChanged()
Have any objects in the universe been changed.
|
boolean |
hasChangedByUser()
Have any objects in the universe been changed.
|
boolean |
hasChild(DBClass mapClass,
DBField parentField,
DBObject parentObject,
DBField childField,
DBObject childObject)
does this map table contain a mapping for the parent to child.
|
boolean |
hasExcludedGroups()
are any contacts excluded ?
|
boolean |
hasSavePoint(java.lang.String id)
Do we have this save point defined ?
|
void |
iAddToUniverse(DBObject obj)
When a DBObject is modified in any way it adds itself
to the MutableDataSource's universe.
|
HashLongMap |
iGetUniverseRowMap()
Returns a hash map of all row IDs -> DBObject changed in this MutableDataSource.
|
boolean |
isChangable()
can we change objects in the mutable data source.
|
boolean |
isChangedByUserDisabled()
Gets current setting for disabling changedByUser flag
|
boolean |
isDisposed()
has this data source been disposed ?
THREAD SAFE: Multi-threaded
|
boolean |
isExcludeFromGroup(ContactGroup group,
Person person)
is the contact excluded from the group.
|
boolean |
isInEventAction()
Are we currently processing event actions ?
|
boolean |
isInValidateUniverse()
Returns true if datasource is validating the universe.
|
boolean |
isOnChangeEventDisabled()
Gets current setting for disabling on change event
|
boolean |
isParallelValidationAllowed()
is parallel validation allowed.
|
boolean |
isSaveDisabled()
Has save been disabled ? Once save is disabled it can't be re-enabled as row ids are generated differently.
|
boolean |
isSaving()
Are we saving ?
THREAD SAFE: Multi-Threaded access allowed.
|
static boolean |
isSimulatingJMS()
is simulating JMS
|
void |
iUpdateCacheKey(GlobalKey gKey,
DBObject obj)
The key has changed for a new DBObject
INTERNAL ONLY |
DBObject[] |
listUniverse()
Returns a list of all DBObjects modified within the dataSource
THREAD SAFE: Multi-Threaded access allowed.
|
DALQuery |
makeQuery(java.lang.String className) |
void |
markSavePoint(java.lang.String id)
Mark the save point which we can rollback to later.
|
long |
nextNumber(java.lang.String key)
Returns the next number for the passed key.
|
long |
nextNumber(java.lang.String key,
int cacheSize)
Returns the next number for the passed key.
|
long |
panicFreeMemory()
Clear all memory.
|
long |
queuedFreeMemory(double percentage)
This method should implement the freeing of the method and maybe synchronized.
|
EventMarker |
raise(DBEvent event,
DBObject base)
Adds this Event to the EventQueue.
|
DBObject |
recycleObject(DBObject obj)
If an DBObject has been returned by this MutableDataSource then return the same java object
We can't return two references to the same row in the database as this may cause modifications
to be missed.
|
void |
reindex()
re-index records
|
void |
resetReadChecks()
The required timezone
|
void |
rollbackTo(java.lang.String id)
Rollback to a save point
|
long |
save(java.lang.String reason)
Validates and then saves all records that have been modified/deleted/created by the
MutableDataSource.
|
MutableDataSource |
setAttribute(java.lang.String name,
java.lang.Object value)
Sets general purpose attributes
|
void |
setCacheObject(java.lang.String key,
java.lang.Object obj)
set a cache object
|
MutableDataSource |
setDisableChangedByUser(boolean disable)
Sets flag to disable setting of changedByUser flag on updates
|
void |
setDisableOnChangeEvent(boolean disable)
Sets flag to disable setting of on change event
|
MutableDataSource |
setNoSave(boolean flag)
Changes to MutableDataSource into "no save" mode.
|
void |
setTimeZone(java.util.TimeZone tz)
The timezone
|
void |
setTransGroup(TransGroup tg)
The transaction group
|
static void |
simulateJMS(boolean flag)
simulate JMS
|
static void |
simulateLockedFieldCache(boolean flag)
simulate locked field cache
|
long |
tidyUp()
Tidy up the memory handler
|
java.lang.String |
toString()
Display the details of this datasource
|
long |
touch()
Record the time the universe was last changed.
|
ValidationList |
validateUniverse()
Validate all DBObjects that have been created/modified/deleted
|
public static final java.lang.String NEXT_NUMBER_ROWID
public static final java.lang.String ATTRIBUTE_MODE
public static final java.lang.String MODE_BULK_LOAD
public static final java.lang.String NEXT_NUMBER_TRANSACTION
protected Login sudoLogin
public static final java.lang.String ENV_VALIDATE_PARALLEL_SIZE
public static final java.lang.String ENV_DEFAULT_VALIDATE_PARALLEL
public MutableDataSource(@Nonnull Login login)
login
- The user's login.public MutableDataSource(@Nonnull Login login, @Nullable Login realLogin)
realLogin
- The real login ( sudo)login
- The user's login.public MutableDataSource(@Nonnull Session session)
session
- the current sessionpublic MutableDataSource(@Nonnull DataSource ds)
ds
- A datasource to source the login and timezonepublic boolean disableParallelValidation(boolean flag)
@CheckReturnValue public boolean isParallelValidationAllowed()
public void addJournalHint(@Nonnull DBClass dbClass, long rowUID)
dbClass
- the classrowUID
- the row UID@CheckReturnValue @Nullable public HintData getJournalHint(@Nonnull DBClass dbClass)
dbClass
- the classpublic static void simulateLockedFieldCache(boolean flag)
flag
- true to turn on.public static void simulateJMS(boolean flag)
flag
- true to turn on.@CheckReturnValue public static boolean isSimulatingJMS()
public boolean changeThreadMode(@Nonnull ThreadCop.MODE mode)
mode
- new mode@CheckReturnValue @Nullable public Session getSession()
getSession
in interface DataSource
@CheckReturnValue public boolean hasChild(@Nonnull DBClass mapClass, @Nonnull DBField parentField, @Nonnull DBObject parentObject, @Nonnull DBField childField, @Nonnull DBObject childObject) throws java.lang.Exception
hasChild
in interface DataSource
mapClass
- The map classparentField
- the parent linkparentObject
- the parent objectchildField
- the child linkchildObject
- the child objectjava.lang.Exception
- a serious problem.@Nonnull @CheckReturnValue public DataSource getCurrentDataSource()
getCurrentDataSource
in interface DataSource
@CheckReturnValue public boolean isDisposed()
public void abort()
public void dispose()
@CheckReturnValue @Nonnull public Globals getGlobalObject() throws java.lang.Exception
getGlobalObject
in interface DataSource
java.lang.Exception
- A serious problem@Nonnull public MutableDataSource setNoSave(boolean flag)
flag
- Turn no save on.@CheckReturnValue public boolean isSaveDisabled()
@CheckReturnValue public long nextNumber(@Nonnull java.lang.String key)
nextNumber
in interface DataSource
key
- The next number key@CheckReturnValue public long nextNumber(@Nonnull java.lang.String key, int cacheSize)
nextNumber
in interface DataSource
key
- The next number keycacheSize
- The number of additional numbers to book. Disabled by zero, default if -1@CheckReturnValue public boolean isInValidateUniverse()
@CheckReturnValue public boolean isChangable()
@CheckReturnValue public boolean isInEventAction()
@Nonnull @CheckReturnValue public DBResult getInwardLinkage(@Nonnull DBClass sourceClass, @Nonnull DBField sourceField, @Nullable DBObject target, @Nullable HintField hint) throws java.lang.Exception
getInwardLinkage
in interface DataSource
hint
- the list of other records we will fetchsourceClass
- The source classsourceField
- The field that points to the target's classtarget
- The actual DBObject that the source field points to.java.lang.Exception
- A serious problempublic long touch()
@CheckReturnValue public boolean hasChanged()
@CheckReturnValue public boolean hasChangedByUser()
public void reindex() throws java.lang.Exception
java.lang.Exception
- A serious problem@CheckReturnValue public boolean hasSavePoint(@Nonnull java.lang.String id)
id
- The save-point to checkpublic void clearSavePoint(@Nonnull java.lang.String id)
public void markSavePoint(@Nonnull java.lang.String id)
id
- the save point idpublic void rollbackTo(@Nonnull java.lang.String id) throws NoSavePointException
id
- save point idNoSavePointException
- No save point found for this idpublic long save(@Nonnull java.lang.String reason) throws java.lang.Exception
reason
- The reason for saving these recordsjava.lang.Exception
- A serious problempublic void setDisableOnChangeEvent(boolean disable)
disable
- - if true, disabled on change event@CheckReturnValue public boolean isOnChangeEventDisabled()
@Nonnull public MutableDataSource setDisableChangedByUser(boolean disable)
disable
- - if true, disabled changed by user setting@CheckReturnValue public boolean isChangedByUserDisabled()
@Nonnull public MutableDataSource setAttribute(@Nonnull java.lang.String name, @Nonnull java.lang.Object value)
name
- The name of the attributevalue
- the value of the attributepublic void excludeFromGroup(@Nonnull ContactGroup group)
group
- the group that the user is to be excludedpublic void excludeFromGroup(@Nonnull ContactGroup group, @Nullable Person person)
person
- the person to excluded.group
- the group to have the contact excluded from@CheckReturnValue public boolean isExcludeFromGroup(@Nonnull ContactGroup group, @Nonnull Person person)
isExcludeFromGroup
in interface DataSource
person
- the person to check.group
- the group to check if the contact is excluded.@CheckReturnValue public boolean hasExcludedGroups()
hasExcludedGroups
in interface DataSource
@CheckReturnValue @Nullable public java.lang.Object getAttribute(@Nonnull java.lang.String name)
getAttribute
in interface DataSource
name
- the name of the attribute@CheckReturnValue public boolean isSaving()
@CheckReturnValue @Nonnull public ValidationList validateUniverse() throws java.lang.Exception
java.lang.Exception
- A serious problem@Nonnull public EventMarker raise(@Nonnull DBEvent event, @Nonnull DBObject base) throws java.lang.Exception
event
- the event that is to be raisedbase
- Base object that we are raising the Event forjava.lang.Exception
- Exceptionpublic void iAddToUniverse(@Nonnull DBObject obj)
obj
- The object to add.@CheckReturnValue @Nonnull public DBObject[] listUniverse()
@CheckReturnValue @Nonnull public VirtualDB getDataBase()
getDataBase
in interface DataSource
@Nonnull @CheckReturnValue public DataSource getDataBaseReadOnly()
getDataBaseReadOnly
in interface DataSource
@Nonnull @CheckReturnValue public DataBase getRawWriteDB() throws java.sql.SQLException
java.sql.SQLException
- a serious problem@Nonnull @CheckReturnValue @Deprecated public DataBase getRawReadDB() throws java.sql.SQLException
java.sql.SQLException
- a serious problem@Nonnull @CheckReturnValue public Login getLogin()
getLogin
in interface DataSource
@Nonnull @CheckReturnValue public Login getRealLogin()
getRealLogin
in interface DataSource
@CheckReturnValue @Nullable public Person getUser()
getUser
in interface DataSource
@Nonnull @CheckReturnValue public java.util.TimeZone getTimeZone()
getTimeZone
in interface DataSource
public final void setTimeZone(@Nonnull java.util.TimeZone tz)
tz
- the timezonepublic void setTransGroup(@Nullable TransGroup tg)
tg
- the TransGroup@Nonnull @CheckReturnValue public DBClass findDBClass(@Nonnull java.lang.String className) throws NotFoundException
findDBClass
in interface DataSource
className
- The class name to find.NotFoundException
- The class name doesn't exist@Nonnull @CheckReturnValue public DBClass findDBClass(@Nonnull GlobalId classId) throws NotFoundException
findDBClass
in interface DataSource
classId
- The class's global id.NotFoundException
- The class was not found.@Nonnull @CheckReturnValue public DBClassAbstract findDBClassAbstract(@Nonnull java.lang.String className) throws NotFoundException
findDBClassAbstract
in interface DataSource
className
- The class name to find.NotFoundException
- The class name doesn't exist@Nonnull @CheckReturnValue public DBClassAbstract findDBClassAbstract(@Nonnull GlobalId classId) throws NotFoundException
findDBClassAbstract
in interface DataSource
classId
- The class's global id.NotFoundException
- The class was not found.@Nonnull @CheckReturnValue public DBObject findKey(@Nonnull GlobalId valueId, @Nonnull GlobalId classId) throws NotFoundException
findKey
in interface DataSource
valueId
- The value idclassId
- The class idNotFoundException
- The DBObject wasn't found@Nonnull @CheckReturnValue public DBObject findKey(@Nonnull GlobalId id, @Nonnull java.lang.String defName) throws NotFoundException
findKey
in interface DataSource
id
- The value iddefName
- The class nameNotFoundException
- The DBObject wasn't found@Nonnull @CheckReturnValue public DBObject findKey(@Nonnull GlobalKey gKey) throws NotFoundException
findKey
in interface DataSource
gKey
- The global keyNotFoundException
- The DBObject wasn't found@Nonnull @CheckReturnValue public DBObject findKey(@Nonnull java.lang.String value, @Nonnull java.lang.String defName) throws NotFoundException, TooManyRowsException, java.lang.Exception
findKey
in interface DataSource
value
- the key value to search fordefName
- the class name to searchNotFoundException
- The object wasn't foundTooManyRowsException
- many objects foundjava.lang.Exception
- A serious problem.@Nonnull @CheckReturnValue public DBObject findRow(long rowId, @Nonnull DBClassConcrete def, @Nullable Hint hint) throws NotFoundException
findRow
in interface DataSource
hint
- The hint of other rows to be fetchedrowId
- The row iddef
- The DBClassNotFoundException
- The row wasn't found@Nonnull public DBObject create(@Nonnull java.lang.String className) throws java.lang.Exception
create
in interface DataSource
className
- The class Namejava.lang.Exception
- A serious problem occurred@Nonnull public DBObject create(@Nonnull DBClass dbClass) throws java.lang.Exception
create
in interface DataSource
dbClass
- The classjava.lang.Exception
- A serious problem occurred@Nonnull public DBObject create(@Nonnull DBClass dbClass, @Nullable FldParams params) throws java.lang.Exception
dbClass
- The classparams
- the parametersjava.lang.Exception
- A serious problem occurred@Nonnull public DBObject create(@Nonnull GlobalId classGid) throws java.lang.Exception
create
in interface DataSource
classGid
- The class idjava.lang.Exception
- A serious problem occurred@Nonnull public DBObject duplicate(@Nonnull DBObject orig) throws java.lang.Exception
orig
- The original DBObject to copyjava.lang.Exception
- A serious problem@CheckReturnValue @Nonnull public HashLongMap iGetUniverseRowMap()
public void resetReadChecks()
@Nullable public DBObject recycleObject(@Nullable DBObject obj) throws java.lang.Exception
obj
- The object to recyclejava.lang.Exception
- A serious problempublic void iUpdateCacheKey(@Nonnull GlobalKey gKey, @Nonnull DBObject obj)
gKey
- the key updated.obj
- The object that we are talking about.@Nonnull @CheckReturnValue public DBQueryHandler getQueryHandler(@Nonnull DBClass searchClass)
getQueryHandler
in interface DataSource
searchClass
- the class that is being searched.public void setCacheObject(@Nonnull java.lang.String key, @Nonnull java.lang.Object obj)
setCacheObject
in interface DataSource
key
- The cache keyobj
- The cached value@CheckReturnValue @Nullable public java.lang.Object getCacheObject(@Nonnull java.lang.String key)
getCacheObject
in interface DataSource
key
- the cache keypublic long forceToDB(@Nonnull java.lang.String message) throws java.lang.Exception
message
- The save messagejava.lang.Exception
- A serious problem@Nonnull @CheckReturnValue public java.lang.String toString()
toString
in class java.lang.Object
@Nonnull @CheckReturnValue public DALQuery makeQuery(@Nonnull java.lang.String className)
@Nonnull @CheckReturnValue public MemoryHandler.Cost getCost()
MemoryHandler
getCost
in interface MemoryHandler
@Nonnegative public long freeMemory(double percentage)
MemoryHandler
freeMemory
in interface MemoryHandler
percentage
- to be freed@Nonnegative public long tidyUp()
MemoryHandler
tidyUp
in interface MemoryHandler
@Nonnegative public long queuedFreeMemory(double percentage)
MemoryHandler
queuedFreeMemory
in interface MemoryHandler
percentage
- The percentage to be cleared.@Nonnegative public long panicFreeMemory()
MemoryHandler
panicFreeMemory
in interface MemoryHandler
@CheckReturnValue @Nonnegative public long getEstimatedSize()
MemoryHandler
getEstimatedSize
in interface MemoryHandler
@CheckReturnValue @Nonnegative public long getLastAccessed()
MemoryHandler
getLastAccessed
in interface MemoryHandler
stSoftware Copyright © 2001-2014 stSoftware All Rights Reserved.