Search in sources :

Example 16 with InterceptSupport

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

the class MSCPPlusIT method onAppStarting.

/**
 * onAppStarting
 *
 * @param args
 */
public void onAppStarting() {
    IConfigurationManager cm = ConfigurationManager.getInstance();
    InterceptSupport iSupport = InterceptSupport.instance();
    InterceptContext context = iSupport.createInterceptContext(Event.WEBCONTAINER_INIT);
    context.put(InterceptConstants.WEBAPPLOADER, this.getClass().getClassLoader());
    context.put(InterceptConstants.WEBWORKDIR, cm.getContext(IConfigurationManager.ROOT));
    context.put(InterceptConstants.CONTEXTPATH, "");
    context.put(InterceptConstants.APPNAME, cm.getContext(IConfigurationManager.NODEAPPID));
    context.put(InterceptConstants.BASEPATH, "/" + cm.getContext(IConfigurationManager.NODEAPPID));
    iSupport.doIntercept(context);
}
Also used : InterceptContext(com.creditease.monitor.interceptframework.spi.InterceptContext) InterceptSupport(com.creditease.monitor.interceptframework.InterceptSupport) IConfigurationManager(com.creditease.agent.spi.IConfigurationManager)

Example 17 with InterceptSupport

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

the class MSCPPlusIT method onAppStart.

/**
 * onAppStart
 *
 * @param args
 */
public void onAppStart() {
    // String featureName = (String) args[0];
    IConfigurationManager cm = ConfigurationManager.getInstance();
    InterceptSupport iSupport = InterceptSupport.instance();
    InterceptContext context = iSupport.createInterceptContext(Event.WEBCONTAINER_STARTED);
    context.put(InterceptConstants.WEBAPPLOADER, this.getClass().getClassLoader());
    context.put(InterceptConstants.WEBWORKDIR, cm.getContext(IConfigurationManager.ROOT));
    context.put(InterceptConstants.CONTEXTPATH, "");
    context.put(InterceptConstants.APPNAME, cm.getContext(IConfigurationManager.NODEAPPID));
    context.put(InterceptConstants.BASEPATH, "/" + cm.getContext(IConfigurationManager.NODEAPPID));
    iSupport.doIntercept(context);
}
Also used : InterceptContext(com.creditease.monitor.interceptframework.spi.InterceptContext) InterceptSupport(com.creditease.monitor.interceptframework.InterceptSupport) IConfigurationManager(com.creditease.agent.spi.IConfigurationManager)

Example 18 with InterceptSupport

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

the class SpringBootTomcatPlusIT method onResourceInit.

@Override
public void onResourceInit(Object... args) {
    ClassLoader cl = Thread.currentThread().getContextClassLoader();
    if (!WebappClassLoader.class.isAssignableFrom(cl.getClass())) {
        return;
    }
    /**
     * for Application Starting's Resource Init
     */
    InterceptSupport iSupport = InterceptSupport.instance();
    InterceptContext context = iSupport.getThreadLocalContext(Event.WEBCONTAINER_RESOURCE_INIT);
    StandardContext sc = (StandardContext) context.get(InterceptConstants.CONTEXTOBJ);
    /**
     * NOTE: spring boot rewrite the tomcat webappclassloader, makes the addURL for nothing, then we can't do
     * anything on this we may use its webappclassloader's parent as the classloader
     */
    context.put(InterceptConstants.WEBAPPLOADER, sc.getLoader().getClassLoader().getParent());
    context.put(InterceptConstants.WEBWORKDIR, sc.getWorkPath());
    String contextPath = (String) ReflectionHelper.getField(StandardContext.class, sc, "encodedPath", true);
    context.put(InterceptConstants.CONTEXTPATH, contextPath);
    context.put(InterceptConstants.APPNAME, ReflectionHelper.getField(StandardContext.class, sc, "displayName", true));
    ServletContext sContext = (ServletContext) ReflectionHelper.getField(StandardContext.class, sc, "context", true);
    context.put(InterceptConstants.SERVLET_CONTEXT, sContext);
    String basePath = sContext.getRealPath("");
    /*
         * NOTE: springboot couldn't get the basePath through method "getRealPath", temporary process
         */
    if (basePath == null) {
        basePath = "";
    } else if (basePath.lastIndexOf("/") == (basePath.length() - 1) || basePath.lastIndexOf("\\") == (basePath.length() - 1)) {
        basePath = basePath.substring(0, basePath.length() - 1);
    }
    context.put(InterceptConstants.BASEPATH, basePath);
    iSupport.doIntercept(context);
}
Also used : WebappClassLoader(org.apache.catalina.loader.WebappClassLoader) InterceptContext(com.creditease.monitor.interceptframework.spi.InterceptContext) InterceptSupport(com.creditease.monitor.interceptframework.InterceptSupport) StandardContext(org.apache.catalina.core.StandardContext) WebappClassLoader(org.apache.catalina.loader.WebappClassLoader) ServletContext(javax.servlet.ServletContext)

Example 19 with InterceptSupport

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

the class SpringBootTomcatPlusIT method onAppStarting.

/**
 * onAppStarting
 *
 * @param args
 */
@Override
public void onAppStarting(Object... args) {
    StandardContext sc = (StandardContext) args[0];
    InterceptSupport iSupport = InterceptSupport.instance();
    InterceptContext context = iSupport.createInterceptContext(Event.WEBCONTAINER_INIT);
    /**
     * NOTE: spring boot rewrite the tomcat webappclassloader, makes the addURL for nothing, then we can't do
     * anything on this we may use its webappclassloader's parent as the classloader
     */
    context.put(InterceptConstants.WEBAPPLOADER, sc.getLoader().getClassLoader().getParent());
    context.put(InterceptConstants.WEBWORKDIR, sc.getWorkPath());
    String contextPath = (String) ReflectionHelper.getField(StandardContext.class, sc, "encodedPath", true);
    context.put(InterceptConstants.CONTEXTPATH, contextPath);
    context.put(InterceptConstants.APPNAME, ReflectionHelper.getField(StandardContext.class, sc, "displayName", true));
    ServletContext sContext = (ServletContext) ReflectionHelper.getField(StandardContext.class, sc, "context", true);
    context.put(InterceptConstants.SERVLET_CONTEXT, sContext);
    String basePath = sContext.getRealPath("");
    /*
         * NOTE: springboot couldn't get the basePath through method "getRealPath", temporary process
         */
    if (basePath == null) {
        basePath = "";
    } else if (basePath.lastIndexOf("/") == (basePath.length() - 1) || basePath.lastIndexOf("\\") == (basePath.length() - 1)) {
        basePath = basePath.substring(0, basePath.length() - 1);
    }
    context.put(InterceptConstants.BASEPATH, basePath);
    iSupport.doIntercept(context);
}
Also used : InterceptContext(com.creditease.monitor.interceptframework.spi.InterceptContext) InterceptSupport(com.creditease.monitor.interceptframework.InterceptSupport) StandardContext(org.apache.catalina.core.StandardContext) ServletContext(javax.servlet.ServletContext)

Example 20 with InterceptSupport

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

the class SpringBootTomcatPlusIT method onResourceCreate.

@Override
public Object onResourceCreate(Object... args) {
    ClassLoader cl = Thread.currentThread().getContextClassLoader();
    if (!WebappClassLoader.class.isAssignableFrom(cl.getClass())) {
        return args[0];
    }
    /**
     * for Application Starting's Resource Create
     */
    InterceptSupport iSupport = InterceptSupport.instance();
    InterceptContext context = iSupport.getThreadLocalContext(Event.WEBCONTAINER_RESOURCE_CREATE);
    StandardContext sc = (StandardContext) context.get(InterceptConstants.CONTEXTOBJ);
    /**
     * NOTE: spring boot rewrite the tomcat webappclassloader, makes the addURL for nothing, then we can't do
     * anything on this we may use its webappclassloader's parent as the classloader
     */
    context.put(InterceptConstants.WEBAPPLOADER, sc.getLoader().getClassLoader().getParent());
    context.put(InterceptConstants.WEBWORKDIR, sc.getWorkPath());
    String contextPath = (String) ReflectionHelper.getField(StandardContext.class, sc, "encodedPath", true);
    context.put(InterceptConstants.CONTEXTPATH, contextPath);
    context.put(InterceptConstants.APPNAME, ReflectionHelper.getField(StandardContext.class, sc, "displayName", true));
    ServletContext sContext = (ServletContext) ReflectionHelper.getField(StandardContext.class, sc, "context", true);
    context.put(InterceptConstants.SERVLET_CONTEXT, sContext);
    String basePath = sContext.getRealPath("");
    /*
         * NOTE: springboot couldn't get the basePath through method "getRealPath", temporary process
         */
    if (basePath == null) {
        basePath = "";
    } else if (basePath.lastIndexOf("/") == (basePath.length() - 1) || basePath.lastIndexOf("\\") == (basePath.length() - 1)) {
        basePath = basePath.substring(0, basePath.length() - 1);
    }
    context.put(InterceptConstants.BASEPATH, basePath);
    context.put(InterceptConstants.RESOURCEOBJ, args[0]);
    context.put(InterceptConstants.RESOURCECFG, args[1]);
    iSupport.doIntercept(context);
    return context.get(InterceptConstants.RESOURCEOBJ);
}
Also used : WebappClassLoader(org.apache.catalina.loader.WebappClassLoader) InterceptContext(com.creditease.monitor.interceptframework.spi.InterceptContext) InterceptSupport(com.creditease.monitor.interceptframework.InterceptSupport) StandardContext(org.apache.catalina.core.StandardContext) WebappClassLoader(org.apache.catalina.loader.WebappClassLoader) ServletContext(javax.servlet.ServletContext)

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