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