Search in sources :

Example 16 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 17 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 18 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 19 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)

Example 20 with Configuration

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

the class JacksonFeature 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);
    // Register Jackson.
    if (!config.isRegistered(JacksonJaxbJsonProvider.class)) {
        // add the default Jackson exception mappers
        context.register(JsonParseExceptionMapper.class);
        context.register(JsonMappingExceptionMapper.class);
        if (EntityFilteringFeature.enabled(config)) {
            context.register(JacksonFilteringFeature.class);
            context.register(FilteringJacksonJaxbJsonProvider.class, MessageBodyReader.class, MessageBodyWriter.class);
        } else {
            context.register(JacksonJaxbJsonProvider.class, MessageBodyReader.class, MessageBodyWriter.class);
        }
    }
    return true;
}
Also used : Configuration(javax.ws.rs.core.Configuration) JacksonJaxbJsonProvider(com.fasterxml.jackson.jaxrs.json.JacksonJaxbJsonProvider) FilteringJacksonJaxbJsonProvider(org.glassfish.jersey.jackson.internal.FilteringJacksonJaxbJsonProvider)

Aggregations

Configuration (javax.ws.rs.core.Configuration)21 Map (java.util.Map)2 SSLContext (javax.net.ssl.SSLContext)2 ServletContext (javax.servlet.ServletContext)2 AbstractBinder (org.glassfish.jersey.internal.inject.AbstractBinder)2 JacksonJaxbJsonProvider (com.fasterxml.jackson.jaxrs.json.JacksonJaxbJsonProvider)1 ImmutableMap (com.google.common.collect.ImmutableMap)1 Bootstrap (io.netty.bootstrap.Bootstrap)1 Channel (io.netty.channel.Channel)1 ChannelPipeline (io.netty.channel.ChannelPipeline)1 SocketChannel (io.netty.channel.socket.SocketChannel)1 NioSocketChannel (io.netty.channel.socket.nio.NioSocketChannel)1 DefaultFullHttpRequest (io.netty.handler.codec.http.DefaultFullHttpRequest)1 DefaultHttpRequest (io.netty.handler.codec.http.DefaultHttpRequest)1 HttpChunkedInput (io.netty.handler.codec.http.HttpChunkedInput)1 HttpClientCodec (io.netty.handler.codec.http.HttpClientCodec)1 HttpContentDecompressor (io.netty.handler.codec.http.HttpContentDecompressor)1 HttpRequest (io.netty.handler.codec.http.HttpRequest)1 HttpProxyHandler (io.netty.handler.proxy.HttpProxyHandler)1 JdkSslContext (io.netty.handler.ssl.JdkSslContext)1