本文整理了Java中org.mortbay.jetty.webapp.WebAppContext.addServlet()
方法的一些代码示例,展示了WebAppContext.addServlet()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。WebAppContext.addServlet()
方法的具体详情如下:
包路径:org.mortbay.jetty.webapp.WebAppContext
类名称:WebAppContext
方法名:addServlet
暂无
代码示例来源:origin: Qihoo360/XLearning
String appDir = getClass().getClassLoader().getResource("xlWebApp").toString();
appWebAppContext.setResourceBase(appDir);
appWebAppContext.addServlet(DefaultServlet.class, "/*");
final String[] ALL_URLS = {"/*"};
FilterHolder[] filterHolders =
代码示例来源:origin: Qihoo360/XLearning
String appDir = getClass().getClassLoader().getResource("xlWebApp").toString();
appWebAppContext.setResourceBase(appDir);
appWebAppContext.addServlet(DefaultServlet.class, "/*");
final String[] ALL_URLS = {"/*"};
FilterHolder[] filterHolders =
代码示例来源:origin: com.facebook.hadoop/hadoop-core
/**
* Add an internal servlet in the server.
* @param name The name of the servlet (can be passed as null)
* @param pathSpec The path spec for the servlet
* @param clazz The servlet class
* @deprecated this is a temporary method
*/
@Deprecated
public void addInternalServlet(String name, String pathSpec,
Class<? extends HttpServlet> clazz) {
ServletHolder holder = new ServletHolder(clazz);
if (name != null) {
holder.setName(name);
}
webAppContext.addServlet(holder, pathSpec);
}
代码示例来源:origin: org.apache.hama/hama-core
/**
* Add an internal servlet in the server.
*
* @param name The name of the servlet (can be passed as null)
* @param pathSpec The path spec for the servlet
* @param clazz The servlet class
* @deprecated this is a temporary method
*/
@Deprecated
public void addInternalServlet(String name, String pathSpec,
Class<? extends HttpServlet> clazz) {
ServletHolder holder = new ServletHolder(clazz);
if (name != null) {
holder.setName(name);
}
webAppContext.addServlet(holder, pathSpec);
}
代码示例来源:origin: apache/hama
/**
* Add an internal servlet in the server.
*
* @param name The name of the servlet (can be passed as null)
* @param pathSpec The path spec for the servlet
* @param clazz The servlet class
* @deprecated this is a temporary method
*/
@Deprecated
public void addInternalServlet(String name, String pathSpec,
Class<? extends HttpServlet> clazz) {
ServletHolder holder = new ServletHolder(clazz);
if (name != null) {
holder.setName(name);
}
webAppContext.addServlet(holder, pathSpec);
}
代码示例来源:origin: io.hops/hadoop-common
/**
* Add a Jersey resource package.
* @param packageName The Java package name containing the Jersey resource.
* @param pathSpec The path spec for the servlet
*/
public void addJerseyResourcePackage(final String packageName,
final String pathSpec) {
LOG.info("addJerseyResourcePackage: packageName=" + packageName
+ ", pathSpec=" + pathSpec);
final ServletHolder sh = new ServletHolder(ServletContainer.class);
sh.setInitParameter("com.sun.jersey.config.property.resourceConfigClass",
"com.sun.jersey.api.core.PackagesResourceConfig");
sh.setInitParameter("com.sun.jersey.config.property.packages", packageName);
webAppContext.addServlet(sh, pathSpec);
}
代码示例来源:origin: io.hops/hadoop-common
/**
* Add a Jersey resource package.
* @param packageName The Java package name containing the Jersey resource.
* @param pathSpec The path spec for the servlet
*/
public void addJerseyResourcePackage(final String packageName,
final String pathSpec) {
LOG.info("addJerseyResourcePackage: packageName=" + packageName
+ ", pathSpec=" + pathSpec);
final ServletHolder sh = new ServletHolder(ServletContainer.class);
sh.setInitParameter("com.sun.jersey.config.property.resourceConfigClass",
"com.sun.jersey.api.core.PackagesResourceConfig");
sh.setInitParameter("com.sun.jersey.config.property.packages", packageName);
webAppContext.addServlet(sh, pathSpec);
}
代码示例来源:origin: ch.cern.hadoop/hadoop-common
/**
* Add a Jersey resource package.
* @param packageName The Java package name containing the Jersey resource.
* @param pathSpec The path spec for the servlet
*/
public void addJerseyResourcePackage(final String packageName,
final String pathSpec) {
LOG.info("addJerseyResourcePackage: packageName=" + packageName
+ ", pathSpec=" + pathSpec);
final ServletHolder sh = new ServletHolder(ServletContainer.class);
sh.setInitParameter("com.sun.jersey.config.property.resourceConfigClass",
"com.sun.jersey.api.core.PackagesResourceConfig");
sh.setInitParameter("com.sun.jersey.config.property.packages", packageName);
webAppContext.addServlet(sh, pathSpec);
}
代码示例来源:origin: com.github.jiayuhan-it/hadoop-common
/**
* Add a Jersey resource package.
* @param packageName The Java package name containing the Jersey resource.
* @param pathSpec The path spec for the servlet
*/
public void addJerseyResourcePackage(final String packageName,
final String pathSpec) {
LOG.info("addJerseyResourcePackage: packageName=" + packageName
+ ", pathSpec=" + pathSpec);
final ServletHolder sh = new ServletHolder(ServletContainer.class);
sh.setInitParameter("com.sun.jersey.config.property.resourceConfigClass",
"com.sun.jersey.api.core.PackagesResourceConfig");
sh.setInitParameter("com.sun.jersey.config.property.packages", packageName);
webAppContext.addServlet(sh, pathSpec);
}
代码示例来源:origin: io.hops/hadoop-common
/**
* Add a Jersey resource package.
* @param packageName The Java package name containing the Jersey resource.
* @param pathSpec The path spec for the servlet
*/
public void addJerseyResourcePackage(final String packageName,
final String pathSpec) {
LOG.info("addJerseyResourcePackage: packageName=" + packageName
+ ", pathSpec=" + pathSpec);
final ServletHolder sh = new ServletHolder(ServletContainer.class);
sh.setInitParameter("com.sun.jersey.config.property.resourceConfigClass",
"com.sun.jersey.api.core.PackagesResourceConfig");
sh.setInitParameter("com.sun.jersey.config.property.packages", packageName);
webAppContext.addServlet(sh, pathSpec);
}
代码示例来源:origin: ch.cern.hadoop/hadoop-common
/**
* Add a Jersey resource package.
* @param packageName The Java package name containing the Jersey resource.
* @param pathSpec The path spec for the servlet
*/
public void addJerseyResourcePackage(final String packageName,
final String pathSpec) {
LOG.info("addJerseyResourcePackage: packageName=" + packageName
+ ", pathSpec=" + pathSpec);
final ServletHolder sh = new ServletHolder(ServletContainer.class);
sh.setInitParameter("com.sun.jersey.config.property.resourceConfigClass",
"com.sun.jersey.api.core.PackagesResourceConfig");
sh.setInitParameter("com.sun.jersey.config.property.packages", packageName);
webAppContext.addServlet(sh, pathSpec);
}
代码示例来源:origin: com.github.jiayuhan-it/hadoop-common
/**
* Add a Jersey resource package.
* @param packageName The Java package name containing the Jersey resource.
* @param pathSpec The path spec for the servlet
*/
public void addJerseyResourcePackage(final String packageName,
final String pathSpec) {
LOG.info("addJerseyResourcePackage: packageName=" + packageName
+ ", pathSpec=" + pathSpec);
final ServletHolder sh = new ServletHolder(ServletContainer.class);
sh.setInitParameter("com.sun.jersey.config.property.resourceConfigClass",
"com.sun.jersey.api.core.PackagesResourceConfig");
sh.setInitParameter("com.sun.jersey.config.property.packages", packageName);
webAppContext.addServlet(sh, pathSpec);
}
代码示例来源:origin: io.fabric8/fabric-hadoop
/**
* Add a Jersey resource package.
* @param packageName The Java package name containing the Jersey resource.
* @param pathSpec The path spec for the servlet
*/
public void addJerseyResourcePackage(final String packageName,
final String pathSpec) {
LOG.info("addJerseyResourcePackage: packageName=" + packageName
+ ", pathSpec=" + pathSpec);
final ServletHolder sh = new ServletHolder(ServletContainer.class);
sh.setInitParameter("com.sun.jersey.config.property.resourceConfigClass",
"com.sun.jersey.api.core.PackagesResourceConfig");
sh.setInitParameter("com.sun.jersey.config.property.packages", packageName);
webAppContext.addServlet(sh, pathSpec);
}
代码示例来源:origin: org.apache.jackrabbit/jackrabbit-standalone
private void prepareWebapp(File file, File repository, File tmp) {
webapp.setContextPath("/");
webapp.setWar(file.getPath());
webapp.setExtractWAR(false);
webapp.setTempDirectory(tmp);
ServletHolder servlet =
new ServletHolder(JackrabbitRepositoryServlet.class);
servlet.setInitOrder(1);
servlet.setInitParameter("repository.home", repository.getPath());
String conf = command.getOptionValue("conf");
if (conf != null) {
servlet.setInitParameter("repository.config", conf);
}
webapp.addServlet(servlet, "/repository.properties");
}
代码示例来源:origin: com.github.jiayuhan-it/hadoop-common
private static WebAppContext createWebAppContext(String name,
Configuration conf, AccessControlList adminsAcl, final String appDir) {
WebAppContext ctx = new WebAppContext();
ctx.setDefaultsDescriptor(null);
ServletHolder holder = new ServletHolder(new DefaultServlet());
Map<String, String> params = ImmutableMap. <String, String> builder()
.put("acceptRanges", "true")
.put("dirAllowed", "false")
.put("gzip", "true")
.put("useFileMappedBuffer", "true")
.build();
holder.setInitParameters(params);
ctx.setWelcomeFiles(new String[] {"index.html"});
ctx.addServlet(holder, "/");
ctx.setDisplayName(name);
ctx.setContextPath("/");
ctx.setWar(appDir + "/" + name);
ctx.getServletContext().setAttribute(CONF_CONTEXT_ATTRIBUTE, conf);
ctx.getServletContext().setAttribute(ADMINS_ACL, adminsAcl);
addNoCacheFilter(ctx);
return ctx;
}
代码示例来源:origin: ch.cern.hadoop/hadoop-common
private static WebAppContext createWebAppContext(String name,
Configuration conf, AccessControlList adminsAcl, final String appDir) {
WebAppContext ctx = new WebAppContext();
ctx.setDefaultsDescriptor(null);
ServletHolder holder = new ServletHolder(new DefaultServlet());
Map<String, String> params = ImmutableMap. <String, String> builder()
.put("acceptRanges", "true")
.put("dirAllowed", "false")
.put("gzip", "true")
.put("useFileMappedBuffer", "true")
.build();
holder.setInitParameters(params);
ctx.setWelcomeFiles(new String[] {"index.html"});
ctx.addServlet(holder, "/");
ctx.setDisplayName(name);
ctx.setContextPath("/");
ctx.setWar(appDir + "/" + name);
ctx.getServletContext().setAttribute(CONF_CONTEXT_ATTRIBUTE, conf);
ctx.getServletContext().setAttribute(ADMINS_ACL, adminsAcl);
addNoCacheFilter(ctx);
return ctx;
}
代码示例来源:origin: com.github.albfernandez.test-jsf/jsf-test-jetty
@Override
public void addServlet(ServletHolder servletHolder) {
Map<String, String> initParameters = servletHolder.getInitParameters();
String mapping = servletHolder.getMapping();
String name = servletHolder.getName();
Servlet servlet = servletHolder.getServlet();
org.mortbay.jetty.servlet.ServletHolder jettyServletHolder = new org.mortbay.jetty.servlet.ServletHolder(
servlet);
jettyServletHolder.setName(name);
jettyServletHolder.setInitParameters(initParameters);
webAppContext.addServlet(jettyServletHolder, mapping);
}
代码示例来源:origin: com.github.albfernandez.test-jsf/jsf-test-jetty
private void createContext() {
webAppContext = new WebAppContext();
webAppContext.setContextPath("/");
webAppContext.setBaseResource(serverRoot);
webAppContext.setClassLoader(getClassLoader());
org.mortbay.jetty.servlet.ServletHolder defaultServletHolder =
new org.mortbay.jetty.servlet.ServletHolder(new DefaultServlet());
//defaultServletHolder.setInitParameter("aliases", Boolean.FALSE.toString());
webAppContext.addServlet(defaultServletHolder, "/");
webAppContext.addEventListener(new HttpSessionListener() {
public void sessionDestroyed(HttpSessionEvent se) {
session = null;
}
public void sessionCreated(HttpSessionEvent se) {
session = se.getSession();
}
});
}
代码示例来源:origin: org.apache.commons/commons-vfs2
private void prepareWebapp(final File file, final File repository, final File tmp) {
webapp.setContextPath("/");
webapp.setWar(file.getPath());
webapp.setClassLoader(JackrabbitMain.class.getClassLoader());
// we use a modified web.xml which has some servlets remove (which produce random empty directories)
final URL res = getResource("/jcrweb.xml");
if (res != null) {
webapp.setDescriptor(res.toString());
}
webapp.setExtractWAR(false);
webapp.setTempDirectory(tmp);
final ServletHolder servlet = new ServletHolder(JackrabbitRepositoryServlet.class);
servlet.setInitOrder(1);
servlet.setInitParameter("repository.home", repository.getAbsolutePath());
final String conf = command.getOptionValue("conf");
if (conf != null) {
servlet.setInitParameter("repository.config", conf);
}
webapp.addServlet(servlet, "/repository.properties");
}
代码示例来源:origin: apache/commons-vfs
private void prepareWebapp(final File file, final File repository, final File tmp) {
webapp.setContextPath("/");
webapp.setWar(file.getPath());
webapp.setClassLoader(JackrabbitMain.class.getClassLoader());
// we use a modified web.xml which has some servlets remove (which produce random empty directories)
final URL res = getResource("/jcrweb.xml");
if (res != null) {
webapp.setDescriptor(res.toString());
}
webapp.setExtractWAR(false);
webapp.setTempDirectory(tmp);
final ServletHolder servlet = new ServletHolder(JackrabbitRepositoryServlet.class);
servlet.setInitOrder(1);
servlet.setInitParameter("repository.home", repository.getAbsolutePath());
final String conf = command.getOptionValue("conf");
if (conf != null) {
servlet.setInitParameter("repository.config", conf);
}
webapp.addServlet(servlet, "/repository.properties");
}
内容来源于网络,如有侵权,请联系作者删除!