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


Java Loader.getClassLoader方法代码示例

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


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

示例1: initializeSerializer

import org.apache.catalina.Loader; //导入方法依赖的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: initializeSerializer

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

	Loader loader = null;

	if (getContext() != null) {
		loader = getContext().getLoader();
	}

	ClassLoader classLoader = null;

	if (loader != null) {
		classLoader = loader.getClassLoader();
	}
	serializer.setClassLoader(classLoader);
}
 
开发者ID:appNG,项目名称:appng-tomcat-session,代码行数:18,代码来源:RedisSessionManager.java

示例3: initializeSerializer

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

   Loader loader = null;

   Context context = this.getContext();
if (context != null) {
	loader = context.getLoader();
}

   /*
    * if (getContainer() != null) {
     loader = getContainer().getLoader();
   }*/
   ClassLoader classLoader = null;

   if (loader != null) {
     classLoader = loader.getClassLoader();
   }
   serializer.setClassLoader(classLoader);
 }
 
开发者ID:xiaowing,项目名称:various_demos,代码行数:23,代码来源:RedisSessionManager.java

示例4: initializeSerializer

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

	Loader loader = null;

	if (getContainer() != null) {
		loader = getContainer().getLoader();
	}

	ClassLoader classLoader = null;

	if (loader != null) {
		classLoader = loader.getClassLoader();
	}
	serializer.setClassLoader(classLoader);
}
 
开发者ID:liuxinglanyue,项目名称:distributed-session-manager,代码行数:24,代码来源:AbstractSessionManager.java

示例5: getClassLoaders

import org.apache.catalina.Loader; //导入方法依赖的package包/类
public static ClassLoader[] getClassLoaders(Container container) {
    Loader loader = null;
    ClassLoader classLoader = null;
    if (container != null) loader = container.getLoader();
    if (loader != null) classLoader = loader.getClassLoader();
    else classLoader = Thread.currentThread().getContextClassLoader();
    if ( classLoader == Thread.currentThread().getContextClassLoader() ) {
        return new ClassLoader[] {classLoader};
    } else {
        return new ClassLoader[] {classLoader,Thread.currentThread().getContextClassLoader()};
    }
}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:13,代码来源:ClusterManagerBase.java

示例6: getClassLoaders

import org.apache.catalina.Loader; //导入方法依赖的package包/类
public ClassLoader[] getClassLoaders() {
    Loader loader = null;
    ClassLoader classLoader = null;
    loader = this.getLoader();
    if (loader != null) classLoader = loader.getClassLoader();
    if ( classLoader == null ) classLoader = Thread.currentThread().getContextClassLoader();
    if ( classLoader == Thread.currentThread().getContextClassLoader() ) {
        return new ClassLoader[] {classLoader};
    } else {
        return new ClassLoader[] {classLoader,Thread.currentThread().getContextClassLoader()};
    }
}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:13,代码来源:ReplicatedContext.java

示例7: getClassLoaders

import org.apache.catalina.Loader; //导入方法依赖的package包/类
public static ClassLoader[] getClassLoaders(Container container) {
	Loader loader = null;
	ClassLoader classLoader = null;
	if (container != null)
		loader = container.getLoader();
	if (loader != null)
		classLoader = loader.getClassLoader();
	else
		classLoader = Thread.currentThread().getContextClassLoader();
	if (classLoader == Thread.currentThread().getContextClassLoader()) {
		return new ClassLoader[] { classLoader };
	} else {
		return new ClassLoader[] { classLoader, Thread.currentThread().getContextClassLoader() };
	}
}
 
开发者ID:how2j,项目名称:lazycat,代码行数:16,代码来源:ClusterManagerBase.java

示例8: getClassLoaders

import org.apache.catalina.Loader; //导入方法依赖的package包/类
public ClassLoader[] getClassLoaders() {
	Loader loader = null;
	ClassLoader classLoader = null;
	loader = this.getLoader();
	if (loader != null)
		classLoader = loader.getClassLoader();
	if (classLoader == null)
		classLoader = Thread.currentThread().getContextClassLoader();
	if (classLoader == Thread.currentThread().getContextClassLoader()) {
		return new ClassLoader[] { classLoader };
	} else {
		return new ClassLoader[] { classLoader, Thread.currentThread().getContextClassLoader() };
	}
}
 
开发者ID:how2j,项目名称:lazycat,代码行数:15,代码来源:ReplicatedContext.java

示例9: main

import org.apache.catalina.Loader; //导入方法依赖的package包/类
public static void main(String[] args) {

    //invoke: http://localhost:8080/Modern or  http://localhost:8080/Primitive

    System.setProperty("catalina.base", System.getProperty("user.dir"));
    Connector connector = new HttpConnector();
    Wrapper wrapper1 = new SimpleWrapper();
    wrapper1.setName("Primitive");
    wrapper1.setServletClass("PrimitiveServlet");
    Wrapper wrapper2 = new SimpleWrapper();
    wrapper2.setName("Modern");
    wrapper2.setServletClass("ModernServlet");

    Context context = new StandardContext();
    // StandardContext's start method adds a default mapper
    context.setPath("/myApp");
    context.setDocBase("myApp");

    context.addChild(wrapper1);
    context.addChild(wrapper2);

    // context.addServletMapping(pattern, name);
    context.addServletMapping("/Primitive", "Primitive");
    context.addServletMapping("/Modern", "Modern");
    // add ContextConfig. This listener is important because it configures
    // StandardContext (sets configured to true), otherwise StandardContext
    // won't start
    LifecycleListener listener = new SimpleContextConfig();
    ((Lifecycle) context).addLifecycleListener(listener);

    // here is our loader
    Loader loader = new WebappLoader();
    // associate the loader with the Context
    context.setLoader(loader);

    connector.setContainer(context);

    try {
      connector.initialize();
      ((Lifecycle) connector).start();
      ((Lifecycle) context).start();
      // now we want to know some details about WebappLoader
      WebappClassLoader classLoader = (WebappClassLoader) loader.getClassLoader();
      System.out.println("Resources' docBase: " + ((ProxyDirContext)classLoader.getResources()).getDocBase());
      String[] repositories = classLoader.findRepositories();
      for (int i=0; i<repositories.length; i++) {
        System.out.println("  repository: " + repositories[i]);
      }

      // make the application wait until we press a key.
      System.in.read();
      ((Lifecycle) context).stop();
    }
    catch (Exception e) {
      e.printStackTrace();
    }
  }
 
开发者ID:eclipsky,项目名称:HowTomcatWorks,代码行数:58,代码来源:Bootstrap.java


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