Class SessionInfo
- All Implemented Interfaces:
- IPrivateStorage,- Cloneable
- Author:
- Christopher Mindus
- Field SummaryFieldsModifier and TypeFieldDescription- static final intThe index for API trace.- static final intThe index for Communication trace.- static final intThe index for Connector trace.- final longThe creation time in milliseconds.- static final intThe index for EndPoint trace.- static final intThe trace level bits.- static final intThe trace level bits for verbose trace.- final byte[]The trace levels of the subsystems Communication, Connector, EndPoint, API.The session user identifier, null if not defined properly.
- Constructor SummaryConstructorsConstructorDescription- SessionInfo- (long connectionID, byte[] defaultTrace, SocketAddress remoteAddress, String hostName) The full constructor with all parameters.- SessionInfo- (long connectionID, SocketAddress remoteAddress, String hostName) The constructor initiates the trace levels to defaults, and no User ID.- SessionInfo- (SocketAddress remoteAddress) The constructor initiates the connection ID to -1 (none), the trace levels to defaults, and no User ID.
- Method SummaryModifier and TypeMethodDescription- void- assignRemoteAddress- (SocketAddress remoteAddress, String hostName, String domain, int port, boolean isSecure) Assigns a remote address.- void- assignServerSessionID- (long serverSessionID) Assigns the connection ID for a Server Session ID.- booleanTemporarily assigns a SessionInfo object to a thread.Creates a copy of an instance of this instance.- void- dispose()Disposes of this instance and cleans up thread usage.- booleanChecks if API binary trace is on.- booleanChecks if API verbose trace is on.- booleanChecks if Communication binary trace is on.- booleanChecks if Communication verbose trace is on.- booleanChecks if Connector binary trace is on.- booleanChecks if Connector verbose trace is on.- booleanChecks if EndPoint binary trace is on.- booleanChecks if EndPoint verbose trace is on.- longGets the connection ID.Gets the connection ID as a string.- static String- getConnectionIDString- (SessionInfo sessionInfo) Gets the connection ID as a string.- static String- getConnectionIDString- (SessionInfo sessionInfo, String threadName, String threadID) Gets the connection ID as a string.Gets the domain name of the server.Gets the host name, as provided by the (web) server for the connection without looking up using reverse DNS, null indicates not set.- static String- getIDString- (long id) Converts an ID into a string.- static longFor Editor, used to get the Session ID.- int- getPort()Gets the port used for the connection.Gets the concurrent hash map used to store the private data.- IGProp<?>Gets the Session's reference look-up property.Gets the address of the remote party, null if none is yet provided.Gets the session ID.- static SessionInfoTries to extract the SessionInfo from the current thread or the thread group.- static SessionInfoTries to extract the SessionInfo from the current thread or the thread group.- static String- getTabDelimitedConnectionIDString- (SessionInfo sessionInfo, String threadName, String threadID) Gets the connection ID as a string.- getUUID()Gets the unique session UUID for client reconnection purposes.Gets the unique session UUID for client reconnection purposes.Gets the worker for the session.- boolean- isSecure()Return if the connection is secured using SSL/TLS.- voidSets the worker for the session.- toString()Gets the string representation of the information in this instance.- static voidCleans up after assigning a SessionInfo object to a thread.- Methods inherited from class java.lang.Object- clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait- Methods inherited from interface com.iizix.api.IPrivateStorage- getPrivateData, getPrivateData, setPrivateData
- Field Details- COMMUNICATION_TRACE_INDEXpublic static final int COMMUNICATION_TRACE_INDEXThe index for Communication trace.- See Also:
 
- CONNECTOR_TRACE_INDEXpublic static final int CONNECTOR_TRACE_INDEXThe index for Connector trace.- See Also:
 
- ENDPOINT_TRACE_INDEXpublic static final int ENDPOINT_TRACE_INDEXThe index for EndPoint trace.- See Also:
 
- API_TRACE_INDEXpublic static final int API_TRACE_INDEXThe index for API trace.- See Also:
 
- TRACE_BIT_BINARYpublic static final int TRACE_BIT_BINARYThe trace level bits.- See Also:
 
- TRACE_BIT_VERBOSEpublic static final int TRACE_BIT_VERBOSEThe trace level bits for verbose trace.- See Also:
 
- userThe session user identifier, null if not defined properly.
- traceLevelspublic final byte[] traceLevelsThe trace levels of the subsystems Communication, Connector, EndPoint, API. The values are initially set to -1 indicating it used the default trace setting. The range of the trace is 0-3, or -1 for default.- The values are: 
 -1 = default trace,
 0 = no trace,
 1 = binary trace,
 2 = verbose trace,
 3 = binary and verbose trace.- The indexes are: 
 0 = Communication,
 1 = Connector,
 2 = EndPoint,
 3 = API.
- creationTimepublic final long creationTimeThe creation time in milliseconds.
 
- Constructor Details- SessionInfoThe constructor initiates the connection ID to -1 (none), the trace levels to defaults, and no User ID.- Parameters:
- remoteAddress- The remote address of the party.
 
- SessionInfoThe constructor initiates the trace levels to defaults, and no User ID.- Parameters:
- connectionID- The connection ID.
- remoteAddress- The remote address of the party.
- hostName- The host name of the remote party.
 
- SessionInfopublic SessionInfo- (long connectionID, byte[] defaultTrace, SocketAddress remoteAddress, String hostName) The full constructor with all parameters.- Parameters:
- connectionID- The connection ID.
- defaultTrace- The array of trace settings, non-null.
- remoteAddress- The remote address of the party.
- hostName- The host name of the remote party.
- Throws:
- NullPointerException- If- defaultTraceis null.
- IllegalArgumentException- If- defaultTraceis is not of length 4.
 
 
- Method Details- getNextIDpublic static long getNextID()For Editor, used to get the Session ID.- Returns:
- The next unique Session ID.
 
- getSessionInfoTries to extract the SessionInfo from the current thread or the thread group.- Returns:
- The SessionInfo instance for the current calling thread or thread group, or null if not found.
 
- getSessionInfoFBTSTries to extract the SessionInfo from the current thread or the thread group.- Returns:
- The SessionInfo instance for the current calling thread or thread group, or the System SessionInfo if no other was found (FBS=FallBackToSystem).
 
- unassignThreadpublic static void unassignThread()Cleans up after assigning a SessionInfo object to a thread.- This call is intended to be used with threads in thread-pools. - This is needed to be called in order not to leak memory. When a SessionInfo object is disposed, it performs a clean-up. 
- getPrivateStorageMapGets the concurrent hash map used to store the private data.- Specified by:
- getPrivateStorageMapin interface- IPrivateStorage
- Returns:
- The private storage map.
 
- getUUIDGets the unique session UUID for client reconnection purposes.- Returns:
- The unique UUID.
 
- getUUIDStringGets the unique session UUID for client reconnection purposes.- Returns:
- String The unique session UUID as UUID.toString()
 
- assignRemoteAddresspublic void assignRemoteAddress- (SocketAddress remoteAddress, String hostName, String domain, int port, boolean isSecure) Assigns a remote address.- Parameters:
- remoteAddress- The remote address.
- hostName- The host name.
- domain- The domain name.
- port- The port number used for the connection, or zero for none specified.
- isSecure- The secure (SSL/TLS) flag.
- Throws:
- IllegalStateException- If the domain name is already set to another value.
 
- assignServerSessionIDpublic void assignServerSessionID- (long serverSessionID) Assigns the connection ID for a Server Session ID.- Parameters:
- serverSessionID- The server session ID to assign.
 
- getRemoteAddressGets the address of the remote party, null if none is yet provided.- Returns:
- The address, or null if not yet assigned.
 
- getHostNameGets the host name, as provided by the (web) server for the connection without looking up using reverse DNS, null indicates not set.- Returns:
- The host name, or null if not set.
 
- getDomainGets the domain name of the server.- Returns:
- The domain name.
 
- getPortpublic int getPort()Gets the port used for the connection.- Returns:
- The port number, or zero for none specified.
 
- isSecurepublic boolean isSecure()Return if the connection is secured using SSL/TLS.- Returns:
- The secure flag. Please note that if the server is behind a proxy, the connection might be secure anyway.
 
- assignThreadpublic boolean assignThread()Temporarily assigns a SessionInfo object to a thread.- This call is intended to be used with threads in thread-pools. - It is very important to clean-up with a "fails-safe" try-finally or similar to call the - unassignThread()method. This is needed EVEN if the thread will not be used for other purposes. Failure in doing so will cause a memory leak until this instance of SessionInfo is disposed of. It is ALSO very important to check the return code whether to call- SessionInfo.unassignThread()or not.- Returns:
- true for successfully assigned and that a call to SessionInfo.unassignThread()in the try-finally clauseMUSTbe done, false if already assigned andSessionInfo.unassignThread()SHOULD NOT be called.
 
- createCloneCreates a copy of an instance of this instance. This is used in the Administration Interface. The session ID and worker instances are cleared.- Returns:
- A cloned SessionInfo instance.
 
- getConnectionIDpublic long getConnectionID()Gets the connection ID.- Returns:
- This connection ID.
 
- getConnectionIDStringGets the connection ID as a string. If no data exists, i.e. source is null or -1, the string "<system>" is returned.- Parameters:
- sessionInfo- The session information, or null for system.
- Returns:
- The string for the session ID in the parameter.
 
- getConnectionIDStringpublic static String getConnectionIDString- (SessionInfo sessionInfo, String threadName, String threadID) Gets the connection ID as a string. If no data exists, i.e. source is null or -1, the string "<system>" is returned.- Parameters:
- sessionInfo- The session information.
- threadName- The name of the thread.
- threadID- The thread ID.
- Returns:
- A string delimited with double spaces.
 
- getTabDelimitedConnectionIDStringpublic static String getTabDelimitedConnectionIDString- (SessionInfo sessionInfo, String threadName, String threadID) Gets the connection ID as a string. If no data exists, i.e. source is null or -1, the string "<system>" is returned. The parameters are tab delimited instead of filled out with spaces.- Parameters:
- sessionInfo- The session information.
- threadName- The name of the thread.
- threadID- The thread ID.
- Returns:
- A tab delimited string.
 
- getConnectionIDStringGets the connection ID as a string. If no data exists, i.e. source is -1, the string "<system>" is returned.- Returns:
- The ID as a string or "<system>" when no ID is present.
 
- getIDStringConverts an ID into a string.- Parameters:
- id- The ID.
- Returns:
- The ID as a String with leading zero's.
 
- doCommunicationBinaryTracepublic boolean doCommunicationBinaryTrace()Checks if Communication binary trace is on.- Returns:
- true if the trace option is selected.
 
- doCommunicationVerboseTracepublic boolean doCommunicationVerboseTrace()Checks if Communication verbose trace is on.- Returns:
- true if the trace option is selected.
 
- doConnectorBinaryTracepublic boolean doConnectorBinaryTrace()Checks if Connector binary trace is on.- Returns:
- true if the trace option is selected.
 
- doConnectorVerboseTracepublic boolean doConnectorVerboseTrace()Checks if Connector verbose trace is on.- Returns:
- true if the trace option is selected.
 
- doEndPointBinaryTracepublic boolean doEndPointBinaryTrace()Checks if EndPoint binary trace is on.- Returns:
- true if the trace option is selected.
 
- doEndPointVerboseTracepublic boolean doEndPointVerboseTrace()Checks if EndPoint verbose trace is on.- Returns:
- true if the trace option is selected.
 
- doAPIBinaryTracepublic boolean doAPIBinaryTrace()Checks if API binary trace is on.- Returns:
- true if the trace option is selected.
 
- doAPIVerboseTracepublic boolean doAPIVerboseTrace()Checks if API verbose trace is on.- Returns:
- true if the trace option is selected.
 
- setWorkerSets the worker for the session. This can only be done once. This method should only be used internally by the server.- Parameters:
- worker- The worker to assign to the session.
- Throws:
- NullPointerException- If worker is null.
- IllegalStateException- If a call to setWorker already has been made.
 
- getWorkerGets the worker for the session.- Returns:
- The worker for the session or null if none is available or yet assigned.
 
- getSessionIDGets the session ID.- Returns:
- The session ID or null if not set.
 
- toStringGets the string representation of the information in this instance.
- disposepublic void dispose()Disposes of this instance and cleans up thread usage.
- getReferenceLookupPropertyGets the Session's reference look-up property.- Returns:
- The property to use for global look-ups with full references.