本文整理匯總了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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
}
示例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;
}
示例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;
}
示例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);
}
}
示例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());
}
});
}
示例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;
}
示例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;
}