當前位置: 首頁>>代碼示例>>Java>>正文


Java ResourceConfig類代碼示例

本文整理匯總了Java中org.glassfish.jersey.server.ResourceConfig的典型用法代碼示例。如果您正苦於以下問題:Java ResourceConfig類的具體用法?Java ResourceConfig怎麽用?Java ResourceConfig使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


ResourceConfig類屬於org.glassfish.jersey.server包,在下文中一共展示了ResourceConfig類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: configure

import org.glassfish.jersey.server.ResourceConfig; //導入依賴的package包/類
@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;
}
 
開發者ID:trellis-ldp,項目名稱:trellis,代碼行數:22,代碼來源:LdpAdminResourceTest.java

示例2: httpBuilder

import org.glassfish.jersey.server.ResourceConfig; //導入依賴的package包/類
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;
}
 
開發者ID:Comcast,項目名稱:redirector,代碼行數:20,代碼來源:WebServiceClientHelper.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();

    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

示例4: jerseyServletRegistration

import org.glassfish.jersey.server.ResourceConfig; //導入依賴的package包/類
@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;

}
 
開發者ID:groovylabs,項目名稱:lyre,代碼行數:20,代碼來源:Lyre.java

示例5: configure

import org.glassfish.jersey.server.ResourceConfig; //導入依賴的package包/類
@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;
}
 
開發者ID:trellis-ldp,項目名稱:trellis,代碼行數:20,代碼來源:LdpUnauthorizedResourceTest.java

示例6: configure

import org.glassfish.jersey.server.ResourceConfig; //導入依賴的package包/類
@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;
}
 
開發者ID:trellis-ldp,項目名稱:trellis,代碼行數:19,代碼來源:LdpResourceNoAgentTest.java

示例7: configure

import org.glassfish.jersey.server.ResourceConfig; //導入依賴的package包/類
@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;
}
 
開發者ID:trellis-ldp,項目名稱:trellis,代碼行數:22,代碼來源:LdpUserResourceTest.java

示例8: configure

import org.glassfish.jersey.server.ResourceConfig; //導入依賴的package包/類
@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;
}
 
開發者ID:trellis-ldp,項目名稱:trellis,代碼行數:19,代碼來源:LdpResourceTest.java

示例9: startServer

import org.glassfish.jersey.server.ResourceConfig; //導入依賴的package包/類
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);
        }
    }
 
開發者ID:PacktPublishing,項目名稱:Java-9-Programming-Blueprints,代碼行數:20,代碼來源:DeskDroidService.java

示例10: configure

import org.glassfish.jersey.server.ResourceConfig; //導入依賴的package包/類
@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;
}
 
開發者ID:micrometer-metrics,項目名稱:micrometer,代碼行數:18,代碼來源:MetricsRequestEventListenerTimedTest.java

示例11: configure

import org.glassfish.jersey.server.ResourceConfig; //導入依賴的package包/類
@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;
}
 
開發者ID:Mercateo,項目名稱:rest-jersey-utils,代碼行數:18,代碼來源:AbstractListingResourceTest.java

示例12: startServer

import org.glassfish.jersey.server.ResourceConfig; //導入依賴的package包/類
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);
    }
}
 
開發者ID:samurayrj,項目名稱:rubenlagus-TelegramBots,代碼行數:26,代碼來源:DefaultWebhook.java

示例13: configure

import org.glassfish.jersey.server.ResourceConfig; //導入依賴的package包/類
@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());
		}
		
	});
	
}
 
開發者ID:jmfgdev,項目名稱:gitplex-mit,代碼行數:27,代碼來源:RestModule.java

示例14: 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

示例15: 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


注:本文中的org.glassfish.jersey.server.ResourceConfig類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。