Java Code Examples for javax.ws.rs.core.FeatureContext#register()
The following examples show how to use
javax.ws.rs.core.FeatureContext#register() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: EntityFieldsFilteringFeature.java From ameba with MIT License | 6 votes |
/** * {@inheritDoc} */ @Override public boolean configure(final FeatureContext context) { final Configuration config = context.getConfiguration(); if (!config.isRegistered(EntityFieldsProcessor.class)) { // register EntityFilteringFeature if (!config.isRegistered(EntityFilteringFeature.class)) { context.register(EntityFilteringFeature.class); } // Entity Processors. context.register(EntityFieldsProcessor.class); // Scope Resolver. context.register(EntityFieldsScopeResolver.class); return true; } return false; }
Example 2
Source File: ServerTracingDynamicFeature.java From java-jaxrs with Apache License 2.0 | 6 votes |
@Override public void configure(ResourceInfo resourceInfo, FeatureContext context) { // TODO why it is called twice for the same endpoint if (!tracingDisabled(resourceInfo)) { log(resourceInfo); context.register(new ServerTracingFilter( builder.tracer, operationName(resourceInfo), builder.spanDecorators, builder.operationNameBuilder.build(resourceInfo.getResourceClass(), resourceInfo.getResourceMethod()), builder.skipPattern != null ? Pattern.compile(builder.skipPattern) : null, builder.joinExistingActiveSpan), builder.priority); if (builder.traceSerialization) { context.register(new ServerTracingInterceptor(builder.tracer, builder.serializationSpanDecorators), builder.serializationPriority); } } }
Example 3
Source File: CacheForFilter.java From syndesis with Apache License 2.0 | 6 votes |
@Override public void configure(ResourceInfo resourceInfo, FeatureContext context) { CacheFor cc = resourceInfo.getResourceClass().getAnnotation(CacheFor.class); CacheFor mcc = resourceInfo.getResourceMethod().getAnnotation(CacheFor.class); if( mcc!=null ) { cc = mcc; } if (cc!=null) { if( cc.value() == 0 ) { context.register(NoCacheFilter.class); } else if( cc.value() > 0 ) { context.register(new CacheFilter("max-age= " + cc.unit().toSeconds(cc.value()))); } } else { context.register(NoCacheFilter.class); } }
Example 4
Source File: ServiceTalkJacksonSerializerFeature.java From servicetalk with Apache License 2.0 | 6 votes |
@Override public boolean configure(final FeatureContext context) { final Configuration config = context.getConfiguration(); final String jsonFeature = getValue(config.getProperties(), config.getRuntimeType(), JSON_FEATURE, ST_JSON_FEATURE, String.class); // Do not register our JSON feature if another one is already registered if (!ST_JSON_FEATURE.equalsIgnoreCase(jsonFeature)) { LOGGER.warn("Skipping registration of: {} as JSON support is already provided by: {}", ST_JSON_FEATURE, jsonFeature); return false; } // Prevent other not yet registered JSON features to register themselves context.property(getPropertyNameForRuntime(JSON_FEATURE, config.getRuntimeType()), ST_JSON_FEATURE); if (!config.isRegistered(JacksonSerializerMessageBodyReaderWriter.class)) { context.register(SerializationExceptionMapper.class); context.register(JacksonSerializerMessageBodyReaderWriter.class); } return true; }
Example 5
Source File: AuthorizationFilterFeature.java From redpipe with Apache License 2.0 | 5 votes |
@Override public void configure(ResourceInfo resourceInfo, FeatureContext context) { List<Annotation> authzSpecs = new ArrayList<>(); boolean canRedirect = true; for (Class<? extends Annotation> annotationClass : filterAnnotations) { // XXX What is the performance of getAnnotation vs getAnnotations? Annotation classAuthzSpec = resourceInfo.getResourceClass().getAnnotation(annotationClass); Annotation methodAuthzSpec = resourceInfo.getResourceMethod().getAnnotation(annotationClass); if (classAuthzSpec != null) authzSpecs.add(classAuthzSpec); if (methodAuthzSpec != null) authzSpecs.add(methodAuthzSpec); if(resourceInfo.getResourceClass().isAnnotationPresent(NoAuthRedirect.class) || resourceInfo.getResourceMethod().isAnnotationPresent(NoAuthRedirect.class)) canRedirect = false; if(resourceInfo.getResourceClass().isAnnotationPresent(NoAuthFilter.class) || resourceInfo.getResourceMethod().isAnnotationPresent(NoAuthFilter.class)) return; } if (!authzSpecs.isEmpty()) { if(canRedirect) context.register(new LoginRedirectFilter(), Priorities.AUTHENTICATION + 1); context.register(new AuthorizationFilter(authzSpecs), Priorities.AUTHORIZATION); } }
Example 6
Source File: RxJerseyClientFeature.java From rx-jersey with MIT License | 5 votes |
@Override public boolean configure(FeatureContext context) { if (client == null) { client = defaultClient(); } client.register(RxBodyReader.class); context.register(new Binder()); return true; }
Example 7
Source File: ExtendedMessageFeature.java From ameba with MIT License | 5 votes |
/** * {@inheritDoc} */ @Override public boolean configure(FeatureContext context) { if (!context.getConfiguration().isRegistered(TextMessageBodyWriter.class)) { context.register(TextMessageBodyWriter.class); } if (!context.getConfiguration().isRegistered(CaptchaWriterInterceptor.class)) { context.register(CaptchaWriterInterceptor.class); } if (!context.getConfiguration().isRegistered(PathMessageBodyWriter.class)) { context.register(PathMessageBodyWriter.class); } if (!context.getConfiguration().isRegistered(ContentLengthWriterInterceptor.class)) { context.register(ContentLengthWriterInterceptor.class); } if (!context.getConfiguration().isRegistered(StreamingWriterInterceptor.class)) { context.register(StreamingWriterInterceptor.class); // streaming process context.register(BlobStreamingProcess.class); context.register(BytesStreamingProcess.class); context.register(ClobStreamingProcess.class); context.register(FileStreamingProcess.class); context.register(InputStreamingProcess.class); context.register(PathStreamingProcess.class); } return false; }
Example 8
Source File: InstrumentedRestApplication.java From java-jaxrs with Apache License 2.0 | 5 votes |
@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); }
Example 9
Source File: KatharsisFeature.java From katharsis-framework with Apache License 2.0 | 5 votes |
@Override public boolean configure(final FeatureContext context) { ObjectMapper objectMapper = boot.getObjectMapper(); ResourceFieldNameTransformer resourceFieldNameTransformer = new ResourceFieldNameTransformer( objectMapper.getSerializationConfig()); PropertiesProvider propertiesProvider = new PropertiesProvider() { @Override public String getProperty(String key) { return (String) context.getConfiguration().getProperty(key); } }; boot.setDefaultServiceUrlProvider(new UriInfoServiceUrlProvider()); boot.setPropertiesProvider(propertiesProvider); boot.setResourceFieldNameTransformer(resourceFieldNameTransformer); boot.addModule(new JaxrsModule(securityContext)); boot.boot(); KatharsisFilter katharsisFilter; try { RequestContextParameterProviderRegistry parameterProviderRegistry = buildParameterProviderRegistry(); String webPathPrefix = boot.getWebPathPrefix(); ResourceRegistry resourceRegistry = boot.getResourceRegistry(); RequestDispatcher requestDispatcher = boot.getRequestDispatcher(); katharsisFilter = createKatharsisFilter(resourceRegistry, parameterProviderRegistry, webPathPrefix, requestDispatcher); } catch (Exception e) { throw new WebApplicationException(e); } context.register(katharsisFilter); registerActionRepositories(context, boot); return true; }
Example 10
Source File: RxJerseyClientFeature.java From rx-jersey with MIT License | 5 votes |
@Override public boolean configure(FeatureContext context) { if (client == null) { client = createClient(); } client.register(RxBodyReader.class); context.register(new Binder()); return true; }
Example 11
Source File: BaragonAuthFeature.java From Baragon with Apache License 2.0 | 5 votes |
@Override public void configure(ResourceInfo resourceInfo, FeatureContext featureContext) { if (authConfiguration.isEnabled()) { if (resourceInfo.getResourceMethod().getAnnotation(NoAuth.class) == null && resourceInfo.getResourceClass().getAnnotation(NoAuth.class) == null) { featureContext.register(requestFilter); } } }
Example 12
Source File: FastJsonFeature.java From metrics with Apache License 2.0 | 5 votes |
public boolean configure(final FeatureContext context) { final String disableMoxy = CommonProperties.MOXY_JSON_FEATURE_DISABLE + '.' + context.getConfiguration().getRuntimeType().name().toLowerCase(); context.property(disableMoxy, true); context.register(FastJsonProvider.class, MessageBodyReader.class, MessageBodyWriter.class); return true; }
Example 13
Source File: Pac4JSecurityFilterFeature.java From jax-rs-pac4j with Apache License 2.0 | 5 votes |
@Override public boolean configure(FeatureContext context) { final SecurityFilter filter = new SecurityFilter(providers); filter.setAuthorizers(authorizers); filter.setClients(clients); filter.setMatchers(matchers); filter.setMultiProfile(multiProfile); filter.setSkipResponse(skipResponse); context.register(filter); return true; }
Example 14
Source File: ServiceFeature.java From jrestless with Apache License 2.0 | 4 votes |
@Override public boolean configure(FeatureContext context) { context.register(AwsFeature.class); return true; }
Example 15
Source File: JAXRS20ClientServerBookTest.java From cxf with Apache License 2.0 | 4 votes |
@Override public boolean configure(FeatureContext context) { context.register(new BookInfoReader()); return true; }
Example 16
Source File: OptionalParamFeature.java From dropwizard-java8 with Apache License 2.0 | 4 votes |
@Override public boolean configure(final FeatureContext context) { context.register(new OptionalParamBinder()); return true; }
Example 17
Source File: JerseyConfigProvider.java From krazo with Apache License 2.0 | 4 votes |
@Override public void configure(FeatureContext context) { context.register(KrazoModelProcessor.class); context.register(KrazoValidationInterceptor.class); }
Example 18
Source File: SnsFeature.java From jrestless with Apache License 2.0 | 4 votes |
@Override public boolean configure(FeatureContext context) { context.register(AwsFeature.class); return true; }
Example 19
Source File: MCRJerseyDefaultFeature.java From mycore with GNU General Public License v3.0 | 4 votes |
protected void registerTransactionFilter(FeatureContext context) { context.register(MCRDBTransactionFilter.class); }
Example 20
Source File: SetProxyTimeoutFeature.java From cloudbreak with Apache License 2.0 | 4 votes |
@Override public boolean configure(FeatureContext context) { context.register(new SetProxyTimeoutFilter(timeout)); return true; }