Search in sources :

Example 31 with Configuration

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

the class SelectableEntityFilteringFeature method configure.

@Override
public boolean configure(final FeatureContext context) {
    final Configuration config = context.getConfiguration();
    if (!config.isRegistered(SelectableEntityProcessor.class)) {
        // register EntityFilteringFeature
        if (!config.isRegistered(EntityFilteringFeature.class)) {
            context.register(EntityFilteringFeature.class);
        }
        // Entity Processors.
        context.register(SelectableEntityProcessor.class);
        // Scope Resolver.
        context.register(SelectableScopeResolver.class);
        return true;
    }
    return true;
}
Also used : Configuration(javax.ws.rs.core.Configuration)

Example 32 with Configuration

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

the class ValidationFeature method configure.

@Override
public boolean configure(final FeatureContext context) {
    final Configuration config = context.getConfiguration();
    // Validation disabled?
    if (PropertiesHelper.isProperty(config.getProperty(ServerProperties.BV_FEATURE_DISABLE))) {
        return false;
    }
    context.register(new ValidationBinder());
    // when ServerProperties.BV_SEND_ERROR_IN_RESPONSE is enabled.
    if (PropertiesHelper.isProperty(config.getProperty(ServerProperties.BV_SEND_ERROR_IN_RESPONSE)) && config.getProperty(ServerProperties.RESPONSE_SET_STATUS_OVER_SEND_ERROR) == null) {
        context.property(ServerProperties.RESPONSE_SET_STATUS_OVER_SEND_ERROR, true);
    }
    return true;
}
Also used : ValidationBinder(org.glassfish.jersey.server.validation.internal.ValidationBinder) Configuration(javax.ws.rs.core.Configuration)

Example 33 with Configuration

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

the class MvcFeature method configure.

@Override
public boolean configure(final FeatureContext context) {
    final Configuration config = context.getConfiguration();
    if (!config.isRegistered(ErrorTemplateExceptionMapper.class)) {
        context.register(ErrorTemplateExceptionMapper.class);
        context.register(new MvcBinder());
        return true;
    }
    return false;
}
Also used : Configuration(javax.ws.rs.core.Configuration) MvcBinder(org.glassfish.jersey.server.mvc.internal.MvcBinder) ErrorTemplateExceptionMapper(org.glassfish.jersey.server.mvc.internal.ErrorTemplateExceptionMapper)

Example 34 with Configuration

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

the class MustacheMvcFeature method configure.

@Override
public boolean configure(final FeatureContext context) {
    final Configuration config = context.getConfiguration();
    if (!config.isRegistered(MustacheTemplateProcessor.class)) {
        // Template Processor.
        Configuration configuration = injectionManager.getInstance(Configuration.class);
        ServletContext servletContext = injectionManager.getInstance(ServletContext.class);
        context.register(new MustacheTemplateProcessor(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 35 with Configuration

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

the class MoxyJsonFeature method configure.

@Override
public boolean configure(final FeatureContext context) {
    final Configuration config = context.getConfiguration();
    if (CommonProperties.getValue(config.getProperties(), config.getRuntimeType(), CommonProperties.MOXY_JSON_FEATURE_DISABLE, Boolean.FALSE, Boolean.class)) {
        return false;
    }
    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);
    // Set a slightly lower priority of workers than JSON-P so MOXy is not pick-ed up for JsonStructures (if both are used).
    final int workerPriority = Priorities.USER + 2000;
    if (EntityFilteringFeature.enabled(config)) {
        context.register(MoxyFilteringFeature.class);
        context.register(FilteringMoxyJsonProvider.class, workerPriority);
    } else {
        context.register(ConfigurableMoxyJsonProvider.class, workerPriority);
    }
    return true;
}
Also used : Configuration(javax.ws.rs.core.Configuration)

Aggregations

Configuration (javax.ws.rs.core.Configuration)56 Test (org.junit.Test)28 MinijaxTest (org.minijax.test.MinijaxTest)17 FeatureContext (javax.ws.rs.core.FeatureContext)7 Client (javax.ws.rs.client.Client)5 ContainerResponseFilter (javax.ws.rs.container.ContainerResponseFilter)4 Map (java.util.Map)3 ClientRequestFilter (javax.ws.rs.client.ClientRequestFilter)3 ClientResponseFilter (javax.ws.rs.client.ClientResponseFilter)3 ContainerRequestFilter (javax.ws.rs.container.ContainerRequestFilter)3 Feature (javax.ws.rs.core.Feature)3 NewCookie (javax.ws.rs.core.NewCookie)3 List (java.util.List)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