當前位置: 首頁>>代碼示例>>Java>>正文


Java ServletHolder.setInitParameter方法代碼示例

本文整理匯總了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();
        }
    }
 
開發者ID:warlock-china,項目名稱:wisp,代碼行數:25,代碼來源:ServerMain.java

示例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);
    }
}
 
開發者ID:bamartinezd,項目名稱:traccar-service,代碼行數:20,代碼來源:WebServer.java

示例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();
}
 
開發者ID:tomkraljevic,項目名稱:jetty-embed-reverse-proxy-example,代碼行數:23,代碼來源:ProxyServer.java

示例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();
    }
}
 
開發者ID:isel-leic-mpd,項目名稱:mpd-2017-i41d,代碼行數:21,代碼來源:WeatherWebApp.java

示例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();
    }
}
 
開發者ID:HydAu,項目名稱:Camel,代碼行數:20,代碼來源:WebsocketCamelRouterWithInitParamTestSupport.java

示例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();
    }
}
 
開發者ID:brmson,項目名稱:jobimservice,代碼行數:24,代碼來源:RestServer.java

示例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();
    }
}
 
開發者ID:mmhelloworld,項目名稱:jvm-assembler,代碼行數:25,代碼來源:AssemblerServer.java

示例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();
        }
    }
}
 
開發者ID:MegafonWebLab,項目名稱:histone-java2,代碼行數:32,代碼來源:HttpConcreteTest.java

示例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();
    }
}
 
開發者ID:zekaf,項目名稱:jetty-nodes,代碼行數:22,代碼來源:App.java

示例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);
}
 
開發者ID:BriData,項目名稱:DBus,代碼行數:12,代碼來源:HttpProxy.java

示例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;
}
 
開發者ID:elasticjob,項目名稱:elastic-job-cloud,代碼行數:10,代碼來源:RestfulServer.java

示例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);
    }
}
 
開發者ID:LWJGLX,項目名稱:debug,代碼行數:31,代碼來源:Profiling.java

示例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);
}
 
開發者ID:code-obos,項目名稱:servicebuilder,代碼行數:14,代碼來源:SwaggerAddon.java

示例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/*");
}
 
開發者ID:Alfresco,項目名稱:alfresco-remote-api,代碼行數:11,代碼來源:CMISTCKJettyComponent.java

示例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/*");
}
 
開發者ID:Alfresco,項目名稱:alfresco-remote-api,代碼行數:11,代碼來源:EnterpriseJettyComponent.java


注:本文中的org.eclipse.jetty.servlet.ServletHolder.setInitParameter方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。