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


Java ResourceConfig.packages方法代码示例

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


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

示例1: initApi

import org.glassfish.jersey.server.ResourceConfig; //导入方法依赖的package包/类
private void initApi() {
    ServletContextHandler servletHandler = new ServletContextHandler(ServletContextHandler.SESSIONS);
    servletHandler.setContextPath("/api");
    servletHandler.getSessionHandler().setSessionManager(sessionManager);

    servletHandler.addServlet(new ServletHolder(new AsyncSocketServlet()), "/socket");

    ResourceConfig resourceConfig = new ResourceConfig();
    resourceConfig.registerClasses(JacksonFeature.class, ObjectMapperProvider.class, ResourceErrorHandler.class);
    resourceConfig.registerClasses(SecurityRequestFilter.class, CorsResponseFilter.class);
    resourceConfig.packages(ServerResource.class.getPackage().getName());

    servletHandler.addServlet(new ServletHolder(new ServletContainer(resourceConfig)), "/*");

    handlers.addHandler(servletHandler);
}
 
开发者ID:bamartinezd,项目名称:traccar-service,代码行数:17,代码来源:WebServer.java

示例2: configure

import org.glassfish.jersey.server.ResourceConfig; //导入方法依赖的package包/类
@Override
protected Application configure() {
    enable(TestProperties.LOG_TRAFFIC);
    enable(TestProperties.DUMP_ENTITY);

    ResourceConfig config = new ResourceConfig();

    FastJsonProvider fastJsonProvider = new FastJsonProvider();
    FastJsonConfig fastJsonConfig = new FastJsonConfig();
    fastJsonConfig.setSerializerFeatures(SerializerFeature.DisableCircularReferenceDetect, SerializerFeature.BrowserSecure);
    fastJsonProvider.setFastJsonConfig(fastJsonConfig);

    config.register(fastJsonProvider);

    config.packages("com.alibaba.json.bvt.issue_1300");
    return config;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:18,代码来源:Issue1341.java

示例3: configure

import org.glassfish.jersey.server.ResourceConfig; //导入方法依赖的package包/类
@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;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:12,代码来源:TestIssue885.java

示例4: configure

import org.glassfish.jersey.server.ResourceConfig; //导入方法依赖的package包/类
@Override
protected Application configure() {
    enable(TestProperties.LOG_TRAFFIC);
    enable(TestProperties.DUMP_ENTITY);

    ResourceConfig config = new ResourceConfig();

    config.register(FastJsonProvider.class);
    config.packages("com.alibaba.json.bvt.issue_1300");
    return config;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:12,代码来源:Issue1367_jaxrs.java

示例5: configure

import org.glassfish.jersey.server.ResourceConfig; //导入方法依赖的package包/类
@Override
protected Application configure() {
    enable(TestProperties.LOG_TRAFFIC);
    enable(TestProperties.DUMP_ENTITY);

    ResourceConfig config = new ResourceConfig();

    config.register(FastJsonResolver.class);

    config.register(FastJsonFeature.class);

    config.packages("com.alibaba.json.bvt.issue_1300");
    return config;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:15,代码来源:Issue1392.java

示例6: startRestServer

import org.glassfish.jersey.server.ResourceConfig; //导入方法依赖的package包/类
public static HttpServer startRestServer() {
    BeanConfig beanConfig = new BeanConfig();
    beanConfig.setVersion("1.0.0");
    beanConfig.setTitle("SlideBar REST Interface");
    beanConfig.setResourcePackage(RootResource.class.getPackage().getName());
    beanConfig.setSchemes(new String[] { "http" });
    beanConfig.setHost("localhost:5055");
    beanConfig.setScan(true);

    final ResourceConfig rc = new ResourceConfig();
    rc.packages(RootResource.class.getPackage().getName());
    rc.register(LoggingFeature.class);
    rc.register(JacksonFeature.class);
    rc.register(ApiListingResource.class);
    rc.register(SwaggerSerializers.class);
    rc.property(ServerProperties.WADL_FEATURE_DISABLE, true);

    Logger l = Logger.getLogger("org.glassfish.grizzly.http.server.HttpHandler");
    l.setLevel(Level.FINE);
    l.setUseParentHandlers(false);
    ConsoleHandler ch = new ConsoleHandler();
    ch.setLevel(Level.ALL);
    l.addHandler(ch);

    try {
        return GrizzlyHttpServerFactory.createHttpServer(new URI("http://localhost:5055"), rc);
    } catch (URISyntaxException e) {
        e.printStackTrace();
        return null;
    }
}
 
开发者ID:SlideKB,项目名称:SlideBar,代码行数:32,代码来源:MainBack.java

示例7: start

import org.glassfish.jersey.server.ResourceConfig; //导入方法依赖的package包/类
public void start() {
  Server server = new Server(new InetSocketAddress(config.getHostname(), config.getPort()));

  ResourceConfig resourceConfig = new ResourceConfig();
  resourceConfig.packages(RESOURCE_PACKAGES_TO_SCAN);
  registerMetrics(resourceConfig);
  ServletContainer servletContainer = new ServletContainer(resourceConfig);
  ServletHolder servletHolder = new ServletHolder(servletContainer);

  ServletContextHandler context = new ServletContextHandler(ServletContextHandler.SESSIONS);
  context.setContextPath("/");
  context.addServlet(servletHolder, API_PREFIX);

  registerMetricsServlets(context);
  server.setHandler(context);
  ServerContainer wscontainer;
  try {
    wscontainer = WebSocketServerContainerInitializer.configureContext(context);
    wscontainer.addEndpoint(EventSocket.class);

  } catch (ServletException | DeploymentException e1) {
    // TODO Auto-generated catch block
    e1.printStackTrace();
  }
  try {
    server.start();
    server.join();
  } catch (Exception e) {
    // TODO
    e.printStackTrace();
  }

}
 
开发者ID:dsmclaughlin,项目名称:onerepmax,代码行数:34,代码来源:JettyServer.java

示例8: runOnSeparateThread

import org.glassfish.jersey.server.ResourceConfig; //导入方法依赖的package包/类
public void runOnSeparateThread() throws Exception {
    for (String resource: resourcesToBeExtractedInDirectory) {
        InputStream resourceAsStream = this.getClass().getResourceAsStream("/" + resource);
        File outputFile = Paths.get(baseOutputDirectory.getAbsolutePath(), resource).toFile();
        FileOutputStream fileOutputStream =  FileUtils.openOutputStream(outputFile);
        IOUtils.copy(resourceAsStream, fileOutputStream);
    }

    ResourceConfig config = new ResourceConfig();
    config.packages("com.hribol.bromium.demo.app");
    ServletHolder servlet = new ServletHolder(new ServletContainer(config));

    server = new Server(0);

    ResourceHandler resourceHandler = new ResourceHandler();
    resourceHandler.setResourceBase(baseOutputDirectory.getAbsolutePath());
    resourceHandler.setDirectoriesListed(true);
    resourceHandler.setWelcomeFiles(resourcesToBeExtractedInDirectory);

    ServletContextHandler context = new ServletContextHandler(server, "/*");
    context.addServlet(servlet, "/*");

    HandlerList handlers = new HandlerList();
    handlers.setHandlers(new Handler[] {
            resourceHandler,
            context
    });
    server.setHandler(handlers);

    server.start();
    this.port = ((ServerConnector) server.getConnectors()[0]).getLocalPort();
    logger.info("Server started on port " + port);

    new Thread(() -> {
        try {
            server.join();
        } catch (InterruptedException e) {
            logger.info("Interrupted!", e);
        }
    }).start();
}
 
开发者ID:hristo-vrigazov,项目名称:bromium,代码行数:42,代码来源:DemoApp.java


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