public void initialize()

in jackson2/src/java/org/apache/fulcrum/json/jackson/Jackson2MapperService.java [652:708]


    public void initialize() throws Exception {
        mapper = new ObjectMapper(null, null, null);// add configurable JsonFactory,.. later?

        initAnnotationInspectors();

        initFeatures();

        initDefaultTyping();

        getLogger().info("setting date format to:" + dateFormat);
        getLogger().info("cacheFilters is:" + isCacheFilters());
        if (!isCacheFilters()) {
            mapper.configure(SerializationFeature.FLUSH_AFTER_WRITE_VALUE, true);
        }

        mapper.setDateFormat(new SimpleDateFormat(dateFormat));

        if (escapeCharsGlobal) {
            mapper.getFactory().setCharacterEscapes(characterEscapes);
        }
        if (escapeCharsClass != null) {
            try {
                characterEscapes = (CharacterEscapes) Class.forName(escapeCharsClass).getConstructor().newInstance();
            } catch (Exception e) {
                throw new InstantiationException(
                        "JsonMapperService: Error instantiating " + escapeCharsClass + " for " + ESCAPE_CHAR_CLASS);
            }
        }

        getLogger().debug("initialized mapper:" + mapper);

        mapper.getSerializerProvider().setNullValueSerializer(new JsonSerializer<Object>() {
            @Override
            public void serialize(Object value, JsonGenerator jgen, SerializerProvider provider) throws IOException {
                jgen.writeString("");

            }
        });
        cacheService = new CacheService(primary);
        if (cacheService instanceof LogEnabled) {
            cacheService.enableLogging(getLogger().getChildLogger(cacheService.getClass().getSimpleName()));
            getLogger().info("setting cacheService logger: " + cacheService.getClass().getSimpleName());
        }

        if (useJsonPath) {
            // set it before runtime
            DefaultJsonPathWrapper djpw = null;
            try {
                djpw = new DefaultJsonPathWrapper(this.mapper);
                getLogger().debug("******** initialized new jsonPath defaults: " + djpw.getJsonPathDefault());
            } catch (Exception e) {
                throw new AssertionError(
                        "JsonMapperService: Error instantiating " + djpw + " using useJsonPath=" + useJsonPath);
            }

        }
    }