本文整理汇总了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);
}
示例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);
}
示例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);
}
示例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);
}
示例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()};
}
}
示例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()};
}
}
示例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() };
}
}
示例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() };
}
}
示例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();
}
}