本文整理匯總了Java中org.eclipse.jetty.servlet.ServletHolder.setInitOrder方法的典型用法代碼示例。如果您正苦於以下問題:Java ServletHolder.setInitOrder方法的具體用法?Java ServletHolder.setInitOrder怎麽用?Java ServletHolder.setInitOrder使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.eclipse.jetty.servlet.ServletHolder
的用法示例。
在下文中一共展示了ServletHolder.setInitOrder方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: main
import org.eclipse.jetty.servlet.ServletHolder; //導入方法依賴的package包/類
public static void main(String[] args) throws Exception {
ServletContextHandler context = new ServletContextHandler(ServletContextHandler.SESSIONS);
context.setContextPath("/");
Server jettyServer = new Server(8067);
jettyServer.setHandler(context);
ServletHolder jerseyServlet = context.addServlet(
org.glassfish.jersey.servlet.ServletContainer.class, "/*");
jerseyServlet.setInitOrder(0);
// Tells the Jersey Servlet which REST service/class to load.
jerseyServlet.setInitParameter(
"jersey.config.server.provider.classnames",
EntryPointTestHandler.class.getCanonicalName());
try {
jettyServer.start();
jettyServer.join();
} finally {
jettyServer.destroy();
}
}
示例2: start
import org.eclipse.jetty.servlet.ServletHolder; //導入方法依賴的package包/類
public void start() throws Exception {
Server server = new Server(REST_SERVICE_PORT);
ServletContextHandler servletContextHandler = new ServletContextHandler(ServletContextHandler.SESSIONS);
servletContextHandler.setContextPath("/");
server.setHandler(servletContextHandler);
ServletHolder servletHolder = servletContextHandler.addServlet(
org.glassfish.jersey.servlet.ServletContainer.class, "/*"
);
servletHolder.setInitOrder(0);
servletHolder.setInitParameter(
"jersey.config.server.provider.classnames",
RestInterface.class.getCanonicalName()
);
try {
server.start();
server.join();
} finally {
server.destroy();
}
}
示例3: init
import org.eclipse.jetty.servlet.ServletHolder; //導入方法依賴的package包/類
public void init() {
setContextPath("/management");
// REST configuration
Servlet servlet = context.servlets().iterator().next();
final ServletHolder servletHolder = new ServletHolder(servlet);
servletHolder.setInitParameter("javax.ws.rs.Application", "io.gravitee.am.gateway.handler.management.api.ManagementApplication");
servletHolder.setInitOrder(0);
addServlet(servletHolder, "/*");
// Attach event listeners
for(EventListener listener : context.listeners()) {
addEventListener(listener);
}
// Attach filters
for(Filter filter : context.filters()) {
addFilter(new FilterHolder(filter), MAPPING_URL, EnumSet.allOf(DispatcherType.class));
}
}
示例4: main
import org.eclipse.jetty.servlet.ServletHolder; //導入方法依賴的package包/類
public static void main(String[] args) throws Exception {
ServletContextHandler context = new ServletContextHandler(ServletContextHandler.SESSIONS);
context.setContextPath("/");
Server jettyServer =
new Server(new InetSocketAddress(Config.getInstance().getServerHost(), Config.getInstance().getServerPort()));
jettyServer.setHandler(context);
ServletHolder echoServlet = context.addServlet(EchoBotServlet.class, "/echo");
echoServlet.setInitOrder(0);
ServletHolder logServlet = context.addServlet(LogBotServlet.class, "/log");
logServlet.setInitOrder(1);
try {
jettyServer.start();
jettyServer.join();
} finally {
jettyServer.destroy();
}
}
示例5: main
import org.eclipse.jetty.servlet.ServletHolder; //導入方法依賴的package包/類
public static void main(String[] args) throws Exception {
ServletContextHandler context = new ServletContextHandler(ServletContextHandler.SESSIONS);
context.setContextPath("/rest/");
Server jettyServer = new Server(8080);
jettyServer.setHandler(context);
ServletHolder jerseyServlet = context.addServlet(
org.glassfish.jersey.servlet.ServletContainer.class, "/*");
jerseyServlet.setInitOrder(0);
jerseyServlet.setInitParameter("jersey.config.server.provider.packages",
"com.rest.test; com.rest.crud; com.rest.howtotoinjava");
try {
jettyServer.start();
jettyServer.join();
} finally {
jettyServer.destroy();
}
}
示例6: main
import org.eclipse.jetty.servlet.ServletHolder; //導入方法依賴的package包/類
/**
*
* @param args
* @throws Exception
*/
public static void main(String[] args) throws Exception {
ServletContextHandler context = new ServletContextHandler(ServletContextHandler.NO_SESSIONS);
context.setContextPath("/");
Logger mainLogger = Logger.getInstance();
mainLogger.out(Level.INFORMATIVE, "Main", "Starting server");
Server server = new Server(8080);
mainLogger.out(Level.INFORMATIVE, "Main", "Set handler");
server.setHandler(context);
ServletHolder jerseyServlet = context.addServlet(ServletContainer.class, "/*");
jerseyServlet.setInitOrder(0);
jerseyServlet.setInitParameter("com.sun.jersey.api.json.POJOMappingFeature", "true");
jerseyServlet.setInitParameter("jersey.config.server.provider.packages", "view");
server.start();
server.join();
mainLogger.out(Level.INFORMATIVE, "Main", "Server started");
}
示例7: start
import org.eclipse.jetty.servlet.ServletHolder; //導入方法依賴的package包/類
public void start() {
workingDir.mkdirs();
ServletContextHandler context = new ServletContextHandler(ServletContextHandler.SESSIONS);
context.setContextPath("/");
ServletHolder jerseyServlet = context.addServlet(ServletContainer.class, "/*");
jerseyServlet.setInitOrder(0);
jerseyServlet.setInitParameter("javax.ws.rs.Application", AssemblerApp.class.getCanonicalName());
Server jettyServer = new Server(port);
jettyServer.setHandler(context);
try {
jettyServer.start();
int runningPort = getPort(jettyServer);
System.out.printf("Server started successfully and is running on port %s.\n", runningPort);
writePort(runningPort);
jettyServer.join();
} catch (Exception e) {
throw new RuntimeException(e);
} finally {
jettyServer.destroy();
}
}
示例8: start
import org.eclipse.jetty.servlet.ServletHolder; //導入方法依賴的package包/類
@Override
public void start() {
if (isStarted()) {
return;
}
jettyServer = new org.eclipse.jetty.server.Server();
int port = serverConfig.getPort();
DispatcherServlet.addHttpHandler(port, new WebServiceHandler());
int threads = serverConfig.getServerBusinessPoolSize();
QueuedThreadPool threadPool = new QueuedThreadPool();
threadPool.setName("JSF-WS-BZ");
threadPool.setDaemon(true);
threadPool.setMaxThreads(threads);
threadPool.setMinThreads(threads);
jettyServer.setThreadPool(threadPool);
SelectChannelConnector connector = new SelectChannelConnector();
connector.setHost(serverConfig.getHost());
connector.setPort(serverConfig.getPort());
jettyServer.addConnector(connector);
ServletHandler servletHandler = new ServletHandler();
ServletHolder servletHolder = servletHandler.addServletWithMapping(DispatcherServlet.class, "/*");
servletHolder.setInitOrder(2);
jettyServer.setHandler(servletHandler);
try {
jettyServer.start();
} catch (Exception e) {
throw new InitErrorException("Failed to start jetty server at port " + port
+ ", cause: " + e.getMessage(), e);
}
}
示例9: addToJettyServer
import org.eclipse.jetty.servlet.ServletHolder; //導入方法依賴的package包/類
@Override
public void addToJettyServer(JettyServer jettyServer) {
ServletHolder apiDocServletHolder = new ServletHolder(new JerseyJaxrsConfig());
apiDocServletHolder.setInitParameter("api.version", apiVersion);
//Remove leading / as swagger adds its own
String apiBasePath =
"//".equals(this.apiBasePath.substring(0, 1))
? this.apiBasePath.substring(1)
: this.apiBasePath;
apiDocServletHolder.setInitParameter("swagger.api.basepath", apiBasePath);
apiDocServletHolder.setInitOrder(2); //NOSONAR
jettyServer.getServletContext().addServlet(apiDocServletHolder, pathSpec);
}
示例10: startJetty
import org.eclipse.jetty.servlet.ServletHolder; //導入方法依賴的package包/類
public static void startJetty() throws Exception {
// Jetty 起動
HandlerList handlers = new HandlerList();
ServletContextHandler context = new ServletContextHandler(ServletContextHandler.SESSIONS);
context.setContextPath("/");
ServletHolder servletHolder = context.addServlet(ServletContainer.class, "/*");
servletHolder.setInitOrder(0);
servletHolder.setInitParameter(
"com.sun.jersey.spi.container.ContainerResponseFilters",
"com.sun.jersey.api.container.filter.GZIPContentEncodingFilter");
// Pasaran API
RestAPIs.installRestApi(servletHolder,
CORSResponseFilter.class,
KeseranApi.class);
// 靜的コンテンツ
ResourceHandler resourceHandler = new ResourceHandler();
resourceHandler.setResourceBase("web");
handlers.addHandler(resourceHandler);
handlers.addHandler(context);
String port = System.getProperty("jetty-port", "2510");
Server jetty = new Server(Integer.parseInt(port));
jetty.setHandler(handlers);
try {
// RolloverFileOutputStream os = new RolloverFileOutputStream("logs/yyyy_mm_dd_jetty.log", true);
// PrintStream logStream = new PrintStream(os);
// System.setOut(logStream);
// System.setErr(logStream);
// Log.getRootLogger().info("JCG Embedded Jetty logging started.", new Object[]{});
jetty.start();
jetty.join();
} finally {
jetty.destroy();
}
}
示例11: main
import org.eclipse.jetty.servlet.ServletHolder; //導入方法依賴的package包/類
public static void main(String[] args) throws Exception {
int port = getPort(args);
Path configDir = getConfigDir(args);
System.out.println("Configuring MNP storage from config directory: "+configDir);
Builder builder = Builder.builder();
storage = builder.
add(new RossvyazMasksParser(configDir.resolve("rossvyaz/Kody_DEF-9kh.csv"))).
add(new CustomMasksParser(configDir.resolve("mnos.xml"))).
//add(new ZniisMnpParser(configDir.resolve("zniis/"))).
idTitle(configDir.resolve("filters/titles.xml")).
idRegion(configDir.resolve("filters/areas.xml")).
build();
System.out.println("Starting server on port: "+port);
ServletContextHandler context = new ServletContextHandler(ServletContextHandler.SESSIONS);
context.setContextPath("/");
Server jettyServer = new Server(port);
jettyServer.setHandler(context);
ServletHolder jerseyServlet = context.addServlet(
org.glassfish.jersey.servlet.ServletContainer.class, "/*");
jerseyServlet.setInitOrder(0);
jerseyServlet.setInitParameter(
"jersey.config.server.provider.classnames",
MnpApi.class.getCanonicalName());
try {
jettyServer.start();
System.out.println("Server started. Example request: http://localhost:"+port+"/mnp?subscriber=79139367911");
jettyServer.join();
} finally {
jettyServer.destroy();
}
}
示例12: addJerseyServlet
import org.eclipse.jetty.servlet.ServletHolder; //導入方法依賴的package包/類
private void addJerseyServlet(ServletContextHandler context) {
ServletHolder jerseyServlet = context.addServlet(ServletContainer.class, REST_PATH);
jerseyServlet.setInitParameter("jersey.config.server.provider.packages", "io.sparkled.rest");
jerseyServlet.setInitParameter("jersey.config.server.provider.classnames", MultiPartFeature.class.getName());
jerseyServlet.setInitParameter("javax.ws.rs.Application", JerseyResourceConfig.class.getName());
jerseyServlet.setInitOrder(0);
}
示例13: jspServletHolder
import org.eclipse.jetty.servlet.ServletHolder; //導入方法依賴的package包/類
private ServletHolder jspServletHolder() {
ServletHolder holderJsp = new ServletHolder(JSP, JettyJspServlet.class);
holderJsp.setInitOrder(0);
holderJsp.setInitParameter(LOG_VERBOSITY_LEVEL, DEBUG);
holderJsp.setInitParameter(FORK, "false");
holderJsp.setInitParameter(XPOWERED_BY, "false");
holderJsp.setInitParameter(COMPILER_TARGET_VM, "1.7");
holderJsp.setInitParameter(COMPILER_SOURCE_VM, "1.7");
holderJsp.setInitParameter(KEEPGENERATED, "true");
return holderJsp;
}
示例14: main
import org.eclipse.jetty.servlet.ServletHolder; //導入方法依賴的package包/類
public static void main(String[] args) throws Exception {
Server server = new Server(8080);
ServletContextHandler handler = new ServletContextHandler();
handler.setContextPath("/");
handler.setInitParameter("contextConfigLocation", "classpath*:spring-mvc.xml");
ServletHolder servletHolder = new ServletHolder();
servletHolder.setInitOrder(1);
servletHolder.setHeldClass(DispatcherServlet.class);
servletHolder.setInitParameter("contextConfigLocation", "classpath*:spring-mvc.xml");
handler.addServlet(servletHolder, "/");
server.setHandler(handler);
server.start();
server.join();
}
示例15: addDefaultServlet
import org.eclipse.jetty.servlet.ServletHolder; //導入方法依賴的package包/類
/**
* Add Jetty's {@code DefaultServlet} to the given {@link WebAppContext}.
* @param context the jetty {@link WebAppContext}
*/
protected final void addDefaultServlet(WebAppContext context) {
Assert.notNull(context, "Context must not be null");
ServletHolder holder = new ServletHolder();
holder.setName("default");
holder.setClassName("org.eclipse.jetty.servlet.DefaultServlet");
holder.setInitParameter("dirAllowed", "false");
holder.setInitOrder(1);
context.getServletHandler().addServletWithMapping(holder, "/");
context.getServletHandler().getServletMapping("/").setDefault(true);
}
開發者ID:vikrammane23,項目名稱:https-github.com-g0t4-jenkins2-course-spring-boot,代碼行數:15,代碼來源:JettyEmbeddedServletContainerFactory.java