- java.lang.Object
-
- org.tentackle.session.SessionUtilities
-
@Service(SessionUtilities.class) public class SessionUtilities extends java.lang.Object
Utility methods for session related stuff.- Author:
- harald
-
-
Constructor Summary
Constructors Constructor Description SessionUtilities()Creates a utility instance.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected SessionKeepAliveDaemoncreateKeepAliveDaemon()Creates the session keep alive daemon.intdetermineClassId(java.lang.Class<?> clazz)Determines the classid from the @ClassId annotation.java.lang.StringdetermineTablename(java.lang.Class<?> clazz)Determines the tablename from the @TableName annotation.intgetClassId(java.lang.String pdoClassName)Gets the classid of a pdo class.java.lang.StringgetClassName(int classId)Gets the classname for a classid.java.lang.StringgetClassName(java.lang.String tableName)Gets the classname for tablename.java.util.Collection<java.lang.String>getClassNames()Gets a list of all class names.
Sorted by name.static SessionUtilitiesgetInstance()The singleton.java.lang.StringgetTableName(java.lang.String className)Gets the tablename of a pdo class.booleanisSomeRemoved(long lastSerial, java.util.List<org.tentackle.misc.IdSerialTuple> expireSet, long maxSerial)Inspects an expiration set and determines whether at least one object has been removed.voidkeepAliveIntervalChanged(Session session)Handles the change of a keep alive interval of a session.voidstartKeepAliveDaemonIfNotRunning()Starts the keep alive thread if not already running.voidterminateHelperThreads()Stops all helper threads.
-
-
-
Method Detail
-
getInstance
public static SessionUtilities getInstance()
The singleton.- Returns:
- the singleton
-
getTableName
public java.lang.String getTableName(java.lang.String className)
Gets the tablename of a pdo class.- Parameters:
className- the classname of the object- Returns:
- the tablename, null if no such class
-
getClassName
public java.lang.String getClassName(java.lang.String tableName)
Gets the classname for tablename.- Parameters:
tableName- the tablename- Returns:
- the name of the class, null if no such tablename
-
getClassId
public int getClassId(java.lang.String pdoClassName)
Gets the classid of a pdo class.- Parameters:
pdoClassName- the classname of the pdo- Returns:
- the classid, 0 if no such class
-
getClassName
public java.lang.String getClassName(int classId)
Gets the classname for a classid.- Parameters:
classId- the classid- Returns:
- the name of the class, null if no such classid
-
getClassNames
public java.util.Collection<java.lang.String> getClassNames()
Gets a list of all class names.
Sorted by name.- Returns:
- the class names
-
determineTablename
public java.lang.String determineTablename(java.lang.Class<?> clazz)
Determines the tablename from the @TableName annotation.- Parameters:
clazz- the class- Returns:
- the tablename, null if no such annotation
-
determineClassId
public int determineClassId(java.lang.Class<?> clazz)
Determines the classid from the @ClassId annotation.- Parameters:
clazz- the class- Returns:
- the tablename, null if no such annotation
-
startKeepAliveDaemonIfNotRunning
public void startKeepAliveDaemonIfNotRunning()
Starts the keep alive thread if not already running.
-
terminateHelperThreads
public void terminateHelperThreads()
Stops all helper threads.
-
keepAliveIntervalChanged
public void keepAliveIntervalChanged(Session session)
Handles the change of a keep alive interval of a session.- Parameters:
session- the session
-
isSomeRemoved
public boolean isSomeRemoved(long lastSerial, java.util.List<org.tentackle.misc.IdSerialTuple> expireSet, long maxSerial)Inspects an expiration set and determines whether at least one object has been removed.- Parameters:
lastSerial- the last known tableserial, ≤0 if unknownexpireSet- the expiration setmaxSerial- the current tableserial- Returns:
- true if some object removed
-
createKeepAliveDaemon
protected SessionKeepAliveDaemon createKeepAliveDaemon()
Creates the session keep alive daemon.- Returns:
- the daemon (not started yet!)
-
-