本文整理汇总了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;
}