Class WebApplication<T>

  • Type Parameters:
    T - the web session key type
    All Implemented Interfaces:
    org.tentackle.dbms.ConnectionManagerProvider, org.tentackle.pdo.DomainContextProvider, org.tentackle.session.SessionPoolProvider, org.tentackle.session.SessionProvider

    public abstract class WebApplication<T>
    extends org.tentackle.persist.app.AbstractServerApplication
    Web Server Application.

    Web applications usually run in a container such as glassfish.

    Author:
    harald
    • Constructor Summary

      Constructors 
      Constructor Description
      WebApplication​(java.lang.String name)
      Creates an instance of a web application.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void addWebSession​(T sessionKey, org.tentackle.session.SessionInfo userInfo)
      Adds a mapping between a web session key and a user session info.
      This is usually done in the login controller.
      protected void cleanup()  
      protected void finishStartup()  
      org.tentackle.session.Session getSession​(T sessionKey)
      Gets a persistence session from the session pool by a web session key.
      java.util.Collection<T> getSessionKeys​(org.tentackle.session.SessionInfo sessionInfo)
      Gets the web session keys for a user session info.
      static <T> WebApplication<T> getWebApplication()
      Gets the current web application instance.
      void putSession​(org.tentackle.session.Session session)
      Release a persistence session.
      Should be invoked after sending/rendering the response to the web browser.
      void removeWebSession​(T sessionKey)
      Removes a mapping between a web session key and a user session info.
      This is usually done in the logout controller.
      protected void startup()  
      • Methods inherited from class org.tentackle.persist.app.AbstractServerApplication

        configurePreferences, configureSessionInfo, createConnectionManager, createSessionPool, deregisterJdbcDrivers, detectContainer, getConnectionManager, getSession, getSessionPool, isRunningInContainer, isServerImpl, isSystemExitNecessaryToStop, login, setSessionInfo
      • Methods inherited from class org.tentackle.app.AbstractApplication

        configure, configureModificationTracker, configureSecurityManager, createDomainContext, createSession, createSessionInfo, getCommandLine, getCreationTime, getDomainContext, getName, getProperties, getProperty, getRunningApplication, getSessionInfo, getUser, getUser, initialize, isInteractive, isInteractiveImpl, isServer, logStackdump, register, setDomainContext, setName, setProperties, start, start, stop, stop, toString, unregister
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
      • Methods inherited from interface org.tentackle.pdo.DomainContextProvider

        on, op
    • Constructor Detail

      • WebApplication

        public WebApplication​(java.lang.String name)
        Creates an instance of a web application.
        Parameters:
        name - the application name
    • Method Detail

      • getWebApplication

        public static <T> WebApplication<T> getWebApplication()
        Gets the current web application instance.

        This is just a convenience method to AbstractApplication.getRunningApplication().

        Type Parameters:
        T - the web session key type
        Returns:
        the application, null if not started yet
      • addWebSession

        public void addWebSession​(T sessionKey,
                                  org.tentackle.session.SessionInfo userInfo)
        Adds a mapping between a web session key and a user session info.
        This is usually done in the login controller. If a session with that key already exists, the user info will be replaced.
        Parameters:
        sessionKey - the (unique) web session key
        userInfo - the user info
      • removeWebSession

        public void removeWebSession​(T sessionKey)
        Removes a mapping between a web session key and a user session info.
        This is usually done in the logout controller. If there is no such session, the method will do nothing.
        Parameters:
        sessionKey - the (unique) web session key
      • getSessionKeys

        public java.util.Collection<T> getSessionKeys​(org.tentackle.session.SessionInfo sessionInfo)
        Gets the web session keys for a user session info.
        Parameters:
        sessionInfo - the user session info
        Returns:
        the web session keys, never null
      • getSession

        public org.tentackle.session.Session getSession​(T sessionKey)
        Gets a persistence session from the session pool by a web session key.
        Parameters:
        sessionKey - the web session key
        Returns:
        the attached session or null if no such session
      • putSession

        public void putSession​(org.tentackle.session.Session session)
        Release a persistence session.
        Should be invoked after sending/rendering the response to the web browser.
        Parameters:
        session - the persistence session to release
      • startup

        protected void startup()
        Overrides:
        startup in class org.tentackle.persist.app.AbstractServerApplication
      • finishStartup

        protected void finishStartup()
        Overrides:
        finishStartup in class org.tentackle.persist.app.AbstractServerApplication
      • cleanup

        protected void cleanup()
        Overrides:
        cleanup in class org.tentackle.persist.app.AbstractServerApplication