Search in sources :

Example 11 with InterceptSupport

use of com.creditease.monitor.interceptframework.InterceptSupport in project uavstack by uavorg.

the class JettyPlusIT method onAppInit.

/**
 * onAppInit
 *
 * @param args
 */
public void onAppInit(Object... args) {
    App sc = (App) args[0];
    InterceptSupport iSupport = InterceptSupport.instance();
    InterceptContext ic = iSupport.getThreadLocalContext(Event.WEBCONTAINER_RESOURCE_INIT);
    InterceptContext ic2 = iSupport.getThreadLocalContext(Event.WEBCONTAINER_RESOURCE_CREATE);
    /**
     * NOTE: onAppInit, we put the Context Object into threadlocal, then all other later process for
     * PRE_WEBCONTAINER_INIT, which can get the object, as not everywhere we can get the object
     *
     * for example, the DataSource related injection
     */
    ic.put(InterceptConstants.CONTEXTOBJ, sc);
    ic2.put(InterceptConstants.CONTEXTOBJ, sc);
}
Also used : App(org.eclipse.jetty.deploy.App) InterceptContext(com.creditease.monitor.interceptframework.spi.InterceptContext) InterceptSupport(com.creditease.monitor.interceptframework.InterceptSupport)

Example 12 with InterceptSupport

use of com.creditease.monitor.interceptframework.InterceptSupport in project uavstack by uavorg.

the class JettyPlusIT method onAppStop.

/**
 * onAppStop
 *
 * @param args
 */
public void onAppStop(Object... args) {
    System.out.println("---------------->onAppStop");
    WebAppContext sc = getWebAppContext(args);
    if (sc == null) {
        return;
    }
    InterceptSupport iSupport = InterceptSupport.instance();
    InterceptContext context = iSupport.createInterceptContext(Event.WEBCONTAINER_STOPPED);
    context.put(InterceptConstants.WEBAPPLOADER, sc.getClassLoader());
    context.put(InterceptConstants.WEBWORKDIR, sc.getServletContext().getRealPath(""));
    context.put(InterceptConstants.CONTEXTPATH, sc.getContextPath());
    context.put(InterceptConstants.APPNAME, sc.getDisplayName());
    ServletContext sContext = sc.getServletContext();
    context.put(InterceptConstants.SERVLET_CONTEXT, sContext);
    getBasePath(context, sContext);
    iSupport.doIntercept(context);
}
Also used : WebAppContext(org.eclipse.jetty.webapp.WebAppContext) InterceptContext(com.creditease.monitor.interceptframework.spi.InterceptContext) InterceptSupport(com.creditease.monitor.interceptframework.InterceptSupport) ServletContext(javax.servlet.ServletContext)

Example 13 with InterceptSupport

use of com.creditease.monitor.interceptframework.InterceptSupport in project uavstack by uavorg.

the class JettyPlusIT method onAppStarting.

/**
 * onAppStarting
 *
 * @param args
 */
public void onAppStarting(Object... args) {
    WebAppContext sc = (WebAppContext) args[0];
    InterceptSupport iSupport = InterceptSupport.instance();
    InterceptContext context = iSupport.createInterceptContext(Event.WEBCONTAINER_INIT);
    context.put(InterceptConstants.WEBAPPLOADER, sc.getClassLoader());
    context.put(InterceptConstants.WEBWORKDIR, sc.getServletContext().getRealPath(""));
    context.put(InterceptConstants.CONTEXTPATH, sc.getContextPath());
    context.put(InterceptConstants.APPNAME, sc.getDisplayName());
    ServletContext sContext = sc.getServletContext();
    context.put(InterceptConstants.SERVLET_CONTEXT, sContext);
    getBasePath(context, sContext);
    iSupport.doIntercept(context);
}
Also used : WebAppContext(org.eclipse.jetty.webapp.WebAppContext) InterceptContext(com.creditease.monitor.interceptframework.spi.InterceptContext) InterceptSupport(com.creditease.monitor.interceptframework.InterceptSupport) ServletContext(javax.servlet.ServletContext)

Example 14 with InterceptSupport

use of com.creditease.monitor.interceptframework.InterceptSupport in project uavstack by uavorg.

the class JettyPlusIT method onServletStop.

/**
 * onServletStop
 *
 * @param args
 */
public void onServletStop(Object... args) {
    ServletHolder sh = (ServletHolder) args[0];
    Servlet servlet;
    try {
        servlet = sh.getServlet();
    } catch (ServletException e) {
        // ignore
        return;
    }
    InterceptSupport iSupport = InterceptSupport.instance();
    InterceptContext context = iSupport.createInterceptContext(Event.BEFORE_SERVLET_DESTROY);
    context.put(InterceptConstants.SERVLET_INSTANCE, servlet);
    context.put(InterceptConstants.WEBAPPLOADER, Thread.currentThread().getContextClassLoader());
    context.put(InterceptConstants.CONTEXTPATH, sh.getContextPath());
    iSupport.doIntercept(context);
}
Also used : ServletException(javax.servlet.ServletException) InterceptContext(com.creditease.monitor.interceptframework.spi.InterceptContext) ServletHolder(org.eclipse.jetty.servlet.ServletHolder) InterceptSupport(com.creditease.monitor.interceptframework.InterceptSupport) Servlet(javax.servlet.Servlet)

Example 15 with InterceptSupport

use of com.creditease.monitor.interceptframework.InterceptSupport in project uavstack by uavorg.

the class JettyPlusIT method onServletStart.

/**
 * onServletStart
 *
 * @param args
 */
public void onServletStart(Object... args) {
    ServletHolder sh = (ServletHolder) args[0];
    Servlet servlet;
    try {
        servlet = sh.getServlet();
    } catch (ServletException e) {
        // ignore
        return;
    }
    InterceptSupport iSupport = InterceptSupport.instance();
    InterceptContext context = iSupport.createInterceptContext(Event.AFTER_SERVET_INIT);
    context.put(InterceptConstants.SERVLET_INSTANCE, servlet);
    context.put(InterceptConstants.WEBAPPLOADER, Thread.currentThread().getContextClassLoader());
    context.put(InterceptConstants.CONTEXTPATH, sh.getContextPath());
    iSupport.doIntercept(context);
}
Also used : ServletException(javax.servlet.ServletException) InterceptContext(com.creditease.monitor.interceptframework.spi.InterceptContext) ServletHolder(org.eclipse.jetty.servlet.ServletHolder) InterceptSupport(com.creditease.monitor.interceptframework.InterceptSupport) Servlet(javax.servlet.Servlet)

Aggregations

InterceptSupport (com.creditease.monitor.interceptframework.InterceptSupport)30 InterceptContext (com.creditease.monitor.interceptframework.spi.InterceptContext)28 ServletContext (javax.servlet.ServletContext)12 StandardContext (org.apache.catalina.core.StandardContext)12 Servlet (javax.servlet.Servlet)6 StandardWrapper (org.apache.catalina.core.StandardWrapper)4 WebappClassLoader (org.apache.catalina.loader.WebappClassLoader)4 WebAppContext (org.eclipse.jetty.webapp.WebAppContext)3 IConfigurationManager (com.creditease.agent.spi.IConfigurationManager)2 ServletException (javax.servlet.ServletException)2 ServletHolder (org.eclipse.jetty.servlet.ServletHolder)2 ServerVendor (com.creditease.monitor.UAVServer.ServerVendor)1 UAVServerJEEController (com.creditease.monitor.globalfilter.jee.UAVServerJEEController)1 InterceptEventListener (com.creditease.monitor.interceptframework.spi.InterceptEventListener)1 TomcatLog (com.creditease.tomcat.plus.util.TomcatLog)1 GlobalFilterDispatchListener (com.creditease.uav.appserver.listeners.GlobalFilterDispatchListener)1 HttpServletRequest (javax.servlet.http.HttpServletRequest)1 HttpServletResponse (javax.servlet.http.HttpServletResponse)1 App (org.eclipse.jetty.deploy.App)1