Java 类org.glassfish.jersey.server.ResourceConfig 实例源码

项目:trellis    文件:LdpAdminResourceTest.java   
@Override
public Application configure() {

    initMocks(this);

    final String baseUri = getBaseUri().toString();
    final String origin = baseUri.substring(0, baseUri.length() - 1);

    final ResourceConfig config = new ResourceConfig();
    config.register(new LdpResource(mockResourceService, ioService, mockBinaryService, BASE_URL));
    config.register(new TestAuthenticationFilter("testUser", ""));
    config.register(new WebAcFilter(emptyList(), mockAccessControlService));
    config.register(new AgentAuthorizationFilter(mockAgentService, asList("testUser")));
    config.register(new MultipartUploader(mockResourceService, mockBinaryResolver, BASE_URL));
    config.register(new CacheControlFilter(86400));
    config.register(new CrossOriginResourceSharingFilter(asList(origin),
                asList("PATCH", "POST", "PUT"),
                asList("Link", "Content-Type", "Accept", "Accept-Datetime"),
                asList("Link", "Content-Type", "Pragma", "Memento-Datetime"), true, 100));
    return config;
}
项目:redirector    文件:WebServiceClientHelper.java   
public static HttpServer httpBuilder (String connectionUrl, String profileName) {
    try {
        URL url = new URL(connectionUrl);

        System.setProperty("spring.profiles.active", profileName);
        AnnotationConfigApplicationContext annotationConfigApplicationContext = new AnnotationConfigApplicationContext(SpringAnnotationConfig.class);

        ResourceConfig resourceConfig = new ResourceConfig();
        resourceConfig.register(RequestContextFilter.class);
        resourceConfig.property("contextConfig", annotationConfigApplicationContext);
        resourceConfig.register(RestSupport.class);

        URI baseUri = URI.create(url.getProtocol() + "://" + url.getAuthority());
        return  GrizzlyHttpServerFactory.createHttpServer(baseUri, resourceConfig, false);
    } catch (Exception e) {
        Assert.fail("Could'n parse configfile." + e.getMessage());
    }
    return null;
}
项目:GitHub    文件:Issue1341.java   
@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;
}
项目:lyre    文件:Lyre.java   
@Bean
public ServletRegistrationBean jerseyServletRegistration(
    JerseyProperties jerseyProperties, ResourceConfig config) {

    ServletRegistrationBean registration = new ServletRegistrationBean(
        new ServletContainer(config));

    for (Map.Entry<String, String> entry : jerseyProperties.getInit().entrySet()) {
        registration.addInitParameter(entry.getKey(), entry.getValue());
    }

    registration.addUrlMappings("/" +
        (StringUtils.isEmpty(lyreProperties.getApplicationPath()) ? "api" : lyreProperties.getApplicationPath())
        + "/*");
    registration.setName(APIx.class.getName());
    registration.setLoadOnStartup(1);
    return registration;

}
项目:trellis    文件:LdpUnauthorizedResourceTest.java   
@Override
public Application configure() {

    final String baseUri = getBaseUri().toString();
    final String origin = baseUri.substring(0, baseUri.length() - 1);

    // Junit runner doesn't seem to work very well with JerseyTest
    initMocks(this);

    final ResourceConfig config = new ResourceConfig();
    config.register(new LdpResource(mockResourceService, ioService, mockBinaryService, "http://example.org/"));
    config.register(new TestAuthenticationFilter("testUser", "group"));
    config.register(new WebAcFilter(asList(BASIC_AUTH, DIGEST_AUTH), mockAccessControlService));
    config.register(new CrossOriginResourceSharingFilter(asList(origin),
                asList("PATCH", "POST", "PUT"),
                asList("Link", "Content-Type", "Accept", "Accept-Datetime"),
                emptyList(), false, 0));
    return config;
}
项目:trellis    文件:LdpResourceNoAgentTest.java   
@Override
public Application configure() {

    // Junit runner doesn't seem to work very well with JerseyTest
    initMocks(this);

    final String baseUri = getBaseUri().toString();
    final String origin = baseUri.substring(0, baseUri.length() - 1);

    final ResourceConfig config = new ResourceConfig();
    config.register(new LdpResource(mockResourceService, ioService, mockBinaryService, BASE_URL));
    config.register(new MultipartUploader(mockResourceService, mockBinaryResolver, BASE_URL));
    config.register(new CacheControlFilter(86400));
    config.register(new CrossOriginResourceSharingFilter(asList(origin), asList("PATCH", "POST", "PUT"),
                    asList("Link", "Content-Type", "Accept-Datetime"),
                    asList("Link", "Content-Type", "Memento-Datetime"), true, 100));
    return config;
}
项目:trellis    文件:LdpUserResourceTest.java   
@Override
public Application configure() {

    // Junit runner doesn't seem to work very well with JerseyTest
    initMocks(this);

    final String baseUri = getBaseUri().toString();
    final String origin = baseUri.substring(0, baseUri.length() - 1);

    final ResourceConfig config = new ResourceConfig();
    config.register(new LdpResource(mockResourceService, ioService, mockBinaryService, BASE_URL));
    config.register(new TestAuthenticationFilter("testUser", "group"));
    config.register(new WebAcFilter(emptyList(), mockAccessControlService));
    config.register(new AgentAuthorizationFilter(mockAgentService, emptyList()));
    config.register(new MultipartUploader(mockResourceService, mockBinaryResolver, BASE_URL));
    config.register(new CacheControlFilter(86400));
    config.register(new CrossOriginResourceSharingFilter(asList(origin), asList("PATCH", "POST", "PUT"),
                    asList("Link", "Content-Type", "Accept-Datetime"),
                    asList("Link", "Content-Type", "Memento-Datetime"), true, 100));
    return config;
}
项目:trellis    文件:LdpResourceTest.java   
@Override
public Application configure() {

    initMocks(this);

    final String baseUri = getBaseUri().toString();
    final String origin = baseUri.substring(0, baseUri.length() - 1);

    final ResourceConfig config = new ResourceConfig();
    config.register(new LdpResource(mockResourceService, ioService, mockBinaryService, BASE_URL));
    config.register(new AgentAuthorizationFilter(mockAgentService, emptyList()));
    config.register(new MultipartUploader(mockResourceService, mockBinaryResolver, BASE_URL));
    config.register(new CacheControlFilter(86400));
    config.register(new CrossOriginResourceSharingFilter(asList(origin), asList("PATCH", "POST", "PUT"),
                    asList("Link", "Content-Type", "Accept-Datetime"),
                    asList("Link", "Content-Type", "Memento-Datetime"), true, 100));
    return config;
}
项目:Java-9-Programming-Blueprints    文件:DeskDroidService.java   
protected void startServer() {
        WifiManager wifiMgr = (WifiManager) getApplicationContext()
                .getSystemService(Service.WIFI_SERVICE);
        if (wifiMgr.isWifiEnabled()) {
            // Deprecated. Does not support ipv6. *shrug* :)
            String ipAddress = Formatter.formatIpAddress(wifiMgr.getConnectionInfo()
                    .getIpAddress());

            URI baseUri = UriBuilder.fromUri("http://" + ipAddress)
                    .port(49152)
                    .build();
            ResourceConfig config = new ResourceConfig(SseFeature.class)
                    .register(JacksonFeature.class);
            config.registerInstances(new SecureFilter(this));
            config.registerInstances(new DeskDroidResource(this));
//            server = JettyHttpContainerFactory.createServer(baseUri, config);
            server = GrizzlyHttpServerFactory.createHttpServer(baseUri, config);
        }
    }
项目:micrometer    文件:MetricsRequestEventListenerTimedTest.java   
@Override
protected Application configure() {
    registry = new SimpleMeterRegistry();
    longTaskRequestStartedLatch = new CountDownLatch(1);
    longTaskRequestReleaseLatch = new CountDownLatch(1);

    final MetricsApplicationEventListener listener = new MetricsApplicationEventListener(
        registry, new DefaultJerseyTagsProvider(), METRIC_NAME, false);

    final ResourceConfig config = new ResourceConfig();
    config.register(listener);
    config.register(
        new TimedResource(longTaskRequestStartedLatch, longTaskRequestReleaseLatch));
    config.register(TimedOnClassResource.class);

    return config;
}
项目:redirector    文件:WebServiceClientHelper.java   
public static HttpServer httpBuilder (String connectionUrl) {
    try {
        URL url = new URL(connectionUrl);

        AnnotationConfigApplicationContext annotationConfigApplicationContext = new AnnotationConfigApplicationContext(SpringAnnotationConfig.class);

        ResourceConfig resourceConfig = new ResourceConfig();
        resourceConfig.register(RequestContextFilter.class);
        resourceConfig.property("contextConfig", annotationConfigApplicationContext);
        resourceConfig.register(RestSupport.class);

        URI baseUri = URI.create(url.getProtocol() + "://" + url.getAuthority());
        return  GrizzlyHttpServerFactory.createHttpServer(baseUri, resourceConfig, false);
    } catch (Exception e) {
        Assert.fail("Could'n parse configfile." + e.getMessage());
    }
    return null;
}
项目:rest-jersey-utils    文件:AbstractListingResourceTest.java   
@Override
protected Application configure() {

    enable(TestProperties.LOG_TRAFFIC);
    enable(TestProperties.DUMP_ENTITY);

    MockitoAnnotations.initMocks(this);

    ResourceConfig rs = new ResourceConfig();
    rs.register(TestBinder.forAllMocksOf(this));
    rs.register(JacksonJaxbJsonProvider.class);
    rs.register(TestResource.class);
    rs.property(ServerProperties.BV_SEND_ERROR_IN_RESPONSE, Boolean.TRUE);
    LinkFactoryResourceConfig.configure(rs);
    linkMetaFactory = LinkMetaFactory.createInsecureFactoryForTest();
    return rs;
}
项目:rubenlagus-TelegramBots    文件:DefaultWebhook.java   
public void startServer() throws TelegramApiRequestException {
    ResourceConfig rc = new ResourceConfig();
    rc.register(restApi);
    rc.register(JacksonFeature.class);

    final HttpServer grizzlyServer;
    if (keystoreServerFile != null && keystoreServerPwd != null) {
        SSLContextConfigurator sslContext = new SSLContextConfigurator();

        // set up security context
        sslContext.setKeyStoreFile(keystoreServerFile); // contains server keypair
        sslContext.setKeyStorePass(keystoreServerPwd);

        grizzlyServer = GrizzlyHttpServerFactory.createHttpServer(getBaseURI(), rc, true,
                new SSLEngineConfigurator(sslContext).setClientMode(false).setNeedClientAuth(false));
    } else {
        grizzlyServer = GrizzlyHttpServerFactory.createHttpServer(getBaseURI(), rc);
    }

    try {
        grizzlyServer.start();
    } catch (IOException e) {
        throw new TelegramApiRequestException("Error starting webhook server", e);
    }
}
项目:gitplex-mit    文件:RestModule.java   
@Override
protected void configure() {
    super.configure();

    bind(ResourceConfig.class).toProvider(ResourceConfigProvider.class).in(Singleton.class);
    bind(ServletContainer.class).to(DefaultServletContainer.class);

    contribute(FilterChainConfigurator.class, new FilterChainConfigurator() {

        @Override
        public void configure(FilterChainManager filterChainManager) {
            filterChainManager.createChain("/rest/**", "noSessionCreation, authcBasic");
        }

    });

    contribute(JerseyConfigurator.class, new JerseyConfigurator() {

        @Override
        public void configure(ResourceConfig resourceConfig) {
            resourceConfig.packages(RestModule.class.getPackage().getName());
        }

    });

}
项目:GitHub    文件:TestIssue885.java   
@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;
}
项目:GitHub    文件:Issue1367_jaxrs.java   
@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;
}
项目:GitHub    文件:Issue1392.java   
@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;
}
项目:rest-jersey-utils    文件:AccessControlAllowOriginResponseFilterIntegrationTest.java   
@Override
protected Application configure() {
    ResourceConfig rs = new ResourceConfig(TestResource.class, JacksonFeature.class);
    originFilter = mock(OriginFilter.class);
    rs.register(new AccessControlAllowOriginResponseFilter(originFilter));
    return rs;
}
项目:trellis    文件:CORSResourceTest.java   
@Override
public Application configure() {

    initMocks(this);

    final String baseUri = getBaseUri().toString();
    final String origin = baseUri.substring(0, baseUri.length() - 1);

    final ResourceConfig config = new ResourceConfig();
    config.register(new LdpResource(mockResourceService, ioService, mockBinaryService, BASE_URL));
    config.register(new CrossOriginResourceSharingFilter(asList("*"),
                asList("PATCH", "POST", "PUT"), asList("Link", "Content-Type", "Accept", "Accept-Datetime"),
                emptyList(), false, 0));
    return config;
}
项目:docker-restful-java    文件:Main.java   
/**
 * Starts Grizzly HTTP server exposing JAX-RS resources defined in this application.
 *
 * @return Grizzly HTTP server.
 */
public static HttpServer startServer() {
    // create a resource config that scans for JAX-RS resources and providers
    // in com.ymonnier.restful.littleapp package
    final ResourceConfig rc = new ResourceConfig()
            .register(CORSFilter.class)
            .packages("com.ymonnier.restful.littleapp");

    // create and start a new instance of grizzly http server
    // exposing the Jersey application at BASE_URI
    final HttpServer server = GrizzlyHttpServerFactory
            .createHttpServer(URI.create(BASE_URI), rc);

    return server;
}
项目:osgi-starterkit    文件:Config.java   
public Config() throws URISyntaxException, ClassNotFoundException{
    ResourceConfig rc = new ResourceConfig();

    //rc.packages() not working properly atm..., add all classes manually here
    //rc.registerClasses(Status.class /*, AnotherResource.class, ...*/);

    String[] packages = {"com.demo.app.restapi.impl"};
    ClassLoader cl = getClass().getClassLoader();
    boolean recur = false;
    OsgiRegistry reg = ReflectionHelper.getOsgiRegistryInstance();
       logger.info("Created! OSGI runtime? " + (reg == null? "No" : "Yes"));

       //CompositeResourceFinder finder = new CompositeResourceFinder();
       //BundleSchemeResourceFinderFactory f = new BundleSchemeResourceFinderFactory(); until it is made public...

       for(String p: packages){
        p = p.replace('.', '/');
        Enumeration<URL> list = reg.getPackageResources(p, cl, recur);
           while(list.hasMoreElements()){
            URL url = list.nextElement();
            String path = url.getPath();
            String cls = (OsgiRegistry.bundleEntryPathToClassName(path, "") + "class").replace(".class", "");
            logger.info("Found(" + url.toURI().getScheme() + "):" + path + "-->" + cls);

            rc.registerClasses(reg.classForNameWithException(cls));
            //finder.push(f.create(url.toURI(), recur));
           }
       }
       //rc.registerFinder(finder);

    //rc.registerFinder(new PackageNamesScanner(cl, packages, false)); !bundleentry is not bundle...
       //INFO: Found(bundleentry):/com/demo/app/restapi/impl/Status.class-->com.demo.app.restapi.impl.Status.

       //////////////////////////////////////////////////////////////////////////
    this.sc = new ServletContainer(rc);
}
项目:open-kilda    文件:OfsMockServer.java   
public static void main(String[] args)  {       
    URI baseUri = UriBuilder.fromUri("http://localhost/").port(9990).build();
    ResourceConfig config = new ResourceConfig(OfsResource.class);
    config.register(JsonProcessingFeature.class);

    HttpServer server = GrizzlyHttpServerFactory.createHttpServer(baseUri, config);
}
项目:rest-jersey-utils    文件:CorsFeatureIntegrationTest.java   
@Override
@SneakyThrows
protected Application configure() {
    ResourceConfig rs = new ResourceConfig(TestResource.class, JacksonFeature.class);

    CORSFeature corsFeature = new CORSFeature(new OriginFilter.Default(
            Lists.newArrayList(new URL("http://localhost:8080")), Lists.newArrayList("0.0.0.0")));
    rs.register(corsFeature);
    return rs;
}
项目:DBus    文件:HttpServerLauncher.java   
public static void main(String[] args) throws Exception {
    int port = Integer.parseInt(ConfUtils.appConf.getProperty("rest.server.port"));
    URI baseUri = UriBuilder.fromUri("http://localhost").port(port).build();
    ResourceConfig config = new RestApplication();
    Server server = JettyHttpContainerFactory.createServer(baseUri, config, false);
    server.start();
}
项目:sdn-controller-nsc-plugin    文件:InspectionHookApisTest.java   
@Override
protected Application configure() {
    baseTestConfiguration();

    //configure services
    this.context = new OsgiContext();

    SdnControllerApi sdnApi = Mockito.mock(SdnControllerApi.class);
    this.context.registerService(SdnControllerApi.class, sdnApi);

    SampleSdnRedirectionApi sdnRedirApi = Mockito.mock(SampleSdnRedirectionApi.class);
    this.context.registerService(SampleSdnRedirectionApi.class, sdnRedirApi);

    InspectionHookApis service = new InspectionHookApis();
    this.context.registerInjectActivateService(service);

    ResourceConfig application = getBaseResourceConfiguration().register(service);

    //configure responses
    this.expectedResponseList = new ArrayList<String>();
    this.expectedResponseList.add("HookId");

    Mockito.<SdnRedirectionApi> when(sdnApi.createRedirectionApi(any(), any())).thenReturn(sdnRedirApi);

    try {
        Mockito.<List<String>> when(sdnRedirApi.getInspectionHooksIds()).thenReturn(this.expectedResponseList);
        Mockito.<InspectionHookElement> when(sdnRedirApi.getInspectionHook(any()))
                .thenReturn(createInspectionHookEntity());
        Mockito.<String> when(sdnRedirApi.installInspectionHook(any(), any(), any(), any(), any(), any()))
        .thenReturn("HookId");
        Mockito.doNothing().when(sdnRedirApi).updateInspectionHook(any());
        Mockito.doNothing().when(sdnRedirApi).removeInspectionHook(any());
        super.callRealMethods(sdnRedirApi);
    } catch (Exception ex) {
        Assert.fail(ex.getClass() + " : " + ex.getMessage());
    }

    return application;
}
项目:sdn-controller-nsc-plugin    文件:InspectionPortApisTest.java   
@Override
protected Application configure() {
    baseTestConfiguration();

    //configure services
    this.context = new OsgiContext();

    SdnControllerApi sdnApi = Mockito.mock(SdnControllerApi.class);
    this.context.registerService(SdnControllerApi.class, sdnApi);

    SampleSdnRedirectionApi sdnRedirApi = Mockito.mock(SampleSdnRedirectionApi.class);
    this.context.registerService(SampleSdnRedirectionApi.class, sdnRedirApi);

    InspectionPortApis service = new InspectionPortApis();
    this.context.registerInjectActivateService(service);

    ResourceConfig application = getBaseResourceConfiguration().register(service);

    //configure responses
    this.expectedResponseList = new ArrayList<String>();
    this.expectedResponseList.add("InspPortId");

    Mockito.<SdnRedirectionApi> when(sdnApi.createRedirectionApi(any(), any()))
    .thenReturn(sdnRedirApi);

    try {
        Mockito.<List<String>> when(sdnRedirApi.getInspectionPortsIds()).thenReturn(this.expectedResponseList);
        Mockito.<InspectionPortElement> when(sdnRedirApi.getInspectionPort(any()))
                .thenReturn(createInspectionPortEntity());
        Mockito.<Element> when(sdnRedirApi.registerInspectionPort(any())).thenReturn(createInspectionPortEntity());
        Mockito.<Element> when(sdnRedirApi.updateInspectionPort(any())).thenReturn(createInspectionPortEntity());
        Mockito.doNothing().when(sdnRedirApi).removeInspectionPort(any());
        super.callRealMethods(sdnRedirApi);
    }
    catch (Exception ex) {
        Assert.fail(ex.getClass() + " : " + ex.getMessage());
    }

    return application;
}
项目:NGSI-LD_Wrapper    文件:Main.java   
/**
 * Starts Grizzly HTTP server exposing JAX-RS rest defined in this application.
 * @return Grizzly HTTP server.
 */
public static HttpServer startServer() {
    // create a resource config that scans for JAX-RS rest and providers
    final ResourceConfig rc = new ResourceConfig().packages("org.fiware.ngsi_ld.rest");

    // create and start a new instance of grizzly http server
    // exposing the Jersey application at BASE_URI
    return GrizzlyHttpServerFactory.createHttpServer(URI.create(BASE_URI), rc);
}
项目:micrometer    文件:MetricsRequestEventListenerTest.java   
@Override
protected Application configure() {
    registry = new SimpleMeterRegistry();

    final MetricsApplicationEventListener listener = new MetricsApplicationEventListener(
        registry, new DefaultJerseyTagsProvider(), METRIC_NAME, true);

    final ResourceConfig config = new ResourceConfig();
    config.register(listener);
    config.register(TestResource.class);

    return config;
}
项目:odoxSync    文件:MainServer.java   
public static HttpServer startServer(String workingDirectory) throws IOException {
    configureLogging();
    DirectorySynchronizer.INSTANCE.start(workingDirectory);
    // create a resource config that scans for JAX-RS resources and providers
    // in com.example package
    final ResourceConfig rc = new ResourceConfig().packages("com.giorgosgaganis.odoxsync.server.net.resources");


    // create and start a new instance of grizzly http server
    // exposing the Jersey application at BASE_URI
    return GrizzlyHttpServerFactory.createHttpServer(URI.create(BASE_URI), rc);
}
项目:Pet-Supply-Store    文件:RegistryTest.java   
/**
 * Setup the test by deploying an embedded tomcat and adding the rest endpoints.
 * @throws Throwable Throws uncaught throwables for test to fail.
 */
@Before
public void setup() throws Throwable {
    testTomcat = new Tomcat();
    testTomcat.setPort(0);
    testTomcat.setBaseDir(testWorkingDir);
    Context context = testTomcat.addWebapp(CONTEXT, testWorkingDir);
    ResourceConfig restServletConfig = new ResourceConfig();
    restServletConfig.register(RegistryREST.class);
    restServletConfig.register(Registry.class);
    ServletContainer restServlet = new ServletContainer(restServletConfig);
    testTomcat.addServlet(CONTEXT, "restServlet", restServlet);
    context.addServletMappingDecoded("/rest/*", "restServlet");
    testTomcat.start();
}
项目:devoxx-2017    文件:Main.java   
/**
 * Starts Grizzly HTTP server exposing JAX-RS resources defined in this application.
 * @return Grizzly HTTP server.
 */
public static HttpServer startServer(int port) {
    HashMap properties = new HashMap();

    bridgeLog();

    // create a resource config that scans for JAX-RS resources and providers
    // in io.github.javathought.devoxx package
    final ResourceConfig rc = new ResourceConfig().packages("io.github.javathought.devoxx", "org.glassfish.jersey.examples.jackson");
    rc.register(SecurityFilter.class);
    rc.register(CrossDomainFilter.class);
    rc.register(SelectableEntityFilteringFeature.class);
    rc.property(SelectableEntityFilteringFeature.QUERY_PARAM_NAME, "select");
    rc.register(JacksonFeature.class);
    rc.register(RolesAllowedDynamicFeature.class);
    rc.register(CsrfProtectionFilter.class);

    rc.register(ApiListingResource.class);
    rc.register(SwaggerSerializers.class);
    BeanConfig beanConfig = new BeanConfig();
    beanConfig.setVersion("1.0");
    beanConfig.setSchemes(new String[]{"http"});
    beanConfig.setHost("localhost:8084");
    beanConfig.setBasePath("/myapp");
    beanConfig.setResourcePackage("io.github.javathought.devoxx.resources");
    beanConfig.setPrettyPrint(true);
    beanConfig.setScan(true);
    // create and start a new instance of grizzly http server
    // exposing the Jersey application at BASE_URI
    return GrizzlyHttpServerFactory.createHttpServer(URI.create(getBaseUri(port)), rc);
}
项目:karate    文件:HelloHttpRunner.java   
@BeforeClass
public static void beforeClass() throws Exception {
    ResourceConfig resourceConfig = new ResourceConfig(HelloResource.class);
    URI uri = URI.create("http://localhost:8080");
    server = GrizzlyHttpServerFactory.createHttpServer(uri, resourceConfig, false);
    server.start();
    logger.info("server started: {}", uri);
}
项目:karate    文件:MockJerseyServlet.java   
/**
 * this zero-arg constructor will be invoked if you use the 'configure
 * httpClientClass' option refer to the MockJerseyServletFactory for how you
 * can construct this manually and have full control over
 * dependency-injection specific to your environment
 *
 * @throws Exception
 */
public MockJerseyServlet() throws Exception {
    logger.info("auto construction of mock http servlet");
    ServletConfig servletConfig = new MockServletConfig();
    servletContext = new MockServletContext();
    ResourceConfig resourceConfig = new ResourceConfig(HelloResource.class);
    servlet = new ServletContainer(resourceConfig);
    servlet.init(servletConfig);
}
项目:dropwizard-pagination    文件:LinkWebAppTest.java   
@Override
protected ResourceConfig configure() {
    enable(TestProperties.LOG_TRAFFIC);
    enable(TestProperties.DUMP_ENTITY);
    final ResourceConfig rc = new ResourceConfig(ItemsResource.class);
    rc.register(LoggingFeature.class);
    rc.register(DeclarativeLinkingFeature.class);
    return rc;
}
项目:rest-jersey-utils    文件:AccessControlAllowOriginRequestFilterIntegrationTest.java   
@Override
protected Application configure() {
    ResourceConfig rs = new ResourceConfig(TestResource.class, JacksonFeature.class);
    originFilter = mock(OriginFilter.class);
    rs.register(new AccessControlAllowOriginRequestFilter(originFilter));
    return rs;
}
项目:holon-jaxrs    文件:JerseyAuthAutoConfiguration.java   
@Override
public void customize(ResourceConfig config) {
    // Realm ContextResolver
    config.register(new ContextResolver<Realm>() {

        @Override
        public Realm getContext(Class<?> type) {
            return realm;
        }
    });
    // Authentication
    config.register(AuthenticationFeature.class);
    // Authorization
    config.register(RolesAllowedDynamicFeature.class);
}
项目:holon-jaxrs    文件:JerseyResourcesPostProcessor.java   
@Override
public void customize(ResourceConfig config) {
    if (resources != null) {
        for (WeakReference<Class<?>> resource : resources) {
            final Class<?> resourceClass = resource.get();
            if (resourceClass != null) {
                config.register(resourceClass);
                LOGGER.debug(() -> "Registered JAX-RS resource class: [" + resourceClass.getName() + "]");
            }
        }
    }
}
项目:holon-jaxrs    文件:JerseyApiListingPostProcessor.java   
@Override
public void customize(ResourceConfig config) {
    if (definitions != null && !definitions.isEmpty()) {
        for (ApiListingDefinition definition : definitions) {
            definition.configureEndpoints(classLoader, apiPath).forEach(e -> {
                config.register(e.getResourceClass());
                LOGGER.info("[Jersey] [" + e.getGroupId() + "] Swagger API listing configured - Path: "
                        + SwaggerJaxrsUtils.composePath(apiPath, e.getPath()));
            });
        }
    }
}
项目:webserver    文件:DefaultResourceConfigProvider.java   
@Override
public ResourceConfig get() {
  ResourceConfig config = new ResourceConfig();

  // Still considering to disable auto discovery...
  //config.property(CommonProperties.FEATURE_AUTO_DISCOVERY_DISABLE, true);

  Stream.concat(features.stream(), featureClasses.stream().map(injector::getInstance))
      .peek(f -> LOGGER.info("Register feature: {}", f))
      .forEach(config::register);

  return config;
}
项目:onerepmax    文件:JettyServer.java   
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();
  }

}