Exemplo n.º 1
0
 /**
  * Creates and starts a lightweight HTTP server. Uses the HTTP server bundled with Java SE.
  * Requires Java SE 6 or later.
  *
  * @return The HTTP server.
  * @throws IOException If any error occurs in the process.
  */
 private static HttpServer createHttpServer() throws IOException {
   // Configure resources that will be published in the HTTP server.
   ResourceConfig weatherForecastResourceConfig = new ResourceConfig();
   // All resources are RESTful web services located in the package
   // ie.tcd.dsg.surf.weatherforecast.service.
   weatherForecastResourceConfig.packages("ie.tcd.dsg.surf.weatherforecast.service");
   // Create the HTTP server with the previous configuration.
   // Note: The server is started automatically.
   return JdkHttpServerFactory.createHttpServer(
       getWeatherForecastURI(), weatherForecastResourceConfig);
 }
Exemplo n.º 2
0
  @Override
  protected Application configure() {
    enable(TestProperties.LOG_TRAFFIC);
    enable(TestProperties.DUMP_ENTITY);

    ResourceConfig config = new ResourceConfig();
    // config.register(new FastJsonFeature()).register(FastJsonProvider.class);
    config.register(new FastJsonFeature()).register(new FastJsonProvider().setPretty(true));
    config.packages("com.alibaba.fastjson");
    return config;
  }