You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airavata.apache.org by ma...@apache.org on 2019/10/11 20:42:13 UTC

[airavata-custos] 06/24: Using dependency injection for DozerBeanMapper

This is an automated email from the ASF dual-hosted git repository.

machristie pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/airavata-custos.git

commit fa997dfbc228435d6a0b7ffccaff34c78132bdd0
Author: Dimuthu Wannipurage <di...@gmail.com>
AuthorDate: Tue Jul 9 01:59:20 2019 -0400

    Using dependency injection for DozerBeanMapper
---
 .../java/org/apache/custos/credential/api/AppConfig.java  | 15 +++++++++++++++
 .../api/controllers/SSHCredentialsController.java         |  3 ++-
 2 files changed, 17 insertions(+), 1 deletion(-)

diff --git a/credential-store/credential-api/src/main/java/org/apache/custos/credential/api/AppConfig.java b/credential-store/credential-api/src/main/java/org/apache/custos/credential/api/AppConfig.java
new file mode 100644
index 0000000..8a2ee86
--- /dev/null
+++ b/credential-store/credential-api/src/main/java/org/apache/custos/credential/api/AppConfig.java
@@ -0,0 +1,15 @@
+package org.apache.custos.credential.api;
+
+import org.dozer.DozerBeanMapper;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+@Configuration
+public class AppConfig {
+
+    // Use for future custom mapping scenarios https://www.java-success.com/dozer-with-spring-maven-tutorial/
+    @Bean
+    public DozerBeanMapper dozerBeanMapper() {
+        return new DozerBeanMapper();
+    }
+}
diff --git a/credential-store/credential-api/src/main/java/org/apache/custos/credential/api/controllers/SSHCredentialsController.java b/credential-store/credential-api/src/main/java/org/apache/custos/credential/api/controllers/SSHCredentialsController.java
index b949526..a6063e5 100644
--- a/credential-store/credential-api/src/main/java/org/apache/custos/credential/api/controllers/SSHCredentialsController.java
+++ b/credential-store/credential-api/src/main/java/org/apache/custos/credential/api/controllers/SSHCredentialsController.java
@@ -16,7 +16,8 @@ public class SSHCredentialsController {
     @Autowired
     private VaultManager vaultManager;
 
-    final private DozerBeanMapper mapper = new DozerBeanMapper();
+    @Autowired
+    private DozerBeanMapper mapper;
 
     @RequestMapping(value = "/ssh/{gateway}/{token}", method = RequestMethod.GET)
     public SSHCredential getSSHCredential(@PathVariable("gateway") String gateway, @PathVariable("token") String token) throws Exception {