本文整理匯總了Java中org.eclipse.jetty.servlet.ServletHolder.setInitParameter方法的典型用法代碼示例。如果您正苦於以下問題:Java ServletHolder.setInitParameter方法的具體用法?Java ServletHolder.setInitParameter怎麽用?Java ServletHolder.setInitParameter使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.eclipse.jetty.servlet.ServletHolder
的用法示例。
在下文中一共展示了ServletHolder.setInitParameter方法的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: initClientProxy
import org.eclipse.jetty.servlet.ServletHolder; //導入方法依賴的package包/類
private void initClientProxy() {
int port = Context.getConfig().getInteger("osmand.port");
if (port != 0) {
ServletContextHandler servletHandler = new ServletContextHandler() {
@Override
public void doScope(
String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response)
throws IOException, ServletException {
if (target.equals("/") && request.getMethod().equals(HttpMethod.POST.asString())) {
super.doScope(target, baseRequest, request, response);
}
}
};
ServletHolder servletHolder = new ServletHolder(new AsyncProxyServlet.Transparent());
servletHolder.setInitParameter("proxyTo", "http://localhost:" + port);
servletHandler.addServlet(servletHolder, "/");
handlers.addHandler(servletHandler);
}
}
示例3: reverseProxy
import org.eclipse.jetty.servlet.ServletHolder; //導入方法依賴的package包/類
private static void reverseProxy() throws Exception{
Server server = new Server();
SocketConnector connector = new SocketConnector();
connector.setHost("127.0.0.1");
connector.setPort(8888);
server.setConnectors(new Connector[]{connector});
// Setup proxy handler to handle CONNECT methods
ConnectHandler proxy = new ConnectHandler();
server.setHandler(proxy);
// Setup proxy servlet
ServletContextHandler context = new ServletContextHandler(proxy, "/", ServletContextHandler.SESSIONS);
ServletHolder proxyServlet = new ServletHolder(ProxyServlet.Transparent.class);
proxyServlet.setInitParameter("ProxyTo", "https://localhost:54321/");
proxyServlet.setInitParameter("Prefix", "/");
context.addServlet(proxyServlet, "/*");
server.start();
}
示例4: main
import org.eclipse.jetty.servlet.ServletHolder; //導入方法依賴的package包/類
public static void main(String[] args) throws Exception {
try(HttpRequest http = new HttpRequest()) {
WeatherService service = new WeatherServiceCache(new WeatherWebApi(http));
WeatherController weatherCtr = new WeatherController(service);
ServletHolder holderHome = new ServletHolder("static-home", DefaultServlet.class);
String resPath = getSystemResource("public").toString();
holderHome.setInitParameter("resourceBase", resPath);
holderHome.setInitParameter("dirAllowed", "true");
holderHome.setInitParameter("pathInfoOnly", "true");
int[] counter = {0};
new HttpServer(3000)
.addHandler("/search", weatherCtr::getSearch)
.addHandler("/search/city", weatherCtr::searchCity)
.addHandler("/weather/*", weatherCtr::last30daysWeather)
.addServletHolder("/public/*", holderHome)
.run();
}
}
示例5: setUp
import org.eclipse.jetty.servlet.ServletHolder; //導入方法依賴的package包/類
@Before
public void setUp() throws Exception {
server = new Server(PORT);
ServletContextHandler context = new ServletContextHandler(ServletContextHandler.SESSIONS);
context.setContextPath("/");
server.setHandler(context);
servletHolder = new ServletHolder(new CamelWebSocketServlet());
servletHolder.setName("CamelWsServlet");
servletHolder.setInitParameter("events", "true");
context.addServlet(servletHolder, "/*");
server.start();
if (startCamelContext) {
super.setUp();
}
}
示例6: 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();
}
}
示例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: concreteTest
import org.eclipse.jetty.servlet.ServletHolder; //導入方法依賴的package包/類
@Test
public void concreteTest() throws Exception {
HistoneTestCase.Case testCase = new HistoneTestCase.Case();
testCase.setExpectedResult("true");
testCase.setContext(getMap());
testCase.setInput("{{var response = loadJSON('http://127.0.0.1:4442/', [headers: ['via': 123]])}}{{response -> isArray() && response.headers['via'] != '123'}}");
try {
ServletContextHandler servletContextHandler = new ServletContextHandler(ServletContextHandler.SESSIONS);
servletContextHandler.setContextPath("/");
// CXF Servlet
ServletHolder cxfServletHolder = new ServletHolder(new CXFNonSpringJaxrsServlet());
cxfServletHolder.setInitParameter("jaxrs.serviceClasses", TestServerResource.class.getName());
servletContextHandler.addServlet(cxfServletHolder, "/*");
server = new Server(4442);
server.setHandler(servletContextHandler);
server.start();
Log.setLog(new StdErrLog());
new CoreTestConsumer(parser, rtti, evaluator).accept(testCase);
} finally {
try {
server.stop();
} catch (Exception e) {
e.printStackTrace();
}
}
}
示例9: 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();
}
}
示例10: configServer
import org.eclipse.jetty.servlet.ServletHolder; //導入方法依賴的package包/類
@Override
protected void configServer(Server server, int port) {
ServletHandler handler = new ServletHandler();
ProxyServlet servlet = new SimpleProxyServlet(ConfUtils.proxyConf);
ServletHolder servletHolder = new ServletHolder(servlet);
servletHolder.setAsyncSupported(true);
servletHolder.setInitParameter("maxThreads", "100");
handler.addServletWithMapping(servletHolder, "/*");
server.setHandler(handler);
}
示例11: getServletHolder
import org.eclipse.jetty.servlet.ServletHolder; //導入方法依賴的package包/類
private ServletHolder getServletHolder(final String packages) {
ServletHolder result = new ServletHolder(ServletContainer.class);
result.setInitParameter(PackagesResourceConfig.PROPERTY_PACKAGES, Joiner.on(",").join(RestfulServer.class.getPackage().getName(), packages));
result.setInitParameter("com.sun.jersey.config.property.resourceConfigClass", PackagesResourceConfig.class.getName());
result.setInitParameter("com.sun.jersey.api.json.POJOMappingFeature", Boolean.TRUE.toString());
result.setInitParameter("resteasy.scan.providers", Boolean.TRUE.toString());
result.setInitParameter("resteasy.use.builtin.providers", Boolean.FALSE.toString());
return result;
}
示例12: startServer
import org.eclipse.jetty.servlet.ServletHolder; //導入方法依賴的package包/類
public static void startServer() throws ServletException {
QueuedThreadPool threadPool = new QueuedThreadPool(10);
threadPool.setDaemon(true);
threadPool.setMaxThreads(10);
Server server = new Server(threadPool);
server.addBean(new ScheduledExecutorScheduler("JettyScheduler", true), true);
ServerConnector http = new ServerConnector(server, new HttpConnectionFactory());
http.setPort(2992);
server.addConnector(http);
ServletContextHandler context = new ServletContextHandler(ServletContextHandler.SESSIONS);
context.setContextPath("/");
context.setBaseResource(Resource.newClassPathResource("/org/lwjglx/debug/static"));
context.setWelcomeFiles(new String[] { "index.html" });
server.setHandler(context);
WebSocketUpgradeFilter wsfilter = WebSocketUpgradeFilter.configureContext(context);
// wsfilter.getFactory().getPolicy().setIdleTimeout(5000);
wsfilter.addMapping(new ServletPathSpec("/ws"), new ProfilingConnectionCreator());
ServletHolder holderDefault = new ServletHolder("default", DefaultServlet.class);
holderDefault.setInitParameter("dirAllowed", "true");
context.addServlet(holderDefault, "/");
try {
server.start();
} catch (Exception e) {
throw new AssertionError("Could not start profiling server", e);
}
}
示例13: 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);
}
示例14: configureWebAppContext
import org.eclipse.jetty.servlet.ServletHolder; //導入方法依賴的package包/類
@Override
protected void configureWebAppContext(WebAppContext webAppContext)
{
super.configure(webAppContext);
// the Chemistry OpenCMIS servlet
ServletHolder servletHolder = new ServletHolder(CmisAtomPubServlet.class);
servletHolder.setInitParameter("callContextHandler", "org.apache.chemistry.opencmis.server.shared.BasicAuthCallContextHandler");
webAppContext.addServlet(servletHolder, "/cmisatom/*");
}
示例15: configureWebAppContext
import org.eclipse.jetty.servlet.ServletHolder; //導入方法依賴的package包/類
@Override
protected void configureWebAppContext(WebAppContext webAppContext)
{
super.configureWebAppContext(webAppContext);
// the tenant servlet with alfresco managed authentication
ServletHolder servletHolder = new ServletHolder(CmisAtomPubServlet.class);
servletHolder.setInitParameter("callContextHandler", "org.apache.chemistry.opencmis.server.shared.BasicAuthCallContextHandler");
webAppContext.addServlet(servletHolder, "/cmisatom/*");
}