Class Utils


  • public final class Utils
    extends java.lang.Object
    Utility class.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private static java.lang.String RESOURCE_CONFIG
      Internal servlet context attribute name under which an instance of resource config can be stored.
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      private Utils()
      Prevents instantiation.
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.util.Map<java.lang.String,​java.lang.Object> getContextParams​(javax.servlet.ServletContext servletContext)
      Extract context params from ServletContext.
      static ResourceConfig retrieve​(javax.servlet.ServletContext context, java.lang.String configName)
      Load resource config from given servlet context.
      static void store​(ResourceConfig config, javax.servlet.ServletContext context, java.lang.String configName)
      Store resource config as an attribute of given servlet context.
      • Methods inherited from class java.lang.Object

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

      • RESOURCE_CONFIG

        private static final java.lang.String RESOURCE_CONFIG
        Internal servlet context attribute name under which an instance of resource config can be stored. The instance is later used to initialize servlet in WebConfig instead of creating a new one.
        See Also:
        Constant Field Values
    • Constructor Detail

      • Utils

        private Utils()
        Prevents instantiation.
    • Method Detail

      • store

        public static void store​(ResourceConfig config,
                                 javax.servlet.ServletContext context,
                                 java.lang.String configName)
        Store resource config as an attribute of given servlet context. If config is null then the previously stored value (if any) is removed. The configName is used as an attribute name suffix.
        Parameters:
        config - resource config to be stored.
        context - servlet context to store the config in.
        configName - name or id of the resource config.
      • retrieve

        public static ResourceConfig retrieve​(javax.servlet.ServletContext context,
                                              java.lang.String configName)
        Load resource config from given servlet context. If found then the resource config is also removed from servlet context. The configName is used as an attribute name suffix.
        Parameters:
        context - servlet context to load resource config from.
        configName - name or id of the resource config.
        Returns:
        previously stored resource config or null if no resource config has been stored.
      • getContextParams

        public static java.util.Map<java.lang.String,​java.lang.Object> getContextParams​(javax.servlet.ServletContext servletContext)
        Extract context params from ServletContext.
        Parameters:
        servletContext - actual servlet context.
        Returns:
        map representing current context parameters.