Package com.db4o.internal
Class LocalObjectContainer
- java.lang.Object
-
- com.db4o.internal.ObjectContainerBase
-
- com.db4o.internal.ExternalObjectContainer
-
- com.db4o.internal.LocalObjectContainer
-
- All Implemented Interfaces:
EmbeddedObjectContainer
,ExtObjectContainer
,InternalObjectContainer
,ObjectContainerSpec
,Internal4
,ObjectContainer
,TransientClass
- Direct Known Subclasses:
IoAdaptedObjectContainer
,TransportObjectContainer
public abstract class LocalObjectContainer extends ExternalObjectContainer implements InternalObjectContainer, EmbeddedObjectContainer
-
-
Field Summary
Fields Modifier and Type Field Description protected FileHeader
_fileHeader
protected ByteArrayBuffer
_pointerIo
-
Fields inherited from class com.db4o.internal.ObjectContainerBase
_blockConverter, _classCollection, _config, _handlers, _lock, _timeStampIdGenerator, _transaction
-
-
Method Summary
-
Methods inherited from class com.db4o.internal.ExternalObjectContainer
activate, activate, backup, backupSync, bind, commit, deactivate, deactivate, delete, descend, ext, getByID, getByUUID, getID, getObjectInfo, inCallback, isActive, isCached, isStored, peekPersisted, purge, query, query, query, query, queryByExample, refresh, rollback, store, store, storedClass, storedClasses
-
Methods inherited from class com.db4o.internal.ObjectContainerBase
activate, activate, activationContextFor, activationDepthProvider, applyRenames, asTopLevelCall, backup, backupSync, bind, bind2, blockConverter, blockSize, blockSize, callbacks, callbacks, checkClosed, checkReadOnly, checkStillToSet, checkTransaction, checkTransaction, classCollection, classMetadataForID, classMetadataForName, classMetadataForObject, classMetadataForReflectClass, classMetadataIdForName, close, closeSystemTransaction, closeTransaction, closeUserTransaction, commit, commitTimestampIndex, config, configImpl, configure, container, createBlockConverter, createClassMetadata, createReferenceSystem, createStatefulBuffer, createStringIO, db4oTypeStored, deactivate, deactivate, decryptedBufferByAddress, defaultActivationDepth, delete, delete1, delete2, deleteByID, detectSchemaChanges, dispatchsEvents, environment, fatalShutdown, fatalStorageShutdown, finalize, flagAsHandled, generateTimeStampId, generateTransactionTimestamp, getActivatedObjectFromCache, getByID, getByID2, getByUUID, getHardObjectReferenceById, getHardReferenceBySignature, getID, getNativeQueryHandler, getObjectInfo, handledInCurrentTopLevelCall, handleExceptionOnClose, handlers, hasShutDownHook, initalizeWeakReferenceSupport, initialize1, initializeClassMetadataRepository, initializePostOpenExcludingTransportObjectContainer, initializeTransactions, isCached, isClient, isClosed, isStored, knownClasses, lock, logMsg, maintainsIndices, needsLockFileThread, needsUpdate, newSystemTransaction, newUserTransaction, newWeakReference, open, openImpl, peekPersisted, peekPersisted, peekReference, produceClassMetadata, purge, purge, query, query, query, query, query, queryByExample, rawBufferByAddress, readActivatedObjectNotInCache, readBytes, readBytes, readWriterByAddress, referenceSystemRegistry, reflector, refresh, refreshInternal, replaceClassMetadataRepository, replicationCallState, reserve, rollback, send, showInternalClasses, shutdownDataStorage, shutdownObjectContainer, stackDepth, stackDepth, stillToActivate, stillToDeactivate, stopSession, store, store, store2, storeAfterReplication, storeAll, storeAll, storeByNewReplication, storedClass, storedClasses, storeInternal, storeInternal, stringIO, syncExec, systemTransaction, threadPool, topLevelCallId, topLevelCallId, toString, transaction, tryGetByID, typeHandlerForClass, typeHandlerForClassMetadataID, updateDepthProvider, useDefaultTransactionTimestamp, uUIDIndex, version, versionIndex, withEnvironment, withTransaction
-
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface com.db4o.EmbeddedObjectContainer
backup
-
Methods inherited from interface com.db4o.ext.ExtObjectContainer
activate, backup, backup, backupSync, backupSync, bind, configure, deactivate, descend, getByID, getByUUID, getID, getObjectInfo, isActive, isCached, isClosed, isStored, knownClasses, lock, peekPersisted, purge, purge, reflector, refresh, store, storedClass, storedClasses, version
-
Methods inherited from interface com.db4o.internal.InternalObjectContainer
callbacks, callbacks, classMetadataForID, classMetadataForName, classMetadataForReflectClass, configImpl, container, getNativeQueryHandler, handlers, inCallback, isClient, storeAll, syncExec, transaction, updateDepthProvider
-
Methods inherited from interface com.db4o.ObjectContainer
activate, close, commit, deactivate, delete, ext, query, query, query, query, query, queryByExample, rollback, store
-
-
-
-
Field Detail
-
_fileHeader
protected FileHeader _fileHeader
-
_pointerIo
protected final ByteArrayBuffer _pointerIo
-
-
Method Detail
-
maximumDatabaseFileSize
protected long maximumDatabaseFileSize(Config4Impl configImpl)
-
newTransaction
public Transaction newTransaction(Transaction parentTransaction, ReferenceSystem referenceSystem, boolean isSystemTransaction)
- Specified by:
newTransaction
in classObjectContainerBase
-
newTransactionalIdSystem
public TransactionalIdSystem newTransactionalIdSystem(TransactionalIdSystem systemIdSystem, Closure4<IdSystem> idSystem)
-
freespaceManager
public FreespaceManager freespaceManager()
-
blockSizeReadFromFile
public void blockSizeReadFromFile(int size)
-
setRegularEndAddress
public void setRegularEndAddress(long address)
-
close2
protected final void close2()
- Specified by:
close2
in classObjectContainerBase
-
commit1
public void commit1(Transaction trans)
- Specified by:
commit1
in classObjectContainerBase
-
converterVersion
public int converterVersion()
- Specified by:
converterVersion
in classObjectContainerBase
-
currentVersion
public long currentVersion()
- Specified by:
currentVersion
in classObjectContainerBase
-
createBTreeClassIndex
public final BTree createBTreeClassIndex(int id)
-
newQueryResult
public final AbstractQueryResult newQueryResult(Transaction trans)
-
newQueryResult
public final AbstractQueryResult newQueryResult(Transaction trans, QueryEvaluationMode mode)
- Specified by:
newQueryResult
in classObjectContainerBase
-
delete4
public final boolean delete4(Transaction transaction, ObjectReference ref, java.lang.Object obj, int cascade, boolean userCall)
- Specified by:
delete4
in classObjectContainerBase
-
fileLength
public abstract long fileLength()
-
fileName
public abstract java.lang.String fileName()
-
free
public void free(Slot slot)
-
free
public void free(int address, int a_length)
-
generateNewIdentity
public void generateNewIdentity()
-
queryAllObjects
public AbstractQueryResult queryAllObjects(Transaction trans)
- Specified by:
queryAllObjects
in classObjectContainerBase
-
getAll
public AbstractQueryResult getAll(Transaction trans, QueryEvaluationMode mode)
-
allocatePointerSlot
public int allocatePointerSlot()
-
isValidPointer
protected boolean isValidPointer(int id)
-
allocateSlot
public Slot allocateSlot(int length)
-
appendBytes
public final Slot appendBytes(long bytes)
-
identity
public Db4oDatabase identity()
Description copied from interface:ExtObjectContainer
returns the Db4oDatabase object for this ObjectContainer.- Specified by:
identity
in interfaceExtObjectContainer
- Specified by:
identity
in classExternalObjectContainer
- Returns:
- the Db4oDatabase identity object for this ObjectContainer.
-
setIdentity
public void setIdentity(Db4oDatabase identity)
-
idForNewUserObject
public final int idForNewUserObject(Transaction trans)
- Specified by:
idForNewUserObject
in classObjectContainerBase
-
raiseCommitTimestamp
public void raiseCommitTimestamp(long minimumVersion)
- Specified by:
raiseCommitTimestamp
in classObjectContainerBase
-
readStatefulBufferById
public StatefulBuffer readStatefulBufferById(Transaction a_ta, int a_id)
- Specified by:
readStatefulBufferById
in classObjectContainerBase
-
readSlotBuffers
public ByteArrayBuffer[] readSlotBuffers(Transaction transaction, int[] ids)
- Specified by:
readSlotBuffers
in classObjectContainerBase
-
readBufferById
public ByteArrayBuffer readBufferById(Transaction trans, int id)
- Specified by:
readBufferById
in classObjectContainerBase
-
readBufferById
public final ByteArrayBuffer readBufferById(Transaction trans, int id, boolean lastCommitted)
- Specified by:
readBufferById
in classObjectContainerBase
-
readStatefulBufferById
public StatefulBuffer readStatefulBufferById(Transaction trans, int id, boolean lastCommitted)
- Specified by:
readStatefulBufferById
in classObjectContainerBase
-
readBufferBySlot
public ByteArrayBuffer readBufferBySlot(Slot slot)
-
readStatefulBufferBySlot
public StatefulBuffer readStatefulBufferBySlot(Transaction trans, int id, Slot slot)
-
doFinalize
protected boolean doFinalize()
- Overrides:
doFinalize
in classObjectContainerBase
-
createIdSystem
protected void createIdSystem()
-
releaseSemaphore
public final void releaseSemaphore(java.lang.String name)
Description copied from interface:ExtObjectContainer
releases a semaphore, if the calling transaction is the owner.- Specified by:
releaseSemaphore
in interfaceExtObjectContainer
- Specified by:
releaseSemaphore
in classObjectContainerBase
- Parameters:
name
- the name of the semaphore to be released.
-
releaseSemaphore
public final void releaseSemaphore(Transaction trans, java.lang.String name)
- Specified by:
releaseSemaphore
in classObjectContainerBase
-
releaseSemaphores
public void releaseSemaphores(Transaction trans)
- Specified by:
releaseSemaphores
in classObjectContainerBase
-
rollback1
public final void rollback1(Transaction trans)
- Specified by:
rollback1
in classObjectContainerBase
-
setDirtyInSystemTransaction
public final void setDirtyInSystemTransaction(PersistentBase a_object)
- Specified by:
setDirtyInSystemTransaction
in classObjectContainerBase
-
setSemaphore
public final boolean setSemaphore(java.lang.String name, int timeout)
Description copied from interface:ExtObjectContainer
attempts to set a semaphore.
Semaphores are transient multi-purpose named flags forObjectContainers
.
A transaction that successfully sets a semaphore becomes the owner of the semaphore. Semaphores can only be owned by a single transaction at one point in time.
This method returns true, if the transaction already owned the semaphore before the method call or if it successfully acquires ownership of the semaphore.
The waitForAvailability parameter allows to specify a time in milliseconds to wait for other transactions to release the semaphore, in case the semaphore is already owned by another transaction.
Semaphores are released by the first occurrence of one of the following:
- the transaction releases the semaphore withExtObjectContainer.releaseSemaphore(java.lang.String)
- the transaction is closed withObjectContainer.close()
- C/S only: the correspondingObjectServer
is closed.
- C/S only: the clientObjectContainer
looses the connection and is timed out.
Semaphores are set immediately. They are independant of callingObjectContainer.commit()
orObjectContainer.rollback()
.
Possible use cases for semaphores:
- prevent other clients from inserting a singleton at the same time. A suggested name for the semaphore: "SINGLETON_" + Object#getClass().getName().
- lock objects. A suggested name: "LOCK_" +getID(Object)
- generate a unique client ID. A suggested name: "CLIENT_" + System.currentTimeMillis().- Specified by:
setSemaphore
in interfaceExtObjectContainer
- Specified by:
setSemaphore
in classObjectContainerBase
- Parameters:
name
- the name of the semaphore to be settimeout
- the time in milliseconds to wait for other transactions to release the semaphore. The parameter may be zero, if the method is to return immediately.- Returns:
- boolean flag
true, if the semaphore could be set or if the calling transaction already owned the semaphore.
false, if the semaphore is owned by another transaction.
-
setSemaphore
public final boolean setSemaphore(Transaction trans, java.lang.String name, int timeout)
- Specified by:
setSemaphore
in classObjectContainerBase
-
setServer
public void setServer(boolean flag)
-
syncFiles
public abstract void syncFiles()
-
syncFiles
public abstract void syncFiles(java.lang.Runnable runnable)
-
defaultToString
protected java.lang.String defaultToString()
- Specified by:
defaultToString
in classObjectContainerBase
-
shutdown
public void shutdown()
- Specified by:
shutdown
in classObjectContainerBase
-
commitTransaction
public final void commitTransaction()
-
writeBytes
public abstract void writeBytes(ByteArrayBuffer buffer, int blockedAddress, int addressOffset)
-
writeDirtyClassMetadata
public final void writeDirtyClassMetadata()
- Specified by:
writeDirtyClassMetadata
in classObjectContainerBase
-
writeEncrypt
public final void writeEncrypt(ByteArrayBuffer buffer, int address, int addressOffset)
-
writeHeader
public void writeHeader(boolean startFileLockingThread, boolean shuttingDown)
-
writeNew
public final void writeNew(Transaction trans, Pointer4 pointer, ClassMetadata classMetadata, ByteArrayBuffer buffer)
- Specified by:
writeNew
in classObjectContainerBase
-
overwriteDeletedBytes
public abstract void overwriteDeletedBytes(int address, int length)
-
overwriteDeletedBlockedSlot
public void overwriteDeletedBlockedSlot(Slot slot)
-
writeTransactionPointer
public final void writeTransactionPointer(int pointer)
-
allocateSlotForUserObjectUpdate
public final Slot allocateSlotForUserObjectUpdate(Transaction trans, int id, int length)
-
allocateSlotForNewUserObject
public final Slot allocateSlotForNewUserObject(Transaction trans, int id, int length)
-
writeUpdate
public final void writeUpdate(Transaction trans, Pointer4 pointer, ClassMetadata classMetadata, ArrayType arrayType, ByteArrayBuffer buffer)
- Specified by:
writeUpdate
in classObjectContainerBase
-
setNextTimeStampId
public void setNextTimeStampId(long val)
-
systemInfo
public SystemInfo systemInfo()
Description copied from interface:ExtObjectContainer
returns theSystemInfo
for this ObjectContainer.
TheSystemInfo
supplies methods that provide information about system state and system settings of this ObjectContainer.- Specified by:
systemInfo
in interfaceExtObjectContainer
- Specified by:
systemInfo
in classObjectContainerBase
- Returns:
- the
SystemInfo
for this ObjectContainer.
-
getFileHeader
public FileHeader getFileHeader()
-
installDebugFreespaceManager
public void installDebugFreespaceManager(FreespaceManager manager)
-
systemData
public SystemData systemData()
-
getIDsForClass
public long[] getIDsForClass(Transaction trans, ClassMetadata clazz)
- Specified by:
getIDsForClass
in classObjectContainerBase
-
classOnlyQuery
public QueryResult classOnlyQuery(QQueryBase query, ClassMetadata clazz)
- Specified by:
classOnlyQuery
in classObjectContainerBase
-
executeQuery
public QueryResult executeQuery(QQuery query)
- Specified by:
executeQuery
in classObjectContainerBase
-
localSystemTransaction
public LocalTransaction localSystemTransaction()
-
instanceCount
public int instanceCount(ClassMetadata clazz, Transaction trans)
- Specified by:
instanceCount
in interfaceInternalObjectContainer
-
openSession
public ObjectContainer openSession()
Description copied from interface:ExtObjectContainer
opens a new ObjectContainer on top of this ObjectContainer. The ObjectContainer will have it's own transaction and it's own reference system.- Specified by:
openSession
in interfaceExtObjectContainer
- Returns:
- the new ObjectContainer session.
-
isDeleted
public boolean isDeleted(Transaction trans, int id)
- Specified by:
isDeleted
in classObjectContainerBase
-
writePointer
public void writePointer(int id, Slot slot)
-
debugReadPointerSlot
public Slot debugReadPointerSlot(int id)
-
readPointerSlot
public final Slot readPointerSlot(int id)
-
closeIdSystem
protected void closeIdSystem()
- Specified by:
closeIdSystem
in classObjectContainerBase
-
idSystem
public IdSystem idSystem()
-
commitHook
public java.lang.Runnable commitHook()
-
allocateSafeSlot
public final Slot allocateSafeSlot(int length)
-
newEventRegistry
public EventRegistryImpl newEventRegistry()
- Specified by:
newEventRegistry
in interfaceInternalObjectContainer
-
from
public <T> QLin<T> from(java.lang.Class<T> clazz)
-
-