Skip to content
This repository has been archived by the owner on Jan 12, 2024. It is now read-only.

Commit

Permalink
Add the object mapper to the guice module so that the whole service u…
Browse files Browse the repository at this point in the history
…ses the same object mapper.
  • Loading branch information
fieldju committed Nov 26, 2016
1 parent b496833 commit 0d026cb
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ public CmsConfig(Config appConfig) {

protected List<Module> getAppGuiceModules(Config appConfig) {
return Arrays.asList(
new CmsGuiceModule(appConfig),
new CmsGuiceModule(appConfig, objectMapper),
new CmsMyBatisModule(),
new BackstopperRiposteConfigGuiceModule(),
new CmsFlywayModule()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

package com.nike.cerberus.server.config.guice;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.inject.name.Names;
import com.nike.backstopper.apierror.projectspecificinfo.ProjectApiErrors;
import com.nike.cerberus.config.CmsEnvPropertiesLoader;
Expand Down Expand Up @@ -96,12 +97,14 @@ public class CmsGuiceModule extends AbstractModule {
private final Logger logger = LoggerFactory.getLogger(this.getClass());

private Config appConfig;
private final ObjectMapper objectMapper;

public CmsGuiceModule(Config appConfig) {
public CmsGuiceModule(Config appConfig, ObjectMapper objectMapper) {
if (appConfig == null)
throw new IllegalArgumentException("appConfig cannot be null");

this.appConfig = appConfig;
this.objectMapper = objectMapper;
}

@Override
Expand All @@ -110,8 +113,9 @@ protected void configure() {

bind(UrlResolver.class).to(CmsVaultUrlResolver.class);
bind(VaultCredentialsProvider.class).to(CmsVaultCredentialsProvider.class);
bind(ObjectMapper.class).toInstance(objectMapper);

String className = this.appConfig.getString("cms.auth.connector");
String className = this.appConfig.getString(AUTH_CONNECTOR_IMPL_KEY);
try
{
Class<?> clazz = Class.forName(className);
Expand Down

0 comments on commit 0d026cb

Please sign in to comment.