本文整理汇总了Java中org.mortbay.jetty.servlet.ServletHolder.setInitParameter方法的典型用法代码示例。如果您正苦于以下问题:Java ServletHolder.setInitParameter方法的具体用法?Java ServletHolder.setInitParameter怎么用?Java ServletHolder.setInitParameter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.mortbay.jetty.servlet.ServletHolder
的用法示例。
在下文中一共展示了ServletHolder.setInitParameter方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setupPspMithraService
import org.mortbay.jetty.servlet.ServletHolder; //导入方法依赖的package包/类
protected void setupPspMithraService()
{
server = new Server(this.getApplicationPort1());
Context context = new Context (server,"/",Context.SESSIONS);
ServletHolder holder = context.addServlet(PspServlet.class, "/PspServlet");
holder.setInitParameter("serviceInterface.MasterCacheService", "com.gs.fw.common.mithra.cache.offheap.MasterCacheService");
holder.setInitParameter("serviceClass.MasterCacheService", "com.gs.fw.common.mithra.cache.offheap.MasterCacheServiceImpl");
holder.setInitOrder(10);
// System.out.println(holder.getServlet().getClass().getName());
try
{
server.start();
}
catch (Exception e)
{
throw new RuntimeException("could not start server", e);
}
finally
{
}
}
示例2: setupServerWithHandler
import org.mortbay.jetty.servlet.ServletHolder; //导入方法依赖的package包/类
protected void setupServerWithHandler(
Handler handler) throws Exception
{
this.port = (int) (Math.random() * 10000.0 + 10000.0);
this.pspUrl = "http://localhost:" + this.port + "/PspServlet";
this.server = new Server(this.port);
Context context = new Context(server, "/", Context.SESSIONS);
if (handler != null)
{
context.addHandler(handler);
}
ServletHolder holder = context.addServlet(PspServlet.class, "/PspServlet");
holder.setInitParameter("serviceInterface.Echo", "com.gs.fw.common.mithra.test.tinyproxy.Echo");
holder.setInitParameter("serviceClass.Echo", "com.gs.fw.common.mithra.test.tinyproxy.EchoImpl");
holder.setInitOrder(10);
this.server.start();
this.servlet = (PspServlet) holder.getServlet();
}
示例3: setupPspMithraService
import org.mortbay.jetty.servlet.ServletHolder; //导入方法依赖的package包/类
protected void setupPspMithraService()
{
server = new Server(this.getApplicationPort1());
Context context = new Context (server,"/",Context.SESSIONS);
ServletHolder holder = context.addServlet(PspServlet.class, "/PspServlet");
holder.setInitParameter("serviceInterface.RemoteMithraService", "com.gs.fw.common.mithra.remote.RemoteMithraService");
holder.setInitParameter("serviceClass.RemoteMithraService", "com.gs.fw.common.mithra.remote.RemoteMithraServiceImpl");
holder.setInitOrder(10);
try
{
server.start();
}
catch (Exception e)
{
throw new RuntimeException("could not start server", e);
}
finally
{
}
}
示例4: createHandler
import org.mortbay.jetty.servlet.ServletHolder; //导入方法依赖的package包/类
private Context createHandler(
Map<String, Path> runfiles,
ImmutableList<Route> routes,
ImmutableList<Class<? extends Filter>> filters) {
Context context = new Context(server, CONTEXT_PATH, Context.SESSIONS);
context.addServlet(new ServletHolder(HealthzServlet.class), "/healthz");
for (Map.Entry<String, Path> runfile : runfiles.entrySet()) {
context.addServlet(
StaticResourceServlet.create(runfile.getKey(), runfile.getValue()),
runfile.getKey());
}
for (Route route : routes) {
context.addServlet(
new ServletHolder(wrapServlet(route.servletClass(), filters)), route.path());
}
ServletHolder holder = new ServletHolder(DefaultServlet.class);
holder.setInitParameter("aliases", "1");
context.addServlet(holder, "/*");
return context;
}
示例5: create
import org.mortbay.jetty.servlet.ServletHolder; //导入方法依赖的package包/类
/**
* Creates a servlet holder for this servlet so it can be used with Jetty.
*
* @param prefix servlet path starting with a slash and ending with {@code "/*"} if {@code root}
* is a directory
* @param root file or root directory to serve
*/
public static ServletHolder create(String prefix, Path root) {
root = root.toAbsolutePath();
checkArgument(Files.exists(root), "Root must exist: %s", root);
checkArgument(prefix.startsWith("/"), "Prefix must start with a slash: %s", prefix);
ServletHolder holder = new ServletHolder(StaticResourceServlet.class);
holder.setInitParameter("root", root.toString());
if (Files.isDirectory(root)) {
checkArgument(prefix.endsWith("/*"),
"Prefix (%s) must end with /* since root (%s) is a directory", prefix, root);
holder.setInitParameter("prefix", prefix.substring(0, prefix.length() - 1));
} else {
holder.setInitParameter("prefix", prefix);
}
return holder;
}
示例6: start
import org.mortbay.jetty.servlet.ServletHolder; //导入方法依赖的package包/类
public void start() throws Exception {
RealmService realmService = new InMemoryRealmService();
RegistryContext regContext = RegistryContext.getBaseInstance(realmService);
regContext.selectDBConfig("in-memory");
//RegistryContext.setSingleton(regContext);
server = new Server(port);
Context context = new Context(server, null/*RegistryProvider.baseURI*/, Context.SESSIONS);
ServletHolder servletHolder = new ServletHolder(new AbderaServlet());
servletHolder.setInitParameter(ServiceManager.PROVIDER,
RegistryProvider.class.getName());
context.addServlet(servletHolder, "/*");
server.start();
// root.addServlet(new ServletHolder(new RegistryServlet()), "/resources/*");
// root.addServlet(new ServletHolder(new AbderaServlet()), "/atom/*");
// server.start();
}
示例7: startServer
import org.mortbay.jetty.servlet.ServletHolder; //导入方法依赖的package包/类
public void startServer(int port, String classBound) throws BindException,
Exception {
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",
classBound);
// custom parameters
// Map<String, Object> initParameters = getCustomInitParamters(port);
// sh.setInitParameters(initParameters);
Server server = new Server(port);
Context context = new Context(server, "/", Context.SESSIONS);
context.addServlet(sh, "/*");
server.start();
}
示例8: addJerseyResourcePackage
import org.mortbay.jetty.servlet.ServletHolder; //导入方法依赖的package包/类
/**
* 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);
}
示例9: start
import org.mortbay.jetty.servlet.ServletHolder; //导入方法依赖的package包/类
public void start() {
String serverPort = ConfigUtils.getProperty(JETTY_PORT);
int port;
if (serverPort == null || serverPort.length() == 0) {
port = DEFAULT_JETTY_PORT;
} else {
port = Integer.parseInt(serverPort);
}
connector = new SelectChannelConnector();
connector.setPort(port);
ServletHandler handler = new ServletHandler();
String resources = ConfigUtils.getProperty(JETTY_DIRECTORY);
if (resources != null && resources.length() > 0) {
FilterHolder resourceHolder = handler.addFilterWithMapping(ResourceFilter.class, "/*", Handler.DEFAULT);
resourceHolder.setInitParameter("resources", resources);
}
ServletHolder pageHolder = handler.addServletWithMapping(PageServlet.class, "/*");
pageHolder.setInitParameter("pages", ConfigUtils.getProperty(JETTY_PAGES));
pageHolder.setInitOrder(2);
Server server = new Server();
server.addConnector(connector);
server.addHandler(handler);
try {
server.start();
} catch (Exception e) {
throw new IllegalStateException("Failed to start jetty server on " + NetUtils.getLocalHost() + ":" + port + ", cause: " + e.getMessage(), e);
}
}
示例10: main
import org.mortbay.jetty.servlet.ServletHolder; //导入方法依赖的package包/类
/**
* Sets up and runs server.
* @param args
*/
public static void main(String[] args)
{
final Server server = new Server();
SelectChannelConnector connector = new SelectChannelConnector();
connector.setPort(8080);
server.addConnector(connector);
Context htmlContext = new Context(server, "/", Context.SESSIONS);
ResourceHandler htmlHandler = new ResourceHandler();
htmlHandler.setResourceBase("web");
htmlContext.setHandler(htmlHandler);
Context servletContext = new Context(server, "/", Context.SESSIONS);
GenericWebApplicationContext springContext = new GenericWebApplicationContext();
springContext.setParent(new ClassPathXmlApplicationContext("org/getahead/dwrdemo/cli/spring.xml"));
servletContext.setAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE, springContext);
ServletHolder holder = new ServletHolder(new DwrSpringServlet());
holder.setInitParameter("pollAndCometEnabled", "true");
holder.setInitParameter("debug", "true");
servletContext.addServlet(holder, "/dwr/*");
try
{
JettyShutdown.addShutdownHook(server);
server.start();
server.join();
}
catch (Exception ex)
{
ex.printStackTrace();
}
}
示例11: main
import org.mortbay.jetty.servlet.ServletHolder; //导入方法依赖的package包/类
/**
* Sets up and runs server.
* @param args
*/
public static void main(String[] args)
{
Server server = new Server();
SelectChannelConnector connector = new SelectChannelConnector();
connector.setPort(8080);
server.addConnector(connector);
Context htmlContext = new Context(server, "/", Context.SESSIONS);
ResourceHandler htmlHandler = new ResourceHandler();
htmlHandler.setResourceBase("web");
htmlContext.setHandler(htmlHandler);
Context servletContext = new Context(server, "/", Context.SESSIONS);
ServletHolder holder = new ServletHolder(new DwrServlet());
holder.setInitParameter("activeReverseAjaxEnabled", "true");
holder.setInitParameter("debug", "true");
servletContext.addServlet(holder, "/dwr/*");
servletContext.setResourceBase("web");
try
{
JettyShutdown.addShutdownHook(server);
server.start();
server.join();
}
catch (Exception ex)
{
ex.printStackTrace();
}
}
示例12: addJerseyResourcePackage
import org.mortbay.jetty.servlet.ServletHolder; //导入方法依赖的package包/类
/**
* 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);
}
示例13: start
import org.mortbay.jetty.servlet.ServletHolder; //导入方法依赖的package包/类
public void start() {
String serverPort = ConfigUtils.getProperty(JETTY_PORT);
int port;
if (serverPort == null || serverPort.length() == 0) {
port = DEFAULT_JETTY_PORT;
} else {
port = Integer.parseInt(serverPort);
}
connector = new SelectChannelConnector();
connector.setPort(port);
ServletHandler handler = new ServletHandler();
String resources = ConfigUtils.getProperty(JETTY_DIRECTORY);
if (resources != null && resources.length() > 0) {
FilterHolder resourceHolder = handler.addFilterWithMapping(ResourceFilter.class, "/*", Handler.DEFAULT);
resourceHolder.setInitParameter("resources", resources);
}
ServletHolder pageHolder = handler.addServletWithMapping(PageServlet.class, "/*");
pageHolder.setInitParameter("pages", ConfigUtils.getProperty(JETTY_PAGES));
pageHolder.setInitOrder(2);
Server server = new Server();
server.addConnector(connector);
server.addHandler(handler);
try {
server.start();
} catch (Exception e) {
throw new IllegalStateException("Failed to start jetty server on " + NetUtils.getLocalHost() + ":" + port + ", cause: " + e.getMessage(), e);
}
}
示例14: startServletContainer
import org.mortbay.jetty.servlet.ServletHolder; //导入方法依赖的package包/类
public void startServletContainer(Configuration conf) throws Exception {
if (server != null) {
LOG.error("ServletContainer already running");
return;
}
// Inject the conf for the test by being first to make singleton
RESTServlet.getInstance(conf);
// set up the Jersey servlet container for Jetty
ServletHolder sh = new ServletHolder(ServletContainer.class);
sh.setInitParameter(
"com.sun.jersey.config.property.resourceConfigClass",
ResourceConfig.class.getCanonicalName());
sh.setInitParameter("com.sun.jersey.config.property.packages",
"jetty");
LOG.info("configured " + ServletContainer.class.getName());
// set up Jetty and run the embedded server
server = new Server(0);
server.setSendServerVersion(false);
server.setSendDateHeader(false);
// set up context
Context context = new Context(server, "/", Context.SESSIONS);
context.addServlet(sh, "/*");
context.addFilter(GzipFilter.class, "/*", 0);
// start the server
server.start();
// get the port
testServletPort = server.getConnectors()[0].getLocalPort();
LOG.info("started " + server.getClass().getName() + " on port " +
testServletPort);
}
示例15: addContext
import org.mortbay.jetty.servlet.ServletHolder; //导入方法依赖的package包/类
public static void addContext(HttpServer server, String strContext, String host, String path, String strWebContext, String strServerContext) {
if (strWebContext == null) strWebContext = "./web";
if (strServerContext == null) strServerContext = "./server";
HttpContext context = new HttpContext();
context.setContextPath(strContext);
context.addWelcomeFile("index.cfm");
if ( host != null && !host.isEmpty() )
context.addVirtualHost(host);
server.addContext(context);
// Create a servlet container
ServletHandler servlets = new ServletHandler();
context.addHandler(servlets);
// Map a servlet onto the container
ServletHolder cfml = servlets.addServlet("CFMLServlet", "*.cfc/*,*.cfm/*,*.cfml/*,*.cfc,*.cfm,*.cfml", "lucee.debug.loader.servlet.CFMLServlet");
cfml.setInitOrder(0);
cfml.setInitParameter("lucee-server-directory", strServerContext);
// Lucee REST Servlet
ServletHolder rest = servlets.addServlet("RESTServlet", "/rest/*", "lucee.debug.loader.servlet.RESTServlet");
rest.setInitOrder(0);
strWebContext += path;
context.setResourceBase(strWebContext);
context.addHandler(new ResourceHandler());
}