syncope-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ilgro...@apache.org
Subject [1/2] syncope git commit: Some cleanings
Date Fri, 14 Apr 2017 12:39:12 GMT
Repository: syncope
Updated Branches:
  refs/heads/2_0_X ec4474841 -> d76009ca6
  refs/heads/master bd5920864 -> 9cc238c97


Some cleanings


Project: http://git-wip-us.apache.org/repos/asf/syncope/repo
Commit: http://git-wip-us.apache.org/repos/asf/syncope/commit/9cc238c9
Tree: http://git-wip-us.apache.org/repos/asf/syncope/tree/9cc238c9
Diff: http://git-wip-us.apache.org/repos/asf/syncope/diff/9cc238c9

Branch: refs/heads/master
Commit: 9cc238c97f8dd63a53ad52ef45f0a6a86aef0324
Parents: bd59208
Author: Francesco Chicchiriccò <ilgrosso@apache.org>
Authored: Fri Apr 14 14:12:30 2017 +0200
Committer: Francesco Chicchiriccò <ilgrosso@apache.org>
Committed: Fri Apr 14 14:12:50 2017 +0200

----------------------------------------------------------------------
 .../syncope/core/logic/AbstractAnyLogic.java    |  3 +-
 .../syncope/core/logic/AnyObjectLogic.java      | 14 ++--
 .../apache/syncope/core/logic/GroupLogic.java   | 22 +++---
 .../apache/syncope/core/logic/UserLogic.java    |  8 +-
 .../persistence/jpa/dao/AbstractAnyDAO.java     | 71 +++++++++++------
 .../persistence/jpa/dao/JPAAnyObjectDAO.java    | 28 +++++--
 .../core/persistence/jpa/dao/JPAConfDAO.java    | 16 +++-
 .../jpa/dao/JPAExternalResourceDAO.java         | 81 ++++++++++++++++----
 .../core/persistence/jpa/dao/JPAGroupDAO.java   | 39 +++++++---
 .../persistence/jpa/dao/JPAPlainSchemaDAO.java  | 13 +++-
 .../core/persistence/jpa/dao/JPARoleDAO.java    | 16 +++-
 .../core/persistence/jpa/dao/JPAUserDAO.java    | 36 ++++++---
 .../persistence/jpa/dao/JPAVirSchemaDAO.java    | 14 +++-
 .../src/main/resources/domains/MasterDomain.xml |  2 +-
 .../src/test/resources/domains/TwoDomain.xml    |  4 +-
 .../java/data/AbstractAnyDataBinder.java        | 54 +++++--------
 .../src/main/resources/restCXFContext.xml       |  5 +-
 .../src/main/resources/jboss/restCXFContext.xml |  5 +-
 18 files changed, 281 insertions(+), 150 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/syncope/blob/9cc238c9/core/logic/src/main/java/org/apache/syncope/core/logic/AbstractAnyLogic.java
----------------------------------------------------------------------
diff --git a/core/logic/src/main/java/org/apache/syncope/core/logic/AbstractAnyLogic.java b/core/logic/src/main/java/org/apache/syncope/core/logic/AbstractAnyLogic.java
index f8467cd..9d57524 100644
--- a/core/logic/src/main/java/org/apache/syncope/core/logic/AbstractAnyLogic.java
+++ b/core/logic/src/main/java/org/apache/syncope/core/logic/AbstractAnyLogic.java
@@ -51,8 +51,7 @@ import org.apache.syncope.core.provisioning.api.LogicActions;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.support.AbstractBeanDefinition;
 
-public abstract class AbstractAnyLogic<TO extends AnyTO, P extends AnyPatch>
-        extends AbstractResourceAssociator<TO> {
+public abstract class AbstractAnyLogic<TO extends AnyTO, P extends AnyPatch> extends AbstractResourceAssociator<TO> {
 
     @Autowired
     private RealmDAO realmDAO;

http://git-wip-us.apache.org/repos/asf/syncope/blob/9cc238c9/core/logic/src/main/java/org/apache/syncope/core/logic/AnyObjectLogic.java
----------------------------------------------------------------------
diff --git a/core/logic/src/main/java/org/apache/syncope/core/logic/AnyObjectLogic.java b/core/logic/src/main/java/org/apache/syncope/core/logic/AnyObjectLogic.java
index 4a24621..efd263d 100644
--- a/core/logic/src/main/java/org/apache/syncope/core/logic/AnyObjectLogic.java
+++ b/core/logic/src/main/java/org/apache/syncope/core/logic/AnyObjectLogic.java
@@ -31,23 +31,22 @@ import org.apache.commons.lang3.tuple.Pair;
 import org.apache.syncope.common.lib.SyncopeClientException;
 import org.apache.syncope.common.lib.patch.AnyObjectPatch;
 import org.apache.syncope.common.lib.patch.StringPatchItem;
-import org.apache.syncope.common.lib.to.PropagationStatus;
 import org.apache.syncope.common.lib.to.AnyObjectTO;
+import org.apache.syncope.common.lib.to.PropagationStatus;
 import org.apache.syncope.common.lib.to.ProvisioningResult;
 import org.apache.syncope.common.lib.types.AnyEntitlement;
 import org.apache.syncope.common.lib.types.AnyTypeKind;
 import org.apache.syncope.common.lib.types.ClientExceptionType;
 import org.apache.syncope.common.lib.types.PatchOperation;
-import org.apache.syncope.core.persistence.api.dao.AnyObjectDAO;
+import org.apache.syncope.core.persistence.api.dao.AnySearchDAO;
 import org.apache.syncope.core.persistence.api.dao.search.OrderByClause;
 import org.apache.syncope.core.persistence.api.dao.search.SearchCond;
-import org.apache.syncope.core.provisioning.api.AnyObjectProvisioningManager;
-import org.apache.syncope.core.provisioning.api.data.AnyObjectDataBinder;
-import org.apache.syncope.core.spring.security.AuthContextUtils;
-import org.apache.syncope.core.persistence.api.dao.AnySearchDAO;
 import org.apache.syncope.core.persistence.api.entity.AnyType;
 import org.apache.syncope.core.persistence.api.entity.anyobject.AnyObject;
+import org.apache.syncope.core.provisioning.api.AnyObjectProvisioningManager;
 import org.apache.syncope.core.provisioning.api.LogicActions;
+import org.apache.syncope.core.provisioning.api.data.AnyObjectDataBinder;
+import org.apache.syncope.core.spring.security.AuthContextUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
 import org.springframework.transaction.annotation.Transactional;
@@ -60,9 +59,6 @@ import org.springframework.transaction.annotation.Transactional;
 public class AnyObjectLogic extends AbstractAnyLogic<AnyObjectTO, AnyObjectPatch> {
 
     @Autowired
-    protected AnyObjectDAO anyObjectDAO;
-
-    @Autowired
     protected AnySearchDAO searchDAO;
 
     @Autowired

http://git-wip-us.apache.org/repos/asf/syncope/blob/9cc238c9/core/logic/src/main/java/org/apache/syncope/core/logic/GroupLogic.java
----------------------------------------------------------------------
diff --git a/core/logic/src/main/java/org/apache/syncope/core/logic/GroupLogic.java b/core/logic/src/main/java/org/apache/syncope/core/logic/GroupLogic.java
index 157a7d6..a460d0c 100644
--- a/core/logic/src/main/java/org/apache/syncope/core/logic/GroupLogic.java
+++ b/core/logic/src/main/java/org/apache/syncope/core/logic/GroupLogic.java
@@ -37,8 +37,8 @@ import org.apache.syncope.common.lib.SyncopeConstants;
 import org.apache.syncope.common.lib.patch.GroupPatch;
 import org.apache.syncope.common.lib.patch.StringPatchItem;
 import org.apache.syncope.common.lib.to.ExecTO;
-import org.apache.syncope.common.lib.to.PropagationStatus;
 import org.apache.syncope.common.lib.to.GroupTO;
+import org.apache.syncope.common.lib.to.PropagationStatus;
 import org.apache.syncope.common.lib.to.ProvisioningResult;
 import org.apache.syncope.common.lib.to.TypeExtensionTO;
 import org.apache.syncope.common.lib.types.AnyTypeKind;
@@ -47,28 +47,28 @@ import org.apache.syncope.common.lib.types.ClientExceptionType;
 import org.apache.syncope.common.lib.types.JobType;
 import org.apache.syncope.common.lib.types.PatchOperation;
 import org.apache.syncope.common.lib.types.StandardEntitlement;
-import org.apache.syncope.core.provisioning.api.utils.RealmUtils;
-import org.apache.syncope.core.persistence.api.dao.GroupDAO;
-import org.apache.syncope.core.persistence.api.dao.UserDAO;
-import org.apache.syncope.core.persistence.api.dao.search.OrderByClause;
-import org.apache.syncope.core.persistence.api.dao.search.SearchCond;
-import org.apache.syncope.core.persistence.api.entity.group.Group;
-import org.apache.syncope.core.provisioning.api.GroupProvisioningManager;
-import org.apache.syncope.core.provisioning.api.data.GroupDataBinder;
-import org.apache.syncope.core.spring.security.AuthContextUtils;
-import org.apache.syncope.core.spring.security.DelegatedAdministrationException;
 import org.apache.syncope.core.persistence.api.dao.AnySearchDAO;
 import org.apache.syncope.core.persistence.api.dao.ConfDAO;
+import org.apache.syncope.core.persistence.api.dao.GroupDAO;
 import org.apache.syncope.core.persistence.api.dao.NotFoundException;
 import org.apache.syncope.core.persistence.api.dao.TaskDAO;
+import org.apache.syncope.core.persistence.api.dao.UserDAO;
+import org.apache.syncope.core.persistence.api.dao.search.OrderByClause;
+import org.apache.syncope.core.persistence.api.dao.search.SearchCond;
 import org.apache.syncope.core.persistence.api.entity.EntityFactory;
+import org.apache.syncope.core.persistence.api.entity.group.Group;
 import org.apache.syncope.core.persistence.api.entity.task.SchedTask;
+import org.apache.syncope.core.provisioning.api.GroupProvisioningManager;
 import org.apache.syncope.core.provisioning.api.LogicActions;
+import org.apache.syncope.core.provisioning.api.data.GroupDataBinder;
 import org.apache.syncope.core.provisioning.api.data.TaskDataBinder;
 import org.apache.syncope.core.provisioning.api.job.JobManager;
 import org.apache.syncope.core.provisioning.api.job.JobNamer;
+import org.apache.syncope.core.provisioning.api.utils.RealmUtils;
 import org.apache.syncope.core.provisioning.java.job.GroupMemberProvisionTaskJobDelegate;
 import org.apache.syncope.core.provisioning.java.job.TaskJob;
+import org.apache.syncope.core.spring.security.AuthContextUtils;
+import org.apache.syncope.core.spring.security.DelegatedAdministrationException;
 import org.quartz.JobDataMap;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.scheduling.quartz.SchedulerFactoryBean;

http://git-wip-us.apache.org/repos/asf/syncope/blob/9cc238c9/core/logic/src/main/java/org/apache/syncope/core/logic/UserLogic.java
----------------------------------------------------------------------
diff --git a/core/logic/src/main/java/org/apache/syncope/core/logic/UserLogic.java b/core/logic/src/main/java/org/apache/syncope/core/logic/UserLogic.java
index 24619f0..22e8ccf 100644
--- a/core/logic/src/main/java/org/apache/syncope/core/logic/UserLogic.java
+++ b/core/logic/src/main/java/org/apache/syncope/core/logic/UserLogic.java
@@ -43,19 +43,19 @@ import org.apache.syncope.common.lib.types.AnyTypeKind;
 import org.apache.syncope.common.lib.types.ClientExceptionType;
 import org.apache.syncope.common.lib.types.PatchOperation;
 import org.apache.syncope.common.lib.types.StandardEntitlement;
-import org.apache.syncope.core.persistence.api.dao.NotFoundException;
+import org.apache.syncope.core.persistence.api.dao.AnySearchDAO;
 import org.apache.syncope.core.persistence.api.dao.GroupDAO;
+import org.apache.syncope.core.persistence.api.dao.NotFoundException;
 import org.apache.syncope.core.persistence.api.dao.UserDAO;
 import org.apache.syncope.core.persistence.api.dao.search.OrderByClause;
 import org.apache.syncope.core.persistence.api.dao.search.SearchCond;
 import org.apache.syncope.core.persistence.api.entity.group.Group;
 import org.apache.syncope.core.persistence.api.entity.user.User;
+import org.apache.syncope.core.provisioning.api.LogicActions;
 import org.apache.syncope.core.provisioning.api.UserProvisioningManager;
 import org.apache.syncope.core.provisioning.api.data.UserDataBinder;
-import org.apache.syncope.core.spring.security.AuthContextUtils;
 import org.apache.syncope.core.provisioning.api.serialization.POJOHelper;
-import org.apache.syncope.core.persistence.api.dao.AnySearchDAO;
-import org.apache.syncope.core.provisioning.api.LogicActions;
+import org.apache.syncope.core.spring.security.AuthContextUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.stereotype.Component;

http://git-wip-us.apache.org/repos/asf/syncope/blob/9cc238c9/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/AbstractAnyDAO.java
----------------------------------------------------------------------
diff --git a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/AbstractAnyDAO.java b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/AbstractAnyDAO.java
index 0eb38ac..25bfe50 100644
--- a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/AbstractAnyDAO.java
+++ b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/AbstractAnyDAO.java
@@ -63,26 +63,50 @@ import org.apache.syncope.core.persistence.api.entity.resource.ExternalResource;
 import org.apache.syncope.core.persistence.api.entity.user.UMembership;
 import org.apache.syncope.core.persistence.api.entity.user.User;
 import org.apache.syncope.core.persistence.jpa.entity.AbstractPlainAttrValue;
-import org.springframework.beans.factory.annotation.Autowired;
+import org.apache.syncope.core.spring.ApplicationContextProvider;
 import org.springframework.transaction.annotation.Propagation;
 import org.springframework.transaction.annotation.Transactional;
 
 public abstract class AbstractAnyDAO<A extends Any<?>> extends AbstractDAO<A> implements AnyDAO<A> {
 
-    @Autowired
-    protected PlainSchemaDAO plainSchemaDAO;
+    private PlainSchemaDAO plainSchemaDAO;
 
-    @Autowired
-    protected DerSchemaDAO derSchemaDAO;
+    private DerSchemaDAO derSchemaDAO;
 
-    @Autowired
-    protected AnySearchDAO searchDAO;
+    private AnySearchDAO searchDAO;
 
-    protected AnyUtils anyUtils;
+    private AnyUtils anyUtils;
+
+    private PlainSchemaDAO plainSchemaDAO() {
+        synchronized (this) {
+            if (plainSchemaDAO == null) {
+                plainSchemaDAO = ApplicationContextProvider.getApplicationContext().getBean(PlainSchemaDAO.class);
+            }
+        }
+        return plainSchemaDAO;
+    }
+
+    private DerSchemaDAO derSchemaDAO() {
+        synchronized (this) {
+            if (derSchemaDAO == null) {
+                derSchemaDAO = ApplicationContextProvider.getApplicationContext().getBean(DerSchemaDAO.class);
+            }
+        }
+        return derSchemaDAO;
+    }
+
+    protected AnySearchDAO searchDAO() {
+        synchronized (this) {
+            if (searchDAO == null) {
+                searchDAO = ApplicationContextProvider.getApplicationContext().getBean(AnySearchDAO.class);
+            }
+        }
+        return searchDAO;
+    }
 
     protected abstract AnyUtils init();
 
-    protected AnyUtils getAnyUtils() {
+    protected AnyUtils anyUtils() {
         synchronized (this) {
             if (anyUtils == null) {
                 anyUtils = init();
@@ -115,13 +139,13 @@ public abstract class AbstractAnyDAO<A extends Any<?>> extends AbstractDAO<A> im
     @Override
     @SuppressWarnings("unchecked")
     public A find(final String key) {
-        return (A) entityManager().find(getAnyUtils().anyClass(), key);
+        return (A) entityManager().find(anyUtils().anyClass(), key);
     }
 
     @SuppressWarnings("unchecked")
     @Override
     public A findByWorkflowId(final String workflowId) {
-        Query query = entityManager().createQuery("SELECT e FROM " + getAnyUtils().anyClass().getSimpleName()
+        Query query = entityManager().createQuery("SELECT e FROM " + anyUtils().anyClass().getSimpleName()
                 + " e WHERE e.workflowId = :workflowId", User.class);
         query.setParameter("workflowId", workflowId);
 
@@ -148,15 +172,15 @@ public abstract class AbstractAnyDAO<A extends Any<?>> extends AbstractDAO<A> im
     @Override
     @SuppressWarnings("unchecked")
     public List<A> findByAttrValue(final String schemaKey, final PlainAttrValue attrValue) {
-        PlainSchema schema = plainSchemaDAO.find(schemaKey);
+        PlainSchema schema = plainSchemaDAO().find(schemaKey);
         if (schema == null) {
             LOG.error("Invalid schema name '{}'", schemaKey);
             return Collections.<A>emptyList();
         }
 
         String entityName = schema.isUniqueConstraint()
-                ? getAnyUtils().plainAttrUniqueValueClass().getName()
-                : getAnyUtils().plainAttrValueClass().getName();
+                ? anyUtils().plainAttrUniqueValueClass().getName()
+                : anyUtils().plainAttrValueClass().getName();
         Query query = findByAttrValueQuery(entityName);
         query.setParameter("schemaKey", schemaKey);
         query.setParameter("stringValue", attrValue.getStringValue());
@@ -184,7 +208,7 @@ public abstract class AbstractAnyDAO<A extends Any<?>> extends AbstractDAO<A> im
 
     @Override
     public A findByAttrUniqueValue(final String schemaKey, final PlainAttrValue attrUniqueValue) {
-        PlainSchema schema = plainSchemaDAO.find(schemaKey);
+        PlainSchema schema = plainSchemaDAO().find(schemaKey);
         if (schema == null) {
             LOG.error("Invalid schema name '{}'", schemaKey);
             return null;
@@ -296,7 +320,7 @@ public abstract class AbstractAnyDAO<A extends Any<?>> extends AbstractDAO<A> im
             if (!used.contains(identifiers.get(i))) {
 
                 // verify schema existence and get schema type
-                PlainSchema schema = plainSchemaDAO.find(identifiers.get(i));
+                PlainSchema schema = plainSchemaDAO().find(identifiers.get(i));
                 if (schema == null) {
                     LOG.error("Invalid schema id '{}'", identifiers.get(i));
                     throw new IllegalArgumentException("Invalid schema id " + identifiers.get(i));
@@ -351,7 +375,7 @@ public abstract class AbstractAnyDAO<A extends Any<?>> extends AbstractDAO<A> im
 
     @Override
     public List<A> findByDerAttrValue(final String schemaKey, final String value) {
-        DerSchema schema = derSchemaDAO.find(schemaKey);
+        DerSchema schema = derSchemaDAO().find(schemaKey);
         if (schema == null) {
             LOG.error("Invalid schema name '{}'", schemaKey);
             return Collections.<A>emptyList();
@@ -368,8 +392,8 @@ public abstract class AbstractAnyDAO<A extends Any<?>> extends AbstractDAO<A> im
             }
 
             querystring.append("SELECT a.owner_id ").
-                    append("FROM ").append(getAnyUtils().plainAttrClass().getSimpleName().substring(3)).append(" a, ").
-                    append(getAnyUtils().plainAttrValueClass().getSimpleName().substring(3)).append(" v, ").
+                    append("FROM ").append(anyUtils().plainAttrClass().getSimpleName().substring(3)).append(" a, ").
+                    append(anyUtils().plainAttrValueClass().getSimpleName().substring(3)).append(" v, ").
                     append(PlainSchema.class.getSimpleName()).append(" s ").
                     append("WHERE ").append(clause);
 
@@ -394,8 +418,7 @@ public abstract class AbstractAnyDAO<A extends Any<?>> extends AbstractDAO<A> im
     @SuppressWarnings("unchecked")
     @Override
     public List<A> findByResource(final ExternalResource resource) {
-        Query query = entityManager().createQuery(
-                "SELECT e FROM " + getAnyUtils().anyClass().getSimpleName() + " e "
+        Query query = entityManager().createQuery("SELECT e FROM " + anyUtils().anyClass().getSimpleName() + " e "
                 + "WHERE :resource MEMBER OF e.resources");
         query.setParameter("resource", resource);
 
@@ -417,8 +440,8 @@ public abstract class AbstractAnyDAO<A extends Any<?>> extends AbstractDAO<A> im
     public List<A> findAll(final Set<String> adminRealms,
             final int page, final int itemsPerPage, final List<OrderByClause> orderBy) {
 
-        return searchDAO.search(adminRealms, getAllMatchingCond(), page, itemsPerPage, orderBy,
-                getAnyUtils().getAnyTypeKind());
+        return searchDAO().search(adminRealms, getAllMatchingCond(), page, itemsPerPage, orderBy,
+                anyUtils().getAnyTypeKind());
     }
 
     @Transactional(propagation = Propagation.REQUIRES_NEW, readOnly = true)
@@ -481,7 +504,7 @@ public abstract class AbstractAnyDAO<A extends Any<?>> extends AbstractDAO<A> im
 
     @Override
     public final int count(final Set<String> adminRealms) {
-        return searchDAO.count(adminRealms, getAllMatchingCond(), getAnyUtils().getAnyTypeKind());
+        return searchDAO().count(adminRealms, getAllMatchingCond(), anyUtils().getAnyTypeKind());
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/syncope/blob/9cc238c9/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/JPAAnyObjectDAO.java
----------------------------------------------------------------------
diff --git a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/JPAAnyObjectDAO.java b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/JPAAnyObjectDAO.java
index 2eae708..164f9a3 100644
--- a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/JPAAnyObjectDAO.java
+++ b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/JPAAnyObjectDAO.java
@@ -58,7 +58,7 @@ import org.apache.syncope.core.persistence.jpa.entity.anyobject.JPAARelationship
 import org.apache.syncope.core.persistence.jpa.entity.anyobject.JPAAnyObject;
 import org.apache.syncope.core.persistence.jpa.entity.group.JPAGroup;
 import org.apache.syncope.core.persistence.jpa.entity.user.JPAURelationship;
-import org.springframework.beans.factory.annotation.Autowired;
+import org.apache.syncope.core.spring.ApplicationContextProvider;
 import org.springframework.stereotype.Repository;
 import org.springframework.transaction.annotation.Propagation;
 import org.springframework.transaction.annotation.Transactional;
@@ -66,12 +66,28 @@ import org.springframework.transaction.annotation.Transactional;
 @Repository
 public class JPAAnyObjectDAO extends AbstractAnyDAO<AnyObject> implements AnyObjectDAO {
 
-    @Autowired
     private UserDAO userDAO;
 
-    @Autowired
     private GroupDAO groupDAO;
 
+    private UserDAO userDAO() {
+        synchronized (this) {
+            if (userDAO == null) {
+                userDAO = ApplicationContextProvider.getApplicationContext().getBean(UserDAO.class);
+            }
+        }
+        return userDAO;
+    }
+
+    private GroupDAO groupDAO() {
+        synchronized (this) {
+            if (groupDAO == null) {
+                groupDAO = ApplicationContextProvider.getApplicationContext().getBean(GroupDAO.class);
+            }
+        }
+        return groupDAO;
+    }
+
     @Override
     public Map<AnyType, Integer> countByType() {
         Query query = entityManager().createQuery(
@@ -182,7 +198,7 @@ public class JPAAnyObjectDAO extends AbstractAnyDAO<AnyObject> implements AnyObj
     public AnyObject save(final AnyObject anyObject) {
         AnyObject merged = super.save(anyObject);
 
-        groupDAO.refreshDynMemberships(merged);
+        groupDAO().refreshDynMemberships(merged);
 
         return merged;
     }
@@ -201,7 +217,7 @@ public class JPAAnyObjectDAO extends AbstractAnyDAO<AnyObject> implements AnyObj
         }
         for (URelationship relationship : findURelationships(any)) {
             relationship.getLeftEnd().getRelationships().remove(relationship);
-            userDAO.save(relationship.getLeftEnd());
+            userDAO().save(relationship.getLeftEnd());
 
             entityManager().remove(relationship);
         }
@@ -227,7 +243,7 @@ public class JPAAnyObjectDAO extends AbstractAnyDAO<AnyObject> implements AnyObj
                     ? (String) ((Object[]) key)[0]
                     : ((String) key);
 
-            Group group = groupDAO.find(actualKey);
+            Group group = groupDAO().find(actualKey);
             if (group == null) {
                 LOG.error("Could not find group with id {}, even though returned by the native query", actualKey);
             } else if (!result.contains(group)) {

http://git-wip-us.apache.org/repos/asf/syncope/blob/9cc238c9/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/JPAConfDAO.java
----------------------------------------------------------------------
diff --git a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/JPAConfDAO.java b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/JPAConfDAO.java
index 2366016..3e4ea2c 100644
--- a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/JPAConfDAO.java
+++ b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/JPAConfDAO.java
@@ -29,7 +29,7 @@ import org.apache.syncope.core.persistence.jpa.entity.conf.JPACPlainAttr;
 import org.apache.syncope.core.persistence.jpa.entity.conf.JPACPlainAttrUniqueValue;
 import org.apache.syncope.core.persistence.jpa.entity.conf.JPACPlainAttrValue;
 import org.apache.syncope.core.persistence.jpa.entity.conf.JPAConf;
-import org.springframework.beans.factory.annotation.Autowired;
+import org.apache.syncope.core.spring.ApplicationContextProvider;
 import org.springframework.stereotype.Repository;
 import org.springframework.transaction.annotation.Transactional;
 
@@ -38,9 +38,17 @@ public class JPAConfDAO extends AbstractDAO<Conf> implements ConfDAO {
 
     private static final String KEY = "cd64d66f-6fff-4008-b966-a06b1cc1436d";
 
-    @Autowired
     private PlainSchemaDAO schemaDAO;
 
+    private PlainSchemaDAO schemaDAO() {
+        synchronized (this) {
+            if (schemaDAO == null) {
+                schemaDAO = ApplicationContextProvider.getApplicationContext().getBean(PlainSchemaDAO.class);
+            }
+        }
+        return schemaDAO;
+    }
+
     @Override
     public Conf get() {
         Conf instance = entityManager().find(JPAConf.class, KEY);
@@ -65,10 +73,10 @@ public class JPAConfDAO extends AbstractDAO<Conf> implements ConfDAO {
     public CPlainAttr find(final String key, final String defaultValue) {
         CPlainAttr result = find(key);
         if (result == null) {
-            PlainSchema schema = schemaDAO.find(key);
+            PlainSchema schema = schemaDAO().find(key);
             if (schema != null) {
                 JPACPlainAttr newAttr = new JPACPlainAttr();
-                newAttr.setSchema(schemaDAO.find(key));
+                newAttr.setSchema(schema);
 
                 PlainAttrValue attrValue;
                 if (newAttr.getSchema().isUniqueConstraint()) {

http://git-wip-us.apache.org/repos/asf/syncope/blob/9cc238c9/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/JPAExternalResourceDAO.java
----------------------------------------------------------------------
diff --git a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/JPAExternalResourceDAO.java b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/JPAExternalResourceDAO.java
index 0658179..222e645 100644
--- a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/JPAExternalResourceDAO.java
+++ b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/JPAExternalResourceDAO.java
@@ -49,6 +49,7 @@ import org.apache.syncope.core.persistence.jpa.entity.resource.JPAExternalResour
 import org.apache.syncope.core.persistence.jpa.entity.resource.JPAMapping;
 import org.apache.syncope.core.persistence.jpa.entity.resource.JPAProvision;
 import org.apache.syncope.core.provisioning.api.ConnectorRegistry;
+import org.apache.syncope.core.spring.ApplicationContextProvider;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Repository;
 import org.springframework.transaction.annotation.Transactional;
@@ -57,25 +58,73 @@ import org.springframework.transaction.annotation.Transactional;
 public class JPAExternalResourceDAO extends AbstractDAO<ExternalResource> implements ExternalResourceDAO {
 
     @Autowired
+    private ConnectorRegistry connRegistry;
+
     private TaskDAO taskDAO;
 
-    @Autowired
     private AnyObjectDAO anyObjectDAO;
 
-    @Autowired
     private UserDAO userDAO;
 
-    @Autowired
     private GroupDAO groupDAO;
 
-    @Autowired
     private PolicyDAO policyDAO;
 
-    @Autowired
     private VirSchemaDAO virSchemaDAO;
 
-    @Autowired
-    private ConnectorRegistry connRegistry;
+    private TaskDAO taskDAO() {
+        synchronized (this) {
+            if (taskDAO == null) {
+                taskDAO = ApplicationContextProvider.getApplicationContext().getBean(TaskDAO.class);
+            }
+        }
+        return taskDAO;
+    }
+
+    private AnyObjectDAO anyObjectDAO() {
+        synchronized (this) {
+            if (anyObjectDAO == null) {
+                anyObjectDAO = ApplicationContextProvider.getApplicationContext().getBean(AnyObjectDAO.class);
+            }
+        }
+        return anyObjectDAO;
+    }
+
+    private UserDAO userDAO() {
+        synchronized (this) {
+            if (userDAO == null) {
+                userDAO = ApplicationContextProvider.getApplicationContext().getBean(UserDAO.class);
+            }
+        }
+        return userDAO;
+    }
+
+    private GroupDAO groupDAO() {
+        synchronized (this) {
+            if (groupDAO == null) {
+                groupDAO = ApplicationContextProvider.getApplicationContext().getBean(GroupDAO.class);
+            }
+        }
+        return groupDAO;
+    }
+
+    private PolicyDAO policyDAO() {
+        synchronized (this) {
+            if (policyDAO == null) {
+                policyDAO = ApplicationContextProvider.getApplicationContext().getBean(PolicyDAO.class);
+            }
+        }
+        return policyDAO;
+    }
+
+    private VirSchemaDAO virSchemaDAO() {
+        synchronized (this) {
+            if (virSchemaDAO == null) {
+                virSchemaDAO = ApplicationContextProvider.getApplicationContext().getBean(VirSchemaDAO.class);
+            }
+        }
+        return virSchemaDAO;
+    }
 
     @Override
     public int count() {
@@ -191,20 +240,20 @@ public class JPAExternalResourceDAO extends AbstractDAO<ExternalResource> implem
             return;
         }
 
-        taskDAO.deleteAll(resource, TaskType.PROPAGATION);
-        taskDAO.deleteAll(resource, TaskType.PULL);
-        taskDAO.deleteAll(resource, TaskType.PUSH);
+        taskDAO().deleteAll(resource, TaskType.PROPAGATION);
+        taskDAO().deleteAll(resource, TaskType.PULL);
+        taskDAO().deleteAll(resource, TaskType.PUSH);
 
-        for (AnyObject anyObject : anyObjectDAO.findByResource(resource)) {
+        for (AnyObject anyObject : anyObjectDAO().findByResource(resource)) {
             anyObject.getResources().remove(resource);
         }
-        for (User user : userDAO.findByResource(resource)) {
+        for (User user : userDAO().findByResource(resource)) {
             user.getResources().remove(resource);
         }
-        for (Group group : groupDAO.findByResource(resource)) {
+        for (Group group : groupDAO().findByResource(resource)) {
             group.getResources().remove(resource);
         }
-        for (AccountPolicy policy : policyDAO.findByResource(resource)) {
+        for (AccountPolicy policy : policyDAO().findByResource(resource)) {
             policy.getResources().remove(resource);
         }
 
@@ -216,8 +265,8 @@ public class JPAExternalResourceDAO extends AbstractDAO<ExternalResource> implem
             provision.setMapping(null);
             provision.setResource(null);
 
-            for (VirSchema schema : virSchemaDAO.findByProvision(provision)) {
-                virSchemaDAO.delete(schema.getKey());
+            for (VirSchema schema : virSchemaDAO().findByProvision(provision)) {
+                virSchemaDAO().delete(schema.getKey());
             }
         }
 

http://git-wip-us.apache.org/repos/asf/syncope/blob/9cc238c9/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/JPAGroupDAO.java
----------------------------------------------------------------------
diff --git a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/JPAGroupDAO.java b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/JPAGroupDAO.java
index 0bcdee2..15a9d3f 100644
--- a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/JPAGroupDAO.java
+++ b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/JPAGroupDAO.java
@@ -58,6 +58,7 @@ import org.apache.syncope.core.persistence.jpa.entity.JPAAnyUtilsFactory;
 import org.apache.syncope.core.persistence.jpa.entity.anyobject.JPAAMembership;
 import org.apache.syncope.core.persistence.jpa.entity.group.JPATypeExtension;
 import org.apache.syncope.core.persistence.jpa.entity.user.JPAUMembership;
+import org.apache.syncope.core.spring.ApplicationContextProvider;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Repository;
 import org.springframework.transaction.annotation.Transactional;
@@ -66,13 +67,29 @@ import org.springframework.transaction.annotation.Transactional;
 public class JPAGroupDAO extends AbstractAnyDAO<Group> implements GroupDAO {
 
     @Autowired
+    private PlainAttrDAO plainAttrDAO;
+
     private AnyObjectDAO anyObjectDAO;
 
-    @Autowired
     private UserDAO userDAO;
 
-    @Autowired
-    private PlainAttrDAO plainAttrDAO;
+    private UserDAO userDAO() {
+        synchronized (this) {
+            if (userDAO == null) {
+                userDAO = ApplicationContextProvider.getApplicationContext().getBean(UserDAO.class);
+            }
+        }
+        return userDAO;
+    }
+
+    private AnyObjectDAO anyObjectDAO() {
+        synchronized (this) {
+            if (anyObjectDAO == null) {
+                anyObjectDAO = ApplicationContextProvider.getApplicationContext().getBean(AnyObjectDAO.class);
+            }
+        }
+        return anyObjectDAO;
+    }
 
     @Override
     protected AnyUtils init() {
@@ -152,14 +169,14 @@ public class JPAGroupDAO extends AbstractAnyDAO<Group> implements GroupDAO {
     @Transactional(readOnly = true)
     @Override
     public List<Group> findOwnedByUser(final String userKey) {
-        User owner = userDAO.find(userKey);
+        User owner = userDAO().find(userKey);
         if (owner == null) {
             return Collections.<Group>emptyList();
         }
 
         StringBuilder queryString = new StringBuilder("SELECT e FROM ").append(JPAGroup.class.getSimpleName()).
                 append(" e WHERE e.userOwner=:owner ");
-        for (String groupKey : userDAO.findAllGroupKeys(owner)) {
+        for (String groupKey : userDAO().findAllGroupKeys(owner)) {
             queryString.append("OR e.groupOwner.id='").append(groupKey).append("' ");
         }
 
@@ -218,7 +235,7 @@ public class JPAGroupDAO extends AbstractAnyDAO<Group> implements GroupDAO {
 
         // refresh dynaminc memberships
         if (merged.getUDynMembership() != null) {
-            List<User> matching = searchDAO.search(
+            List<User> matching = searchDAO().search(
                     buildDynMembershipCond(merged.getUDynMembership().getFIQLCond(), merged.getRealm()),
                     AnyTypeKind.USER);
 
@@ -228,7 +245,7 @@ public class JPAGroupDAO extends AbstractAnyDAO<Group> implements GroupDAO {
             }
         }
         for (ADynGroupMembership memb : merged.getADynMemberships()) {
-            List<AnyObject> matching = searchDAO.search(
+            List<AnyObject> matching = searchDAO().search(
                     buildDynMembershipCond(memb.getFIQLCond(), merged.getRealm()),
                     AnyTypeKind.ANY_OBJECT);
 
@@ -254,7 +271,7 @@ public class JPAGroupDAO extends AbstractAnyDAO<Group> implements GroupDAO {
                 plainAttrDAO.delete(attr);
             }
 
-            anyObjectDAO.save(leftEnd);
+            anyObjectDAO().save(leftEnd);
         }
         for (UMembership membership : findUMemberships(group)) {
             User leftEnd = membership.getLeftEnd();
@@ -267,7 +284,7 @@ public class JPAGroupDAO extends AbstractAnyDAO<Group> implements GroupDAO {
                 plainAttrDAO.delete(attr);
             }
 
-            userDAO.save(leftEnd);
+            userDAO().save(leftEnd);
         }
 
         entityManager().remove(group);
@@ -288,7 +305,7 @@ public class JPAGroupDAO extends AbstractAnyDAO<Group> implements GroupDAO {
     public void refreshDynMemberships(final AnyObject anyObject) {
         for (Group group : findAll()) {
             for (ADynGroupMembership memb : group.getADynMemberships()) {
-                if (searchDAO.matches(
+                if (searchDAO().matches(
                         anyObject,
                         buildDynMembershipCond(memb.getFIQLCond(), group.getRealm()))) {
 
@@ -305,7 +322,7 @@ public class JPAGroupDAO extends AbstractAnyDAO<Group> implements GroupDAO {
     public void refreshDynMemberships(final User user) {
         for (Group group : findAll()) {
             if (group.getUDynMembership() != null) {
-                if (searchDAO.matches(
+                if (searchDAO().matches(
                         user,
                         buildDynMembershipCond(group.getUDynMembership().getFIQLCond(), group.getRealm()))) {
 

http://git-wip-us.apache.org/repos/asf/syncope/blob/9cc238c9/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/JPAPlainSchemaDAO.java
----------------------------------------------------------------------
diff --git a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/JPAPlainSchemaDAO.java b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/JPAPlainSchemaDAO.java
index 2e3bef5..dfc3840 100644
--- a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/JPAPlainSchemaDAO.java
+++ b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/JPAPlainSchemaDAO.java
@@ -32,6 +32,7 @@ import org.apache.syncope.core.persistence.api.entity.PlainAttr;
 import org.apache.syncope.core.persistence.api.entity.PlainSchema;
 import org.apache.syncope.core.persistence.jpa.entity.JPAAnyUtilsFactory;
 import org.apache.syncope.core.persistence.jpa.entity.JPAPlainSchema;
+import org.apache.syncope.core.spring.ApplicationContextProvider;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Repository;
 
@@ -41,9 +42,17 @@ public class JPAPlainSchemaDAO extends AbstractDAO<PlainSchema> implements Plain
     @Autowired
     private PlainAttrDAO plainAttrDAO;
 
-    @Autowired
     private ExternalResourceDAO resourceDAO;
 
+    private ExternalResourceDAO resourceDAO() {
+        synchronized (this) {
+            if (resourceDAO == null) {
+                resourceDAO = ApplicationContextProvider.getApplicationContext().getBean(ExternalResourceDAO.class);
+            }
+        }
+        return resourceDAO;
+    }
+
     @Override
     public PlainSchema find(final String key) {
         return entityManager().find(JPAPlainSchema.class, key);
@@ -101,7 +110,7 @@ public class JPAPlainSchemaDAO extends AbstractDAO<PlainSchema> implements Plain
                 plainAttrDAO.delete(attr.getKey(), anyUtils.plainAttrClass());
             }
 
-            resourceDAO.deleteMapping(key);
+            resourceDAO().deleteMapping(key);
         }
 
         if (schema.getAnyTypeClass() != null) {

http://git-wip-us.apache.org/repos/asf/syncope/blob/9cc238c9/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/JPARoleDAO.java
----------------------------------------------------------------------
diff --git a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/JPARoleDAO.java b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/JPARoleDAO.java
index b636fc6..dbf4f66 100644
--- a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/JPARoleDAO.java
+++ b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/JPARoleDAO.java
@@ -30,16 +30,24 @@ import org.apache.syncope.core.persistence.api.entity.Role;
 import org.apache.syncope.core.persistence.api.entity.user.User;
 import org.apache.syncope.core.persistence.jpa.entity.JPARole;
 import org.apache.syncope.core.persistence.jpa.entity.user.JPAUser;
-import org.springframework.beans.factory.annotation.Autowired;
+import org.apache.syncope.core.spring.ApplicationContextProvider;
 import org.springframework.stereotype.Repository;
 import org.springframework.transaction.annotation.Transactional;
 
 @Repository
 public class JPARoleDAO extends AbstractDAO<Role> implements RoleDAO {
 
-    @Autowired
     private AnySearchDAO searchDAO;
 
+    private AnySearchDAO searchDAO() {
+        synchronized (this) {
+            if (searchDAO == null) {
+                searchDAO = ApplicationContextProvider.getApplicationContext().getBean(AnySearchDAO.class);
+            }
+        }
+        return searchDAO;
+    }
+
     @Override
     public int count() {
         Query query = entityManager().createQuery(
@@ -71,7 +79,7 @@ public class JPARoleDAO extends AbstractDAO<Role> implements RoleDAO {
     public Role save(final Role role) {
         // refresh dynaminc memberships
         if (role.getDynMembership() != null) {
-            List<User> matchingUsers = searchDAO.search(
+            List<User> matchingUsers = searchDAO().search(
                     SearchCondConverter.convert(role.getDynMembership().getFIQLCond()), AnyTypeKind.USER);
 
             role.getDynMembership().getMembers().clear();
@@ -111,7 +119,7 @@ public class JPARoleDAO extends AbstractDAO<Role> implements RoleDAO {
     public void refreshDynMemberships(final User user) {
         for (Role role : findAll()) {
             if (role.getDynMembership() != null) {
-                if (searchDAO.matches(user, SearchCondConverter.convert(role.getDynMembership().getFIQLCond()))) {
+                if (searchDAO().matches(user, SearchCondConverter.convert(role.getDynMembership().getFIQLCond()))) {
                     role.getDynMembership().add(user);
                 } else {
                     role.getDynMembership().getMembers().remove(user);

http://git-wip-us.apache.org/repos/asf/syncope/blob/9cc238c9/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/JPAUserDAO.java
----------------------------------------------------------------------
diff --git a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/JPAUserDAO.java b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/JPAUserDAO.java
index 3580136..3dff783 100644
--- a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/JPAUserDAO.java
+++ b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/JPAUserDAO.java
@@ -89,12 +89,6 @@ public class JPAUserDAO extends AbstractAnyDAO<User> implements UserDAO {
             Pattern.compile("^" + SyncopeConstants.NAME_PATTERN, Pattern.CASE_INSENSITIVE | Pattern.UNICODE_CASE);
 
     @Autowired
-    private RealmDAO realmDAO;
-
-    @Autowired
-    private GroupDAO groupDAO;
-
-    @Autowired
     private RoleDAO roleDAO;
 
     @Autowired
@@ -109,6 +103,28 @@ public class JPAUserDAO extends AbstractAnyDAO<User> implements UserDAO {
     @Resource(name = "anonymousUser")
     private String anonymousUser;
 
+    private RealmDAO realmDAO;
+
+    private GroupDAO groupDAO;
+
+    private RealmDAO realmDAO() {
+        synchronized (this) {
+            if (realmDAO == null) {
+                realmDAO = ApplicationContextProvider.getApplicationContext().getBean(RealmDAO.class);
+            }
+        }
+        return realmDAO;
+    }
+
+    private GroupDAO groupDAO() {
+        synchronized (this) {
+            if (groupDAO == null) {
+                groupDAO = ApplicationContextProvider.getApplicationContext().getBean(GroupDAO.class);
+            }
+        }
+        return groupDAO;
+    }
+
     @Override
     protected AnyUtils init() {
         return new JPAAnyUtilsFactory().getInstance(AnyTypeKind.USER);
@@ -244,7 +260,7 @@ public class JPAUserDAO extends AbstractAnyDAO<User> implements UserDAO {
         }
 
         // add realm policies
-        for (Realm realm : realmDAO.findAncestors(user.getRealm())) {
+        for (Realm realm : realmDAO().findAncestors(user.getRealm())) {
             policy = realm.getPasswordPolicy();
             if (policy != null) {
                 policies.add(policy);
@@ -266,7 +282,7 @@ public class JPAUserDAO extends AbstractAnyDAO<User> implements UserDAO {
         }
 
         // add realm policies
-        for (Realm realm : realmDAO.findAncestors(user.getRealm())) {
+        for (Realm realm : realmDAO().findAncestors(user.getRealm())) {
             AccountPolicy policy = realm.getAccountPolicy();
             if (policy != null) {
                 policies.add(policy);
@@ -415,7 +431,7 @@ public class JPAUserDAO extends AbstractAnyDAO<User> implements UserDAO {
         }
 
         roleDAO.refreshDynMemberships(merged);
-        groupDAO.refreshDynMemberships(merged);
+        groupDAO().refreshDynMemberships(merged);
 
         return merged;
     }
@@ -483,7 +499,7 @@ public class JPAUserDAO extends AbstractAnyDAO<User> implements UserDAO {
                     ? (String) ((Object[]) key)[0]
                     : ((String) key);
 
-            Group group = groupDAO.find(actualKey);
+            Group group = groupDAO().find(actualKey);
             if (group == null) {
                 LOG.error("Could not find group with id {}, even though returned by the native query", actualKey);
             } else if (!result.contains(group)) {

http://git-wip-us.apache.org/repos/asf/syncope/blob/9cc238c9/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/JPAVirSchemaDAO.java
----------------------------------------------------------------------
diff --git a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/JPAVirSchemaDAO.java b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/JPAVirSchemaDAO.java
index 4636f7d..4dfc8db 100644
--- a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/JPAVirSchemaDAO.java
+++ b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/JPAVirSchemaDAO.java
@@ -38,15 +38,23 @@ import org.apache.syncope.core.persistence.jpa.entity.policy.JPAPullPolicy;
 import org.apache.syncope.core.persistence.jpa.entity.resource.JPAExternalResource;
 import org.apache.syncope.core.persistence.jpa.entity.resource.JPAMapping;
 import org.apache.syncope.core.persistence.jpa.entity.resource.JPAProvision;
-import org.springframework.beans.factory.annotation.Autowired;
+import org.apache.syncope.core.spring.ApplicationContextProvider;
 import org.springframework.stereotype.Repository;
 
 @Repository
 public class JPAVirSchemaDAO extends AbstractDAO<VirSchema> implements VirSchemaDAO {
 
-    @Autowired
     private ExternalResourceDAO resourceDAO;
 
+    private ExternalResourceDAO resourceDAO() {
+        synchronized (this) {
+            if (resourceDAO == null) {
+                resourceDAO = ApplicationContextProvider.getApplicationContext().getBean(ExternalResourceDAO.class);
+            }
+        }
+        return resourceDAO;
+    }
+
     @Override
     public VirSchema find(final String key) {
         return entityManager().find(JPAVirSchema.class, key);
@@ -118,7 +126,7 @@ public class JPAVirSchemaDAO extends AbstractDAO<VirSchema> implements VirSchema
             return;
         }
 
-        resourceDAO.deleteMapping(key);
+        resourceDAO().deleteMapping(key);
 
         if (schema.getAnyTypeClass() != null) {
             schema.getAnyTypeClass().getVirSchemas().remove(schema);

http://git-wip-us.apache.org/repos/asf/syncope/blob/9cc238c9/core/persistence-jpa/src/main/resources/domains/MasterDomain.xml
----------------------------------------------------------------------
diff --git a/core/persistence-jpa/src/main/resources/domains/MasterDomain.xml b/core/persistence-jpa/src/main/resources/domains/MasterDomain.xml
index f949e32..b5363e4 100644
--- a/core/persistence-jpa/src/main/resources/domains/MasterDomain.xml
+++ b/core/persistence-jpa/src/main/resources/domains/MasterDomain.xml
@@ -43,7 +43,7 @@ under the License.
   <!-- Use JNDI datasource as default but, when not available, revert to
   local datasource, with different properties for execution and testing. 
   In any case, get all JDBC connections with a determined isolation level. -->
-  <bean id="MasterDataSource" class="org.springframework.jndi.JndiObjectFactoryBean">
+  <bean id="MasterDataSource" class="org.springframework.jndi.JndiObjectFactoryBean" primary="true">
     <property name="jndiName" value="java:comp/env/jdbc/syncopeMasterDataSource"/>
     <property name="defaultObject" ref="localMasterDataSource"/>
   </bean>

http://git-wip-us.apache.org/repos/asf/syncope/blob/9cc238c9/core/persistence-jpa/src/test/resources/domains/TwoDomain.xml
----------------------------------------------------------------------
diff --git a/core/persistence-jpa/src/test/resources/domains/TwoDomain.xml b/core/persistence-jpa/src/test/resources/domains/TwoDomain.xml
index 506c068..46e1c79 100644
--- a/core/persistence-jpa/src/test/resources/domains/TwoDomain.xml
+++ b/core/persistence-jpa/src/test/resources/domains/TwoDomain.xml
@@ -43,7 +43,7 @@ under the License.
   <!-- Use JNDI datasource as default but, when not available, revert to
   local datasource, with different properties for execution and testing. 
   In any case, get all JDBC connections with a determined isolation level. -->
-  <bean id="TwoDataSource" class="org.springframework.jndi.JndiObjectFactoryBean">
+  <bean id="TwoDataSource" class="org.springframework.jndi.JndiObjectFactoryBean" primary="true">
     <property name="jndiName" value="java:comp/env/jdbc/syncopeTwoDataSource"/>
     <property name="defaultObject" ref="localTwoDataSource"/>
   </bean>
@@ -122,4 +122,4 @@ under the License.
   
   <tx:annotation-driven transaction-manager="TwoTransactionManager"/>
 
-</beans>
\ No newline at end of file
+</beans>

http://git-wip-us.apache.org/repos/asf/syncope/blob/9cc238c9/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/data/AbstractAnyDataBinder.java
----------------------------------------------------------------------
diff --git a/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/data/AbstractAnyDataBinder.java b/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/data/AbstractAnyDataBinder.java
index 0bb5e25..160c702 100644
--- a/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/data/AbstractAnyDataBinder.java
+++ b/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/data/AbstractAnyDataBinder.java
@@ -40,57 +40,54 @@ import org.apache.syncope.common.lib.types.ClientExceptionType;
 import org.apache.syncope.common.lib.types.PatchOperation;
 import org.apache.syncope.common.lib.types.ResourceOperation;
 import org.apache.syncope.core.persistence.api.attrvalue.validation.InvalidPlainAttrValueException;
-import org.apache.syncope.core.persistence.api.dao.DerSchemaDAO;
-import org.apache.syncope.core.persistence.api.dao.ExternalResourceDAO;
-import org.apache.syncope.core.persistence.api.dao.PlainAttrDAO;
-import org.apache.syncope.core.persistence.api.dao.PlainAttrValueDAO;
-import org.apache.syncope.core.persistence.api.dao.PlainSchemaDAO;
-import org.apache.syncope.core.persistence.api.dao.PolicyDAO;
-import org.apache.syncope.core.persistence.api.dao.GroupDAO;
-import org.apache.syncope.core.persistence.api.dao.UserDAO;
-import org.apache.syncope.core.persistence.api.dao.VirSchemaDAO;
-import org.apache.syncope.core.persistence.api.entity.DerSchema;
-import org.apache.syncope.core.persistence.api.entity.EntityFactory;
-import org.apache.syncope.core.persistence.api.entity.PlainAttr;
-import org.apache.syncope.core.persistence.api.entity.PlainAttrValue;
-import org.apache.syncope.core.persistence.api.entity.PlainSchema;
-import org.apache.syncope.core.persistence.api.entity.group.Group;
-import org.apache.syncope.core.provisioning.api.PropagationByResource;
 import org.apache.syncope.core.persistence.api.dao.AllowedSchemas;
-import org.apache.syncope.core.provisioning.java.utils.ConnObjectUtils;
-import org.apache.syncope.core.provisioning.java.jexl.JexlUtils;
-import org.apache.syncope.core.provisioning.api.utils.EntityUtils;
 import org.apache.syncope.core.persistence.api.dao.AnyObjectDAO;
 import org.apache.syncope.core.persistence.api.dao.AnySearchDAO;
 import org.apache.syncope.core.persistence.api.dao.AnyTypeClassDAO;
+import org.apache.syncope.core.persistence.api.dao.ExternalResourceDAO;
+import org.apache.syncope.core.persistence.api.dao.GroupDAO;
 import org.apache.syncope.core.persistence.api.dao.NotFoundException;
+import org.apache.syncope.core.persistence.api.dao.PlainAttrDAO;
+import org.apache.syncope.core.persistence.api.dao.PlainAttrValueDAO;
+import org.apache.syncope.core.persistence.api.dao.PlainSchemaDAO;
+import org.apache.syncope.core.persistence.api.dao.PolicyDAO;
 import org.apache.syncope.core.persistence.api.dao.RealmDAO;
 import org.apache.syncope.core.persistence.api.dao.RelationshipTypeDAO;
+import org.apache.syncope.core.persistence.api.dao.UserDAO;
 import org.apache.syncope.core.persistence.api.entity.Any;
 import org.apache.syncope.core.persistence.api.entity.AnyTypeClass;
 import org.apache.syncope.core.persistence.api.entity.AnyUtils;
 import org.apache.syncope.core.persistence.api.entity.AnyUtilsFactory;
+import org.apache.syncope.core.persistence.api.entity.DerSchema;
+import org.apache.syncope.core.persistence.api.entity.EntityFactory;
 import org.apache.syncope.core.persistence.api.entity.GroupablePlainAttr;
+import org.apache.syncope.core.persistence.api.entity.GroupableRelatable;
 import org.apache.syncope.core.persistence.api.entity.Membership;
+import org.apache.syncope.core.persistence.api.entity.PlainAttr;
+import org.apache.syncope.core.persistence.api.entity.PlainAttrValue;
+import org.apache.syncope.core.persistence.api.entity.PlainSchema;
 import org.apache.syncope.core.persistence.api.entity.Realm;
 import org.apache.syncope.core.persistence.api.entity.Relationship;
 import org.apache.syncope.core.persistence.api.entity.VirSchema;
 import org.apache.syncope.core.persistence.api.entity.anyobject.AnyObject;
+import org.apache.syncope.core.persistence.api.entity.group.Group;
 import org.apache.syncope.core.persistence.api.entity.resource.ExternalResource;
 import org.apache.syncope.core.persistence.api.entity.resource.MappingItem;
 import org.apache.syncope.core.persistence.api.entity.resource.Provision;
 import org.apache.syncope.core.persistence.api.entity.user.User;
 import org.apache.syncope.core.provisioning.api.DerAttrHandler;
+import org.apache.syncope.core.provisioning.api.IntAttrName;
 import org.apache.syncope.core.provisioning.api.MappingManager;
+import org.apache.syncope.core.provisioning.api.PropagationByResource;
 import org.apache.syncope.core.provisioning.api.VirAttrHandler;
+import org.apache.syncope.core.provisioning.api.data.SchemaDataBinder;
+import org.apache.syncope.core.provisioning.api.utils.EntityUtils;
+import org.apache.syncope.core.provisioning.java.IntAttrNameParser;
+import org.apache.syncope.core.provisioning.java.jexl.JexlUtils;
+import org.apache.syncope.core.provisioning.java.utils.MappingUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.apache.syncope.core.persistence.api.entity.GroupableRelatable;
-import org.apache.syncope.core.provisioning.java.IntAttrNameParser;
-import org.apache.syncope.core.provisioning.api.IntAttrName;
-import org.apache.syncope.core.provisioning.api.data.SchemaDataBinder;
-import org.apache.syncope.core.provisioning.java.utils.MappingUtils;
 
 abstract class AbstractAnyDataBinder {
 
@@ -118,12 +115,6 @@ abstract class AbstractAnyDataBinder {
     protected PlainSchemaDAO plainSchemaDAO;
 
     @Autowired
-    protected DerSchemaDAO derSchemaDAO;
-
-    @Autowired
-    protected VirSchemaDAO virSchemaDAO;
-
-    @Autowired
     protected PlainAttrDAO plainAttrDAO;
 
     @Autowired
@@ -154,9 +145,6 @@ abstract class AbstractAnyDataBinder {
     protected VirAttrHandler virAttrHandler;
 
     @Autowired
-    protected ConnObjectUtils connObjectUtils;
-
-    @Autowired
     protected MappingManager mappingManager;
 
     @Autowired

http://git-wip-us.apache.org/repos/asf/syncope/blob/9cc238c9/core/rest-cxf/src/main/resources/restCXFContext.xml
----------------------------------------------------------------------
diff --git a/core/rest-cxf/src/main/resources/restCXFContext.xml b/core/rest-cxf/src/main/resources/restCXFContext.xml
index c918942..4701652 100644
--- a/core/rest-cxf/src/main/resources/restCXFContext.xml
+++ b/core/rest-cxf/src/main/resources/restCXFContext.xml
@@ -21,15 +21,12 @@ under the License.
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xmlns:jaxrs="http://cxf.apache.org/jaxrs"
        xmlns:context="http://www.springframework.org/schema/context"
-       xmlns:aop="http://www.springframework.org/schema/aop"
        xsi:schemaLocation="http://www.springframework.org/schema/beans
                            http://www.springframework.org/schema/beans/spring-beans.xsd
                            http://cxf.apache.org/jaxrs
                            http://cxf.apache.org/schemas/jaxrs.xsd
                            http://www.springframework.org/schema/context
-                           http://www.springframework.org/schema/context/spring-context.xsd
-                           http://www.springframework.org/schema/aop 
-                           http://www.springframework.org/schema/aop/spring-aop.xsd">
+                           http://www.springframework.org/schema/context/spring-context.xsd">
 
   <import resource="classpath:META-INF/cxf/cxf.xml"/>
   <import resource="classpath:META-INF/cxf/cxf-servlet.xml"/>

http://git-wip-us.apache.org/repos/asf/syncope/blob/9cc238c9/fit/core-reference/src/main/resources/jboss/restCXFContext.xml
----------------------------------------------------------------------
diff --git a/fit/core-reference/src/main/resources/jboss/restCXFContext.xml b/fit/core-reference/src/main/resources/jboss/restCXFContext.xml
index f64da85..dd6c88c 100644
--- a/fit/core-reference/src/main/resources/jboss/restCXFContext.xml
+++ b/fit/core-reference/src/main/resources/jboss/restCXFContext.xml
@@ -21,15 +21,12 @@ under the License.
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xmlns:jaxrs="http://cxf.apache.org/jaxrs"
        xmlns:context="http://www.springframework.org/schema/context"
-       xmlns:aop="http://www.springframework.org/schema/aop"
        xsi:schemaLocation="http://www.springframework.org/schema/beans
                            http://www.springframework.org/schema/beans/spring-beans.xsd
                            http://cxf.apache.org/jaxrs
                            http://cxf.apache.org/schemas/jaxrs.xsd
                            http://www.springframework.org/schema/context
-                           http://www.springframework.org/schema/context/spring-context.xsd
-                           http://www.springframework.org/schema/aop 
-                           http://www.springframework.org/schema/aop/spring-aop.xsd">
+                           http://www.springframework.org/schema/context/spring-context.xsd">
 
   <import resource="classpath:META-INF/cxf/cxf.xml"/>
   <import resource="classpath:META-INF/cxf/cxf-servlet.xml"/>


Mime
View raw message