|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.odi.Session
A session allows the use of the PSE/PSE Pro API. PSE/PSE Pro uses the abstract com.odi.Session class to represent sessions.
Your application must create a session. After a session is created, it is an active session. A session remains active until your application or PSE/PSE Pro terminates it. After a session is terminated, it is never used again. You can, however, create a new session.
A session consists of a set of persistent objects, and a set of PSE/PSE Pro API objects, such as an instance of the Transaction class and an instance of the Database class.
Different products allow different numbers of sessions in a single Java VM process:
Field Summary | |
protected static int |
numExpectedSessions
An integer to hold the number of expected sessions. |
Method Summary | |
static Enumeration |
activeSessions()
Obtains an enumeration of the active sessions at the time that the entrypoint is called. |
static Session |
create(String host,
Properties properties)
Creates a session that permits the caller to use the rest of the PSE/PSE Pro API. |
static Session |
create(String host,
Properties properties,
String name)
Creates a session and allows you to specify a name for the session. |
static Session |
createGlobal(String host,
Properties properties)
Creates a global session, which permits the caller to use the rest of the PSE/PSE Pro API. |
static Session |
createSchemaEvolve(String host,
int numThreads,
int prefetchKB,
int secondaryPSRSize,
Properties properties)
Creates sessions for schema evolve and returns the main session. |
abstract Transaction |
currentTransaction()
Obtains the current transaction for this session. |
abstract Properties |
getCounters(boolean reset)
Gets the internal counters and meters for the session. |
static Session |
getCurrent()
Obtains the session for the calling thread if it is associated with a session. |
static Session |
getGlobal()
Obtains the current global session. |
String |
getName()
Returns the name of the session. |
abstract Properties |
getSessionProperties()
Returns the properties associated with this session. |
abstract String |
getSessionProperty(String name)
Returns a property associated with this session. |
abstract boolean |
inTransaction()
Determines whether or not this session has a transaction in progress. |
boolean |
isActive()
Indicates whether or not this session is active. |
void |
join()
Associates the calling thread with this session. |
static void |
leave()
Disassociates the calling thread from its associated session. |
static Session |
of(Object object)
Obtains the session associated with the specified persistent object. |
static Session |
ofThread(Thread thread)
Obtains the session associated with the specified thread. |
IPersistent |
remapObject(IPersistent persistentObject)
Map a reference to a persistent object in some session, to a reference to an object in this session. |
abstract Segment |
segmentOfpreFlushContentsObject()
Call this method from a class's preFlushContents() method if preFlushContents() must be able to identify the object's segment. |
void |
terminate()
Terminates the session. |
void |
terminateSchemaEvolve()
Terminate Schema Evolve sessions. |
Field Detail |
protected static int numExpectedSessions
Method Detail |
public static Session create(String host, Properties properties)
This method throws FatalApplicationException if there is an active global session. In PSE, this method throws FatalApplicationException if there is an active nonglobal session. In PSE Pro, multiple active nonglobal sessions are allowed.
In PSE Pro, a thread that belongs to a nonglobal session can call the Session.create() method to create another nonglobal session.
host
- PSE/PSE Pro ignores this argument. Specify null. properties
- A property list that contains additional
information needed to establish the session. PSE/PSE Pro first looks for
properties defined in this list and then looks at the system properties
list. If PSE/PSE Pro cannot find a property in either list it uses the
default. All PSE/PSE Pro properties start with com.odi. You can
pass in property information by making it a system property.
All property values are strings, so if a property value is a Boolean, you must put true and false in double quotation marks.
You can specify the following properties:
com.odi.disableCrossTransactionCaching - A Boolean value that defaults to true. This means that PSE/PSE Pro makes retained objects hollow at the start of a new transaction. This is the same way that ObjectStore functions.
When this property is set to false, at the beginning of a new transaction, PSE/PSE Pro does not hollow objects whose contents were retained after a committed transaction. This means that after you commit a transaction with ObjectStore.RETAIN_READONLY or ObjectStore.RETAIN_UPDATE, you have access to all objects that you read or updated during the previous transaction. If you then start a new transaction, the contents of objects that were retained are not hollowed out. If you always retain object contents when you commit a transaction, you have access to all objects you read or updated in the current session.
This property will be deprecated in a future release when an API that performs a similar function is available.
com.odi.disableWeakReferences- A Boolean value that defaults to false. When you specify this property, PSE/PSE Pro does not use the weak reference facility.
com.odi.disableSoftReferences - A Boolean value that defaults to false. If set to true, the soft reference facility is not used by PSE/PSE Pro.
When you start the first session in a Java process, the setting of the com.odi.disableWeakReferences and com.odi.disableSoftReferences properties are in effect for the duration of the Java process. If you terminate the session and start another session with a different value for the com.odi.disableWeakReferences or com.odi.disableSoftReferences properties, the new values are ignored.
By default, the soft reference reference facility is used. If you want to use the weak reference reference facility, set the com.odi.disableSoftReferences property to true. To be able to use the strong reference facility, the com.odi.disableWeakReferences property should be set to true.
A weak or soft reference to an object is a reference that does not prevent the object from being garbage collected by the Java VM's garbage collector. In its internal object table, PSE/PSE Pro uses weak or soft references to hold references to unmodified persistent objects. If your program does not have any references to a persistent object and the reference in the Object Table is the only reference, the object can be garbage collected. If the persistent object has been modified and the changes have not yet been saved, PSE/PSE Pro uses a strong reference to hold the reference to the object. A strong reference prevents the object from being garbage collected.
com.odi.queryDebugLevel - Allows you to control debugging output when you are using the query facility defined in the com.odi.util.query.Query class. In PSE, this property does nothing.
The default level is 0, which does not output any information. Set the property to a value greater than 0 to print debugging output to System.err. As the value of this property increases, the query facility outputs more information as follows:
com.odi.trapUnregisteredType - Used to troubleshoot for ClassCastExceptions. The default is that this property is not set, and it is usually best to use the default.
When PSE/PSE Pro encounters a type for which it does not have information (that is, the type is unregistered), it checks the setting of the com.odi.trapUnregisteredType property.
If the property is not set, PSE/PSE Pro creates an instance of the UnregisteredType class to represent the unknown type. Your application continues to run as long as it does not try to use the UnregisteredType object. Often, this can be fine because your application has no need for that particular field. However, if you do try to use the unregistered type, PSE/PSE Pro throws ClassCastException.
If com.odi.trapUnregisteredType is set, PSE/PSE Pro throws FatalApplicationException and provides a message that indicates the name of the unregistered class. See the user guide for additional information.
com.odi.useDatabaseLocking - Allows you to turn cross-process locking off. By default, cross-process locking is turned on. This means that if a session has a database open, a session in another Java VM process cannot open that database. If a session tries to open a database that is already open in another process, PSE/PSE Pro throws com.odi.DatabaseLockedException.
com.odi.useFsync - A Boolean value that defaults to true. If it is false, disk buffers are not forced to disk from the underlying operating system buffers prior to commit. It is recommended that this be left at the default setting of true.
com.odi.useImmediateStrings - Specifies whether PSE/PSE Pro should attempt to store small Strings as immediate values. Immediate strings are enabled by default or if the value is set to true. Set the value to false to disable immediate strings.
If immediate strings are enabled, Strings of eight characters or less might not be stored as independent objects in the database, unless they are explicitly migrated. The result is smaller databases and elimination of the run-time overhead of tracking the Strings in the object table.
When immediate strings are in use, applications should not assume that Strings stored as the values of fields in persistent objects will themselves be persistent, unless the application explicitly calls ObjectStore.migrate() on the String.
IllegalArgumentException
- If the values for any of the specified
properties are not valid values.
FatalApplicationException
- If you are running PSE and there is
an active session.
ObjectStoreException
- If there is an active global session.public static Session create(String host, Properties properties, String name)
This method throws FatalApplicationException if there is an active global session. In PSE, this method throws FatalApplicationException if there is an active nonglobal session. In PSE Pro, multiple active nonglobal sessions are allowed.
In PSE Pro, a thread that belongs to a nonglobal session can call the Session.create() method to create another nonglobal session.
host
- PSE/PSE Pro ignores this argument. Specify null. properties
- A property list that contains additional
information needed to establish the session. PSE/PSE Pro first looks for
properties defined in this list and then looks at the system properties
list. If PSE/PSE Pro cannot find a property in either list it uses the
default. All PSE/PSE Pro properties start with com.odi. You can
pass in property information by making it a system property.
All property values are strings, so if a property value is a Boolean, you must put true and false in double quotation marks.
You can specify the following properties:
com.odi.disableCrossTransactionCaching - A Boolean value that defaults to true. This means that PSE/PSE Pro makes retained objects hollow at the start of a new transaction. This is the same way that ObjectStore functions.
When this property is set to false at the beginning of a new transaction, PSE/PSE Pro does not hollow objects whose contents were retained after a committed transaction. This means that after you commit a transaction with ObjectStore.RETAIN_READONLY or ObjectStore.RETAIN_UPDATE, you have access to all objects that you read or updated during the previous transaction. If you then start a new transaction, the contents of objects that were retained are not hollowed out. If you always retain object contents when you commit a transaction, you have access to all objects you read or updated in the current session.
This property will be deprecated in a future release when an API that performs a similar function is available.
com.odi.disableWeakReferences - A Boolean value that defaults to false. When you specify this property, PSE/PSE Pro does not use the weak reference facility.
com.odi.disableSoftReferences - A Boolean value that defaults to false. If set to true, the soft reference facility is not used by PSE/PSE Pro.
By default, the soft reference reference facility is used. If you want to use the weak reference reference facility, set the com.odi.disableSoftReferences property to true. To be able to use the strong reference facility, the com.odi.disableWeakReferences property should be set to true.
When you start the first session in a Java process, the setting of the com.odi.disableWeakReferences and com.odi.disableSoftReferences properties are in effect for the duration of the Java process. If you terminate the session and start another session with a different value for the com.odi.disableWeakReferences or com.odi.disableSoftReferences properties, the new values are ignored.
A weak or soft reference to an object is a reference that does not prevent the object from being garbage collected by the Java VM's garbage collector. In its internal Object table, PSE/PSE Pro uses weak or soft references to hold references to unmodified persistent objects. If your program does not have any references to a persistent object and the reference in the object table is the only reference, the object can be garbage collected. If the persistent object has been modified and the changes have not yet been saved, PSE/PSE Pro uses a strong reference to hold the reference to the object. A strong reference prevents the object from being garbage collected.
com.odi.stringPoolSize - Specifies the maximum size of the persistent string pool. The value of this property specifies the maximum number of newly created strings that PSE/PSE Pro can maintain in the string pool. If the number of newly created strings exceeds this number, only the ones that were most recently created and used are tracked by the pool. The default value is 100.
Before PSE/PSE Pro migrates a string into a segment, it checks the pool to see if a string with the same value is already available in the segment. If it is, the string is reused and PSE/PSE Pro does not create a new one. PSE/PSE Pro clears the pool at the start of each transaction. You can turn off the pooling mechanism by setting the value of this property to 0.
com.odi.queryDebugLevel - Allows you to control debugging output when you are using the PSE Pro query facility defined in the com.odi.util.query.Query class. In PSE, this property does nothing.
The default level is 0, which does not output any information. Set the property to a value greater than 0 to print debugging output to System.err. As the value of this property increases, the query facility outputs more information as follows:
com.odi.trapUnregisteredType - Used to troubleshoot ClassCastExceptions. The default is that this property is not set, and it is usually best to use the default.
When PSE/PSE Pro encounters a type for which it does not have information, it checks the setting of the com.odi.trapUnregisteredType property.
If the property is not set, PSE/PSE Pro creates an instance of the UnregisteredType class to represent the unknown type. Your application continues to run as long as it does not try to use the UnregisteredType object. Often, this can be fine because your application has no need for that particular field. However, if you do try to use the unregistered type, PSE/PSE Pro throws ClassCastException.
If com.odi.trapUnregisteredType is set, PSE/PSE Pro throws FatalApplicationException and provides a message that indicates the name of the unregistered class. See the user guide for additional information.
com.odi.useDatabaseLocking - Allows you to turn cross-process locking off. By default, cross-process locking is turned on. This means that if a session has a database open, a session in another Java VM process cannot open that database. If a session tries to open a database that is already open in another process, PSE/PSE Pro throws com.odi.DatabaseLockedException.
com.odi.useFsync - A Boolean value that defaults to true. If it is false, disk buffers are not forced to disk from the underlying operating system buffers prior to commit. It is recommended that this be left at the default setting of true.
com.odi.useImmediateStrings - Specifies whether PSE/PSE Pro should attempt to store small Strings as immediate values. Immediate strings are enabled by default, or if the value is set to true. Set the value to false to disable immediate strings.
If immediate strings are enabled, Strings of eight characters or less might not be stored as independent objects in the database, unless they are explicitly migrated. The result is smaller databases and elimination of the runtime overhead of tracking the Strings in the object table.
When immediate strings are in use, applications should not assume that Strings stored as the values of fields in persistent objects will themselves be persistent, unless the application explicitly calls ObjectStore.migrate() on the String.
name
- The name of the session. If the name is null, then a unique
name is generated.
FatalApplicationException
- If you are running PSE and there is
an active session.
IllegalArgumentException
- If the values for any of the specified
properties are not valid values.
ObjectStoreException
- If there is an active global session.public static Session createGlobal(String host, Properties properties)
This method throws an exception if there is an active session.
host
- PSE/PSE Pro ignores this argument. Specify null. properties
- A property list that contains additional
information needed to establish the session. PSE/PSE Pro first looks for
properties defined in this list and then looks at the system properties
list. If PSE/PSE Pro cannot find a property in either list it uses the
default. All PSE/PSE Pro properties start with com.odi. You can
pass in property information by making it a system property.
All property values are strings, so if a property value is a Boolean, you must put true and false in double quotation marks.
You can specify the following properties:
com.odi.disableCrossTransactionCaching - Defaults to true. This means that PSE/PSE Pro makes retained objects hollow at the start of a new transaction. This is the same way that ObjectStore functions. When this property is set to false, at the beginning of a new transaction, PSE/PSE Pro does not hollow objects whose contents were retained after a committed transaction. This means that after you commit a transaction with ObjectStore.RETAIN_READONLY or ObjectStore.RETAIN_UPDATE, you have access to all objects that you read or updated during the previous transaction. If you then start a new transaction, the contents of objects that were retained are not hollowed out. If you always retain object contents when you commit a transaction, you have access to all objects you read or updated in the current session.
This property will be deprecated in a future release when an API that performs a similar function is available.
com.odi.disableWeakReferences is a Boolean value that defaults to false. When you specify this property, PSE/PSE Pro does not use the weak reference facility.
com.odi.disableSoftReferences - A Boolean value that defaults to false. If set to true, the soft reference facility is not used by PSE/PSE Pro.
By default, the soft reference reference facility is used. If you want to use the weak reference reference facility, set the com.odi.disableSoftReferences property to true. To be able to use the strong reference facility, the com.odi.disableWeakReferences property should be set to true.
When you start the first session in a Java process, the setting of the com.odi.disableWeakReferences and com.odi.disableSoftReferences properties are in effect for the duration of the Java process. If you terminate the session and start another session with a different value for the com.odi.disableWeakReferences or com.odi.disableSoftReferences properties, the new values are ignored.
A weak or soft reference to an object is a reference that does not prevent the object from being garbage collected by the Java VM's garbage collector. In its internal object table, PSE/PSE Pro uses weak or soft references to hold references to unmodified persistent objects. If your program does not have any references to a persistent object and the reference in the Object Table is the only reference, the object can be garbage collected. If the persistent object has been modified and the changes have not yet been saved, PSE/PSE Pro uses a strong reference to the reference to the object. A strong reference prevents the object from being garbage collected.
com.odi.queryDebugLevel - Allows you to control debugging output when you are using the PSE Pro query facility defined in the com.odi.util.query.Query class. In PSE, this property does nothing. The default level is 0, which does not output any information. Set the property to a value greater than 0 to print debugging output to System.err. As the value of this property increases, the query facility outputs more information as follows:
com.odi.stringPoolSize - Specifies the maximum size of the persistent string pool. The value of this property specifies the maximum number of newly created strings that PSE/PSE Pro can maintain in the string pool. If the number of newly created strings exceeds this number, only the ones that were most recently created and used are tracked by the pool. In PSE Pro, the default is 100. In PSE, the default is 0, that is, string pooling is disabled by default. In PSE, there is no persistent garbage collector and so string pooling might not be safe. Before PSE/PSE Pro migrates a string into a segment, it checks the pool to see if a string with the same value is already available in the segment. If it is, the string is reused and PSE/PSE Pro does not create a new one. PSE/PSE Pro clears the pool at the start of each transaction. You can turn off the pooling mechanism by setting the value of this property to 0.
com.odi.trapUnregisteredType Used to troubleshoot ClassCastExceptions. The default is that this property is not set, and it is usually best to use the default.
When PSE/PSE Pro encounters a type for which it does not have information, it checks the setting of the com.odi.trapUnregisteredType property.
If the property is not set, PSE/PSE Pro creates an instance of the UnregisteredType class to represent the unknown type. Your application continues to run as long as it does not try to use the UnregisteredType object. Often, this can be fine because your application has no need for that particular field. However, if you do try to use the unregistered type, PSE/PSE Pro throws ClassCastException. If com.odi.trapUnregisteredType is set, PSE/PSE Pro throws FatalApplicationException and provides a message that indicates the name of the unregistered class. See the user guide for additional information.
com.odi.useDatabaseLocking - Allows you to turn cross process locking off. By default, cross-process locking is turned on. This means that if a session has a database open, a session in another Java VM process cannot open that database. If a session tries to open a database that is already open in another process, PSE/PSE Pro throws com.odi.DatabaseLockedException.
com.odi.useFsync - A Boolean value that defaults to true. If it is false, disk buffers are not forced to disk from the underlying operating system buffers prior to commit. It is recommended that this be left at the default setting of true.
com.odi.useImmediateStrings - Specifies whether PSE/PSE Pro should attempt to store small Strings as immediate values. Immediate strings are enabled by default, or if the value is set to true. Set the value to false to disable immediate strings.
If immediate strings are enabled, Strings of eight characters or less might not be stored as independent objects in the database, unless they are explicitly migrated. The result is smaller databases and elimination of the run-time overhead of tracking the Strings in the object table.
When immediate strings are in use, applications should not assume that Strings stored as the values of fields in persistent objects will themselves be persistent, unless the application explicitly calls ObjectStore.migrate() on the String.
IllegalArgumentException
- If the values for any of the specified
properties are not valid values.
ObjectStoreException
- If there is an active global session.public static Session createSchemaEvolve(String host, int numThreads, int prefetchKB, int secondaryPSRSize, Properties properties)
ObjectException
- If the application is using PSE or PSE Pro.public void terminate()
public void terminateSchemaEvolve()
public void join()
WrongSessionException
- If the calling thread is already associated
with a different session.
NoSessionException
- If the session was terminated.public static void leave()
public abstract Transaction currentTransaction()
ObjectStoreException
- If this session was terminated.
NoTransactionInProgressException
- If this session does not have a
transaction in progress.public abstract boolean inTransaction()
ObjectStoreException
- If this session was terminated.public static Session getGlobal()
public final boolean isActive()
public static Enumeration activeSessions()
public abstract Segment segmentOfpreFlushContentsObject()
NoTransactionInProgressException
- If there is no transaction
in progress.
ObjectStoreException
- If this method is not invoked in the dynamic
scope of a preFlushContents() call.public static Session getCurrent()
public static Session ofThread(Thread thread)
IllegalArgumentException
- If the thread argument is null.public final String getName()
public static Session of(Object object)
object
- A persistent object.
public abstract Properties getCounters(boolean reset)
reset
- If true, resets the counters to 0.
ObjectStoreException
- If the session has been terminated.public IPersistent remapObject(IPersistent persistentObject)
persistentObject
- an instance of a persistence-capable object.
ObjectNotFoundException
- If the object was destroyed, or its
segment or cluster was destroyed.
ObjectException
- If the persistentObject reference is stale.
DatabaseNotOpenException
- If the database containing the
persistent object is not open in this session.
NoTransactionInProgressException
- If no transaction is in
progress in this session.
NoSessionException
- If this session is not active.public abstract Properties getSessionProperties()
public abstract String getSessionProperty(String name)
name
- the property name whose value is required.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |