Class 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 SessionKeepAliveDaemon createKeepAliveDaemon()
      Creates the session keep alive daemon.
      int determineClassId​(java.lang.Class<?> clazz)
      Determines the classid from the @ClassId annotation.
      java.lang.String determineTablename​(java.lang.Class<?> clazz)
      Determines the tablename from the @TableName annotation.
      int getClassId​(java.lang.String pdoClassName)
      Gets the classid of a pdo class.
      java.lang.String getClassName​(int classId)
      Gets the classname for a classid.
      java.lang.String getClassName​(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 SessionUtilities getInstance()
      The singleton.
      java.lang.String getTableName​(java.lang.String className)
      Gets the tablename of a pdo class.
      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.
      void keepAliveIntervalChanged​(Session session)
      Handles the change of a keep alive interval of a session.
      void startKeepAliveDaemonIfNotRunning()
      Starts the keep alive thread if not already running.
      void terminateHelperThreads()
      Stops all helper threads.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • SessionUtilities

        public SessionUtilities()
        Creates a utility instance.
    • 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 unknown
        expireSet - the expiration set
        maxSerial - 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!)