Class DefaultEnvironment

    • Constructor Detail

      • DefaultEnvironment

        protected DefaultEnvironment()
      • DefaultEnvironment

        public DefaultEnvironment​(javax.servlet.ServletRequest servletRequest,
                                  javax.servlet.ServletResponse servletResponse)
    • Method Detail

      • init

        public void init​(javax.servlet.ServletContext servletContext,
                         javax.servlet.ServletRequest servletRequest,
                         javax.servlet.ServletResponse servletResponse)
      • get

        public static DefaultEnvironment get​(javax.servlet.jsp.PageContext pageContext)
        Returns a fully initialized DefaultEnvironment.
        Parameters:
        pageContext - a PageContext
      • get

        public static DefaultEnvironment get​(javax.servlet.ServletContext context,
                                             javax.servlet.ServletRequest request)
        Returns a fully initialized DefaultEnvironment.
        Parameters:
        context - a ServletContext
        request - a ServletRequest
        Returns:
        a new DefaultEnvironment
      • get

        public static DefaultEnvironment get​(javax.servlet.ServletRequest request,
                                             javax.servlet.ServletResponse response)
        Returns a fully initialized DefaultEnvironment.
        Parameters:
        request - a ServletRequest
        response - a ServletResponse
        Returns:
        a new DefaultEnvironment
      • get

        public static DefaultEnvironment get​(javax.servlet.ServletContext context,
                                             javax.servlet.ServletRequest request,
                                             javax.servlet.ServletResponse response)
        Returns a fully initialized DefaultEnvironment.
        Parameters:
        context - a ServletContext
        request - a ServletRequest
        response - a ServletResponse
        Returns:
        a new DefaultEnvironment
      • setAttribute

        public void setAttribute​(Scope scope,
                                 String name,
                                 Object value)
        Description copied from interface: Environment
        Sets an attribute for the given Scope to the given value.
        Specified by:
        setAttribute in interface Environment
        Parameters:
        scope - the Scope of the attribute to set
        name - the name of the attribute to set
        value - the attribute to set
      • getAttribute

        public <T> T getAttribute​(Scope scope,
                                  String name)
        Description copied from interface: Environment
        Returns the attribute with the given name for the given Scope.
        Specified by:
        getAttribute in interface Environment
        Parameters:
        scope - the Scope of the attribute to get
        name - the name of the attribute to get
        Returns:
        the attribute of the desired type, or null if the attribute does not exist in the given Scope
      • removeAttribute

        public <T> T removeAttribute​(Scope scope,
                                     String name)
        Description copied from interface: Environment
        Removes the attribute with the given name from the given Scope and returns it.
        Specified by:
        removeAttribute in interface Environment
        Parameters:
        scope - the Scope of the attribute to remove
        name - the name of the attribute to remove
        Returns:
        the attribute of the desired type, or null if the attribute does not exist in the given Scope
      • getAttributeAsString

        public String getAttributeAsString​(Scope scope,
                                           String name)
        Description copied from interface: Environment
        Returns the string-representation of an attribute, calling toString() on the resulting object.
        Specified by:
        getAttributeAsString in interface Environment
        Parameters:
        scope - the Scope of the attribute to get
        name - the name of the attribute to get
        Returns:
        the string-representation of the attribute, or null if the attribute does not exist in the given Scope
      • keySet

        public Set<String> keySet​(Scope scope)
        Description copied from interface: Environment
        Returns a Set of all attribute names for the given Scope
        Specified by:
        keySet in interface Environment
        Parameters:
        scope - the Scope the get the attribute names for
        Returns:
        a Set containing all attribute names, or null if the Scope is not available
      • getServletContext

        public javax.servlet.ServletContext getServletContext()
        Returns the current ServletContext.
        Returns:
        the ServletContext
      • getServletRequest

        public javax.servlet.http.HttpServletRequest getServletRequest()
        Returns the current HttpServletRequest.
        Returns:
        the HttpServletRequest
      • getServletResponse

        public javax.servlet.http.HttpServletResponse getServletResponse()
        Returns the current HttpServletResponse.
        Returns:
        the HttpServletResponse
      • isSubjectAuthenticated

        public boolean isSubjectAuthenticated()
        Description copied from interface: Environment
        Returns true if the current Subject is authenticated, false otherwise
        Specified by:
        isSubjectAuthenticated in interface Environment
        Returns:
        true if the current Subject is authenticated, false otherwise
      • setSubject

        public void setSubject​(Subject subject)
        Sets the Subject fur the current HttpSession.
        Parameters:
        subject - the Subject to set
      • setLocale

        public void setLocale​(Locale locale)
      • setTimeZone

        public void setTimeZone​(TimeZone timeZone)
      • logoutSubject

        public void logoutSubject()
        Removes the current Subject form the HttpSession and invalidates the latter.
      • disable

        public void disable​(Scope scope)
        Disables the given Scope for this environment
        Parameters:
        scope - the Scope to disable
        See Also:
        enable(Scope)
      • enable

        public void enable​(Scope scope)
        Enables the given Scope for this environment
        Parameters:
        scope - the Scope to enable
        See Also:
        disable(Scope)
      • clearSiteScope

        public void clearSiteScope​(Site site)
        Clears the site-scoped attributes for the given Site.
        Parameters:
        site - The Site to clear the site-scope for.