You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by go...@apache.org on 2017/11/14 17:55:31 UTC
[cxf-fediz] 01/03: DBLoaderSpring propagates caller environment
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 <ad...@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" <co...@cxf.apache.org>.