In below spring bean declaration, I wonder why do we need explicit scope="singleton"
. Isn't it redundant?
<bean class="com.foo.blah.JerseyJacksonConfigFactory" factory-method="getProvider" scope="singleton"/>
public class JerseyJacksonConfigFactory {
public static ClientConfig getConfig() {
JacksonJsonProvider jsonProvider = getProvider();
DefaultClientConfig config = new DefaultClientConfig();
config.getSingletons().add(jsonProvider);
return config;
}
public static JacksonJsonProvider getProvider() {
ObjectMapper mapper = getObjectMapper();
JacksonJsonProvider jsonProvider = new JacksonJsonProvider();
jsonProvider.setMapper(mapper);
return jsonProvider;
}
public static ObjectMapper getObjectMapper() {
return new ObjectMapper()
.configure(DeserializationConfig.Feature.FAIL_ON_UNKNOWN_PROPERTIES, false)
.setPropertyNamingStrategy(PropertyNamingStrategy.CAMEL_CASE_TO_LOWER_CASE_WITH_UNDERSCORES)
.setSerializationInclusion(JsonSerialize.Inclusion.NON_EMPTY);
}
}
Aucun commentaire:
Enregistrer un commentaire