本文整理汇总了Java中javax.ws.rs.container.ContainerRequestFilter类的典型用法代码示例。如果您正苦于以下问题:Java ContainerRequestFilter类的具体用法?Java ContainerRequestFilter怎么用?Java ContainerRequestFilter使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ContainerRequestFilter类属于javax.ws.rs.container包,在下文中一共展示了ContainerRequestFilter类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: RequestHandler
import javax.ws.rs.container.ContainerRequestFilter; //导入依赖的package包/类
public RequestHandler() {
// configure the application with the resource
ResourceConfig config = new ResourceConfig()
.register(GatewayFeature.class)
.packages("com.jrestless.aws.examples")
.register(ApplicationExceptionMapper.class)
// auto-discovery works, too
// .register(GlobalExceptionMapper.class)
.register(new ContainerRequestFilter() {
@Override
public void filter(ContainerRequestContext request) throws IOException {
LOG.info("baseUri: " + request.getUriInfo().getBaseUri());
LOG.info("requestUri: " + request.getUriInfo().getRequestUri());
}
});
init(config);
start();
}
示例2: configure
import javax.ws.rs.container.ContainerRequestFilter; //导入依赖的package包/类
@Override
protected Application configure() {
enable(TestProperties.LOG_TRAFFIC);
ResourceConfig config = new ResourceConfig();
config.register(LocaleContextFilter.class, 1);
config.register(new ContainerRequestFilter() {
@Override
public void filter(ContainerRequestContext requestContext) throws IOException {
called.incrementAndGet();
locale = LocaleContextKeeper.getLocale();
}
}, 2);
config.register(TestResource.class);
return config;
}
示例3: build
import javax.ws.rs.container.ContainerRequestFilter; //导入依赖的package包/类
public static <F,T> ContainerRequestFilter build(
final ContainerRequestPredicate predicate,
final Function<ContainerRequestContext, F> extractData,
final Function<F,T> transform,
final Function<ContainerRequestContext, DateTime> determineTimestamp,
final WritingWorkerManager<T> writingWorkerManager,
final boolean skipNulls)
{
final Recorder<ContainerRequestContext> recorder = new BasicRecorder<>(
predicate,
extractData,
transform,
determineTimestamp,
writingWorkerManager,
skipNulls
);
return new ContainerRequestFilter() {
@Override
public void filter(ContainerRequestContext requestContext) {
recorder.record(requestContext);
}
};
}
示例4: registerFilter
import javax.ws.rs.container.ContainerRequestFilter; //导入依赖的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);
}
}
示例5: configure
import javax.ws.rs.container.ContainerRequestFilter; //导入依赖的package包/类
@Override
public void configure(ResourceInfo resourceInfo, FeatureContext context) {
context.register(new ContainerRequestFilter() {
@Override
public void filter(ContainerRequestContext requestContext) throws IOException {
if (requestContext.getUriInfo().getPath().endsWith("filtered")) {
throw new ForbiddenException();
}
}
}, Priorities.AUTHORIZATION);
}
示例6: createAuthFactory
import javax.ws.rs.container.ContainerRequestFilter; //导入依赖的package包/类
/**
* Default implementation for the Keycloak auth factory. Please provide your own if you implement
* your own User's representation.
*
* @param configuration the application's configuration
* @return Keycloak auth factory
*/
protected ContainerRequestFilter createAuthFactory(T configuration) {
return new KeycloakAuthFilter.Builder<Principal>()
.setConfig(getKeycloakConfiguration(configuration))
.setAuthenticator(createAuthenticator(getKeycloakConfiguration(configuration)))
.setAuthorizer(createAuthorizer())
.setRealm(getRealm(configuration))
.buildAuthFilter();
}
示例7: getAuthFilter
import javax.ws.rs.container.ContainerRequestFilter; //导入依赖的package包/类
protected ContainerRequestFilter getAuthFilter() {
BasicCredentialAuthFilter.Builder<Principal> builder = new BasicCredentialAuthFilter.Builder<>();
builder.setAuthorizer(AuthUtil.getTestAuthorizer(ADMIN_USER, ADMIN_ROLE));
builder.setAuthenticator(AuthUtil.getBasicAuthenticator(ImmutableList.of(ADMIN_USER, ORDINARY_USER)));
builder.setPrefix(CUSTOM_PREFIX);
return builder.buildAuthFilter();
}
示例8: WSApplication
import javax.ws.rs.container.ContainerRequestFilter; //导入依赖的package包/类
/**
* Register JAX-RS application components.
*/
public WSApplication () {
// Register JAX-RS ContainerRequestFilter.
register(ContainerRequestFilter.class);
//Register Jackson feature for JSON
register(JacksonFeature.class);
// Default test factory container
property(TestProperties.CONTAINER_FACTORY, org.glassfish.jersey.test.grizzly.GrizzlyTestContainerFactory.class);
}
示例9: isProvider
import javax.ws.rs.container.ContainerRequestFilter; //导入依赖的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);
}
示例10: runRequestFilters
import javax.ws.rs.container.ContainerRequestFilter; //导入依赖的package包/类
private void runRequestFilters(final MinijaxRequestContext context) throws IOException {
for (final Class<? extends ContainerRequestFilter> filterClass : requestFilters) {
final ContainerRequestFilter filter = get(filterClass);
filter.filter(context);
}
}
示例11: requestLoggerFilter
import javax.ws.rs.container.ContainerRequestFilter; //导入依赖的package包/类
ContainerRequestFilter requestLoggerFilter() {
return (req) -> LOGGER.info("Request: {}", req.getUriInfo().getRequestUri().getPath());
}
示例12: RegisterAuthDynamicFeature
import javax.ws.rs.container.ContainerRequestFilter; //导入依赖的package包/类
public RegisterAuthDynamicFeature(Class<? extends ContainerRequestFilter> filterClass) {
this.filterClass = filterClass;
}
示例13: createApplicationPathFilter
import javax.ws.rs.container.ContainerRequestFilter; //导入依赖的package包/类
private static ContainerRequestFilter createApplicationPathFilter(Application app) {
ApplicationPathFilter filter = new ApplicationPathFilter();
filter.setApplication(app);
return filter;
}
示例14: addContainerRequestFilter
import javax.ws.rs.container.ContainerRequestFilter; //导入依赖的package包/类
public void addContainerRequestFilter(ContainerRequestFilter requestFilter) {
jerseyEndpoints.addContainerRequestFilter(requestFilter);
}
示例15: addContainerRequestFilter
import javax.ws.rs.container.ContainerRequestFilter; //导入依赖的package包/类
public JerseyEndpoints addContainerRequestFilter(ContainerRequestFilter containerRequestFilter) {
containerRequestFilters.add(containerRequestFilter);
return this;
}