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


Java ServletHandler类代码示例

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


ServletHandler类属于org.mortbay.jetty.servlet包,在下文中一共展示了ServletHandler类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setupServer

import org.mortbay.jetty.servlet.ServletHandler; //导入依赖的package包/类
private void setupServer() throws Exception
{
    this.server = new HttpServer();
    SocketListener listener = new SocketListener();
    listener.setPort(PORT);
    this.server.addListener(listener);
    HttpContext context = new HttpContext();
    context.setContextPath("/");

    ServletHandler servletHandler = new ServletHandler();
    context.addHandler(servletHandler);

    // Map a servlet onto the container
    ServletHolder holder =
            servletHandler.addServlet("JrpipServlet", "/JrpipServlet", "com.gs.jrpip.server.JrpipServlet");
    holder.put("serviceInterface.Echo", "com.gs.jrpip.Echo");
    holder.put("vmBoundServiceClass.Echo", "com.gs.jrpip.EchoImpl");
    holder.setInitOrder(10);

    this.server.addContext(context);

    this.server.start();
    this.servlet = (JrpipServlet) holder.getServlet();
}
 
开发者ID:goldmansachs,项目名称:jrpip,代码行数:25,代码来源:VmBoundServiceTest.java

示例2: filters

import org.mortbay.jetty.servlet.ServletHandler; //导入依赖的package包/类
/**
 * Add an internal servlet in the server, specifying whether or not to
 * protect with Kerberos authentication. 
 * Note: This method is to be used for adding servlets that facilitate
 * internal communication and not for user facing functionality. For
 +   * servlets added using this method, filters (except internal Kerberos
 * filters) are not enabled. 
 * 
 * @param name The name of the servlet (can be passed as null)
 * @param pathSpec The path spec for the servlet
 * @param clazz The servlet class
 * @param requireAuth Require Kerberos authenticate to access servlet
 */
public void addInternalServlet(String name, String pathSpec, 
    Class<? extends HttpServlet> clazz, boolean requireAuth) {
  ServletHolder holder = new ServletHolder(clazz);
  if (name != null) {
    holder.setName(name);
  }
  webAppContext.addServlet(holder, pathSpec);

  if(requireAuth && UserGroupInformation.isSecurityEnabled()) {
     LOG.info("Adding Kerberos (SPNEGO) filter to " + name);
     ServletHandler handler = webAppContext.getServletHandler();
     FilterMapping fmap = new FilterMapping();
     fmap.setPathSpec(pathSpec);
     fmap.setFilterName(SPNEGO_FILTER);
     fmap.setDispatches(Handler.ALL);
     handler.addFilterMapping(fmap);
  }
}
 
开发者ID:chendave,项目名称:hadoop-TCP,代码行数:32,代码来源:HttpServer.java

示例3: filters

import org.mortbay.jetty.servlet.ServletHandler; //导入依赖的package包/类
/**
 * Add an internal servlet in the server, specifying whether or not to
 * protect with Kerberos authentication.
 * Note: This method is to be used for adding servlets that facilitate
 * internal communication and not for user facing functionality. For
 +   * servlets added using this method, filters (except internal Kerberos
 * filters) are not enabled.
 *
 * @param name The name of the servlet (can be passed as null)
 * @param pathSpec The path spec for the servlet
 * @param clazz The servlet class
 * @param requireAuth Require Kerberos authenticate to access servlet
 */
public void addInternalServlet(String name, String pathSpec,
    Class<? extends HttpServlet> clazz, boolean requireAuth) {
  ServletHolder holder = new ServletHolder(clazz);
  if (name != null) {
    holder.setName(name);
  }
  webAppContext.addServlet(holder, pathSpec);

  if(requireAuth && UserGroupInformation.isSecurityEnabled()) {
     LOG.info("Adding Kerberos (SPNEGO) filter to " + name);
     ServletHandler handler = webAppContext.getServletHandler();
     FilterMapping fmap = new FilterMapping();
     fmap.setPathSpec(pathSpec);
     fmap.setFilterName(SPNEGO_FILTER);
     fmap.setDispatches(Handler.ALL);
     handler.addFilterMapping(fmap);
  }
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:32,代码来源:HttpServer2.java

示例4: setUp

import org.mortbay.jetty.servlet.ServletHandler; //导入依赖的package包/类
@Before
public void setUp() throws Exception {

  ContextHandler context = new ContextHandler();
  context.setContextPath("/");
  context.setResourceBase(RES_DIR);
  ServletHandler sh = new ServletHandler();
  sh.addServletWithMapping("org.apache.jasper.servlet.JspServlet", "*.jsp");
  context.addHandler(sh);
  context.addHandler(new SessionHandler());

  server = new Server();
  server.addHandler(context);

  conf = new Configuration();
  conf.addResource("nutch-default.xml");
  conf.addResource("nutch-site-test.xml");

  http = new Http();
  http.setConf(conf);
}
 
开发者ID:jorcox,项目名称:GeoCrawler,代码行数:22,代码来源:TestProtocolHttpClient.java

示例5: removeServlet

import org.mortbay.jetty.servlet.ServletHandler; //导入依赖的package包/类
/**
 * Remove a servlet in the server.
 * @param name The name of the servlet (can be passed as null)
 * @param pathSpec The path spec for the servlet
 * @param clazz The servlet class
 */
public void removeServlet(String name, String pathSpec,
    Class<? extends HttpServlet> clazz) {
  if(clazz == null) {
     return;
  }

  //remove the filters from filterPathMapping
  ServletHandler servletHandler = webAppContext.getServletHandler();
  List<FilterMapping> newFilterMappings = new ArrayList<FilterMapping>();

  //only add the filter whose pathSpec is not the to-be-removed servlet
  for(FilterMapping mapping: servletHandler.getFilterMappings()) {
    for(String mappingPathSpec: mapping.getPathSpecs()) {
      if(!mappingPathSpec.equals(pathSpec)){
        newFilterMappings.add(mapping);
      }
    }
  }

  servletHandler.setFilterMappings(newFilterMappings.toArray(new FilterMapping[newFilterMappings.size()]));

  removeInternalServlet(name, pathSpec, clazz);
}
 
开发者ID:rhli,项目名称:hadoop-EAR,代码行数:30,代码来源:HttpServer.java

示例6: setUp

import org.mortbay.jetty.servlet.ServletHandler; //导入依赖的package包/类
protected void setUp() throws Exception {

    ContextHandler context = new ContextHandler();
    context.setContextPath("/");
    context.setResourceBase(RES_DIR);
    ServletHandler sh = new ServletHandler();
    sh.addServlet("org.apache.jasper.servlet.JspServlet", "*.jsp");
    context.addHandler(sh);
    context.addHandler(new SessionHandler());

    server = new Server();
    server.addHandler(context);

    conf = new Configuration();
    conf.addResource("nutch-default.xml");
    conf.addResource("nutch-site-test.xml");
    
    http = new Http();
    http.setConf(conf);
  }
 
开发者ID:yahoo,项目名称:anthelion,代码行数:21,代码来源:TestProtocolHttpClient.java

示例7: beforeClass

import org.mortbay.jetty.servlet.ServletHandler; //导入依赖的package包/类
@BeforeClass
public static void beforeClass() throws Exception {
	ourPort = PortUtil.findFreePort();
	ourServer = new Server(ourPort);

	DummyProvider patientProvider = new DummyProvider();

	ServletHandler proxyHandler = new ServletHandler();
	RestfulServer servlet = new RestfulServer();
	ourCtx = servlet.getFhirContext();
	servlet.setResourceProviders(patientProvider, new DummyBinaryProvider());
	ServletHolder servletHolder = new ServletHolder(servlet);
	proxyHandler.addServletWithMapping(servletHolder, "/*");
	ourServer.setHandler(proxyHandler);
	ourServer.start();

	PoolingHttpClientConnectionManager connectionManager = new PoolingHttpClientConnectionManager(5000, TimeUnit.MILLISECONDS);
	HttpClientBuilder builder = HttpClientBuilder.create();
	builder.setConnectionManager(connectionManager);
	ourClient = builder.build();

}
 
开发者ID:gajen0981,项目名称:FHIR-Server,代码行数:23,代码来源:ReadTest.java

示例8: start

import org.mortbay.jetty.servlet.ServletHandler; //导入依赖的package包/类
public void start() throws Exception {
  this.jetty.addConnector(connector);

  ServletHandler servletHandler = new ServletHandler();

  String filterName = "MyriadGuiceFilter";
  FilterHolder holder = new FilterHolder(filter);
  holder.setName(filterName);

  FilterMapping filterMapping = new FilterMapping();
  filterMapping.setPathSpec("/*");
  filterMapping.setDispatches(Handler.ALL);
  filterMapping.setFilterName(filterName);

  servletHandler.addFilter(holder, filterMapping);

  Context context = new Context();
  context.setServletHandler(servletHandler);
  context.addServlet(DefaultServlet.class, "/");

  String staticDir = this.getClass().getClassLoader().getResource("webapp/public").toExternalForm();
  context.setResourceBase(staticDir);

  this.jetty.addHandler(context);
  this.jetty.start();
}
 
开发者ID:apache,项目名称:incubator-myriad,代码行数:27,代码来源:MyriadWebServer.java

示例9: startHTTPServer

import org.mortbay.jetty.servlet.ServletHandler; //导入依赖的package包/类
private void startHTTPServer(){
	int httpPort = settings.getInt(Settings.HTTP_PORT, -1);
	Server server = new Server(httpPort);
       ServletHandler handler = new ServletHandler();
       server.setHandler(handler);
       //handler.addServletWithMapping("org.http.channel.server.servlet.CommandServlet", "/~/*");
       handler.addServletWithMapping("org.emop.weixin.router.servlet.ImageProxyServlet", "/img/*");
       handler.addServletWithMapping("org.emop.weixin.router.servlet.RouterServlet", "/route/*");
       handler.addServletWithMapping("org.emop.weixin.router.servlet.SessionStatusServlet", "/ss/*");
       handler.addServletWithMapping("org.emop.weixin.router.servlet.ApiServlet", "/api/*");
       handler.addServletWithMapping("org.emop.weixin.router.servlet.StatusServlet", "/status/*");
       handler.addServletWithMapping("org.emop.weixin.router.servlet.IndexServlet", "/*");

       try {
       	log.info("Start http server at " + httpPort);
		server.start();
		server.join();
	} catch (Exception e) {
		log.error(e.toString(), e);
	}
}
 
开发者ID:emop,项目名称:WeixinRouter,代码行数:22,代码来源:HttpServer.java

示例10: addInternalServlet

import org.mortbay.jetty.servlet.ServletHandler; //导入依赖的package包/类
/**
 * Add an internal servlet in the server, specifying whether or not to
 * protect with Kerberos authentication. 
 * Note: This method is to be used for adding servlets that facilitate
 * internal communication and not for user facing functionality. For
 * servlets added using this method, filters (except internal Kerberos
 * filters) are not enabled. 
 * 
 * @param name The name of the servlet (can be passed as null)
 * @param pathSpec The path spec for the servlet
 * @param clazz The servlet class
 * @param requireAuth Require Kerberos authenticate to access servlet
 */
public void addInternalServlet(String name, String pathSpec, 
    Class<? extends HttpServlet> clazz, boolean requireAuth) {
  ServletHolder holder = new ServletHolder(clazz);
  if (name != null) {
    holder.setName(name);
  }
  webAppContext.addServlet(holder, pathSpec);
  
  if(requireAuth && UserGroupInformation.isSecurityEnabled()) {
     LOG.info("Adding Kerberos (SPNEGO) filter to " + name);
     ServletHandler handler = webAppContext.getServletHandler();
     FilterMapping fmap = new FilterMapping();
     fmap.setPathSpec(pathSpec);
     fmap.setFilterName(SPNEGO_FILTER);
     fmap.setDispatches(Handler.ALL);
     handler.addFilterMapping(fmap);
  }
}
 
开发者ID:Seagate,项目名称:hadoop-on-lustre,代码行数:32,代码来源:HttpServer.java

示例11: startHttpServer

import org.mortbay.jetty.servlet.ServletHandler; //导入依赖的package包/类
protected void startHttpServer(Object servlet){
	int httpPort = settings.getInt(HTTP_PORT, 8083);		
	Server server = new Server(httpPort);
	System.out.println("Listening HTTP port:" + httpPort);
	
       ServletHandler handler=new ServletHandler();
       server.setHandler(handler);
       handler.addServletWithMapping("org.socialnet.servlet.StatusServlet", "/*");
       try {
		server.start();
        server.join();
        System.out.println("Shutdown HTTP service..");
	} catch (Exception e) {
		System.err.println("Stop HTTP service, with error:" + e.toString());
	}
}
 
开发者ID:deonwu,项目名称:Goku,代码行数:17,代码来源:BaseServer.java

示例12: setUpClass

import org.mortbay.jetty.servlet.ServletHandler; //导入依赖的package包/类
@Before
public void setUpClass() throws Exception {

    LOG.info("---------------------------------------------");
    LOG.info("Starting Jetty");
    LOG.info("---------------------------------------------");

    setupServer();
    final HttpContext context = createContext();
    final ServletHandler servlets = createServletHandler();
    context.addHandler(servlets);
    server.addContext(context);
    server.start();

    service = AtomClientFactory.getAtomService(getEndpoint(), new BasicAuthStrategy(getUsername(), getPassword()));
}
 
开发者ID:rometools,项目名称:rome,代码行数:17,代码来源:AtomClientServerTest.java

示例13: addFilterPathMapping

import org.mortbay.jetty.servlet.ServletHandler; //导入依赖的package包/类
/**
 * Add the path spec to the filter path mapping.
 * @param pathSpec The path spec
 * @param webAppCtx The WebApplicationContext to add to
 */
protected void addFilterPathMapping(String pathSpec,
    Context webAppCtx) {
  ServletHandler handler = webAppCtx.getServletHandler();
  for(String name : filterNames) {
    FilterMapping fmap = new FilterMapping();
    fmap.setPathSpec(pathSpec);
    fmap.setFilterName(name);
    fmap.setDispatches(Handler.ALL);
    handler.addFilterMapping(fmap);
  }
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:17,代码来源:HttpServer2.java

示例14: JettyHttpServer

import org.mortbay.jetty.servlet.ServletHandler; //导入依赖的package包/类
public JettyHttpServer(URL url, final HttpHandler handler){
    super(url, handler);
    DispatcherServlet.addHttpHandler(url.getPort(), handler);
    
    int threads = url.getParameter(Constants.THREADS_KEY, Constants.DEFAULT_THREADS);
    QueuedThreadPool threadPool = new QueuedThreadPool();
    threadPool.setDaemon(true);
    threadPool.setMaxThreads(threads);
    threadPool.setMinThreads(threads);

    SelectChannelConnector connector = new SelectChannelConnector();
    if (! url.isAnyHost() && NetUtils.isValidLocalHost(url.getHost())) {
        connector.setHost(url.getHost());
    }
    connector.setPort(url.getPort());

    server = new Server();
    server.setThreadPool(threadPool);
    server.addConnector(connector);
    
    ServletHandler servletHandler = new ServletHandler();
    ServletHolder servletHolder = servletHandler.addServletWithMapping(DispatcherServlet.class, "/*");
    servletHolder.setInitOrder(2);
    
    server.addHandler(servletHandler);
    
    try {
        server.start();
    } catch (Exception e) {
        throw new IllegalStateException("Failed to start jetty server on " + url.getAddress() + ", cause: "
                                        + e.getMessage(), e);
    }
}
 
开发者ID:dachengxi,项目名称:EatDubbo,代码行数:34,代码来源:JettyHttpServer.java

示例15: start

import org.mortbay.jetty.servlet.ServletHandler; //导入依赖的package包/类
public void start() {
    String serverPort = ConfigUtils.getProperty(JETTY_PORT);
    int port;
    if (serverPort == null || serverPort.length() == 0) {
        port = DEFAULT_JETTY_PORT;
    } else {
        port = Integer.parseInt(serverPort);
    }
    connector = new SelectChannelConnector();
    connector.setPort(port);
    ServletHandler handler = new ServletHandler();
    
    String resources = ConfigUtils.getProperty(JETTY_DIRECTORY);
    if (resources != null && resources.length() > 0) {
        FilterHolder resourceHolder = handler.addFilterWithMapping(ResourceFilter.class, "/*", Handler.DEFAULT);
        resourceHolder.setInitParameter("resources", resources);
    }
    
    ServletHolder pageHolder = handler.addServletWithMapping(PageServlet.class, "/*");
    pageHolder.setInitParameter("pages", ConfigUtils.getProperty(JETTY_PAGES));
    pageHolder.setInitOrder(2);
    
    Server server = new Server();
    server.addConnector(connector);
    server.addHandler(handler);
    try {
        server.start();
    } catch (Exception e) {
        throw new IllegalStateException("Failed to start jetty server on " + NetUtils.getLocalHost() + ":" + port + ", cause: " + e.getMessage(), e);
    }
}
 
开发者ID:dachengxi,项目名称:EatDubbo,代码行数:32,代码来源:JettyContainer.java


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