本文整理汇总了Java中org.apache.catalina.Context.setPath方法的典型用法代码示例。如果您正苦于以下问题:Java Context.setPath方法的具体用法?Java Context.setPath怎么用?Java Context.setPath使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.catalina.Context
的用法示例。
在下文中一共展示了Context.setPath方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addContext
import org.apache.catalina.Context; //导入方法依赖的package包/类
public Context addContext(Host host, String contextPath, String contextName,
String dir) {
silence(host, contextName);
Context ctx = createContext(host, contextPath);
ctx.setName(contextName);
ctx.setPath(contextPath);
ctx.setDocBase(dir);
ctx.addLifecycleListener(new FixContextListener());
if (host == null) {
getHost().addChild(ctx);
} else {
host.addChild(ctx);
}
return ctx;
}
示例2: addWebapp
import org.apache.catalina.Context; //导入方法依赖的package包/类
/**
* @see #addWebapp(String, String)
*
* @param name Ignored. The contextPath will be used
*
* @deprecated Use {@link #addWebapp(Host, String, String)}
*/
@Deprecated
public Context addWebapp(Host host, String contextPath, String name, String docBase) {
silence(host, contextPath);
Context ctx = createContext(host, contextPath);
ctx.setPath(contextPath);
ctx.setDocBase(docBase);
ctx.addLifecycleListener(new DefaultWebXmlListener());
ctx.setConfigFile(getWebappConfigFile(docBase, contextPath));
ContextConfig ctxCfg = new ContextConfig();
ctx.addLifecycleListener(ctxCfg);
// prevent it from looking ( if it finds one - it'll have dup error )
ctxCfg.setDefaultWebXml(noDefaultWebXmlPath());
if (host == null) {
getHost().addChild(ctx);
} else {
host.addChild(ctx);
}
return ctx;
}
示例3: deploy
import org.apache.catalina.Context; //导入方法依赖的package包/类
/**
* Deploy a web application for the specified user if they have such an
* application in the defined directory within their home directory.
*
* @param user Username owning the application to be deployed
* @param home Home directory of this user
*/
private void deploy(String user, String home) {
// Does this user have a web application to be deployed?
String contextPath = "/~" + user;
if (host.findChild(contextPath) != null)
return;
File app = new File(home, directoryName);
if (!app.exists() || !app.isDirectory())
return;
/*
File dd = new File(app, "/WEB-INF/web.xml");
if (!dd.exists() || !dd.isFile() || !dd.canRead())
return;
*/
host.getLogger().info(sm.getString("userConfig.deploy", user));
// Deploy the web application for this user
try {
Class<?> clazz = Class.forName(contextClass);
Context context =
(Context) clazz.newInstance();
context.setPath(contextPath);
context.setDocBase(app.toString());
clazz = Class.forName(configClass);
LifecycleListener listener =
(LifecycleListener) clazz.newInstance();
context.addLifecycleListener(listener);
host.addChild(context);
} catch (Exception e) {
host.getLogger().error(sm.getString("userConfig.error", user), e);
}
}
示例4: deploy
import org.apache.catalina.Context; //导入方法依赖的package包/类
/**
* Deploy a web application for the specified user if they have such an
* application in the defined directory within their home directory.
*
* @param user Username owning the application to be deployed
* @param home Home directory of this user
*/
private void deploy(String user, String home) {
// Does this user have a web application to be deployed?
String contextPath = "/~" + user;
if (host.findChild(contextPath) != null)
return;
File app = new File(home, directoryName);
if (!app.exists() || !app.isDirectory())
return;
/*
File dd = new File(app, "/WEB-INF/web.xml");
if (!dd.exists() || !dd.isFile() || !dd.canRead())
return;
*/
host.getLogger().info(sm.getString("userConfig.deploy", user));
// Deploy the web application for this user
try {
Class clazz = Class.forName(contextClass);
Context context =
(Context) clazz.newInstance();
context.setPath(contextPath);
context.setDocBase(app.toString());
if (context instanceof Lifecycle) {
clazz = Class.forName(configClass);
LifecycleListener listener =
(LifecycleListener) clazz.newInstance();
((Lifecycle) context).addLifecycleListener(listener);
}
host.addChild(context);
} catch (Exception e) {
host.getLogger().error(sm.getString("userConfig.error", user), e);
}
}
示例5: deploy
import org.apache.catalina.Context; //导入方法依赖的package包/类
/**
* Deploy a web application for the specified user if they have such an
* application in the defined directory within their home directory.
*
* @param user Username owning the application to be deployed
* @param home Home directory of this user
*/
private void deploy(String user, String home) {
// Does this user have a web application to be deployed?
String contextPath = "/~" + user;
if (host.findChild(contextPath) != null)
return;
File app = new File(home, directoryName);
if (!app.exists() || !app.isDirectory())
return;
/*
File dd = new File(app, "/WEB-INF/web.xml");
if (!dd.exists() || !dd.isFile() || !dd.canRead())
return;
*/
log(sm.getString("userConfig.deploy", user));
// Deploy the web application for this user
try {
Class clazz = Class.forName(contextClass);
Context context =
(Context) clazz.newInstance();
context.setPath(contextPath);
context.setDocBase(app.toString());
if (context instanceof Lifecycle) {
clazz = Class.forName(configClass);
LifecycleListener listener =
(LifecycleListener) clazz.newInstance();
((Lifecycle) context).addLifecycleListener(listener);
}
host.addChild(context);
} catch (Exception e) {
log(sm.getString("userConfig.error", user), e);
}
}
示例6: deploy
import org.apache.catalina.Context; //导入方法依赖的package包/类
/**
* Deploy a web application for the specified user if they have such an
* application in the defined directory within their home directory.
*
* @param user
* Username owning the application to be deployed
* @param home
* Home directory of this user
*/
private void deploy(String user, String home) {
// Does this user have a web application to be deployed?
String contextPath = "/~" + user;
if (host.findChild(contextPath) != null)
return;
File app = new File(home, directoryName);
if (!app.exists() || !app.isDirectory())
return;
/*
* File dd = new File(app, "/WEB-INF/web.xml"); if (!dd.exists() ||
* !dd.isFile() || !dd.canRead()) return;
*/
host.getLogger().info(sm.getString("userConfig.deploy", user));
// Deploy the web application for this user
try {
Class<?> clazz = Class.forName(contextClass);
Context context = (Context) clazz.newInstance();
context.setPath(contextPath);
context.setDocBase(app.toString());
clazz = Class.forName(configClass);
LifecycleListener listener = (LifecycleListener) clazz.newInstance();
context.addLifecycleListener(listener);
host.addChild(context);
} catch (Exception e) {
host.getLogger().error(sm.getString("userConfig.error", user), e);
}
}
示例7: testBug57190
import org.apache.catalina.Context; //导入方法依赖的package包/类
@Test
public void testBug57190() throws Exception {
Tomcat tomcat = getTomcatInstance();
Context foo1 = new StandardContext();
foo1.setName("/foo##1");
foo1.setPath("/foo");
foo1.setWebappVersion("1");
foo1.setDocBase(System.getProperty("java.io.tmpdir"));
foo1.addLifecycleListener(new FixContextListener());
foo1.addLifecycleListener(new SetIdListener("foo1"));
tomcat.getHost().addChild(foo1);
Context foo2 = new StandardContext();
foo2.setName("/foo##2");
foo2.setPath("/foo");
foo2.setWebappVersion("2");
foo2.setDocBase(System.getProperty("java.io.tmpdir"));
foo2.addLifecycleListener(new FixContextListener());
foo2.addLifecycleListener(new SetIdListener("foo2"));
tomcat.getHost().addChild(foo2);
// No file system docBase required
Context bar = tomcat.addContext("/bar", null);
bar.addLifecycleListener(new SetIdListener("bar"));
// No file system docBase required
Context ctx = tomcat.addContext("", null);
ctx.addLifecycleListener(new SetIdListener("ROOT"));
ctx.setCrossContext(true);
Tomcat.addServlet(ctx, "Bug57190Servlet", new Bug57190Servlet());
ctx.addServletMapping("/", "Bug57190Servlet");
tomcat.start();
ByteChunk res = getUrl("http://localhost:" + getPort() + "/");
String body = res.toString();
Assert.assertTrue(body, body.contains("01-bar"));
Assert.assertTrue(body, body.contains("02-foo2"));
Assert.assertTrue(body, body.contains("03-foo1"));
Assert.assertTrue(body, body.contains("04-foo2"));
Assert.assertTrue(body, body.contains("05-foo2"));
Assert.assertTrue(body, body.contains("06-ROOT"));
Assert.assertTrue(body, body.contains("07-ROOT"));
Assert.assertTrue(body, body.contains("08-foo2"));
Assert.assertTrue(body, body.contains("09-ROOT"));
}