當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。