当前位置: 首页>>代码示例>>Java>>正文


Java ServletHolder类代码示例

本文整理汇总了Java中org.eclipse.jetty.servlet.ServletHolder的典型用法代码示例。如果您正苦于以下问题:Java ServletHolder类的具体用法?Java ServletHolder怎么用?Java ServletHolder使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


ServletHolder类属于org.eclipse.jetty.servlet包,在下文中一共展示了ServletHolder类的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: onServletStop

import org.eclipse.jetty.servlet.ServletHolder; //导入依赖的package包/类
/**
 * onServletStop
 * 
 * @param args
 */
public void onServletStop(Object... args) {

    ServletHolder sh = (ServletHolder) args[0];
    Servlet servlet;
    try {
        servlet = sh.getServlet();
    }
    catch (ServletException e) {
        // ignore
        return;
    }

    InterceptSupport iSupport = InterceptSupport.instance();
    InterceptContext context = iSupport.createInterceptContext(Event.BEFORE_SERVLET_DESTROY);
    context.put(InterceptConstants.SERVLET_INSTANCE, servlet);
    context.put(InterceptConstants.WEBAPPLOADER, Thread.currentThread().getContextClassLoader());
    context.put(InterceptConstants.CONTEXTPATH, sh.getContextPath());
    iSupport.doIntercept(context);
}
 
开发者ID:uavorg,项目名称:uavstack,代码行数:25,代码来源:JettyPlusIT.java

示例3: JettyAdminServer

import org.eclipse.jetty.servlet.ServletHolder; //导入依赖的package包/类
public JettyAdminServer(String address, int port, int timeout, String commandUrl) {
    this.port = port;
    this.idleTimeout = timeout;
    this.commandUrl = commandUrl;
    this.address = address;

    server = new Server();
    ServerConnector connector = new ServerConnector(server);
    connector.setHost(address);
    connector.setPort(port);
    connector.setIdleTimeout(idleTimeout);
    server.addConnector(connector);

    ServletContextHandler context = new ServletContextHandler(ServletContextHandler.SESSIONS);
    context.setContextPath("/*");
    server.setHandler(context);

    context.addServlet(new ServletHolder(new CommandServlet()), commandUrl + "/*");
}
 
开发者ID:didichuxing2,项目名称:https-github.com-apache-zookeeper,代码行数:20,代码来源:JettyAdminServer.java

示例4: onServletStart

import org.eclipse.jetty.servlet.ServletHolder; //导入依赖的package包/类
/**
 * onServletStart
 * 
 * @param args
 */
public void onServletStart(Object... args) {

    ServletHolder sh = (ServletHolder) args[0];
    Servlet servlet;
    try {
        servlet = sh.getServlet();
    }
    catch (ServletException e) {
        // ignore
        return;
    }

    InterceptSupport iSupport = InterceptSupport.instance();
    InterceptContext context = iSupport.createInterceptContext(Event.AFTER_SERVET_INIT);
    context.put(InterceptConstants.SERVLET_INSTANCE, servlet);
    context.put(InterceptConstants.WEBAPPLOADER, Thread.currentThread().getContextClassLoader());

    context.put(InterceptConstants.CONTEXTPATH, sh.getContextPath());

    iSupport.doIntercept(context);
}
 
开发者ID:uavorg,项目名称:uavstack,代码行数:27,代码来源:JettyPlusIT.java

示例5: testStarted

import org.eclipse.jetty.servlet.ServletHolder; //导入依赖的package包/类
public void testStarted() {
	// update the configuration
	this.reconfigure();
	this.server = new Server(this.getSaveConfig().getPort());

	ServletContextHandler context = new ServletContextHandler();
	context.setContextPath("/");
	server.setHandler(context);
	context.addServlet(new ServletHolder(new MetricsServlet()), "/metrics");

	try {
		server.start();
	} catch (Exception e) {
		log.error("Couldn't start http server", e);
	}

}
 
开发者ID:johrstrom,项目名称:jmeter-prometheus-plugin,代码行数:18,代码来源:PrometheusListener.java

示例6: run

import org.eclipse.jetty.servlet.ServletHolder; //导入依赖的package包/类
public void run() throws Exception {
	org.eclipse.jetty.util.log.Log.setLog(new Slf4jLog());
	Server server = new Server(port);
       ServletContextHandler context = new ServletContextHandler(ServletContextHandler.SESSIONS);
       context.setContextPath("/");
       context.setWelcomeFiles(new String[]{ "demo.html" });
       context.setResourceBase(httpPath);
       HashSessionIdManager idmanager = new HashSessionIdManager();
       server.setSessionIdManager(idmanager);
       HashSessionManager manager = new HashSessionManager();
       SessionHandler sessions = new SessionHandler(manager);
       sessions.setHandler(context);
       context.addServlet(new ServletHolder(new Servlet(this::getPinto)),"/pinto/*");
       ServletHolder holderPwd = new ServletHolder("default", DefaultServlet.class);
       context.addServlet(holderPwd,"/*");
       server.setHandler(sessions);
       server.start();
       server.join();
}
 
开发者ID:punkbrwstr,项目名称:pinto,代码行数:20,代码来源:Demo.java

示例7: main

import org.eclipse.jetty.servlet.ServletHolder; //导入依赖的package包/类
public static void main(String[] args) {
    int port = Configuration.INSTANCE.getInt("port", 8080);
    Server server = new Server(port);
    ServletContextHandler contextHandler
            = new ServletContextHandler(ServletContextHandler.SESSIONS);
    contextHandler.setContextPath("/");
    ServletHolder sh = new ServletHolder(new VaadinServlet());
    contextHandler.addServlet(sh, "/*");
    contextHandler.setInitParameter("ui", AnalysisUI.class.getCanonicalName());
    contextHandler.setInitParameter("productionMode", String.valueOf(PRODUCTION_MODE));
    server.setHandler(contextHandler);
    try {
        server.start();
        server.join();
    } catch (Exception e) {
        LOG.error("Failed to start application", e);
    }
}
 
开发者ID:tokenmill,项目名称:crawling-framework,代码行数:19,代码来源:Application.java

示例8: main

import org.eclipse.jetty.servlet.ServletHolder; //导入依赖的package包/类
public static void main(String[] args) throws Exception {

        ResourceHandler resourceHandler = new ResourceHandler();
        resourceHandler.setResourceBase(PUBLIC_HTML);

        ServletContextHandler context = new ServletContextHandler(ServletContextHandler.SESSIONS);

        //page reloaded by the timer
        context.addServlet(TimerServlet.class, "/timer");
        //part of a page reloaded by the timer
        context.addServlet(AjaxTimerServlet.class, "/server-time");
        //long-polling waits till a message
        context.addServlet(new ServletHolder(new MessengerServlet()), "/messenger");
        //web chat
        context.addServlet(WebSocketChatServlet.class, "/chat");

        Server server = new Server(PORT);
        server.setHandler(new HandlerList(resourceHandler, context));

        server.start();
        server.join();
    }
 
开发者ID:vitaly-chibrikov,项目名称:otus_java_2017_06,代码行数:23,代码来源:Main.java

示例9: main

import org.eclipse.jetty.servlet.ServletHolder; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
  initWeixin();

  Server server = new Server(8080);

  ServletHandler servletHandler = new ServletHandler();
  server.setHandler(servletHandler);

  ServletHolder endpointServletHolder = new ServletHolder(new WxCpEndpointServlet(wxCpConfigStorage, wxCpService, wxCpMessageRouter));
  servletHandler.addServletWithMapping(endpointServletHolder, "/*");

  ServletHolder oauthServletHolder = new ServletHolder(new WxCpOAuth2Servlet(wxCpService));
  servletHandler.addServletWithMapping(oauthServletHolder, "/oauth2/*");

  server.start();
  server.join();
}
 
开发者ID:11590692,项目名称:Wechat-Group,代码行数:18,代码来源:WxCpDemoServer.java

示例10: 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

示例11: startWebSocket

import org.eclipse.jetty.servlet.ServletHolder; //导入依赖的package包/类
/**
 * start server
 * 
 * @param port
 * @param path
 * @param handlerClass
 */
public static void startWebSocket(int port, String path, String handlerClass) {
	try {
		Server server = new Server(port);
		HandlerList handlerList = new HandlerList();
		ServletContextHandler context = new ServletContextHandler(
				ServletContextHandler.SESSIONS);
		context.setContextPath("/");
		context.addServlet(new ServletHolder(new Jwservlet(handlerClass)),
				path);
		handlerList.addHandler(context);
		handlerList.addHandler(new DefaultHandler());
		server.setHandler(handlerList);
		server.start();
		server.join();
	} catch (Exception e) {
		e.printStackTrace();
		LogUtil.LOG("start websocket server error:" + e.getMessage(),
				LogLev.ERROR, WebSocketServer.class);
		System.exit(1);
	}
}
 
开发者ID:Sunature,项目名称:websocket,代码行数:29,代码来源:WebSocketServer.java

示例12: main

import org.eclipse.jetty.servlet.ServletHolder; //导入依赖的package包/类
public static void main(String[] args) {
    int port = Configuration.INSTANCE.getInt("port", 8080);
    Server server = new Server(port);
    ServletContextHandler contextHandler
            = new ServletContextHandler(ServletContextHandler.SESSIONS);
    contextHandler.setContextPath("/");
    ServletHolder sh = new ServletHolder(new VaadinServlet());
    contextHandler.addServlet(sh, "/*");
    contextHandler.setInitParameter("ui", CrawlerAdminUI.class.getCanonicalName());
    contextHandler.setInitParameter("productionMode", String.valueOf(PRODUCTION_MODE));
    server.setHandler(contextHandler);
    try {
        server.start();
        server.join();
    } catch (Exception e) {
        LOG.error("Failed to start application", e);
    }
}
 
开发者ID:tokenmill,项目名称:crawling-framework,代码行数:19,代码来源:Application.java

示例13: 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

示例14: addApplication

import org.eclipse.jetty.servlet.ServletHolder; //导入依赖的package包/类
private void addApplication(final ServletContextHandler context, final MinijaxApplication application)
        throws IllegalAccessException, InvocationTargetException, NoSuchMethodException {

    // (0) Sort the resource methods by literal length
    application.sortResourceMethods();

    // (1) Add Minijax filter (must come before websocket!)
    context.addFilter(new FilterHolder(new MinijaxFilter(application)), "/*", EnumSet.of(DispatcherType.REQUEST));

    // (2) WebSocket endpoints
    if (OptionalClasses.WEB_SOCKET_UTILS != null) {
        OptionalClasses.WEB_SOCKET_UTILS
                .getMethod("init", ServletContextHandler.class, MinijaxApplication.class)
                .invoke(null, context, application);
    }

    // (3) Dynamic JAX-RS content
    final MinijaxServlet servlet = new MinijaxServlet(application);
    final ServletHolder servletHolder = new ServletHolder(servlet);
    servletHolder.getRegistration().setMultipartConfig(new MultipartConfigElement(""));
    context.addServlet(servletHolder, "/*");
}
 
开发者ID:minijax,项目名称:minijax,代码行数:23,代码来源:Minijax.java

示例15: main

import org.eclipse.jetty.servlet.ServletHolder; //导入依赖的package包/类
public static void main(String[] args) throws Exception {

        ResourceHandler resourceHandler = new ResourceHandler();
        resourceHandler.setResourceBase(PUBLIC_HTML);

        ServletContextHandler context = new ServletContextHandler(ServletContextHandler.SESSIONS);

        context.addServlet(new ServletHolder(new LoginServlet("anonymous")), "/login");
        context.addServlet(AdminServlet.class, "/admin");
        context.addServlet(TimerServlet.class, "/timer");

        Server server = new Server(PORT);
        server.setHandler(new HandlerList(resourceHandler, context));

        server.start();
        server.join();
    }
 
开发者ID:vitaly-chibrikov,项目名称:otus_java_2017_04,代码行数:18,代码来源:Main.java


注:本文中的org.eclipse.jetty.servlet.ServletHolder类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。