当前位置: 首页>>代码示例>>Java>>正文


Java Context.getLoader方法代码示例

本文整理汇总了Java中org.apache.catalina.Context.getLoader方法的典型用法代码示例。如果您正苦于以下问题:Java Context.getLoader方法的具体用法?Java Context.getLoader怎么用?Java Context.getLoader使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.catalina.Context的用法示例。


在下文中一共展示了Context.getLoader方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: initializeSerializer

import org.apache.catalina.Context; //导入方法依赖的package包/类
private void initializeSerializer() throws ClassNotFoundException, IllegalAccessException, InstantiationException {
   log.info("Attempting to use serializer :" + serializationStrategyClass);
   serializer = (Serializer) Class.forName(serializationStrategyClass).newInstance();

   Loader loader = null;
   
   /* 默认支持tomcat7.x
   if (getContainer() != null) {
     loader = getContainer().getLoader();
   }
   */
   
   // 修改为支持tomcat8.x
   Context context = this.getContext();
   
   if (context != null) {
	loader = context.getLoader();
}

   ClassLoader classLoader = null;

   if (loader != null) {
     classLoader = loader.getClassLoader();
   }
   serializer.setClassLoader(classLoader);
 }
 
开发者ID:ctchengt,项目名称:tomcat8-redis-session-manager,代码行数:27,代码来源:RedisSessionManager.java

示例2: bind

import org.apache.catalina.Context; //导入方法依赖的package包/类
private void bind(Context context) {
    // Bind the context CL to the current thread
    if (clBindRequired && context.getLoader() != null) {
        if (Globals.IS_SECURITY_ENABLED) {
            PrivilegedAction<Void> pa =
                    new PrivilegedSetTccl(context.getLoader().getClassLoader());
            AccessController.doPrivileged(pa);                
        } else {
            Thread.currentThread().setContextClassLoader(context.getLoader().getClassLoader());
        }
    }
}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:13,代码来源:PersistentValve.java

示例3: invoke

import org.apache.catalina.Context; //导入方法依赖的package包/类
/**
 * Select the appropriate child Context to process this request,
 * based on the specified request URI.  If no matching Context can
 * be found, return an appropriate HTTP error.
 *
 * @param request Request to be processed
 * @param response Response to be produced
 * @param valveContext Valve context used to forward to the next Valve
 *
 * @exception IOException if an input/output error occurred
 * @exception ServletException if a servlet error occurred
 */
public final void invoke(Request request, Response response)
    throws IOException, ServletException {

    // Select the Context to be used for this Request
    Context context = request.getContext();
    if (context == null) {
        response.sendError
            (HttpServletResponse.SC_INTERNAL_SERVER_ERROR,
             sm.getString("standardHost.noContext"));
        return;
    }

    // Bind the context CL to the current thread
    if( context.getLoader() != null ) {
        // Not started - it should check for availability first
        // This should eventually move to Engine, it's generic.
        Thread.currentThread().setContextClassLoader
                (context.getLoader().getClassLoader());
    }

    // Ask this Context to process this request
    context.getPipeline().getFirst().invoke(request, response);

    // Access a session (if present) to update last accessed time, based on a
    // strict interpretation of the specification
    if (Globals.STRICT_SERVLET_COMPLIANCE) {
        request.getSession(false);
    }

    // Error page processing
    response.setSuspended(false);

    Throwable t = (Throwable) request.getAttribute(Globals.EXCEPTION_ATTR);

    if (t != null) {
        throwable(request, response, t);
    } else {
        status(request, response);
    }

    // Restore the context classloader
    Thread.currentThread().setContextClassLoader
        (StandardHostValve.class.getClassLoader());

}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:58,代码来源:StandardHostValve.java

示例4: bind

import org.apache.catalina.Context; //导入方法依赖的package包/类
private void bind(Context context) {
	// Bind the context CL to the current thread
	if (clBindRequired && context.getLoader() != null) {
		if (Globals.IS_SECURITY_ENABLED) {
			PrivilegedAction<Void> pa = new PrivilegedSetTccl(context.getLoader().getClassLoader());
			AccessController.doPrivileged(pa);
		} else {
			Thread.currentThread().setContextClassLoader(context.getLoader().getClassLoader());
		}
	}
}
 
开发者ID:how2j,项目名称:lazycat,代码行数:12,代码来源:PersistentValve.java

示例5: createMBeans

import org.apache.catalina.Context; //导入方法依赖的package包/类
/**
     * Create the MBeans for the specified Context and its nested components.
     *
     * @param context Context for which to create MBeans
     *
     * @exception Exception if an exception is thrown during MBean creation
     */
    protected void createMBeans(Context context) throws Exception {

        // Create the MBean for the Context itself
//        if (log.isDebugEnabled())
//            log.debug("Creating MBean for Context " + context);
//        MBeanUtils.createMBean(context);
        context.addContainerListener(this);
        if (context instanceof StandardContext) {
            ((StandardContext) context).addPropertyChangeListener(this);
            ((StandardContext) context).addLifecycleListener(this);
        }

        // If the context is privileged, give a reference to it
        // in a servlet context attribute
        if (context.getPrivileged()) {
            context.getServletContext().setAttribute
                (Globals.MBEAN_REGISTRY_ATTR,
                 MBeanUtils.createRegistry());
            context.getServletContext().setAttribute
                (Globals.MBEAN_SERVER_ATTR,
                 MBeanUtils.createServer());
        }

        // Create the MBeans for the associated nested components
        Loader cLoader = context.getLoader();
        if (cLoader != null) {
            if (log.isDebugEnabled())
                log.debug("Creating MBean for Loader " + cLoader);
            //MBeanUtils.createMBean(cLoader);
        }
        Manager cManager = context.getManager();
        if (cManager != null) {
            if (log.isDebugEnabled())
                log.debug("Creating MBean for Manager " + cManager);
            //MBeanUtils.createMBean(cManager);
        }
        Realm hRealm = context.getParent().getRealm();
        Realm cRealm = context.getRealm();
        if ((cRealm != null) && (cRealm != hRealm)) {
            if (log.isDebugEnabled())
                log.debug("Creating MBean for Realm " + cRealm);
            //MBeanUtils.createMBean(cRealm);
        }

        // Create the MBeans for the NamingResources (if any)
        NamingResources resources = context.getNamingResources();
        createMBeans(resources);

    }
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:57,代码来源:ServerLifecycleListener.java

示例6: destroyMBeans

import org.apache.catalina.Context; //导入方法依赖的package包/类
/**
 * Deregister the MBeans for the specified Context and its nested
 * components.
 *
 * @param context Context for which to deregister MBeans
 *
 * @exception Exception if an exception is thrown during MBean destruction
 */
protected void destroyMBeans(Context context) throws Exception {

    // Deregister ourselves as a ContainerListener
    context.removeContainerListener(this);

    // Destroy the MBeans for the associated nested components
    Realm hRealm = context.getParent().getRealm();
    Realm cRealm = context.getRealm();
    if ((cRealm != null) && (cRealm != hRealm)) {
        if (log.isDebugEnabled())
            log.debug("Destroying MBean for Realm " + cRealm);
        //MBeanUtils.destroyMBean(cRealm);
    }
    Manager cManager = context.getManager();
    if (cManager != null) {
        if (log.isDebugEnabled())
            log.debug("Destroying MBean for Manager " + cManager);
        //MBeanUtils.destroyMBean(cManager);
    }
    Loader cLoader = context.getLoader();
    if (cLoader != null) {
        if (log.isDebugEnabled())
            log.debug("Destroying MBean for Loader " + cLoader);
        //MBeanUtils.destroyMBean(cLoader);
    }

    // Destroy the MBeans for the NamingResources (if any)
    NamingResources resources = context.getNamingResources();
    if (resources != null) {
        destroyMBeans(resources);
    }

    // deregister the MBean for the Context itself
    if (log.isDebugEnabled())
        log.debug("Destroying MBean for Context " + context);
    //MBeanUtils.destroyMBean(context);
    if (context instanceof StandardContext) {
        ((StandardContext) context).
            removePropertyChangeListener(this);
    }

}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:51,代码来源:ServerLifecycleListener.java

示例7: createMBeans

import org.apache.catalina.Context; //导入方法依赖的package包/类
/**
 * Create the MBeans for the specified Context and its nested components.
 *
 * @param context Context for which to create MBeans
 *
 * @exception Exception if an exception is thrown during MBean creation
 */
protected void createMBeans(Context context) throws Exception {
    // Create the MBean for the Context itself
    if (debug >= 4)
        log("Creating MBean for Context " + context);
    MBeanUtils.createMBean(context);
    context.addContainerListener(this);
    if (context instanceof StandardContext) {
        ((StandardContext) context).addPropertyChangeListener(this);
        ((StandardContext) context).addLifecycleListener(this);
    }

    // If the context is privileged, give a reference to it
    // in a servlet context attribute
    if (context.getPrivileged()) {
        context.getServletContext().setAttribute
            (Globals.MBEAN_REGISTRY_ATTR,
             MBeanUtils.createRegistry());
        context.getServletContext().setAttribute
            (Globals.MBEAN_SERVER_ATTR, 
             MBeanUtils.createServer());
    }

    // Create the MBeans for the associated nested components
    Loader cLoader = context.getLoader();
    if (cLoader != null) {
        if (debug >= 4)
            log("Creating MBean for Loader " + cLoader);
        MBeanUtils.createMBean(cLoader);
    }
    Logger hLogger = context.getParent().getLogger();
    Logger cLogger = context.getLogger();
    if ((cLogger != null) && (cLogger != hLogger)) {
        if (debug >= 4)
            log("Creating MBean for Logger " + cLogger);
        MBeanUtils.createMBean(cLogger);
    }
    Manager cManager = context.getManager();
    if (cManager != null) {
        if (debug >= 4)
            log("Creating MBean for Manager " + cManager);
        MBeanUtils.createMBean(cManager);
    }
    Realm hRealm = context.getParent().getRealm();
    Realm cRealm = context.getRealm();
    if ((cRealm != null) && (cRealm != hRealm)) {
        if (debug >= 4)
            log("Creating MBean for Realm " + cRealm);
        MBeanUtils.createMBean(cRealm);
    }

    // Create the MBeans for the associated Valves
    if (context instanceof StandardContext) {
        Valve cValves[] = ((StandardContext)context).getValves();
        for (int l = 0; l < cValves.length; l++) {
            if (debug >= 4)
                log("Creating MBean for Valve " + cValves[l]);
            MBeanUtils.createMBean(cValves[l]);
        }
        
    }        
    
    // Create the MBeans for the NamingResources (if any)
    NamingResources resources = context.getNamingResources();
    createMBeans(resources);

}
 
开发者ID:c-rainstorm,项目名称:jerrydog,代码行数:74,代码来源:ServerLifecycleListener.java

示例8: destroyMBeans

import org.apache.catalina.Context; //导入方法依赖的package包/类
/**
 * Deregister the MBeans for the specified Context and its nested
 * components.
 *
 * @param context Context for which to deregister MBeans
 *
 * @exception Exception if an exception is thrown during MBean destruction
 */
protected void destroyMBeans(Context context) throws Exception {

    // Deregister ourselves as a ContainerListener
    context.removeContainerListener(this);

    // destroy the MBeans for the associated Valves
    if (context instanceof StandardContext) {
        Valve cValves[] = ((StandardContext)context).getValves();
        for (int l = 0; l < cValves.length; l++) {
            if (debug >= 4)
                log("Destroying MBean for Valve " + cValves[l]);
            MBeanUtils.destroyMBean(cValves[l], context);
        }
        
    }

    // Destroy the MBeans for the associated nested components
    Realm hRealm = context.getParent().getRealm();
    Realm cRealm = context.getRealm();
    if ((cRealm != null) && (cRealm != hRealm)) {
        if (debug >= 4)
            log("Destroying MBean for Realm " + cRealm);
        MBeanUtils.destroyMBean(cRealm);
    }
    Manager cManager = context.getManager();
    if (cManager != null) {
        if (debug >= 4)
            log("Destroying MBean for Manager " + cManager);
        MBeanUtils.destroyMBean(cManager);
    }
    Logger hLogger = context.getParent().getLogger();
    Logger cLogger = context.getLogger();
    if ((cLogger != null) && (cLogger != hLogger)) {
        if (debug >= 4)
            log("Destroying MBean for Logger " + cLogger);
        MBeanUtils.destroyMBean(cLogger);
    }
    Loader cLoader = context.getLoader();
    if (cLoader != null) {
        if (debug >= 4)
            log("Destroying MBean for Loader " + cLoader);
        MBeanUtils.destroyMBean(cLoader);
    }

    // Destroy the MBeans for the NamingResources (if any)
    NamingResources resources = context.getNamingResources();
    if (resources != null) {
        destroyMBeans(resources);
    }
    
    // deregister the MBean for the Context itself
    if (debug >= 4)
        log("Destroying MBean for Context " + context);
    MBeanUtils.destroyMBean(context);
    if (context instanceof StandardContext) {
        ((StandardContext) context).
            removePropertyChangeListener(this);
    }

}
 
开发者ID:c-rainstorm,项目名称:jerrydog,代码行数:69,代码来源:ServerLifecycleListener.java


注:本文中的org.apache.catalina.Context.getLoader方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。