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


Java HttpServer.add方法代码示例

本文整理汇总了Java中com.neverwinterdp.netty.http.HttpServer.add方法的典型用法代码示例。如果您正苦于以下问题:Java HttpServer.add方法的具体用法?Java HttpServer.add怎么用?Java HttpServer.add使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.neverwinterdp.netty.http.HttpServer的用法示例。


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

示例1: setup

import com.neverwinterdp.netty.http.HttpServer; //导入方法依赖的package包/类
@Before
public void setup() throws Exception {
  server = new HttpServer();
  Map<String, String> props = new HashMap<String, String>();
  props.put("port", Integer.toString(port));
  server.configure(props);
  server.add("/hello", new HelloHandler());
  new Thread() {
    public void run() {
      try {
        server.start() ;
      } catch (Exception e) {
        e.printStackTrace();
      }
    }
  }.start() ;
  Thread.sleep(1000);
}
 
开发者ID:DemandCube,项目名称:NeverwinterDP-Commons,代码行数:19,代码来源:WebAppUnitTest.java

示例2: main

import com.neverwinterdp.netty.http.HttpServer; //导入方法依赖的package包/类
static public void main(String[] args) throws Exception {
  Options options = new Options() ;
  JCommander jcommander = new JCommander(options, args) ;
  jcommander.usage(); 
  
  LoggerFactory lfactory = new LoggerFactory() ;
  MetricRegistry mRegistry = new MetricRegistry() ;
  
  HttpServer server = new HttpServer() ;
  server.setLoggerFactory(lfactory) ;
  server.setPort(options.httpListenPort) ;
  
  MessageForwarder forwarder = null ;
  if("kafka".equals(options.forwarder)) {
    forwarder = new KafkaMessageForwarder(lfactory, mRegistry, options.kafkaParams) ;
  } else {
    forwarder = new NullDevMessageForwarder(options.sparknginParams) ;
  }
  Sparkngin sparkngin = new Sparkngin(mRegistry, forwarder, options.dataDir) ;
  server.add("/message/json", new JSONMessageRouteHandler(sparkngin));
  server.add("/message/jbinary", new JBinaryMessageRouteHandler(sparkngin));
  server.add("/tracker/:trackerName/:site", new TrackingPixelRouteHandler(sparkngin, options.sparknginParams));
  server.startAsDeamon() ;
  Thread.currentThread().join();
}
 
开发者ID:DemandCube,项目名称:Sparkngin,代码行数:26,代码来源:Main.java

示例3: start

import com.neverwinterdp.netty.http.HttpServer; //导入方法依赖的package包/类
public void start() throws Exception {
  logger.info("Start start()");
  logger.info("Properties:\n" + JSONSerializer.INSTANCE.toString(serviceInfo)) ;
  server = new HttpServer() ;
  server.setPort(serviceInfo.httpListenPort()) ;
  server.setLoggerFactory(loggerFactory) ;
  if(serviceInfo.wwwDir() != null) {
    StaticFileHandler fileHandler = new StaticFileHandler(serviceInfo.wwwDir()) ;
    fileHandler.setLogger(loggerFactory.getLogger(StaticFileHandler.class)) ;
    server.setDefault(fileHandler) ;
  }
  
  server.add("/message/json", new JSONMessageRouteHandler(sparkngin));
  server.add("/message/jbinary", new JBinaryMessageRouteHandler(sparkngin));
  server.add("/tracker/:trackerName/:site", new TrackingPixelRouteHandler(sparkngin, serviceInfo.getProperties()));
  server.startAsDeamon();
  logger.info("Finish start()");
}
 
开发者ID:DemandCube,项目名称:Sparkngin,代码行数:19,代码来源:SparknginHttpConnectorService.java

示例4: setup

import com.neverwinterdp.netty.http.HttpServer; //导入方法依赖的package包/类
@Before
public void setup() throws Exception {
  FileUtil.removeIfExist("build/queue", false) ;
  forwarder = new AssertMessageForwarder() ;
  MetricRegistry mRegistry = new MetricRegistry() ;
  Sparkngin sparkngin = new Sparkngin(mRegistry, forwarder, "build/queue/data") ;
  server = new HttpServer() ;
  
  server.startAsDeamon() ;
  
  Map<String, String> config = new HashMap<String, String>() ;
  config.put("tracking.site.extract-headers", "Host.*,content.*") ;
  server.add("/tracker/:trackerName/:site", new TrackingPixelRouteHandler(sparkngin, config)) ;
  
  Thread.sleep(2000) ;
}
 
开发者ID:DemandCube,项目名称:Sparkngin,代码行数:17,代码来源:TrackingPixelRouteHandlerUnitTest.java

示例5: HttpServerSimulator

import com.neverwinterdp.netty.http.HttpServer; //导入方法依赖的package包/类
public HttpServerSimulator(int numOfWorkers, int minProcessTime, int maxProcessTime) {
  server = new HttpServer();
  handler = new MessageHandler();
  server.add("/message", handler);
  server.setPort(7080);
  server.setNumberOfWorkers(numOfWorkers);
  handler.setMinProcessTime(minProcessTime);
  handler.setMaxProcessTime(maxProcessTime);
}
 
开发者ID:DemandCube,项目名称:DemandSpike,代码行数:10,代码来源:HttpServerSimulator.java

示例6: setup

import com.neverwinterdp.netty.http.HttpServer; //导入方法依赖的package包/类
@Before
public void setup() throws Exception {
  server = new HttpServer();
  server.add("/ping", new Ping());
  server.add("/ping/:topic", new PingTopic());
  server.startAsDeamon();
  Thread.sleep(1000);
}
 
开发者ID:DemandCube,项目名称:NeverwinterDP-Commons,代码行数:9,代码来源:HttpRestUnitTest.java

示例7: NettyHttpService

import com.neverwinterdp.netty.http.HttpServer; //导入方法依赖的package包/类
public NettyHttpService(AppMaster appMaster, int port) throws Exception {
  server = new HttpServer();
  server.setPort(port) ;
  InfoRouteHandler infoHandler = new InfoRouteHandler(appMaster) ;
  server.add("/"    ,         infoHandler);
  server.add("/info",         infoHandler);
  server.add("/info/:view",   infoHandler);
  server.add("/info/container/:id",   infoHandler);
  server.add("/rest/:res",  new AppRestRouteHandler(appMaster));
}
 
开发者ID:DemandCube,项目名称:NeverwinterDP-Commons,代码行数:11,代码来源:NettyHttpService.java

示例8: setup

import com.neverwinterdp.netty.http.HttpServer; //导入方法依赖的package包/类
@Before
public void setup() throws Exception {
  FileUtil.removeIfExist("build/queue", false) ;
  forwarder = new NullDevMessageForwarder() ;
  server = new HttpServer() ;
  server.setPort(7080) ;
  metricRegistry = new MetricRegistry() ;
  sparkngin = new Sparkngin(metricRegistry, forwarder, "build/queue/data") ;
  server.add("/message/json", new JSONMessageRouteHandler(sparkngin)) ;
  server.startAsDeamon() ;
}
 
开发者ID:DemandCube,项目名称:Sparkngin,代码行数:12,代码来源:SparknginAppenderUnitTest.java

示例9: SparknginServer

import com.neverwinterdp.netty.http.HttpServer; //导入方法依赖的package包/类
public SparknginServer() throws Exception {
  FileUtil.removeIfExist("build/queue", false) ;
  forwarder = new NullDevMessageForwarder() ;
  server = new HttpServer() ;
  server.setPort(7080) ;
  metricRegistry = new MetricRegistry() ;
  server.add("/message/json", new JSONMessageRouteHandler(new Sparkngin(metricRegistry, forwarder, "build/queue/data"))) ;
  server.setDefault(new StaticFileHandler(".")) ;
  server.startAsDeamon() ;
  Thread.sleep(2000) ;
}
 
开发者ID:DemandCube,项目名称:Sparkngin,代码行数:12,代码来源:SparknginServer.java


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