當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。