Search in sources :

Example 1 with Configuration

use of javax.ws.rs.core.Configuration in project jersey by jersey.

the class FreemarkerMvcFeature method configure.

@Override
public boolean configure(final FeatureContext context) {
    final Configuration config = context.getConfiguration();
    if (!config.isRegistered(FreemarkerViewProcessor.class)) {
        // Template Processor.
        Configuration configuration = injectionManager.getInstance(Configuration.class);
        ServletContext servletContext = injectionManager.getInstance(ServletContext.class);
        context.register(new FreemarkerViewProcessor(configuration, servletContext, injectionManager::createAndInitialize));
        // MvcFeature.
        if (!config.isRegistered(MvcFeature.class)) {
            context.register(MvcFeature.class);
        }
        return true;
    }
    return false;
}
Also used : Configuration(javax.ws.rs.core.Configuration) ServletContext(javax.servlet.ServletContext) MvcFeature(org.glassfish.jersey.server.mvc.MvcFeature)

Example 2 with Configuration

use of javax.ws.rs.core.Configuration in project jersey by jersey.

the class DeclarativeLinkingFeature method configure.

@Override
public boolean configure(FeatureContext context) {
    Configuration config = context.getConfiguration();
    if (!config.isRegistered(ResponseLinkFilter.class)) {
        context.register(new AbstractBinder() {

            @Override
            protected void configure() {
                bindAsContract(NaiveResourceMappingContext.class).to(ResourceMappingContext.class).in(Singleton.class);
            }
        });
        context.register(ResponseLinkFilter.class);
        // context.register(RequestLinkFilter.class);
        return true;
    }
    return false;
}
Also used : Configuration(javax.ws.rs.core.Configuration) Singleton(javax.inject.Singleton) AbstractBinder(org.glassfish.jersey.internal.inject.AbstractBinder) NaiveResourceMappingContext(org.glassfish.jersey.linking.mapping.NaiveResourceMappingContext)

Example 3 with Configuration

use of javax.ws.rs.core.Configuration in project jersey by jersey.

the class EntityFilteringFeature method configure.

@Override
public boolean configure(final FeatureContext context) {
    final Configuration config = context.getConfiguration();
    if (!config.isRegistered(EntityFilteringProcessor.class)) {
        // Binder (FilteringObjectProvider/FilteringGraphTransformer).
        if (!config.isRegistered(EntityFilteringBinder.class)) {
            context.register(new EntityFilteringBinder());
        }
        // Entity Processors.
        context.register(EntityFilteringProcessor.class);
        if (!config.isRegistered(DefaultEntityProcessor.class)) {
            context.register(DefaultEntityProcessor.class);
        }
        // Scope Providers.
        context.register(EntityFilteringScopeResolver.class);
        // Scope Resolver.
        if (RuntimeType.SERVER == config.getRuntimeType()) {
            context.register(ServerScopeProvider.class);
        } else {
            context.register(CommonScopeProvider.class);
        }
        return true;
    }
    return false;
}
Also used : Configuration(javax.ws.rs.core.Configuration)

Example 4 with Configuration

use of javax.ws.rs.core.Configuration in project jersey by jersey.

the class Jackson1Feature method configure.

@Override
public boolean configure(final FeatureContext context) {
    final Configuration config = context.getConfiguration();
    final String jsonFeature = CommonProperties.getValue(config.getProperties(), config.getRuntimeType(), InternalProperties.JSON_FEATURE, JSON_FEATURE, String.class);
    // Other JSON providers registered.
    if (!JSON_FEATURE.equalsIgnoreCase(jsonFeature)) {
        return false;
    }
    // Disable other JSON providers.
    context.property(PropertiesHelper.getPropertyNameForRuntime(InternalProperties.JSON_FEATURE, config.getRuntimeType()), JSON_FEATURE);
    // add the default Jackson exception mappers
    context.register(JsonParseExceptionMapper.class);
    context.register(JsonMappingExceptionMapper.class);
    context.register(JacksonJaxbJsonProvider.class, MessageBodyReader.class, MessageBodyWriter.class);
    return true;
}
Also used : Configuration(javax.ws.rs.core.Configuration)

Example 5 with Configuration

use of javax.ws.rs.core.Configuration in project jersey by jersey.

the class JettisonFeature method configure.

@Override
public boolean configure(final FeatureContext context) {
    final Configuration config = context.getConfiguration();
    final String jsonFeature = CommonProperties.getValue(config.getProperties(), config.getRuntimeType(), InternalProperties.JSON_FEATURE, JSON_FEATURE, String.class);
    // Other JSON providers registered.
    if (!JSON_FEATURE.equalsIgnoreCase(jsonFeature)) {
        return false;
    }
    // Disable other JSON providers.
    context.property(PropertiesHelper.getPropertyNameForRuntime(InternalProperties.JSON_FEATURE, config.getRuntimeType()), JSON_FEATURE);
    for (final Class<?> provider : PROVIDERS) {
        context.register(provider, MessageBodyReader.class, MessageBodyWriter.class);
    }
    return true;
}
Also used : Configuration(javax.ws.rs.core.Configuration)

Aggregations

Configuration (javax.ws.rs.core.Configuration)53 Test (org.junit.Test)27 MinijaxTest (org.minijax.test.MinijaxTest)17 FeatureContext (javax.ws.rs.core.FeatureContext)7 Client (javax.ws.rs.client.Client)4 ContainerResponseFilter (javax.ws.rs.container.ContainerResponseFilter)4 Map (java.util.Map)3 ContainerRequestFilter (javax.ws.rs.container.ContainerRequestFilter)3 NewCookie (javax.ws.rs.core.NewCookie)3 List (java.util.List)2 ClientRequestFilter (javax.ws.rs.client.ClientRequestFilter)2 ClientResponseFilter (javax.ws.rs.client.ClientResponseFilter)2 Feature (javax.ws.rs.core.Feature)2 ClassResourceInfo (org.apache.cxf.jaxrs.model.ClassResourceInfo)2 OperationResourceInfo (org.apache.cxf.jaxrs.model.OperationResourceInfo)2 AbstractBinder (org.glassfish.jersey.internal.inject.AbstractBinder)2 LocalResteasyProviderFactory (org.jboss.resteasy.client.jaxrs.internal.LocalResteasyProviderFactory)2 ResteasyJackson2Provider (org.jboss.resteasy.plugins.providers.jackson.ResteasyJackson2Provider)2 ResteasyProviderFactory (org.jboss.resteasy.spi.ResteasyProviderFactory)2 JacksonJaxbJsonProvider (com.fasterxml.jackson.jaxrs.json.JacksonJaxbJsonProvider)1