本文整理了Java中org.apache.catalina.Context.setLoader()
方法的一些代码示例,展示了Context.setLoader()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Context.setLoader()
方法的具体详情如下:
包路径:org.apache.catalina.Context
类名称:Context
方法名:setLoader
[英]Set the Loader with which this Context is associated.
[中]设置与此上下文关联的加载程序。
代码示例来源:origin: stackoverflow.com
rootContext.setLoader(loader);
rootContext.setReloadable(true);
代码示例来源:origin: apache/geode
rootContext.setLoader(loader);
rootContext.setReloadable(true);
代码示例来源:origin: org.apache.tomcat/tomcat-catalina
/**
* Remove an existing Loader.
*
* @param name MBean Name of the component to remove
*
* @exception Exception if a component cannot be removed
*/
public void removeLoader(String name) throws Exception {
ObjectName oname = new ObjectName(name);
// Acquire a reference to the component to be removed
Container container = getParentContainerFromChild(oname);
if (container instanceof Context) {
((Context) container).setLoader(null);
}
}
代码示例来源:origin: codefollower/Tomcat-Research
/**
* Remove an existing Loader.
*
* @param name MBean Name of the component to remove
*
* @exception Exception if a component cannot be removed
*/
public void removeLoader(String name) throws Exception {
ObjectName oname = new ObjectName(name);
// Acquire a reference to the component to be removed
Container container = getParentContainerFromChild(oname);
if (container instanceof Context) {
((Context) container).setLoader(null);
}
}
代码示例来源:origin: org.ops4j.pax.tipi/org.ops4j.pax.tipi.tomcat-embed-core
/**
* Remove an existing Loader.
*
* @param name MBean Name of the component to remove
*
* @exception Exception if a component cannot be removed
*/
public void removeLoader(String name) throws Exception {
ObjectName oname = new ObjectName(name);
// Acquire a reference to the component to be removed
Container container = getParentContainerFromChild(oname);
if (container instanceof Context) {
((Context) container).setLoader(null);
}
}
代码示例来源:origin: apache/meecrowave
public Meecrowave deployClasspath(final DeploymentMeta meta) {
ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
final ClassLoader parentLoader = tomcat.getServer().getParentClassLoader();
if (parentLoader.getParent() == classLoader) {
classLoader = parentLoader;
}
final ProvidedLoader loader = new ProvidedLoader(classLoader, configuration.isTomcatWrapLoader());
final Consumer<Context> builtInCustomizer = c -> {
c.setLoader(loader);
configuration.getInitializers().forEach(i -> c.addServletContainerInitializer(i, emptySet()));
};
return deployWebapp(new DeploymentMeta(meta.context, meta.docBase, ofNullable(meta.consumer).map(c -> (Consumer<Context>) ctx -> {
builtInCustomizer.accept(ctx);
c.accept(ctx);
}).orElse(builtInCustomizer)));
}
代码示例来源:origin: org.apache.meecrowave/meecrowave-core
public Meecrowave deployClasspath(final DeploymentMeta meta) {
ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
final ClassLoader parentLoader = tomcat.getServer().getParentClassLoader();
if (parentLoader.getParent() == classLoader) {
classLoader = parentLoader;
}
final ProvidedLoader loader = new ProvidedLoader(classLoader, configuration.isTomcatWrapLoader());
final Consumer<Context> builtInCustomizer = c -> {
c.setLoader(loader);
configuration.getInitializers().forEach(i -> c.addServletContainerInitializer(i, emptySet()));
};
return deployWebapp(new DeploymentMeta(meta.context, meta.docBase, ofNullable(meta.consumer).map(c -> (Consumer<Context>) ctx -> {
builtInCustomizer.accept(ctx);
c.accept(ctx);
}).orElse(builtInCustomizer)));
}
代码示例来源:origin: codefollower/Tomcat-Research
/**
* Create a new Web Application Loader.
*
* @param parent MBean Name of the associated parent component
*
* @exception Exception if an MBean cannot be created or registered
*/
public String createWebappLoader(String parent)
throws Exception {
// Create a new WebappLoader instance
WebappLoader loader = new WebappLoader();
// Add the new instance to its parent component
ObjectName pname = new ObjectName(parent);
Container container = getParentContainerFromParent(pname);
if (container instanceof Context) {
((Context) container).setLoader(loader);
}
// FIXME add Loader.getObjectName
//ObjectName oname = loader.getObjectName();
ObjectName oname =
MBeanUtils.createObjectName(pname.getDomain(), loader);
return (oname.toString());
}
代码示例来源:origin: org.apache.tomcat/tomcat-catalina
/**
* Create a new Web Application Loader.
*
* @param parent MBean Name of the associated parent component
* @return the object name of the created loader
*
* @exception Exception if an MBean cannot be created or registered
*/
public String createWebappLoader(String parent)
throws Exception {
// Create a new WebappLoader instance
WebappLoader loader = new WebappLoader();
// Add the new instance to its parent component
ObjectName pname = new ObjectName(parent);
Container container = getParentContainerFromParent(pname);
if (container instanceof Context) {
((Context) container).setLoader(loader);
}
// FIXME add Loader.getObjectName
//ObjectName oname = loader.getObjectName();
ObjectName oname =
MBeanUtils.createObjectName(pname.getDomain(), loader);
return oname.toString();
}
代码示例来源:origin: org.ops4j.pax.tipi/org.ops4j.pax.tipi.tomcat-embed-core
/**
* Create a new Web Application Loader.
*
* @param parent MBean Name of the associated parent component
* @return the object name of the created loader
*
* @exception Exception if an MBean cannot be created or registered
*/
public String createWebappLoader(String parent)
throws Exception {
// Create a new WebappLoader instance
WebappLoader loader = new WebappLoader();
// Add the new instance to its parent component
ObjectName pname = new ObjectName(parent);
Container container = getParentContainerFromParent(pname);
if (container instanceof Context) {
((Context) container).setLoader(loader);
}
// FIXME add Loader.getObjectName
//ObjectName oname = loader.getObjectName();
ObjectName oname =
MBeanUtils.createObjectName(pname.getDomain(), loader);
return oname.toString();
}
代码示例来源:origin: net.disy.legato/legato-testing
@Override
public void addWebAppContext(
final String contextPath,
final String location,
final boolean cookies) {
final Context context = container.createContext(contextPath, location);
context.setLoader(webAppLoader);
context.setReloadable(true);
context.setCookies(cookies);
localHost.addChild(context);
}
代码示例来源:origin: apache/tomcat-maven-plugin
context.setLoader( webappLoader );
代码示例来源:origin: org.wso2.ei/service-samples
public void startPeopleService() throws Exception {
final File base = createBaseDirectory();
log.info("Using base folder: " + base.getAbsolutePath());
final Tomcat tomcat = new Tomcat();
tomcat.setPort(8080);
tomcat.setBaseDir(base.getAbsolutePath());
Context context = tomcat.addContext("/", base.getAbsolutePath());
Tomcat.addServlet(context, "CXFServlet", new CXFServlet());
context.addServletMapping("/rest/*", "CXFServlet");
context.addApplicationListener(ContextLoaderListener.class.getName());
context.setLoader(new WebappLoader(Thread.currentThread().getContextClassLoader()));
context.addParameter("contextClass", AnnotationConfigWebApplicationContext.class.getName());
context.addParameter("contextConfigLocation", AppConfig.class.getName());
tomcat.start();
tomcat.getServer().await();
}
代码示例来源:origin: org.wso2.esb/service-samples
public static void main(final String[] args) throws Exception {
final File base = createBaseDirectory();
log.info("Using base folder: " + base.getAbsolutePath());
final Tomcat tomcat = new Tomcat();
tomcat.setPort(8080);
tomcat.setBaseDir( base.getAbsolutePath() );
Context context = tomcat.addContext( "/", base.getAbsolutePath() );
Tomcat.addServlet( context, "CXFServlet", new CXFServlet() );
context.addServletMapping( "/rest/*", "CXFServlet" );
context.addApplicationListener( ContextLoaderListener.class.getName() );
context.setLoader( new WebappLoader( Thread.currentThread().getContextClassLoader() ) );
context.addParameter( "contextClass", AnnotationConfigWebApplicationContext.class.getName() );
context.addParameter( "contextConfigLocation", MusicConfig.class.getName() );
tomcat.start();
tomcat.getServer().await();
}
代码示例来源:origin: org.wso2.ei/service-samples
public static void main(final String[] args) throws Exception {
final File base = createBaseDirectory();
log.info("Using base folder: " + base.getAbsolutePath());
final Tomcat tomcat = new Tomcat();
tomcat.setPort(8080);
tomcat.setBaseDir( base.getAbsolutePath() );
Context context = tomcat.addContext( "/", base.getAbsolutePath() );
Tomcat.addServlet( context, "CXFServlet", new CXFServlet() );
context.addServletMapping( "/rest/*", "CXFServlet" );
context.addApplicationListener( ContextLoaderListener.class.getName() );
context.setLoader( new WebappLoader( Thread.currentThread().getContextClassLoader() ) );
context.addParameter( "contextClass", AnnotationConfigWebApplicationContext.class.getName() );
context.addParameter( "contextConfigLocation", MusicConfig.class.getName() );
tomcat.start();
tomcat.getServer().await();
}
代码示例来源:origin: org.wso2.esb/service-samples
public void startPeopleService() throws Exception {
final File base = createBaseDirectory();
log.info("Using base folder: " + base.getAbsolutePath());
final Tomcat tomcat = new Tomcat();
tomcat.setPort(8080);
tomcat.setBaseDir(base.getAbsolutePath());
Context context = tomcat.addContext("/", base.getAbsolutePath());
Tomcat.addServlet(context, "CXFServlet", new CXFServlet());
context.addServletMapping("/rest/*", "CXFServlet");
context.addApplicationListener(ContextLoaderListener.class.getName());
context.setLoader(new WebappLoader(Thread.currentThread().getContextClassLoader()));
context.addParameter("contextClass", AnnotationConfigWebApplicationContext.class.getName());
context.addParameter("contextConfigLocation", AppConfig.class.getName());
tomcat.start();
tomcat.getServer().await();
}
代码示例来源:origin: org.springframework.osgi/spring-osgi-web
protected WarDeployment createDeployment(Bundle bundle, String contextPath) throws Exception {
String docBase = createDocBase(bundle, contextPath);
Context catalinaContext = createDefaultContext(contextPath, docBase);
catalinaContext.setLoader(createCatalinaLoader(bundle));
catalinaContext.setPrivileged(false);
catalinaContext.setReloadable(false);
// create Tomcat specific deployment
TomcatWarDeployment deployment = new TomcatWarDeployment(new TomcatContextUndeployer() {
public void undeploy(Context catalinaContext) throws OsgiWarDeploymentException {
stopCatalinaContext(catalinaContext);
}
}, bundle, catalinaContext);
return deployment;
}
代码示例来源:origin: Red5/red5-plugins
ctx.setLoader(wldr);
代码示例来源:origin: org.springframework.osgi/org.springframework.osgi.web
protected WarDeployment createDeployment(Bundle bundle, String contextPath) throws Exception {
String docBase = createDocBase(bundle, contextPath);
Context catalinaContext = createDefaultContext(contextPath, docBase);
catalinaContext.setLoader(createCatalinaLoader(bundle));
catalinaContext.setPrivileged(false);
catalinaContext.setReloadable(false);
// create Tomcat specific deployment
TomcatWarDeployment deployment = new TomcatWarDeployment(new TomcatContextUndeployer() {
public void undeploy(Context catalinaContext) throws OsgiWarDeploymentException {
stopCatalinaContext(catalinaContext);
}
}, bundle, catalinaContext);
return deployment;
}
代码示例来源:origin: apache/tomcat-maven-plugin
context.setLoader( webappLoader );
File contextFile = getContextFile();
if ( contextFile != null )
内容来源于网络,如有侵权,请联系作者删除!