Package psiprobe.tools
Class ApplicationUtils
- java.lang.Object
-
- psiprobe.tools.ApplicationUtils
-
public final class ApplicationUtils extends Object
The Class ApplicationUtils.
-
-
Field Summary
Fields Modifier and Type Field Description private static org.slf4j.Logger
logger
The Constant logger.
-
Constructor Summary
Constructors Modifier Constructor Description private
ApplicationUtils()
Prevent Instantiation.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static void
collectApplicationServletStats(org.apache.catalina.Context context, Application app)
Calculates Sum of requestCount, errorCount and processingTime for all servlets for the given application.static Application
getApplication(org.apache.catalina.Context context, ContainerWrapperBean containerWrapper)
Gets the application.static Application
getApplication(org.apache.catalina.Context context, ResourceResolver resourceResolver, boolean calcSize, ContainerWrapperBean containerWrapper)
Creates Application instance from Tomcat Context object.static List<Attribute>
getApplicationAttributes(org.apache.catalina.Context context)
Gets the application attributes.static int[]
getApplicationDataSourceUsageScores(org.apache.catalina.Context context, ResourceResolver resolver, ContainerWrapperBean containerWrapper)
Gets the application data source usage scores.static List<FilterInfo>
getApplicationFilters(org.apache.catalina.Context context, ContainerWrapperBean containerWrapper)
Gets the application filters.static List<ApplicationParam>
getApplicationInitParams(org.apache.catalina.Context context, ContainerWrapperBean containerWrapper)
Gets the application init params.static ServletInfo
getApplicationServlet(org.apache.catalina.Context context, String servletName)
Gets the application servlet.static List<ServletMapping>
getApplicationServletMaps(org.apache.catalina.Context context)
Gets the application servlet maps.static List<ServletInfo>
getApplicationServlets(org.apache.catalina.Context context)
Gets the application servlets.static ApplicationSession
getApplicationSession(org.apache.catalina.Session session, boolean calcSize, boolean addAttributes)
Gets the application session.private static ServletInfo
getServletInfo(org.apache.catalina.Wrapper wrapper, String contextName)
Gets the servlet info.
-
-
-
Method Detail
-
getApplication
public static Application getApplication(org.apache.catalina.Context context, ContainerWrapperBean containerWrapper)
Gets the application.- Parameters:
context
- the contextcontainerWrapper
- 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 ApplicationresourceResolver
- the resolver to use for resources associated with the given contextcalcSize
- flag which controls whether to calculate session sizecontainerWrapper
- 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 collectedapp
- 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 contextresolver
- the resolvercontainerWrapper
- 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 sessioncalcSize
- the calc sizeaddAttributes
- 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 contextcontainerWrapper
- 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 contextservletName
- 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 wrappercontextName
- 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 contextcontainerWrapper
- the container wrapper- Returns:
- the application filters
-
-