cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gonza...@apache.org
Subject [cxf-fediz] 01/03: DBLoaderSpring propagates caller environment
Date Tue, 14 Nov 2017 17:55:31 GMT
This is an automated email from the ASF dual-hosted git repository.

gonzalad pushed a commit to branch 1.4.x-fixes
in repository https://gitbox.apache.org/repos/asf/cxf-fediz.git

commit 8b81221d2f82ce9f0f7bca445aaedb86ee973633
Author: gonzalad <adr_gonzalez@yahoo.fr>
AuthorDate: Sun Nov 12 23:58:00 2017 +0100

    DBLoaderSpring propagates caller environment
    
    DBLoaderSpring now propagates the Spring
    environment from the calling context.
---
 .../cxf/fediz/service/idp/service/jpa/DBLoaderSpring.java  | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/services/idp-core/src/main/java/org/apache/cxf/fediz/service/idp/service/jpa/DBLoaderSpring.java
b/services/idp-core/src/main/java/org/apache/cxf/fediz/service/idp/service/jpa/DBLoaderSpring.java
index 1d58a77..4cbd5d0 100644
--- a/services/idp-core/src/main/java/org/apache/cxf/fediz/service/idp/service/jpa/DBLoaderSpring.java
+++ b/services/idp-core/src/main/java/org/apache/cxf/fediz/service/idp/service/jpa/DBLoaderSpring.java
@@ -25,11 +25,14 @@ import javax.persistence.PersistenceContext;
 
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
+import org.springframework.context.EnvironmentAware;
 import org.springframework.context.support.GenericXmlApplicationContext;
+import org.springframework.core.env.ConfigurableEnvironment;
+import org.springframework.core.env.Environment;
 import org.springframework.transaction.annotation.Transactional;
 
 @Transactional
-public class DBLoaderSpring implements DBLoader {
+public class DBLoaderSpring implements DBLoader, EnvironmentAware {
 
     public static final String NAME = "SPRINGDBLOADER";
 
@@ -37,6 +40,7 @@ public class DBLoaderSpring implements DBLoader {
 
     private EntityManager em;
     private String resource;
+    private Environment environment;
 
     @PersistenceContext
     public void setEntityManager(EntityManager entityManager) {
@@ -57,6 +61,11 @@ public class DBLoaderSpring implements DBLoader {
     }
 
     @Override
+    public void setEnvironment(Environment environment) {
+        this.environment = environment;
+    }
+
+    @Override
     public void load() {
 
         GenericXmlApplicationContext ctx = null;
@@ -67,6 +76,9 @@ public class DBLoaderSpring implements DBLoader {
             }
 
             ctx = new GenericXmlApplicationContext();
+            if (environment instanceof ConfigurableEnvironment) {
+                ctx.setEnvironment((ConfigurableEnvironment) environment);
+            }
             ctx.load(resource);
             ctx.refresh();
             ctx.start();

-- 
To stop receiving notification emails like this one, please contact
"commits@cxf.apache.org" <commits@cxf.apache.org>.

Mime
View raw message