本文整理汇总了Java中javax.ws.rs.container.ContainerResponseFilter类的典型用法代码示例。如果您正苦于以下问题:Java ContainerResponseFilter类的具体用法?Java ContainerResponseFilter怎么用?Java ContainerResponseFilter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ContainerResponseFilter类属于javax.ws.rs.container包,在下文中一共展示了ContainerResponseFilter类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testExtensionWithoutAName
import javax.ws.rs.container.ContainerResponseFilter; //导入依赖的package包/类
@Test
public void testExtensionWithoutAName() {
Dictionary<String, Object> properties = new Hashtable<>();
properties.put(JAX_RS_EXTENSION, true);
ServiceRegistration<ContainerResponseFilter> registration =
bundleContext.registerService(
ContainerResponseFilter.class, new TestFilter(), properties);
try {
RuntimeDTO runtimeDTO = _runtime.getRuntimeDTO();
assertEquals(
(long)registration.getReference().getProperty("service.id"),
runtimeDTO.defaultApplication.extensionDTOs[0].serviceId);
}
finally {
registration.unregister();
}
}
示例2: ControllerAdminApiApplication
import javax.ws.rs.container.ContainerResponseFilter; //导入依赖的package包/类
public ControllerAdminApiApplication(String consoleWebPath) {
super();
CONSOLE_WEB_PATH = consoleWebPath;
if (!CONSOLE_WEB_PATH.endsWith("/")) {
CONSOLE_WEB_PATH += "/";
}
packages(RESOURCE_PACKAGE);
// TODO See ControllerResponseFilter
// register(new LoggingFeature());
register(JacksonFeature.class);
register(MultiPartFeature.class);
registerClasses(io.swagger.jaxrs.listing.ApiListingResource.class);
registerClasses(io.swagger.jaxrs.listing.SwaggerSerializers.class);
register(new ContainerResponseFilter() {
@Override
public void filter(ContainerRequestContext containerRequestContext,
ContainerResponseContext containerResponseContext)
throws IOException {
containerResponseContext.getHeaders().add("Access-Control-Allow-Origin", "*");
}
});
// property("jersey.config.server.tracing.type", "ALL");
// property("jersey.config.server.tracing.threshold", "VERBOSE");
}
示例3: AdminApiApplication
import javax.ws.rs.container.ContainerResponseFilter; //导入依赖的package包/类
public AdminApiApplication(ServerInstance instance) {
this.serverInstance = instance;
packages(RESOURCE_PACKAGE);
register(new AbstractBinder() {
@Override
protected void configure() {
bind(serverInstance).to(ServerInstance.class);
}
});
register(JacksonFeature.class);
registerClasses(io.swagger.jaxrs.listing.ApiListingResource.class);
registerClasses(io.swagger.jaxrs.listing.SwaggerSerializers.class);
register(new ContainerResponseFilter() {
@Override
public void filter(ContainerRequestContext containerRequestContext,
ContainerResponseContext containerResponseContext)
throws IOException {
containerResponseContext.getHeaders().add("Access-Control-Allow-Origin", "*");
}
});
}
示例4: buildResponseFilter
import javax.ws.rs.container.ContainerResponseFilter; //导入依赖的package包/类
public static <F,T> ContainerResponseFilter buildResponseFilter(
final ContainerResponsePredicate predicate,
final Function<ContainerRequestAndResponse, F> extractData,
final Function<F,T> transform,
final Function<ContainerRequestAndResponse, DateTime> determineTimestamp,
final WritingWorkerManager<T> writingWorkerManager,
final boolean skipNulls)
{
final Recorder<ContainerRequestAndResponse> recorder = new BasicRecorder<>(
predicate,
extractData,
transform,
determineTimestamp,
writingWorkerManager,
skipNulls);
return buildResponseFilter(recorder);
}
示例5: registerFilter
import javax.ws.rs.container.ContainerResponseFilter; //导入依赖的package包/类
@SuppressWarnings("unchecked")
private void registerFilter(final Class<?> c) {
if (ContainerRequestFilter.class.isAssignableFrom(c)) {
requestFilters.add((Class<? extends ContainerRequestFilter>) c);
}
if (ContainerResponseFilter.class.isAssignableFrom(c)) {
responseFilters.add((Class<? extends ContainerResponseFilter>) c);
}
}
示例6: runResponseFilters
import javax.ws.rs.container.ContainerResponseFilter; //导入依赖的package包/类
private void runResponseFilters(final MinijaxRequestContext context, final Response response) throws IOException {
final ContainerResponseContext responseContext = (ContainerResponseContext) response;
for (final Class<? extends ContainerResponseFilter> filterClass : responseFilters) {
final ContainerResponseFilter filter = get(filterClass);
filter.filter(context, responseContext);
}
}
示例7: setContainerResponseFilter
import javax.ws.rs.container.ContainerResponseFilter; //导入依赖的package包/类
@Reference(
cardinality = MULTIPLE, policyOption = GREEDY,
target = "(liferay.apio.architect.container.response.filter=true)"
)
public void setContainerResponseFilter(
ServiceReference<ContainerResponseFilter> serviceReference,
ContainerResponseFilter containerResponseFilter) {
_containerResponseFilters.add(containerResponseFilter);
}
示例8: unsetContainerResponseFilter
import javax.ws.rs.container.ContainerResponseFilter; //导入依赖的package包/类
@SuppressWarnings("unused")
public <T> void unsetContainerResponseFilter(
ServiceReference<ContainerResponseFilter> serviceReference,
ContainerResponseFilter containerResponseFilter) {
_containerResponseFilters.remove(containerResponseFilter);
}
示例9: configure
import javax.ws.rs.container.ContainerResponseFilter; //导入依赖的package包/类
@Override
public void configure(ResourceInfo resourceInfo, FeatureContext context) {
Method resourceMethod = resourceInfo.getResourceMethod();
if (resourceMethod.getReturnType() != Optional.class) {
return;
}
Type returnType = resourceMethod.getGenericReturnType();
if ((returnType instanceof ParameterizedType) == false) {
return;
}
ParameterizedType pt = (ParameterizedType) returnType;
if (pt.getActualTypeArguments()[0] != UIResponse.class) {
return;
}
context.register(new ContainerResponseFilter() {
@Override
public void filter(ContainerRequestContext requestContext,
ContainerResponseContext responseContext) throws IOException {
if (responseContext.hasEntity() == false) {
return;
}
Optional<?> opt = (Optional<?>) responseContext.getEntity();
responseContext.setEntity(opt.orElse(null));
responseContext.setStatusInfo(
opt.map(a -> responseContext.getStatusInfo()).orElse(Status.NOT_FOUND));
}
});
}
示例10: isProvider
import javax.ws.rs.container.ContainerResponseFilter; //导入依赖的package包/类
private static <T> boolean isProvider(final Class<T> clazz) {
return MessageBodyReader.class.isAssignableFrom(clazz) ||
MessageBodyWriter.class.isAssignableFrom(clazz) ||
ParamConverter.class.isAssignableFrom(clazz) ||
ContainerRequestFilter.class.isAssignableFrom(clazz) ||
ContainerResponseFilter.class.isAssignableFrom(clazz) ||
ReaderInterceptor.class.isAssignableFrom(clazz) ||
WriterInterceptor.class.isAssignableFrom(clazz) ||
ParamConverterProvider.class.isAssignableFrom(clazz) ||
ContextResolver.class.isAssignableFrom(clazz) ||
new MetaAnnotatedClass<>(clazz).isAnnotationPresent(Provider.class);
}
示例11: getResponseFilters
import javax.ws.rs.container.ContainerResponseFilter; //导入依赖的package包/类
@Override
public ContainerResponseFilter[] getResponseFilters() {
return responseFilters;
}
示例12: setResponseFilters
import javax.ws.rs.container.ContainerResponseFilter; //导入依赖的package包/类
@Override
public void setResponseFilters(final ContainerResponseFilter[] responseFilters) {
this.responseFilters = responseFilters;
}
示例13: xPoweredByFilter
import javax.ws.rs.container.ContainerResponseFilter; //导入依赖的package包/类
ContainerResponseFilter xPoweredByFilter() {
return (req, res) -> res.getHeaders().add("X-Powered-By", "UnitTest-Webserver (1.0-SNAPSHOT)");
}
示例14: registerExtension
import javax.ws.rs.container.ContainerResponseFilter; //导入依赖的package包/类
private ServiceRegistration<?> registerExtension(
String name, Object... keyValues) {
TestFilter testFilter = new TestFilter();
Dictionary<String, Object> properties = new Hashtable<>();
properties.put(JAX_RS_EXTENSION, true);
properties.put(JAX_RS_NAME, name);
for (int i = 0; i < keyValues.length; i = i + 2) {
properties.put(keyValues[i].toString(), keyValues[i + 1]);
}
ServiceRegistration<ContainerResponseFilter> serviceRegistration =
bundleContext.registerService(
ContainerResponseFilter.class, testFilter, properties);
_registrations.add(serviceRegistration);
return serviceRegistration;
}
示例15: addContainerResponseFilter
import javax.ws.rs.container.ContainerResponseFilter; //导入依赖的package包/类
public JerseyEndpoints addContainerResponseFilter(ContainerResponseFilter containerResponseFilter) {
containerResponseFilters.add(containerResponseFilter);
return this;
}