/** * <p> * Checks whether a class is present at the application's class path. * </p> * <p> * This method works very similarly to {@link #findClass(String)} but will just return {@code true} * or {@code false} depending on whether the class could be found or not. * </p> * * @param className the name of the class to be checked. * @return {@code true} if the class was found (by any class loader), {@code false} if not. * * @since 3.0.3 * */ public static boolean isClassPresent(final String className) { return findClass(className) != null; }
JacksonStandardJavaScriptSerializer(final String jacksonPrefix) { super(); this.mapper = new ObjectMapper(); this.mapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS); this.mapper.disable(JsonGenerator.Feature.AUTO_CLOSE_TARGET); this.mapper.enable(JsonGenerator.Feature.ESCAPE_NON_ASCII); this.mapper.getFactory().setCharacterEscapes(new JacksonThymeleafCharacterEscapes()); this.mapper.setDateFormat(new JacksonThymeleafISO8601DateFormat()); /* * Now try to (conditionally) initialize support for Jackson serialization of JSR310 (java.time) objects, * by making use of the 'jackson-datatype-jsr310' optional dependency. */ final Class<?> javaTimeModuleClass = ClassLoaderUtils.findClass(jacksonPrefix + ".datatype.jsr310.JavaTimeModule"); if (javaTimeModuleClass != null) { // JSR310 support for Jackson is present in classpath try { this.mapper.registerModule((Module)javaTimeModuleClass.newInstance()); this.mapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false); } catch (final InstantiationException e) { throw new ConfigurationException("Exception while trying to initialize JSR310 support for Jackson", e); } catch (final IllegalAccessException e) { throw new ConfigurationException("Exception while trying to initialize JSR310 support for Jackson", e); } } }