Class ApplicationUtils


  • public final class ApplicationUtils
    extends Object
    The Class ApplicationUtils.
    • Field Detail

      • logger

        private static final org.slf4j.Logger logger
        The Constant logger.
    • Constructor Detail

      • ApplicationUtils

        private ApplicationUtils()
        Prevent Instantiation.
    • Method Detail

      • getApplication

        public static Application getApplication​(org.apache.catalina.Context context,
                                                 ContainerWrapperBean containerWrapper)
        Gets the application.
        Parameters:
        context - the context
        containerWrapper - the container wrapper
        Returns:
        the application
      • getApplication

        public static Application getApplication​(org.apache.catalina.Context context,
                                                 ResourceResolver resourceResolver,
                                                 boolean calcSize,
                                                 ContainerWrapperBean containerWrapper)
        Creates Application instance from Tomcat Context object. If ResourceResolver is passed the method will also collect additional information about the application such as session count, session attribute count, application attribute count, servlet count, servlet stats summary and datasource usage summary. Collecting additional information can be CPU intensive and time consuming so this should be avoided unless absolutely required. Some datasource implementations (c3p0) are known to be prone to internal deadlocks, so this method can also hang is datasource usage stats is to be collected.
        Parameters:
        context - the context from which to create the Application
        resourceResolver - the resolver to use for resources associated with the given context
        calcSize - flag which controls whether to calculate session size
        containerWrapper - the wrapper for the context's root containing server
        Returns:
        Application object
      • collectApplicationServletStats

        public static void collectApplicationServletStats​(org.apache.catalina.Context context,
                                                          Application app)
        Calculates Sum of requestCount, errorCount and processingTime for all servlets for the given application. It also works out minimum value of minTime and maximum value for maxTime for all servlets.
        Parameters:
        context - the context whose stats will be collected
        app - the application in which to store the collected stats
      • getApplicationDataSourceUsageScores

        public static int[] getApplicationDataSourceUsageScores​(org.apache.catalina.Context context,
                                                                ResourceResolver resolver,
                                                                ContainerWrapperBean containerWrapper)
        Gets the application data source usage scores.
        Parameters:
        context - the context
        resolver - the resolver
        containerWrapper - the container wrapper
        Returns:
        the application data source usage scores
      • getApplicationSession

        public static ApplicationSession getApplicationSession​(org.apache.catalina.Session session,
                                                               boolean calcSize,
                                                               boolean addAttributes)
        Gets the application session.
        Parameters:
        session - the session
        calcSize - the calc size
        addAttributes - the add attributes
        Returns:
        the application session
      • getApplicationAttributes

        public static List<Attribute> getApplicationAttributes​(org.apache.catalina.Context context)
        Gets the application attributes.
        Parameters:
        context - the context
        Returns:
        the application attributes
      • getApplicationInitParams

        public static List<ApplicationParam> getApplicationInitParams​(org.apache.catalina.Context context,
                                                                      ContainerWrapperBean containerWrapper)
        Gets the application init params.
        Parameters:
        context - the context
        containerWrapper - the container wrapper
        Returns:
        the application init params
      • getApplicationServlet

        public static ServletInfo getApplicationServlet​(org.apache.catalina.Context context,
                                                        String servletName)
        Gets the application servlet.
        Parameters:
        context - the context
        servletName - the servlet name
        Returns:
        the application servlet
      • getServletInfo

        private static ServletInfo getServletInfo​(org.apache.catalina.Wrapper wrapper,
                                                  String contextName)
        Gets the servlet info.
        Parameters:
        wrapper - the wrapper
        contextName - the context name
        Returns:
        the servlet info
      • getApplicationServlets

        public static List<ServletInfo> getApplicationServlets​(org.apache.catalina.Context context)
        Gets the application servlets.
        Parameters:
        context - the context
        Returns:
        the application servlets
      • getApplicationServletMaps

        public static List<ServletMapping> getApplicationServletMaps​(org.apache.catalina.Context context)
        Gets the application servlet maps.
        Parameters:
        context - the context
        Returns:
        the application servlet maps
      • getApplicationFilters

        public static List<FilterInfo> getApplicationFilters​(org.apache.catalina.Context context,
                                                             ContainerWrapperBean containerWrapper)
        Gets the application filters.
        Parameters:
        context - the context
        containerWrapper - the container wrapper
        Returns:
        the application filters