本文整理汇总了Java中javax.ws.rs.core.Application类的典型用法代码示例。如果您正苦于以下问题:Java Application类的具体用法?Java Application怎么用?Java Application使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Application类属于javax.ws.rs.core包,在下文中一共展示了Application类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: configure
import javax.ws.rs.core.Application; //导入依赖的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: configure
import javax.ws.rs.core.Application; //导入依赖的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;
}
示例3: configure
import javax.ws.rs.core.Application; //导入依赖的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;
}
示例4: configure
import javax.ws.rs.core.Application; //导入依赖的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;
}
示例5: configure
import javax.ws.rs.core.Application; //导入依赖的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;
}
示例6: configure
import javax.ws.rs.core.Application; //导入依赖的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;
}
示例7: configure
import javax.ws.rs.core.Application; //导入依赖的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;
}
示例8: multipleRegisterToRouter
import javax.ws.rs.core.Application; //导入依赖的package包/类
/**
* Convenience method to construct and register the routes to a Vert.x router
* with a base Spring application context.
*
* @param router
* vert.x router
* @param applicationClasses
* application classes
* @return the handlers
*/
@SafeVarargs
public static SwaggerHandler[] multipleRegisterToRouter(final Router router,
final Class<? extends Application>... applicationClasses) {
final SwaggerHandler[] ret = new SwaggerHandler[applicationClasses.length];
int i = 0;
for (final Class<? extends Application> applicationClass : applicationClasses) {
final SwaggerHandler requestHandler = new SwaggerHandler(applicationClass);
router.route(requestHandler.baseUriRoute())
.useNormalisedPath(true)
.handler(requestHandler);
ret[i++] = requestHandler;
}
return ret;
}
示例9: activate
import javax.ws.rs.core.Application; //导入依赖的package包/类
@Activate
public void activate(BundleContext bundleContext) {
Application application = bundleContext.getService(_serviceReference);
Dictionary<String, Object> properties = new Hashtable<>();
String[] propertyKeys = _serviceReference.getPropertyKeys();
for (String key : propertyKeys) {
Object value = _serviceReference.getProperty(key);
properties.put(key, value);
}
properties.put("osgi.jaxrs.application.base", "/");
properties.put("osgi.jaxrs.name", ".default");
_serviceRegistration = bundleContext.registerService(
Application.class, application, properties);
}
示例10: configure
import javax.ws.rs.core.Application; //导入依赖的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;
}
示例11: configure
import javax.ws.rs.core.Application; //导入依赖的package包/类
@Override
protected Application configure() {
//enable(TestProperties.LOG_TRAFFIC);
//enable(TestProperties.DUMP_ENTITY);
//
// TODO: load web.xml directly
// .property(
// "contextConfigLocation",
// "classpath:**/my-web-test-context.xml"
//
return new ResourceConfig(MyResource.class)
.register(ParsecMoxyProvider.class)
.register(JaxbExceptionMapper.class)
.property(JaxbExceptionMapper.PROP_JAXB_DEFAULT_ERROR_CODE, JAXB_ERROR_CODE)
.property(JaxbExceptionMapper.PROP_JAXB_DEFAULT_ERROR_MSG, JAXB_ERROR_MSG)
.register(ValidationConfigurationContextResolver.class)
.register(ParsecValidationExceptionMapper.class)
.property(ParsecValidationExceptionMapper.PROP_VALIDATION_DEFAULT_ERROR_CODE, VALIDATION_ERROR_CODE)
.property(ParsecValidationExceptionMapper.PROP_VALIDATION_DEFAULT_ERROR_MSG, VALIDATION_ERROR_MSG)
.property(ServerProperties.METAINF_SERVICES_LOOKUP_DISABLE, true)
.register(new MoxyJsonConfig().setFormattedOutput(true)
.property(MarshallerProperties.BEAN_VALIDATION_MODE, BeanValidationMode.NONE).resolver());
}
示例12: buildFailedApplicationDTO
import javax.ws.rs.core.Application; //导入依赖的package包/类
private static FailedApplicationDTO buildFailedApplicationDTO(
int reason, CachingServiceReference<Application> serviceReference) {
FailedApplicationDTO failedApplicationDTO = new FailedApplicationDTO();
Object nameProperty = serviceReference.getProperty(
JaxRSWhiteboardConstants.JAX_RS_NAME);
failedApplicationDTO.name = nameProperty == null ?
generateApplicationName(serviceReference::getProperty) :
nameProperty.toString();
failedApplicationDTO.serviceId =
(long)serviceReference.getProperty("service.id");
failedApplicationDTO.failureReason = reason;
return failedApplicationDTO;
}
示例13: configure
import javax.ws.rs.core.Application; //导入依赖的package包/类
@Override
protected Application configure() {
ResourceConfig application = new ResourceConfig();
application.register(new AbstractLambdaContextReferencingBinder() {
@Override
protected void configure() {
bindReferencingLambdaContextFactory();
}
});
testService = mock(TestService.class);
lambdaContextProvider = mock(LambdaContextProvider.class);
Binder binder = new InstanceBinder.Builder()
.addInstance(testService, TestService.class, Singleton.class)
.addInstance(lambdaContextProvider, LambdaContextProvider.class, Singleton.class)
.build();
application.register(binder);
application.register(TestResource.class);
application.register(LambdaContextSetter.class);
return application;
}
示例14: configure
import javax.ws.rs.core.Application; //导入依赖的package包/类
@Override
protected Application configure() {
CorsFilter corsFilter = new CorsFilter.Builder()
.allowMethod(HttpMethod.DELETE)
.allowMethod(HttpMethod.OPTIONS)
.allowHeader("ah0")
.allowHeader("ah1")
.allowOrigin(DEFAULT_ORIGIN)
.allowOrigin("http://test.com")
.exposeHeader("eh0")
.exposeHeader("eh1")
.build();
ResourceConfig application = new ResourceConfig();
application.register(corsFilter);
application.register(TestResource.class);
return application;
}
示例15: deployApplication
import javax.ws.rs.core.Application; //导入依赖的package包/类
private OSGi<ServiceTuple<Application>> deployApplication(
ServiceTuple<Application> tuple) {
return
just(this::createBus).flatMap(bus ->
just(() -> {
CachingServiceReference<Application> serviceReference =
tuple.getCachingServiceReference();
Map<String, Object> properties = getProperties(
serviceReference);
properties.computeIfAbsent(
JAX_RS_NAME, (__) -> generateApplicationName(
serviceReference::getProperty));
return properties;
}).flatMap(properties ->
deployRegistrator(bus, tuple, properties).then(
registerCXFServletService(bus, properties)).then(
just(tuple)
)));
}