Class AbstractHttpSessionModel
- java.lang.Object
-
- com.tangosol.util.Base
-
- com.tangosol.coherence.servlet.AbstractHttpSessionModel
-
- All Implemented Interfaces:
HttpSessionModel
,ExternalizableLite
,Externalizable
,Serializable
- Direct Known Subclasses:
MonolithicHttpSessionModel
,TraditionalHttpSessionModel
public abstract class AbstractHttpSessionModel extends Base implements HttpSessionModel, Externalizable, ExternalizableLite
An abstract base class from which implementations of HttpSessionModel can be more easily built.Note that the Externalizable implementation on this class is just there to throw exceptions that this class is not Serializable or Externalizable. Use ExternalizableLite instead.
- Version:
- Coherence 2.3
- Author:
- cp 2003.10.15
- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class com.tangosol.util.Base
Base.LoggingWriter
-
-
Field Summary
Fields Modifier and Type Field Description static String
CTX_OPTIMIZE_MODIFIED_SESSIONS
The configuration property that specifies to use the flush cache optimization for sessions that have been modified.static int
MAGIC_V350
Coherence*Web version identifier for serialization.String[]
STRING_ARRAY
Zero-length array of String objects.
-
Constructor Summary
Constructors Constructor Description AbstractHttpSessionModel()
Default constructor for deserialization.AbstractHttpSessionModel(AbstractHttpSessionCollection collection, javax.servlet.http.HttpSession session, String sId)
Session creation constructor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
activate(javax.servlet.http.HttpSession session)
Activate the session model.protected void
addEnteredThread()
Add the currently running thread to the list of threads that have entered this session model.protected void
bind(AttributeHolder holderOld, AttributeHolder holderNew)
Bind the specified session attribute, replacing the specified attribute if it exists.protected void
checkActive()
Make sure that the model is 'active', 'usable' and 'valid'.protected void
checkUsable()
Make sure that the model is 'usable'.protected void
checkValid()
Make sure that the model is 'usable' and 'valid'.protected void
discard()
When the session model is no longer usable, it is discarded.protected void
enter()
Increment the usage count of the session by this thread.protected void
exit()
Decrement the usage count of the session by this thread.protected String
extractAttributeName(String sAttribute)
Given a potentially qualified attribute name, return the original (fully unqualified) attribute name.protected String[]
extractAttributeNames(String[] asAttribute)
Given an array of potentially qualified attribute name, return an array of the original (fully unqualified) attribute names.protected void
flush()
Flush the changes to this model to whatever data structure (for example, a cache) that is responsible for managing the model's data.protected Map
getActualAttributeMap()
Get the map of session attributes that are part of this session (not "local".)Object
getAttribute(String sName)
Returns the object bound with the specified name in this session, ornull
if no object is bound under the name.protected Map
getAttributeMap()
Get a view of the session's attributes as a Map.String[]
getAttributeNameArray()
Returns an array of attribute names for this session.protected AbstractHttpSessionCollection
getCollection()
Determine the collection that this model belongs to.long
getCreationTime()
Returns the creation time for this session.protected String
getDescription()
Returns a string representation of this object's attributes.protected Set<Thread>
getEnteredThreads()
Retrieve the list of all threads that have entered this session model.protected javax.servlet.http.HttpSession
getHttpSession()
Determine the HttpSession that this model is bound to.String
getId()
Returns the session identifier for this session.long
getLastAccessedTime()
Returns the last time the client sent a request associated with this session, as the number of milliseconds since midnight, January 1, 1970 GMT.protected long
getLastFlushedTime()
Returns the last time this session was flushed, as the number of milliseconds since midnight, January 1, 1970 GMT.protected Map
getLocalAttributeMap()
Get the map of session attributes that are owned by this model but are stored in a "local" manner.int
getMaxInactiveInterval()
Returns the maximum time interval, in seconds, between client requests before the servlet container will invalidate the session.String
getNewId()
Returns the updated session identifier for this session after authentication.int
getReferenceCount()
Determine the reference count (unmatched enter calls) for this model.protected Thread
getThreadOwner()
Retrieve the thread that has entered this session model.protected int
getVersion()
Return the version indicator for this model.protected AttributeHolder
instantiateAttributeHolder()
Factory method: Instantiate an AttributeHolder for deserialization purposes.protected AttributeHolder
instantiateAttributeHolder(String sName, Object oValue)
Factory method: Instantiate an AttributeHolder to manage the passed value.protected boolean
isActivatableAttributes()
Determine if the session model may have attributes that need to be activated and passivated.protected boolean
isActive()
Determine if the session model is active (not passivated).boolean
isExpired()
A helper method to determine if the session data has expired.protected boolean
isExpiredInternal(long currentTime)
Check if the session has expired.static boolean
isImmutable(Object o)
Determine if the passed object is definitely of an immutable type.protected boolean
isLastAccessTimeFlushRequired()
Determine if the LastAccessTime property (and only that property) needs to be flushed.protected boolean
isLocal()
Determine whether the session is local (not distributed).protected boolean
isModified()
Determine if the session has been modified since it was deserialized or last marked as not-modified.boolean
isNew()
Returnstrue
if the client does not yet know about the session or if the client chooses not to join the session.protected boolean
isOwnedByThisThread()
Determine if this model is owned by the current thread.boolean
isUsable()
Determine if this session model is a usable object.boolean
isValid()
Determine if this session model is valid.protected void
logAttributeSerializationFailure(AttributeHolder holder, Throwable e)
Log a serialization failure for an attribute holder.protected boolean
obtainThreadOwnership()
Obtain thread ownership of this model, if necessary.protected void
passivate()
Passivate the session model.protected String
qualifyAttributeName(String sAttribute)
Given an attribute name, return a potentially qualified name.protected void
readAttributes(DataInput in)
Helper to read the session attributes from a stream.void
readExternal(DataInput in)
Helper to read the object state from a stream.void
readExternal(ObjectInput in)
The object implements the readExternal method to restore its contents by calling the methods of DataInput for primitive types and readObject for objects, strings and arrays.protected boolean
releaseThreadOwnership()
Release thread ownership of this model.void
removeAttribute(String sName)
Removes the object bound with the specified name from this session.protected void
removeEnteredThread()
Remove the currently running thread from the list of threads that have entered this session model.void
resetReferenceCount()
Reset the reference count to 0.void
sessionReturned()
Indicates to the session that it is no longer new, because the session ID has been returned to the client to allow the client to accept it, as described in the Servlet specification.protected void
setActivatableAttributes(boolean fActivatable)
Specify whether the session model may or may not have attributes that need to be activated and passivated.void
setAttribute(String sName, Object oValue)
Binds an object to this session, using the name specified.protected void
setCollection(AbstractHttpSessionCollection collection)
After deserialization, the collection needs to be configured.protected void
setHttpSession(javax.servlet.http.HttpSession session)
Configure the HttpSession that this model is bound to.protected void
setId(String sId)
Allow a sub-class to specify the session ID, for example during deserialization.protected void
setLastAccessedTime(long ldtLastAccessedTime)
Set the time this session was last accessed, as the number of milliseconds since midnight, January 1, 1970 GMT.protected void
setLastFlushedTime(long ldtLastFlushedTime)
Set the time this session was last flushed, as the number of milliseconds since midnight, January 1, 1970 GMT.void
setMaxInactiveInterval(int cSeconds)
Set the maximum time interval, in seconds, between client requests before the servlet container will invalidate the session.protected void
setModified(boolean fModified)
Specify whether or not the session has been modified.protected void
setNewId(String sNewId)
Set the updated session id after authentication has occured.protected void
setValid(boolean fValid)
Allow a sub-class to explicitly validate the session model, for example at the completion of deserialization.protected void
setVersion(int nVersion)
Set the version indicator of this model.String
toString()
Returns a string representation of the object.void
touch()
Update the last-accessed time for the session.protected void
unbind()
Unbind session attributes.protected void
unbind(AttributeHolder holder, boolean fAll)
Unbind the specified session attributes name and value.protected void
writeAttributes(DataOutput out)
Helper to write the session attributes to a stream.void
writeExternal(DataOutput out)
Helper to write the object state to a stream.void
writeExternal(ObjectOutput out)
The object implements the writeExternal method to save its contents by calling the methods of DataOutput for its primitive values or calling the writeObject method of ObjectOutput for objects, strings, and arrays.-
Methods inherited from class com.tangosol.util.Base
azzert, azzert, azzert, azzertFailed, breakLines, breakLines, capitalize, checkNotEmpty, checkNotNull, checkRange, computeSafeWaitTime, decimalValue, dup, dup, ensureBigDecimal, ensureClassLoader, ensureRuntimeException, ensureRuntimeException, equals, equalsDeep, err, err, err, err, err, escape, formatDateTime, getCallerStackFrame, getCommonMonitor, getCommonMonitor, getCommonMonitor, getContextClassLoader, getContextClassLoader, getDeepMessage, getErr, getLastSafeTimeMillis, getLog, getMaxDecDigits, getMaxHexDigits, getOriginalException, getOut, getProcessRandom, getRandom, getRandomBinary, getRandomBinary, getRandomString, getSafeTimeMillis, getStackFrame, getStackFrames, getStackTrace, getStackTrace, getStackTrace, getThreadFactory, getTimeZone, getUpTimeMillis, hashCode, hexValue, indentString, indentString, isDecimal, isHex, isLogEcho, isOctal, log, log, log, log, log, makeInteger, makeLong, makeThread, mergeArray, mergeBooleanArray, mergeByteArray, mergeCharArray, mergeDoubleArray, mergeFloatArray, mergeIntArray, mergeLongArray, mod, mod, octalValue, out, out, out, out, out, pad, parseBandwidth, parseBandwidth, parseDelimitedString, parseHex, parseHex, parseMemorySize, parseMemorySize, parsePercentage, parseTime, parseTime, parseTimeNanos, parseTimeNanos, printStackTrace, randomize, randomize, randomize, randomize, read, read, read, read, read, read, read, replace, setErr, setLog, setLogEcho, setOut, sleep, toBandwidthString, toBandwidthString, toCharEscape, toCrc, toCrc, toCrc, toCrc, toCrc, toDecString, toDelimitedString, toDelimitedString, toDelimitedString, toDelimitedString, toHex, toHex, toHexDump, toHexEscape, toHexEscape, toHexEscape, toHexEscape, toHexString, toMemorySizeString, toMemorySizeString, toQuotedCharEscape, toQuotedStringEscape, toSqlString, toString, toString, toStringEscape, toUnicodeEscape, trace, trace, trace, trace, trace, trace, trace, trace, trace, truncateString, truncateString, wait
-
-
-
-
Field Detail
-
STRING_ARRAY
public String[] STRING_ARRAY
Zero-length array of String objects.
-
MAGIC_V350
public static final int MAGIC_V350
Coherence*Web version identifier for serialization.- Since:
- Coherence 3.5
- See Also:
- Constant Field Values
-
CTX_OPTIMIZE_MODIFIED_SESSIONS
public static final String CTX_OPTIMIZE_MODIFIED_SESSIONS
The configuration property that specifies to use the flush cache optimization for sessions that have been modified.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
AbstractHttpSessionModel
public AbstractHttpSessionModel()
Default constructor for deserialization.
-
AbstractHttpSessionModel
public AbstractHttpSessionModel(AbstractHttpSessionCollection collection, javax.servlet.http.HttpSession session, String sId)
Session creation constructor.- Parameters:
collection
- the collection that manages this modelsession
- the session that delegates to this modelsId
- the session ID
-
-
Method Detail
-
getAttribute
public Object getAttribute(String sName)
Returns the object bound with the specified name in this session, ornull
if no object is bound under the name.- Specified by:
getAttribute
in interfaceHttpSessionModel
- Parameters:
sName
- a string specifying the name of the object- Returns:
- the object with the specified name
-
getAttributeNameArray
public String[] getAttributeNameArray()
Returns an array of attribute names for this session.- Specified by:
getAttributeNameArray
in interfaceHttpSessionModel
- Returns:
- an array of
String
objects specifying the names of all the objects bound to this session
-
getCreationTime
public long getCreationTime()
Returns the creation time for this session.- Specified by:
getCreationTime
in interfaceHttpSessionModel
- Returns:
- the creation time for this session
-
getId
public String getId()
Returns the session identifier for this session.- Specified by:
getId
in interfaceHttpSessionModel
- Returns:
- the session identifier for this session.
-
getNewId
public String getNewId()
Returns the updated session identifier for this session after authentication.- Returns:
- the updated session identifier for this session.
-
getLastAccessedTime
public long getLastAccessedTime()
Returns the last time the client sent a request associated with this session, as the number of milliseconds since midnight, January 1, 1970 GMT. Actions that your application takes, such as getting or setting a value associated with the session, do not affect the access time.- Specified by:
getLastAccessedTime
in interfaceHttpSessionModel
- Returns:
- the last time the client sent a request associated with this session, as the number of milliseconds since midnight, January 1, 1970 GMT. Actions that your application takes, such as getting or setting a value associated with the session, do not affect the access time
-
getMaxInactiveInterval
public int getMaxInactiveInterval()
Returns the maximum time interval, in seconds, between client requests before the servlet container will invalidate the session. A negative time indicates that the session should never time out.- Specified by:
getMaxInactiveInterval
in interfaceHttpSessionModel
- Returns:
- the maximum time interval, in seconds, between client requests before the servlet container will invalidate the session. A negative time indicates that the session should never time out
-
isExpired
public boolean isExpired()
A helper method to determine if the session data has expired.- Specified by:
isExpired
in interfaceHttpSessionModel
- Returns:
- true if the session served by this session model has expired
-
isExpiredInternal
protected boolean isExpiredInternal(long currentTime)
Check if the session has expired.- Parameters:
currentTime
- the current time in millis- Returns:
- true, if the session has expired
-
isNew
public boolean isNew()
Returnstrue
if the client does not yet know about the session or if the client chooses not to join the session. For example, if the server used only cookie-based sessions, and the client had disabled the use of cookies, then a session would be new on each request.- Specified by:
isNew
in interfaceHttpSessionModel
- Returns:
true
if the server has created a session, but the client has not yet joined
-
isUsable
public boolean isUsable()
Determine if this session model is a usable object. For example, a session model may become unusable if it is passivated and then held beyond the request scope.When a session model becomes unusable, the only method that can be assumed to respond without throwing an exception is
HttpSessionModel.getId()
.- Specified by:
isUsable
in interfaceHttpSessionModel
- Returns:
- true if this session model object is still usable, false if the session model should be re-obtained from its collection
-
isValid
public boolean isValid()
Determine if this session model is valid.- Specified by:
isValid
in interfaceHttpSessionModel
- Returns:
true
if the session has not been destroyed, otherwisefalse
-
removeAttribute
public void removeAttribute(String sName)
Removes the object bound with the specified name from this session. If the session does not have an object bound with the specified name, this method does nothing.- Specified by:
removeAttribute
in interfaceHttpSessionModel
- Parameters:
sName
- the name of the object to remove from this session
-
sessionReturned
public void sessionReturned()
Indicates to the session that it is no longer new, because the session ID has been returned to the client to allow the client to accept it, as described in the Servlet specification.- Specified by:
sessionReturned
in interfaceHttpSessionModel
-
setAttribute
public void setAttribute(String sName, Object oValue)
Binds an object to this session, using the name specified. If an object of the same name is already bound to the session, the object is replaced.- Specified by:
setAttribute
in interfaceHttpSessionModel
- Parameters:
sName
- the name to which the object is bound; cannot be nulloValue
- the object to be bound; cannot be null
-
setMaxInactiveInterval
public void setMaxInactiveInterval(int cSeconds)
Set the maximum time interval, in seconds, between client requests before the servlet container will invalidate the session. A negative time indicates that the session should never time out.- Specified by:
setMaxInactiveInterval
in interfaceHttpSessionModel
- Parameters:
cSeconds
- the new maximum interval
-
touch
public void touch()
Update the last-accessed time for the session.- Specified by:
touch
in interfaceHttpSessionModel
-
toString
public String toString()
Returns a string representation of the object.
-
getCollection
protected AbstractHttpSessionCollection getCollection()
Determine the collection that this model belongs to.- Returns:
- the AbstractHttpSessionCollection that this model belongs to
-
setCollection
protected void setCollection(AbstractHttpSessionCollection collection)
After deserialization, the collection needs to be configured.- Parameters:
collection
- the AbstractHttpSessionCollection that this model belongs to
-
getHttpSession
protected javax.servlet.http.HttpSession getHttpSession()
Determine the HttpSession that this model is bound to.- Returns:
- the HttpSession that this model is bound to, or null if the model is not active
-
setHttpSession
protected void setHttpSession(javax.servlet.http.HttpSession session)
Configure the HttpSession that this model is bound to.- Parameters:
session
- the HttpSession that this model is bound to; may be null to deactivate the model
-
setId
protected void setId(String sId)
Allow a sub-class to specify the session ID, for example during deserialization.- Parameters:
sId
- the session id
-
setNewId
protected void setNewId(String sNewId)
Set the updated session id after authentication has occured. Used in web containers that implement Servlet 3.1.- Parameters:
sNewId
- the new session id
-
setValid
protected void setValid(boolean fValid)
Allow a sub-class to explicitly validate the session model, for example at the completion of deserialization.- Parameters:
fValid
- true if the session model is valid, false otherwise
-
getVersion
protected int getVersion()
Return the version indicator for this model.The version indicator is used to detect concurrent modifications when member-level locking is disabled.
- Returns:
- the version indicator for this model
-
setVersion
protected void setVersion(int nVersion)
Set the version indicator of this model.- Parameters:
nVersion
- the new version indicator; must be >= 0
-
isLocal
protected boolean isLocal()
Determine whether the session is local (not distributed). This is possible only if a session distribution controller is used.- Returns:
- true if the session is not yet distributed
-
getAttributeMap
protected Map getAttributeMap()
Get a view of the session's attributes as a Map.- Returns:
- a view of the session's attributes as a Map
-
getActualAttributeMap
protected Map getActualAttributeMap()
Get the map of session attributes that are part of this session (not "local".)- Returns:
- the map of not "local" session attributes
-
getLocalAttributeMap
protected Map getLocalAttributeMap()
Get the map of session attributes that are owned by this model but are stored in a "local" manner.- Returns:
- the map of "local" session attributes
-
isActive
protected boolean isActive()
Determine if the session model is active (not passivated).- Returns:
- true if the session model is active
-
isActivatableAttributes
protected boolean isActivatableAttributes()
Determine if the session model may have attributes that need to be activated and passivated.- Returns:
- true if any of the session attributes may require activation
-
setActivatableAttributes
protected void setActivatableAttributes(boolean fActivatable)
Specify whether the session model may or may not have attributes that need to be activated and passivated. This is intended to allow some model implementations to optimize their activation and passivation.- Parameters:
fActivatable
- passtrue if any of the session attributes may require activation
-
activate
protected void activate(javax.servlet.http.HttpSession session)
Activate the session model. If the model is already active, this does not have any effect.This method may only be called by a thread that owns this model. See
AbstractHttpSessionCollection.obtainThreadOwnership(java.lang.String)
.- Parameters:
session
- the HttpSession to bind this model to
-
passivate
protected void passivate()
Passivate the session model. This issues events and releases the reference to the HttpSession. If the model is not active, this does not have any effect.This method may only be called by a thread that owns this model. See
AbstractHttpSessionCollection.obtainThreadOwnership(java.lang.String)
.
-
bind
protected void bind(AttributeHolder holderOld, AttributeHolder holderNew)
Bind the specified session attribute, replacing the specified attribute if it exists.This method may only be called by a thread that owns this model. See
AbstractHttpSessionCollection.obtainThreadOwnership(java.lang.String)
.- Parameters:
holderOld
- the attribute information to unbind; may be nullholderNew
- the attribute information to bind
-
unbind
protected void unbind(AttributeHolder holder, boolean fAll)
Unbind the specified session attributes name and value.This method may only be called by a thread that owns this model. See
AbstractHttpSessionCollection.obtainThreadOwnership(java.lang.String)
.- Parameters:
holder
- the attribute information to unbindfAll
- true if this method is called within the context of anunbind()
call
-
unbind
protected void unbind()
Unbind session attributes.This method may only be called by a thread that owns this model. See
AbstractHttpSessionCollection.obtainThreadOwnership(java.lang.String)
.
-
logAttributeSerializationFailure
protected void logAttributeSerializationFailure(AttributeHolder holder, Throwable e)
Log a serialization failure for an attribute holder.- Parameters:
holder
- the attribute holder that failed to serialize its valuee
- the throwable object that resulted from the serialization failure
-
discard
protected void discard()
When the session model is no longer usable, it is discarded.This method may only be called by a thread that owns this model. See
AbstractHttpSessionCollection.obtainThreadOwnership(java.lang.String)
.
-
isModified
protected boolean isModified()
Determine if the session has been modified since it was deserialized or last marked as not-modified.- Returns:
- true if the session has been modified
-
setModified
protected void setModified(boolean fModified)
Specify whether or not the session has been modified.- Parameters:
fModified
- true if the session has been modified, false to reset the modified indicator
-
setLastAccessedTime
protected void setLastAccessedTime(long ldtLastAccessedTime)
Set the time this session was last accessed, as the number of milliseconds since midnight, January 1, 1970 GMT.- Parameters:
ldtLastAccessedTime
- the last time this session was accessed, as the number of milliseconds since midnight, January 1, 1970 GMT
-
getLastFlushedTime
protected long getLastFlushedTime()
Returns the last time this session was flushed, as the number of milliseconds since midnight, January 1, 1970 GMT.- Returns:
- the last time this session was flushed, as the number of milliseconds since midnight, January 1, 1970 GMT
-
setLastFlushedTime
protected void setLastFlushedTime(long ldtLastFlushedTime)
Set the time this session was last flushed, as the number of milliseconds since midnight, January 1, 1970 GMT.- Parameters:
ldtLastFlushedTime
- the last time this session was flushed, as the number of milliseconds since midnight, January 1, 1970 GMT
-
isLastAccessTimeFlushRequired
protected boolean isLastAccessTimeFlushRequired()
Determine if the LastAccessTime property (and only that property) needs to be flushed.- Returns:
- true if only the timestamp needs to be flushed
-
getEnteredThreads
protected Set<Thread> getEnteredThreads()
Retrieve the list of all threads that have entered this session model.- Returns:
- the Set of threads that have entered this session model
-
addEnteredThread
protected void addEnteredThread()
Add the currently running thread to the list of threads that have entered this session model.
-
removeEnteredThread
protected void removeEnteredThread()
Remove the currently running thread from the list of threads that have entered this session model.
-
getThreadOwner
protected Thread getThreadOwner()
Retrieve the thread that has entered this session model. Only relevant if thread level session locking is enabled.- Returns:
- the thread that has entered this session model
-
obtainThreadOwnership
protected boolean obtainThreadOwnership()
Obtain thread ownership of this model, if necessary.If thread locking is enforced this method has no effect and false is returned; otherwise, this model is locked in the local owned cache and true is returned. A return value of true implies that
releaseThreadOwnership()
must be called when exclusive access to the model is no longer required.- Returns:
- true if this model was locked in the local owned cache; false otherwise
- See Also:
AbstractHttpSessionCollection.obtainThreadOwnership(String)
-
releaseThreadOwnership
protected boolean releaseThreadOwnership()
Release thread ownership of this model.- Returns:
- true if the thread ownership is released; false otherwise
- See Also:
AbstractHttpSessionCollection.releaseThreadOwnership(String)
-
isOwnedByThisThread
protected boolean isOwnedByThisThread()
Determine if this model is owned by the current thread.- Returns:
- true if the session model is owned by this thread
-
getReferenceCount
public int getReferenceCount()
Determine the reference count (unmatched enter calls) for this model.- Specified by:
getReferenceCount
in interfaceHttpSessionModel
- Returns:
- the reference count (unmatched enter calls) for this model
-
resetReferenceCount
public void resetReferenceCount()
Reset the reference count to 0.
-
enter
protected void enter()
Increment the usage count of the session by this thread.This method may only be called by a thread that owns this model. See
AbstractHttpSessionCollection.obtainThreadOwnership(java.lang.String)
.
-
exit
protected void exit()
Decrement the usage count of the session by this thread.This method may only be called by a thread that owns this model. See
AbstractHttpSessionCollection.obtainThreadOwnership(java.lang.String)
.
-
flush
protected void flush()
Flush the changes to this model to whatever data structure (for example, a cache) that is responsible for managing the model's data.This method may only be called by a thread that owns this model. See
AbstractHttpSessionCollection.obtainThreadOwnership(java.lang.String)
.
-
readExternal
public void readExternal(ObjectInput in) throws IOException
The object implements the readExternal method to restore its contents by calling the methods of DataInput for primitive types and readObject for objects, strings and arrays. The readExternal method must read the values in the same sequence and with the same types as were written by writeExternal.- Specified by:
readExternal
in interfaceExternalizable
- Parameters:
in
- the stream to read data from in order to restore the object- Throws:
IOException
- if an I/O exception occurs
-
writeExternal
public void writeExternal(ObjectOutput out) throws IOException
The object implements the writeExternal method to save its contents by calling the methods of DataOutput for its primitive values or calling the writeObject method of ObjectOutput for objects, strings, and arrays.- Specified by:
writeExternal
in interfaceExternalizable
- Parameters:
out
- the stream to write the object to- Throws:
IOException
- if an I/O exception occurs
-
readExternal
public void readExternal(DataInput in) throws IOException
Helper to read the object state from a stream.- Specified by:
readExternal
in interfaceExternalizableLite
- Parameters:
in
- the stream to read data from in order to restore the object- Throws:
IOException
- if an I/O exception occurs
-
writeExternal
public void writeExternal(DataOutput out) throws IOException
Helper to write the object state to a stream.- Specified by:
writeExternal
in interfaceExternalizableLite
- Parameters:
out
- the stream to write the object to- Throws:
IOException
- if an I/O exception occurs
-
readAttributes
protected void readAttributes(DataInput in) throws IOException
Helper to read the session attributes from a stream.- Parameters:
in
- the stream to read data from in order to restore the object- Throws:
IOException
- if an I/O exception occurs
-
writeAttributes
protected void writeAttributes(DataOutput out) throws IOException
Helper to write the session attributes to a stream.- Parameters:
out
- the stream to write the object to- Throws:
IOException
- if an I/O exception occurs
-
getDescription
protected String getDescription()
Returns a string representation of this object's attributes.- Returns:
- a string representation of this object's attributes
-
checkActive
protected void checkActive()
Make sure that the model is 'active', 'usable' and 'valid'.- Throws:
IllegalStateException
- if the model is not 'active', 'usable' and 'valid'
-
checkValid
protected void checkValid()
Make sure that the model is 'usable' and 'valid'.- Throws:
IllegalStateException
- if the model is not both 'usable' and 'valid'
-
checkUsable
protected void checkUsable()
Make sure that the model is 'usable'.- Throws:
IllegalStateException
- if the model is not 'usable'
-
qualifyAttributeName
protected String qualifyAttributeName(String sAttribute)
Given an attribute name, return a potentially qualified name.- Parameters:
sAttribute
- the name that the application identifies the attribute by- Returns:
- either the name as passed in, or a qualified name
-
extractAttributeName
protected String extractAttributeName(String sAttribute)
Given a potentially qualified attribute name, return the original (fully unqualified) attribute name.- Parameters:
sAttribute
- an attribute name that may be qualified- Returns:
- the unqualified attribute name
-
extractAttributeNames
protected String[] extractAttributeNames(String[] asAttribute)
Given an array of potentially qualified attribute name, return an array of the original (fully unqualified) attribute names.- Parameters:
asAttribute
- an array of attribute names that may be qualified- Returns:
- an array of unqualified attribute names
-
instantiateAttributeHolder
protected AttributeHolder instantiateAttributeHolder()
Factory method: Instantiate an AttributeHolder for deserialization purposes.- Returns:
- a new AttributeHolder that can be deserialized into
-
instantiateAttributeHolder
protected AttributeHolder instantiateAttributeHolder(String sName, Object oValue)
Factory method: Instantiate an AttributeHolder to manage the passed value.- Parameters:
sName
- the attribute nameoValue
- a non-null Object value- Returns:
- a new AttributeHolder that will manage the passed value
-
isImmutable
public static boolean isImmutable(Object o)
Determine if the passed object is definitely of an immutable type.- Parameters:
o
- an object to check for immutability- Returns:
- true if the object is of a type that is known to be immutable
-
-