当前位置: 首页>>代码示例>>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;未经允许,请勿转载。