Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 package com.yammer.dropwizard.json;
 
 
class Log4jModule extends Module {
    private static class LevelDeserializer extends JsonDeserializer<Level> {
        @Override
        public Level deserialize(JsonParser jp,
                                 DeserializationContext ctxtthrows IOException {
            return Level.toLevel(jp.getText());
        }
    }
    private static class Log4jDeserializers extends Deserializers.Base {
        @Override
        public JsonDeserializer<?> findBeanDeserializer(JavaType type,
                                                        DeserializationConfig config,
                                                        DeserializerProvider provider,
                                                        BeanDescription beanDesc,
                                                        BeanProperty propertythrows JsonMappingException {
            if (Level.class.isAssignableFrom(type.getRawClass())) {
                return new LevelDeserializer();
            }
            return super.findBeanDeserializer(typeconfigproviderbeanDescproperty);
        }
    }
    @Override
    public String getModuleName() {
        return "log4j";
    }
    @Override
    public Version version() {
        return Version.unknownVersion();
    }
    @Override
    public void setupModule(SetupContext context) {
        context.addDeserializers(new Log4jDeserializers());
    }
New to GrepCode? Check out our FAQ X