http://git-wip-us.apache.org/repos/asf/syncope/blob/d30c8526/syncope620/ext/camel/logic/src/main/java/org/apache/syncope/server/logic/init/CamelRouteLoader.java
----------------------------------------------------------------------
diff --git 
a/syncope620/ext/camel/logic/src/main/java/org/apache/syncope/server/logic/init/CamelRouteLoader.java
 
b/syncope620/ext/camel/logic/src/main/java/org/apache/syncope/server/logic/init/CamelRouteLoader.java
deleted file mode 100644
index 2dd3b52..0000000
--- 
a/syncope620/ext/camel/logic/src/main/java/org/apache/syncope/server/logic/init/CamelRouteLoader.java
+++ /dev/null
@@ -1,167 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.syncope.server.logic.init;
-
-import java.io.StringWriter;
-import java.util.List;
-import java.util.Map;
-import javax.sql.DataSource;
-import org.apache.syncope.common.lib.types.SubjectType;
-import org.apache.syncope.server.misc.spring.ResourceWithFallbackLoader;
-import org.apache.syncope.server.persistence.api.SyncopeLoader;
-import org.apache.syncope.server.persistence.api.entity.CamelEntityFactory;
-import org.apache.syncope.server.persistence.api.entity.CamelRoute;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.core.io.Resource;
-import org.springframework.dao.DataAccessException;
-import org.springframework.jdbc.core.JdbcTemplate;
-import org.springframework.stereotype.Component;
-import org.springframework.transaction.annotation.Transactional;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-import org.w3c.dom.bootstrap.DOMImplementationRegistry;
-import org.w3c.dom.ls.DOMImplementationLS;
-import org.w3c.dom.ls.LSInput;
-import org.w3c.dom.ls.LSOutput;
-import org.w3c.dom.ls.LSParser;
-import org.w3c.dom.ls.LSSerializer;
-
-@Component
-public class CamelRouteLoader implements SyncopeLoader {
-
-    private static final Logger LOG = 
LoggerFactory.getLogger(CamelRouteLoader.class);
-
-    @javax.annotation.Resource(name = "userRoutes")
-    private ResourceWithFallbackLoader userRoutesLoader;
-
-    @javax.annotation.Resource(name = "roleRoutes")
-    private ResourceWithFallbackLoader roleRoutesLoader;
-
-    @Autowired
-    private DataSource dataSource;
-
-    @Autowired
-    private CamelEntityFactory entityFactory;
-
-    private boolean loaded = false;
-
-    @Override
-    public Integer getPriority() {
-        return 1000;
-    }
-
-    @Transactional
-    public void load() {
-        synchronized (this) {
-            if (!loaded) {
-                loadRoutes(userRoutesLoader.getResource(), SubjectType.USER);
-                loadRoutes(roleRoutesLoader.getResource(), SubjectType.ROLE);
-                loadEntitlements();
-                loaded = true;
-            }
-        }
-    }
-
-    private boolean loadRoutesFor(final SubjectType subject) {
-        final String sql = String.format("SELECT * FROM %s WHERE SUBJECTTYPE = 
?", CamelRoute.class.getSimpleName());
-        final JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource);
-        final List<Map<String, Object>> rows = jdbcTemplate.queryForList(sql, 
new Object[] { subject.name() });
-        return rows.isEmpty();
-    }
-
-    private String nodeToString(final Node content, final DOMImplementationLS 
domImpl) {
-        StringWriter writer = new StringWriter();
-        try {
-            LSSerializer serializer = domImpl.createLSSerializer();
-            serializer.getDomConfig().setParameter("xml-declaration", false);
-            LSOutput lso = domImpl.createLSOutput();
-            lso.setCharacterStream(writer);
-            serializer.write(content, lso);
-        } catch (Exception e) {
-            LOG.debug("While serializing route node", e);
-        }
-        return writer.toString();
-    }
-
-    private void loadRoutes(final Resource resource, final SubjectType 
subjectType) {
-        if (loadRoutesFor(subjectType)) {
-            String query = String.format("INSERT INTO %s(NAME, SUBJECTTYPE, 
CONTENT) VALUES (?, ?, ?)",
-                    CamelRoute.class.getSimpleName());
-            JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource);
-
-            try {
-                DOMImplementationRegistry reg = 
DOMImplementationRegistry.newInstance();
-                DOMImplementationLS domImpl = (DOMImplementationLS) 
reg.getDOMImplementation("LS");
-                LSInput lsinput = domImpl.createLSInput();
-                lsinput.setByteStream(resource.getInputStream());
-
-                LSParser parser = 
domImpl.createLSParser(DOMImplementationLS.MODE_SYNCHRONOUS, null);
-
-                NodeList routeNodes = 
parser.parse(lsinput).getDocumentElement().getElementsByTagName("route");
-                for (int s = 0; s < routeNodes.getLength(); s++) {
-                    Node routeElement = routeNodes.item(s);
-                    String routeContent = nodeToString(routeNodes.item(s), 
domImpl);
-                    String routeId = ((Element) 
routeElement).getAttribute("id");
-
-                    CamelRoute route = entityFactory.newCamelRoute();
-                    route.setSubjectType(subjectType);
-                    route.setKey(routeId);
-                    route.setContent(routeContent);
-
-                    jdbcTemplate.update(query, new Object[] { routeId, 
subjectType.name(), routeContent });
-                    LOG.debug("Route {} successfully loaded", routeId);
-                }
-            } catch (DataAccessException e) {
-                LOG.error("While trying to store queries {}", e);
-            } catch (Exception e) {
-                LOG.error("Route load failed {}", e.getMessage());
-            }
-        }
-    }
-
-    private void loadEntitlements() {
-        final JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource);
-
-        boolean existingData;
-        try {
-            existingData = jdbcTemplate.queryForObject(
-                    "SELECT COUNT(0) FROM Entitlement WHERE NAME LIKE 
'ROUTE_%'", Integer.class) > 0;
-        } catch (DataAccessException e) {
-            LOG.error("Could not access to Entitlement table", e);
-            existingData = true;
-        }
-
-        if (existingData) {
-            LOG.info("Data found in the database, leaving untouched");
-        } else {
-            LOG.info("Empty database found, loading default content");
-
-            try {
-                jdbcTemplate.update("INSERT INTO Entitlement(NAME) 
VALUES('ROUTE_READ')");
-                jdbcTemplate.update("INSERT INTO Entitlement(NAME) 
VALUES('ROUTE_LIST')");
-                jdbcTemplate.update("INSERT INTO Entitlement(NAME) 
VALUES('ROUTE_UPDATE')");
-            } catch (Exception e) {
-                LOG.error("While adding additional entitlements", e);
-            }
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/syncope/blob/d30c8526/syncope620/ext/camel/persistence-api/pom.xml
----------------------------------------------------------------------
diff --git a/syncope620/ext/camel/persistence-api/pom.xml 
b/syncope620/ext/camel/persistence-api/pom.xml
index 75f89af..ab3acfb 100644
--- a/syncope620/ext/camel/persistence-api/pom.xml
+++ b/syncope620/ext/camel/persistence-api/pom.xml
@@ -39,8 +39,8 @@ under the License.
 
   <dependencies>
     <dependency>
-      <groupId>org.apache.syncope.server</groupId>
-      <artifactId>syncope-server-persistence-api</artifactId>
+      <groupId>org.apache.syncope.core</groupId>
+      <artifactId>syncope-core-persistence-api</artifactId>
       <version>${project.version}</version>
     </dependency>
   </dependencies>

http://git-wip-us.apache.org/repos/asf/syncope/blob/d30c8526/syncope620/ext/camel/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/dao/CamelRouteDAO.java
----------------------------------------------------------------------
diff --git 
a/syncope620/ext/camel/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/dao/CamelRouteDAO.java
 
b/syncope620/ext/camel/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/dao/CamelRouteDAO.java
new file mode 100644
index 0000000..dbec544
--- /dev/null
+++ 
b/syncope620/ext/camel/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/dao/CamelRouteDAO.java
@@ -0,0 +1,37 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.syncope.core.persistence.api.dao;
+
+import java.util.List;
+import org.apache.syncope.common.lib.types.SubjectType;
+import 
org.apache.syncope.core.persistence.api.attrvalue.validation.InvalidEntityException;
+import org.apache.syncope.core.persistence.api.entity.CamelRoute;
+
+public interface CamelRouteDAO extends DAO<CamelRoute, String> {
+
+    CamelRoute find(String key);
+
+    List<CamelRoute> find(SubjectType subjectType);
+
+    List<CamelRoute> findAll();
+
+    CamelRoute save(CamelRoute route) throws InvalidEntityException;
+
+    void delete(String key);
+}

http://git-wip-us.apache.org/repos/asf/syncope/blob/d30c8526/syncope620/ext/camel/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/CamelEntityFactory.java
----------------------------------------------------------------------
diff --git 
a/syncope620/ext/camel/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/CamelEntityFactory.java
 
b/syncope620/ext/camel/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/CamelEntityFactory.java
new file mode 100644
index 0000000..4c73cb4
--- /dev/null
+++ 
b/syncope620/ext/camel/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/CamelEntityFactory.java
@@ -0,0 +1,24 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.syncope.core.persistence.api.entity;
+
+public interface CamelEntityFactory {
+
+    CamelRoute newCamelRoute();
+}

http://git-wip-us.apache.org/repos/asf/syncope/blob/d30c8526/syncope620/ext/camel/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/CamelRoute.java
----------------------------------------------------------------------
diff --git 
a/syncope620/ext/camel/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/CamelRoute.java
 
b/syncope620/ext/camel/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/CamelRoute.java
new file mode 100644
index 0000000..ef01fbd
--- /dev/null
+++ 
b/syncope620/ext/camel/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/CamelRoute.java
@@ -0,0 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.syncope.core.persistence.api.entity;
+
+import org.apache.syncope.common.lib.types.SubjectType;
+
+public interface CamelRoute extends Entity<String> {
+
+    String getContent();
+
+    SubjectType getSubjectType();
+
+    void setKey(String name);
+
+    void setContent(String routeContent);
+
+    void setSubjectType(SubjectType subject);
+}

http://git-wip-us.apache.org/repos/asf/syncope/blob/d30c8526/syncope620/ext/camel/persistence-api/src/main/java/org/apache/syncope/server/persistence/api/dao/CamelRouteDAO.java
----------------------------------------------------------------------
diff --git 
a/syncope620/ext/camel/persistence-api/src/main/java/org/apache/syncope/server/persistence/api/dao/CamelRouteDAO.java
 
b/syncope620/ext/camel/persistence-api/src/main/java/org/apache/syncope/server/persistence/api/dao/CamelRouteDAO.java
deleted file mode 100644
index dd39781..0000000
--- 
a/syncope620/ext/camel/persistence-api/src/main/java/org/apache/syncope/server/persistence/api/dao/CamelRouteDAO.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.syncope.server.persistence.api.dao;
-
-import java.util.List;
-import org.apache.syncope.common.lib.types.SubjectType;
-import 
org.apache.syncope.server.persistence.api.attrvalue.validation.InvalidEntityException;
-import org.apache.syncope.server.persistence.api.entity.CamelRoute;
-
-public interface CamelRouteDAO extends DAO<CamelRoute, String> {
-
-    CamelRoute find(String key);
-
-    List<CamelRoute> find(SubjectType subjectType);
-
-    List<CamelRoute> findAll();
-
-    CamelRoute save(CamelRoute route) throws InvalidEntityException;
-
-    void delete(String key);
-}

http://git-wip-us.apache.org/repos/asf/syncope/blob/d30c8526/syncope620/ext/camel/persistence-api/src/main/java/org/apache/syncope/server/persistence/api/entity/CamelEntityFactory.java
----------------------------------------------------------------------
diff --git 
a/syncope620/ext/camel/persistence-api/src/main/java/org/apache/syncope/server/persistence/api/entity/CamelEntityFactory.java
 
b/syncope620/ext/camel/persistence-api/src/main/java/org/apache/syncope/server/persistence/api/entity/CamelEntityFactory.java
deleted file mode 100644
index 49bd2cb..0000000
--- 
a/syncope620/ext/camel/persistence-api/src/main/java/org/apache/syncope/server/persistence/api/entity/CamelEntityFactory.java
+++ /dev/null
@@ -1,24 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.syncope.server.persistence.api.entity;
-
-public interface CamelEntityFactory {
-
-    CamelRoute newCamelRoute();
-}

http://git-wip-us.apache.org/repos/asf/syncope/blob/d30c8526/syncope620/ext/camel/persistence-api/src/main/java/org/apache/syncope/server/persistence/api/entity/CamelRoute.java
----------------------------------------------------------------------
diff --git 
a/syncope620/ext/camel/persistence-api/src/main/java/org/apache/syncope/server/persistence/api/entity/CamelRoute.java
 
b/syncope620/ext/camel/persistence-api/src/main/java/org/apache/syncope/server/persistence/api/entity/CamelRoute.java
deleted file mode 100644
index f2b166c..0000000
--- 
a/syncope620/ext/camel/persistence-api/src/main/java/org/apache/syncope/server/persistence/api/entity/CamelRoute.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.syncope.server.persistence.api.entity;
-
-import org.apache.syncope.common.lib.types.SubjectType;
-
-public interface CamelRoute extends Entity<String> {
-
-    String getContent();
-
-    SubjectType getSubjectType();
-
-    void setKey(String name);
-
-    void setContent(String routeContent);
-
-    void setSubjectType(SubjectType subject);
-}

http://git-wip-us.apache.org/repos/asf/syncope/blob/d30c8526/syncope620/ext/camel/persistence-jpa/pom.xml
----------------------------------------------------------------------
diff --git a/syncope620/ext/camel/persistence-jpa/pom.xml 
b/syncope620/ext/camel/persistence-jpa/pom.xml
index ab16419..f738c70 100644
--- a/syncope620/ext/camel/persistence-jpa/pom.xml
+++ b/syncope620/ext/camel/persistence-jpa/pom.xml
@@ -39,8 +39,8 @@ under the License.
 
   <dependencies>    
     <dependency>
-      <groupId>org.apache.syncope.server</groupId>
-      <artifactId>syncope-server-persistence-jpa</artifactId>
+      <groupId>org.apache.syncope.core</groupId>
+      <artifactId>syncope-core-persistence-jpa</artifactId>
       <version>${project.version}</version>
     </dependency>
     <dependency>
@@ -64,8 +64,8 @@ under the License.
           </dependency>
         </dependencies>
         <configuration>
-          
<persistenceXmlFile>${rootpom.basedir}/server/persistence-jpa/src/main/resources/META-INF/spring-persistence.xml</persistenceXmlFile>
 
-          
<includes>org/apache/syncope/server/persistence/jpa/entity/**/*.class</includes>
+          
<persistenceXmlFile>${rootpom.basedir}/core/persistence-jpa/src/test/resources/META-INF/persistence-enhance.xml</persistenceXmlFile>
 
+          
<includes>org/apache/syncope/core/persistence/jpa/entity/**/*.class</includes>
           
<connectionDriverName>org.springframework.jdbc.datasource.DriverManagerDataSource</connectionDriverName>
           <connectionProperties>
             driverClassName=org.h2.Driver,
@@ -97,7 +97,7 @@ under the License.
 
     <testResources>
       <testResource>
-        
<directory>${rootpom.basedir}/server/persistence-jpa/src/main/resources</directory>
+        
<directory>${rootpom.basedir}/core/persistence-jpa/src/main/resources</directory>
         <filtering>true</filtering>        
       </testResource>
     </testResources>

http://git-wip-us.apache.org/repos/asf/syncope/blob/d30c8526/syncope620/ext/camel/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/JPACamelRouteDAO.java
----------------------------------------------------------------------
diff --git 
a/syncope620/ext/camel/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/JPACamelRouteDAO.java
 
b/syncope620/ext/camel/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/JPACamelRouteDAO.java
new file mode 100644
index 0000000..5f17b1e
--- /dev/null
+++ 
b/syncope620/ext/camel/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/JPACamelRouteDAO.java
@@ -0,0 +1,71 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.syncope.core.persistence.jpa.dao;
+
+import java.util.List;
+import javax.persistence.TypedQuery;
+import org.apache.syncope.common.lib.types.SubjectType;
+import 
org.apache.syncope.core.persistence.api.attrvalue.validation.InvalidEntityException;
+import org.apache.syncope.core.persistence.api.dao.CamelRouteDAO;
+import org.apache.syncope.core.persistence.api.entity.CamelRoute;
+import org.apache.syncope.core.persistence.jpa.entity.JPACamelRoute;
+import org.springframework.stereotype.Repository;
+import org.springframework.transaction.annotation.Transactional;
+
+@Repository
+public class JPACamelRouteDAO extends AbstractDAO<CamelRoute, String> 
implements CamelRouteDAO {
+
+    @Override
+    public CamelRoute find(final String key) {
+        return entityManager.find(JPACamelRoute.class, key);
+    }
+
+    @Transactional(readOnly = true)
+    @Override
+    public List<CamelRoute> find(final SubjectType subjectType) {
+        TypedQuery<CamelRoute> query = entityManager.createQuery(
+                "SELECT e FROM " + JPACamelRoute.class.getSimpleName()
+                + " e WHERE e.subjectType = :subjectType", CamelRoute.class);
+        query.setParameter("subjectType", subjectType);
+
+        return query.getResultList();
+    }
+
+    @Transactional(readOnly = true)
+    @Override
+    public List<CamelRoute> findAll() {
+        TypedQuery<CamelRoute> query = entityManager.createQuery(
+                "SELECT e FROM " + JPACamelRoute.class.getSimpleName() + " e 
", CamelRoute.class);
+        return query.getResultList();
+    }
+
+    @Override
+    public CamelRoute save(final CamelRoute route) throws 
InvalidEntityException {
+        return entityManager.merge(route);
+    }
+
+    @Override
+    public void delete(final String key) {
+        CamelRoute route = find(key);
+        if (route != null) {
+            entityManager.remove(route);
+        }
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/syncope/blob/d30c8526/syncope620/ext/camel/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/JPACamelEntityFactory.java
----------------------------------------------------------------------
diff --git 
a/syncope620/ext/camel/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/JPACamelEntityFactory.java
 
b/syncope620/ext/camel/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/JPACamelEntityFactory.java
new file mode 100644
index 0000000..1f8e051
--- /dev/null
+++ 
b/syncope620/ext/camel/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/JPACamelEntityFactory.java
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.syncope.core.persistence.jpa.entity;
+
+import org.apache.syncope.core.persistence.api.entity.CamelEntityFactory;
+import org.apache.syncope.core.persistence.api.entity.CamelRoute;
+import org.springframework.stereotype.Component;
+
+@Component
+public class JPACamelEntityFactory implements CamelEntityFactory {
+
+    @Override
+    public CamelRoute newCamelRoute() {
+        return new JPACamelRoute();
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/syncope/blob/d30c8526/syncope620/ext/camel/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/JPACamelRoute.java
----------------------------------------------------------------------
diff --git 
a/syncope620/ext/camel/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/JPACamelRoute.java
 
b/syncope620/ext/camel/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/JPACamelRoute.java
new file mode 100644
index 0000000..38803e5
--- /dev/null
+++ 
b/syncope620/ext/camel/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/JPACamelRoute.java
@@ -0,0 +1,79 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.syncope.core.persistence.jpa.entity;
+
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.Lob;
+import javax.persistence.EnumType;
+import javax.persistence.Enumerated;
+import javax.persistence.Table;
+import javax.validation.constraints.NotNull;
+import org.apache.syncope.common.lib.types.SubjectType;
+import org.apache.syncope.core.persistence.api.entity.CamelRoute;
+
+@Entity
+@Table(name = JPACamelRoute.TABLE)
+public class JPACamelRoute extends AbstractEntity<String> implements 
CamelRoute {
+
+    private static final long serialVersionUID = -2767606675667839161L;
+
+    public static final String TABLE = "CamelRoute";
+
+    @Id
+    private String name;
+
+    @NotNull
+    @Enumerated(EnumType.STRING)
+    private SubjectType subjectType;
+
+    @Lob
+    private String content;
+
+    @Override
+    public String getKey() {
+        return name;
+    }
+
+    @Override
+    public void setKey(final String name) {
+        this.name = name;
+    }
+
+    @Override
+    public SubjectType getSubjectType() {
+        return subjectType;
+    }
+
+    @Override
+    public void setSubjectType(final SubjectType subjectType) {
+        this.subjectType = subjectType;
+    }
+
+    @Override
+    public String getContent() {
+        return content;
+    }
+
+    @Override
+    public void setContent(final String content) {
+        this.content = content;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/syncope/blob/d30c8526/syncope620/ext/camel/persistence-jpa/src/main/java/org/apache/syncope/server/persistence/jpa/dao/JPACamelRouteDAO.java
----------------------------------------------------------------------
diff --git 
a/syncope620/ext/camel/persistence-jpa/src/main/java/org/apache/syncope/server/persistence/jpa/dao/JPACamelRouteDAO.java
 
b/syncope620/ext/camel/persistence-jpa/src/main/java/org/apache/syncope/server/persistence/jpa/dao/JPACamelRouteDAO.java
deleted file mode 100644
index 6b5fcb2..0000000
--- 
a/syncope620/ext/camel/persistence-jpa/src/main/java/org/apache/syncope/server/persistence/jpa/dao/JPACamelRouteDAO.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.syncope.server.persistence.jpa.dao;
-
-import java.util.List;
-import javax.persistence.TypedQuery;
-import org.apache.syncope.common.lib.types.SubjectType;
-import 
org.apache.syncope.server.persistence.api.attrvalue.validation.InvalidEntityException;
-import org.apache.syncope.server.persistence.api.dao.CamelRouteDAO;
-import org.apache.syncope.server.persistence.api.entity.CamelRoute;
-import org.apache.syncope.server.persistence.jpa.entity.JPACamelRoute;
-import org.springframework.stereotype.Repository;
-import org.springframework.transaction.annotation.Transactional;
-
-@Repository
-public class JPACamelRouteDAO extends AbstractDAO<CamelRoute, String> 
implements CamelRouteDAO {
-
-    @Override
-    public CamelRoute find(final String key) {
-        return entityManager.find(JPACamelRoute.class, key);
-    }
-
-    @Transactional(readOnly = true)
-    @Override
-    public List<CamelRoute> find(final SubjectType subjectType) {
-        TypedQuery<CamelRoute> query = entityManager.createQuery(
-                "SELECT e FROM " + JPACamelRoute.class.getSimpleName()
-                + " e WHERE e.subjectType = :subjectType", CamelRoute.class);
-        query.setParameter("subjectType", subjectType);
-
-        return query.getResultList();
-    }
-
-    @Transactional(readOnly = true)
-    @Override
-    public List<CamelRoute> findAll() {
-        TypedQuery<CamelRoute> query = entityManager.createQuery(
-                "SELECT e FROM " + JPACamelRoute.class.getSimpleName() + " e 
", CamelRoute.class);
-        return query.getResultList();
-    }
-
-    @Override
-    public CamelRoute save(final CamelRoute route) throws 
InvalidEntityException {
-        return entityManager.merge(route);
-    }
-
-    @Override
-    public void delete(final String key) {
-        CamelRoute route = find(key);
-        if (route != null) {
-            entityManager.remove(route);
-        }
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/syncope/blob/d30c8526/syncope620/ext/camel/persistence-jpa/src/main/java/org/apache/syncope/server/persistence/jpa/entity/JPACamelEntityFactory.java
----------------------------------------------------------------------
diff --git 
a/syncope620/ext/camel/persistence-jpa/src/main/java/org/apache/syncope/server/persistence/jpa/entity/JPACamelEntityFactory.java
 
b/syncope620/ext/camel/persistence-jpa/src/main/java/org/apache/syncope/server/persistence/jpa/entity/JPACamelEntityFactory.java
deleted file mode 100644
index f4fee00..0000000
--- 
a/syncope620/ext/camel/persistence-jpa/src/main/java/org/apache/syncope/server/persistence/jpa/entity/JPACamelEntityFactory.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.syncope.server.persistence.jpa.entity;
-
-import org.apache.syncope.server.persistence.api.entity.CamelEntityFactory;
-import org.apache.syncope.server.persistence.api.entity.CamelRoute;
-import org.springframework.stereotype.Component;
-
-@Component
-public class JPACamelEntityFactory implements CamelEntityFactory {
-
-    @Override
-    public CamelRoute newCamelRoute() {
-        return new JPACamelRoute();
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/syncope/blob/d30c8526/syncope620/ext/camel/persistence-jpa/src/main/java/org/apache/syncope/server/persistence/jpa/entity/JPACamelRoute.java
----------------------------------------------------------------------
diff --git 
a/syncope620/ext/camel/persistence-jpa/src/main/java/org/apache/syncope/server/persistence/jpa/entity/JPACamelRoute.java
 
b/syncope620/ext/camel/persistence-jpa/src/main/java/org/apache/syncope/server/persistence/jpa/entity/JPACamelRoute.java
deleted file mode 100644
index 2606305..0000000
--- 
a/syncope620/ext/camel/persistence-jpa/src/main/java/org/apache/syncope/server/persistence/jpa/entity/JPACamelRoute.java
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.syncope.server.persistence.jpa.entity;
-
-import javax.persistence.Entity;
-import javax.persistence.Id;
-import javax.persistence.Lob;
-import javax.persistence.EnumType;
-import javax.persistence.Enumerated;
-import javax.persistence.Table;
-import javax.validation.constraints.NotNull;
-import org.apache.syncope.common.lib.types.SubjectType;
-import org.apache.syncope.server.persistence.api.entity.CamelRoute;
-
-@Entity
-@Table(name = JPACamelRoute.TABLE)
-public class JPACamelRoute extends AbstractEntity<String> implements 
CamelRoute {
-
-    private static final long serialVersionUID = -2767606675667839161L;
-
-    public static final String TABLE = "CamelRoute";
-
-    @Id
-    private String name;
-
-    @NotNull
-    @Enumerated(EnumType.STRING)
-    private SubjectType subjectType;
-
-    @Lob
-    private String content;
-
-    @Override
-    public String getKey() {
-        return name;
-    }
-
-    @Override
-    public void setKey(final String name) {
-        this.name = name;
-    }
-
-    @Override
-    public SubjectType getSubjectType() {
-        return subjectType;
-    }
-
-    @Override
-    public void setSubjectType(final SubjectType subjectType) {
-        this.subjectType = subjectType;
-    }
-
-    @Override
-    public String getContent() {
-        return content;
-    }
-
-    @Override
-    public void setContent(final String content) {
-        this.content = content;
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/syncope/blob/d30c8526/syncope620/ext/camel/provisioning-api/pom.xml
----------------------------------------------------------------------
diff --git a/syncope620/ext/camel/provisioning-api/pom.xml 
b/syncope620/ext/camel/provisioning-api/pom.xml
index b9bd6b9..3d108b4 100644
--- a/syncope620/ext/camel/provisioning-api/pom.xml
+++ b/syncope620/ext/camel/provisioning-api/pom.xml
@@ -39,8 +39,8 @@ under the License.
 
   <dependencies>
     <dependency>
-      <groupId>org.apache.syncope.server</groupId>
-      <artifactId>syncope-server-provisioning-api</artifactId>
+      <groupId>org.apache.syncope.core</groupId>
+      <artifactId>syncope-core-provisioning-api</artifactId>
       <version>${project.version}</version>
     </dependency>
     <dependency>

http://git-wip-us.apache.org/repos/asf/syncope/blob/d30c8526/syncope620/ext/camel/provisioning-api/src/main/java/org/apache/syncope/core/provisioning/api/data/CamelRouteDataBinder.java
----------------------------------------------------------------------
diff --git 
a/syncope620/ext/camel/provisioning-api/src/main/java/org/apache/syncope/core/provisioning/api/data/CamelRouteDataBinder.java
 
b/syncope620/ext/camel/provisioning-api/src/main/java/org/apache/syncope/core/provisioning/api/data/CamelRouteDataBinder.java
new file mode 100644
index 0000000..f355b2b
--- /dev/null
+++ 
b/syncope620/ext/camel/provisioning-api/src/main/java/org/apache/syncope/core/provisioning/api/data/CamelRouteDataBinder.java
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.syncope.core.provisioning.api.data;
+
+import org.apache.syncope.common.lib.to.CamelRouteTO;
+import org.apache.syncope.core.persistence.api.entity.CamelRoute;
+
+public interface CamelRouteDataBinder {
+
+    CamelRouteTO getRouteTO(CamelRoute route);
+
+    void update(CamelRoute route, CamelRouteTO routeTO);
+}

http://git-wip-us.apache.org/repos/asf/syncope/blob/d30c8526/syncope620/ext/camel/provisioning-api/src/main/java/org/apache/syncope/server/provisioning/api/data/CamelRouteDataBinder.java
----------------------------------------------------------------------
diff --git 
a/syncope620/ext/camel/provisioning-api/src/main/java/org/apache/syncope/server/provisioning/api/data/CamelRouteDataBinder.java
 
b/syncope620/ext/camel/provisioning-api/src/main/java/org/apache/syncope/server/provisioning/api/data/CamelRouteDataBinder.java
deleted file mode 100644
index 4d8e4ec..0000000
--- 
a/syncope620/ext/camel/provisioning-api/src/main/java/org/apache/syncope/server/provisioning/api/data/CamelRouteDataBinder.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.syncope.server.provisioning.api.data;
-
-import org.apache.syncope.common.lib.to.CamelRouteTO;
-import org.apache.syncope.server.persistence.api.entity.CamelRoute;
-
-public interface CamelRouteDataBinder {
-
-    CamelRouteTO getRouteTO(CamelRoute route);
-
-    void update(CamelRoute route, CamelRouteTO routeTO);
-}

http://git-wip-us.apache.org/repos/asf/syncope/blob/d30c8526/syncope620/ext/camel/provisioning-camel/pom.xml
----------------------------------------------------------------------
diff --git a/syncope620/ext/camel/provisioning-camel/pom.xml 
b/syncope620/ext/camel/provisioning-camel/pom.xml
index 5218d62..9ffa877 100644
--- a/syncope620/ext/camel/provisioning-camel/pom.xml
+++ b/syncope620/ext/camel/provisioning-camel/pom.xml
@@ -52,8 +52,8 @@ under the License.
     </dependency>
       
     <dependency>
-      <groupId>org.apache.syncope.server</groupId>
-      <artifactId>syncope-server-provisioning-java</artifactId>
+      <groupId>org.apache.syncope.core</groupId>
+      <artifactId>syncope-core-provisioning-java</artifactId>
       <version>${project.version}</version>
     </dependency>
     <dependency>

http://git-wip-us.apache.org/repos/asf/syncope/blob/d30c8526/syncope620/ext/camel/provisioning-camel/src/main/java/org/apache/syncope/core/provisioning/camel/AbstractCamelProvisioningManager.java
----------------------------------------------------------------------
diff --git 
a/syncope620/ext/camel/provisioning-camel/src/main/java/org/apache/syncope/core/provisioning/camel/AbstractCamelProvisioningManager.java
 
b/syncope620/ext/camel/provisioning-camel/src/main/java/org/apache/syncope/core/provisioning/camel/AbstractCamelProvisioningManager.java
new file mode 100644
index 0000000..e3b798a
--- /dev/null
+++ 
b/syncope620/ext/camel/provisioning-camel/src/main/java/org/apache/syncope/core/provisioning/camel/AbstractCamelProvisioningManager.java
@@ -0,0 +1,103 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.syncope.core.provisioning.camel;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import org.apache.camel.Endpoint;
+import org.apache.camel.Exchange;
+import org.apache.camel.PollingConsumer;
+import org.apache.camel.ProducerTemplate;
+import org.apache.camel.impl.DefaultExchange;
+import org.apache.camel.impl.DefaultMessage;
+import org.apache.camel.model.RoutesDefinition;
+import org.apache.camel.spring.SpringCamelContext;
+import org.apache.syncope.core.persistence.api.dao.CamelRouteDAO;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+
+abstract class AbstractCamelProvisioningManager {
+
+    private static final Logger LOG = 
LoggerFactory.getLogger(AbstractCamelProvisioningManager.class);
+
+    @Autowired
+    protected CamelRouteDAO routeDAO;
+
+    @Autowired
+    protected SyncopeCamelContext contextFactory;
+
+    protected SpringCamelContext camelContext;
+
+    protected RoutesDefinition routes;
+
+    protected final Map<String, PollingConsumer> consumerMap = new HashMap<>();
+
+    protected final List<String> knownURIs = new ArrayList<>();
+
+    protected SpringCamelContext getContext() {
+        return contextFactory.getContext();
+    }
+
+    protected void sendMessage(final String uri, final Object obj) {
+        Exchange exchange = new DefaultExchange(getContext());
+
+        DefaultMessage message = new DefaultMessage();
+        message.setBody(obj);
+        exchange.setIn(message);
+
+        ProducerTemplate template = getContext().createProducerTemplate();
+        template.send(uri, exchange);
+    }
+
+    protected void sendMessage(final String uri, final Object obj, final 
Map<String, Object> properties) {
+        Exchange exchange = new DefaultExchange(getContext());
+
+        for (Map.Entry<String, Object> property : properties.entrySet()) {
+            exchange.setProperty(property.getKey(), property.getValue());
+            LOG.debug("Added property {}", property.getKey());
+        }
+
+        DefaultMessage message = new DefaultMessage();
+        message.setBody(obj);
+        exchange.setIn(message);
+        ProducerTemplate template = getContext().createProducerTemplate();
+        template.send(uri, exchange);
+    }
+
+    protected PollingConsumer getConsumer(String uri) {
+        if (!knownURIs.contains(uri)) {
+            knownURIs.add(uri);
+            Endpoint endpoint = getContext().getEndpoint(uri);
+            PollingConsumer pollingConsumer = null;
+            try {
+                pollingConsumer = endpoint.createPollingConsumer();
+                consumerMap.put(uri, pollingConsumer);
+                pollingConsumer.start();
+            } catch (Exception ex) {
+                LOG.error("Unexpected error in Consumer creation ", ex);
+            }
+            return pollingConsumer;
+        } else {
+            return consumerMap.get(uri);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/syncope/blob/d30c8526/syncope620/ext/camel/provisioning-camel/src/main/java/org/apache/syncope/core/provisioning/camel/CamelRoleProvisioningManager.java
----------------------------------------------------------------------
diff --git 
a/syncope620/ext/camel/provisioning-camel/src/main/java/org/apache/syncope/core/provisioning/camel/CamelRoleProvisioningManager.java
 
b/syncope620/ext/camel/provisioning-camel/src/main/java/org/apache/syncope/core/provisioning/camel/CamelRoleProvisioningManager.java
new file mode 100644
index 0000000..096816a
--- /dev/null
+++ 
b/syncope620/ext/camel/provisioning-camel/src/main/java/org/apache/syncope/core/provisioning/camel/CamelRoleProvisioningManager.java
@@ -0,0 +1,174 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.syncope.core.provisioning.camel;
+
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import org.apache.camel.Exchange;
+import org.apache.camel.PollingConsumer;
+import org.apache.syncope.common.lib.mod.RoleMod;
+import org.apache.syncope.common.lib.to.PropagationStatus;
+import org.apache.syncope.common.lib.to.RoleTO;
+import org.apache.syncope.core.provisioning.api.RoleProvisioningManager;
+import 
org.apache.syncope.core.provisioning.api.propagation.PropagationException;
+
+public class CamelRoleProvisioningManager extends 
AbstractCamelProvisioningManager implements RoleProvisioningManager {
+
+    @Override
+    public Map.Entry<Long, List<PropagationStatus>> create(final RoleTO 
subject) {
+        return create(subject, Collections.<String>emptySet());
+    }
+
+    @Override
+    @SuppressWarnings("unchecked")
+    public Map.Entry<Long, List<PropagationStatus>> create(final RoleTO 
roleTO, final Set<String> excludedResources) {
+        PollingConsumer pollingConsumer = getConsumer("direct:createRolePort");
+
+        Map<String, Object> props = new HashMap<>();
+        props.put("excludedResources", excludedResources);
+
+        sendMessage("direct:createRole", roleTO, props);
+
+        Exchange exchange = pollingConsumer.receive();
+
+        if (exchange.getProperty(Exchange.EXCEPTION_CAUGHT) != null) {
+            throw (RuntimeException) 
exchange.getProperty(Exchange.EXCEPTION_CAUGHT);
+        }
+
+        return exchange.getIn().getBody(Map.Entry.class);
+    }
+
+    @Override
+    @SuppressWarnings("unchecked")
+    public Map.Entry<Long, List<PropagationStatus>> create(final RoleTO 
roleTO, final Map<Long, String> roleOwnerMap,
+            final Set<String> excludedResources) throws PropagationException {
+
+        PollingConsumer pollingConsumer = 
getConsumer("direct:createRoleInSyncPort");
+
+        Map<String, Object> props = new HashMap<>();
+        props.put("roleOwnerMap", roleOwnerMap);
+        props.put("excludedResources", excludedResources);
+
+        sendMessage("direct:createRoleInSync", roleTO, props);
+
+        Exchange exchange = pollingConsumer.receive();
+
+        if (exchange.getProperty(Exchange.EXCEPTION_CAUGHT) != null) {
+            throw (RuntimeException) 
exchange.getProperty(Exchange.EXCEPTION_CAUGHT);
+        }
+
+        return exchange.getIn().getBody(Map.Entry.class);
+    }
+
+    @Override
+    public Map.Entry<Long, List<PropagationStatus>> update(final RoleMod 
subjectMod) {
+        return update(subjectMod, Collections.<String>emptySet());
+    }
+
+    @Override
+    @SuppressWarnings("unchecked")
+    public Map.Entry<Long, List<PropagationStatus>> update(
+            final RoleMod subjectMod, final Set<String> excludedResources) {
+
+        PollingConsumer pollingConsumer = getConsumer("direct:updateRolePort");
+
+        Map<String, Object> props = new HashMap<>();
+        props.put("excludedResources", excludedResources);
+
+        sendMessage("direct:updateRole", subjectMod, props);
+
+        Exchange exchange = pollingConsumer.receive();
+
+        if (exchange.getProperty(Exchange.EXCEPTION_CAUGHT) != null) {
+            throw (RuntimeException) 
exchange.getProperty(Exchange.EXCEPTION_CAUGHT);
+        }
+
+        return exchange.getIn().getBody(Map.Entry.class);
+    }
+
+    @Override
+    @SuppressWarnings("unchecked")
+    public List<PropagationStatus> delete(final Long roleKey) {
+        PollingConsumer pollingConsumer = getConsumer("direct:deleteRolePort");
+
+        sendMessage("direct:deleteRole", roleKey);
+
+        Exchange exchange = pollingConsumer.receive();
+
+        if (exchange.getProperty(Exchange.EXCEPTION_CAUGHT) != null) {
+            throw (RuntimeException) 
exchange.getProperty(Exchange.EXCEPTION_CAUGHT);
+        }
+
+        return exchange.getIn().getBody(List.class);
+    }
+
+    @Override
+    public Long unlink(final RoleMod roleMod) {
+        PollingConsumer pollingConsumer = getConsumer("direct:unlinkRolePort");
+
+        sendMessage("direct:unlinkRole", roleMod);
+
+        Exchange exchange = pollingConsumer.receive();
+
+        if (exchange.getProperty(Exchange.EXCEPTION_CAUGHT) != null) {
+            throw (RuntimeException) 
exchange.getProperty(Exchange.EXCEPTION_CAUGHT);
+        }
+
+        return exchange.getIn().getBody(Long.class);
+    }
+
+    @Override
+    public Long link(final RoleMod roleMod) {
+        PollingConsumer pollingConsumer = getConsumer("direct:linkRolePort");
+
+        sendMessage("direct:linkRole", roleMod);
+
+        Exchange exchange = pollingConsumer.receive();
+
+        if (exchange.getProperty(Exchange.EXCEPTION_CAUGHT) != null) {
+            throw (RuntimeException) 
exchange.getProperty(Exchange.EXCEPTION_CAUGHT);
+        }
+
+        return exchange.getIn().getBody(Long.class);
+    }
+
+    @Override
+    @SuppressWarnings("unchecked")
+    public List<PropagationStatus> deprovision(final Long roleKey, 
Collection<String> resources) {
+        PollingConsumer pollingConsumer = 
getConsumer("direct:deprovisionRolePort");
+
+        Map<String, Object> props = new HashMap<>();
+        props.put("resources", resources);
+
+        sendMessage("direct:deprovisionRole", roleKey, props);
+
+        Exchange exchange = pollingConsumer.receive();
+
+        if (exchange.getProperty(Exchange.EXCEPTION_CAUGHT) != null) {
+            throw (RuntimeException) 
exchange.getProperty(Exchange.EXCEPTION_CAUGHT);
+        }
+
+        return exchange.getIn().getBody(List.class);
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/syncope/blob/d30c8526/syncope620/ext/camel/provisioning-camel/src/main/java/org/apache/syncope/core/provisioning/camel/CamelUserProvisioningManager.java
----------------------------------------------------------------------
diff --git 
a/syncope620/ext/camel/provisioning-camel/src/main/java/org/apache/syncope/core/provisioning/camel/CamelUserProvisioningManager.java
 
b/syncope620/ext/camel/provisioning-camel/src/main/java/org/apache/syncope/core/provisioning/camel/CamelUserProvisioningManager.java
new file mode 100644
index 0000000..c182c57
--- /dev/null
+++ 
b/syncope620/ext/camel/provisioning-camel/src/main/java/org/apache/syncope/core/provisioning/camel/CamelUserProvisioningManager.java
@@ -0,0 +1,342 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.syncope.core.provisioning.camel;
+
+import java.util.AbstractMap;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import org.apache.camel.Exchange;
+import org.apache.camel.PollingConsumer;
+import org.apache.syncope.common.lib.mod.StatusMod;
+import org.apache.syncope.common.lib.mod.UserMod;
+import org.apache.syncope.common.lib.to.PropagationStatus;
+import org.apache.syncope.common.lib.to.UserTO;
+import org.apache.syncope.common.lib.types.PropagationByResource;
+import org.apache.syncope.core.persistence.api.entity.user.User;
+import org.apache.syncope.core.provisioning.api.UserProvisioningManager;
+import org.apache.syncope.core.provisioning.api.WorkflowResult;
+import org.apache.syncope.core.provisioning.api.sync.ProvisioningResult;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class CamelUserProvisioningManager extends 
AbstractCamelProvisioningManager implements UserProvisioningManager {
+
+    private static final Logger LOG = 
LoggerFactory.getLogger(CamelUserProvisioningManager.class);
+
+    @Override
+    public Map.Entry<Long, List<PropagationStatus>> create(final UserTO 
userTO) {
+        return create(userTO, true, false, null, 
Collections.<String>emptySet());
+    }
+
+    @Override
+    public Map.Entry<Long, List<PropagationStatus>> create(final UserTO 
userTO, boolean storePassword) {
+        return create(userTO, storePassword, false, null, 
Collections.<String>emptySet());
+    }
+
+    @Override
+    @SuppressWarnings("unchecked")
+    public Map.Entry<Long, List<PropagationStatus>> create(final UserTO 
userTO, final boolean storePassword,
+            boolean disablePwdPolicyCheck, Boolean enabled, Set<String> 
excludedResources) {
+
+        PollingConsumer pollingConsumer = getConsumer("direct:createPort");
+
+        Map<String, Object> props = new HashMap<>();
+        props.put("storePassword", storePassword);
+        props.put("disablePwdPolicyCheck", disablePwdPolicyCheck);
+        props.put("enabled", enabled);
+        props.put("excludedResources", excludedResources);
+
+        sendMessage("direct:createUser", userTO, props);
+
+        Exchange exchange = pollingConsumer.receive();
+
+        if (exchange.getProperty(Exchange.EXCEPTION_CAUGHT) != null) {
+            throw (RuntimeException) 
exchange.getProperty(Exchange.EXCEPTION_CAUGHT);
+        }
+
+        return exchange.getIn().getBody(Map.Entry.class);
+    }
+
+    @Override
+    public Map.Entry<Long, List<PropagationStatus>> update(final UserMod 
userMod) {
+        return update(userMod, false);
+    }
+
+    @Override
+    @SuppressWarnings("unchecked")
+    public Map.Entry<Long, List<PropagationStatus>> update(UserMod userMod, 
boolean removeMemberships) {
+        PollingConsumer pollingConsumer = getConsumer("direct:updatePort");
+
+        Map<String, Object> props = new HashMap<>();
+        props.put("removeMemberships", removeMemberships);
+
+        sendMessage("direct:updateUser", userMod, props);
+
+        Exchange exchange = pollingConsumer.receive();
+
+        if (exchange.getProperty(Exchange.EXCEPTION_CAUGHT) != null) {
+            throw (RuntimeException) 
exchange.getProperty(Exchange.EXCEPTION_CAUGHT);
+        }
+
+        return exchange.getIn().getBody(Map.Entry.class);
+    }
+
+    @Override
+    public List<PropagationStatus> delete(final Long userKey) {
+        return delete(userKey, Collections.<String>emptySet());
+    }
+
+    @Override
+    @SuppressWarnings("unchecked")
+    public List<PropagationStatus> delete(final Long userKey, final 
Set<String> excludedResources) {
+        PollingConsumer pollingConsumer = getConsumer("direct:deletePort");
+
+        Map<String, Object> props = new HashMap<>();
+        props.put("excludedResources", excludedResources);
+
+        sendMessage("direct:deleteUser", userKey, props);
+
+        Exchange exchange = pollingConsumer.receive();
+
+        if (exchange.getProperty(Exchange.EXCEPTION_CAUGHT) != null) {
+            throw (RuntimeException) 
exchange.getProperty(Exchange.EXCEPTION_CAUGHT);
+        }
+
+        return exchange.getIn().getBody(List.class);
+    }
+
+    @Override
+    public Long unlink(final UserMod userMod) {
+        PollingConsumer pollingConsumer = getConsumer("direct:unlinkPort");
+
+        sendMessage("direct:unlinkUser", userMod);
+
+        Exchange exchange = pollingConsumer.receive();
+
+        if (exchange.getProperty(Exchange.EXCEPTION_CAUGHT) != null) {
+            throw (RuntimeException) 
exchange.getProperty(Exchange.EXCEPTION_CAUGHT);
+        }
+
+        
exchange.getIn().setBody((exchange.getIn().getBody(UserMod.class).getKey()));
+        return exchange.getIn().getBody(Long.class);
+    }
+
+    @Override
+    @SuppressWarnings("unchecked")
+    public Map.Entry<Long, List<PropagationStatus>> activate(final User user, 
final StatusMod statusMod) {
+        PollingConsumer pollingConsumer = getConsumer("direct:statusPort");
+
+        Map<String, Object> props = new HashMap<>();
+        props.put("token", statusMod.getToken());
+        props.put("user", user);
+        props.put("statusMod", statusMod);
+
+        if (statusMod.isOnSyncope()) {
+            sendMessage("direct:activateUser", user.getKey(), props);
+        } else {
+            WorkflowResult<Long> updated =
+                    new WorkflowResult<>(user.getKey(), null, 
statusMod.getType().name().toLowerCase());
+            sendMessage("direct:userStatusPropagation", updated, props);
+        }
+
+        Exchange exchange = pollingConsumer.receive();
+
+        if (exchange.getProperty(Exchange.EXCEPTION_CAUGHT) != null) {
+            throw (RuntimeException) 
exchange.getProperty(Exchange.EXCEPTION_CAUGHT);
+        }
+
+        return exchange.getIn().getBody(Map.Entry.class);
+    }
+
+    @Override
+    @SuppressWarnings("unchecked")
+    public Map.Entry<Long, List<PropagationStatus>> reactivate(final User 
user, final StatusMod statusMod) {
+        PollingConsumer pollingConsumer = getConsumer("direct:statusPort");
+
+        Map<String, Object> props = new HashMap<>();
+        props.put("user", user);
+        props.put("statusMod", statusMod);
+
+        if (statusMod.isOnSyncope()) {
+            sendMessage("direct:reactivateUser", user.getKey(), props);
+        } else {
+            WorkflowResult<Long> updated =
+                    new WorkflowResult<>(user.getKey(), null, 
statusMod.getType().name().toLowerCase());
+            sendMessage("direct:userStatusPropagation", updated, props);
+        }
+
+        Exchange exchange = pollingConsumer.receive();
+
+        if (exchange.getProperty(Exchange.EXCEPTION_CAUGHT) != null) {
+            throw (RuntimeException) 
exchange.getProperty(Exchange.EXCEPTION_CAUGHT);
+        }
+
+        return exchange.getIn().getBody(Map.Entry.class);
+    }
+
+    @Override
+    @SuppressWarnings("unchecked")
+    public Map.Entry<Long, List<PropagationStatus>> suspend(final User user, 
final StatusMod statusMod) {
+        PollingConsumer pollingConsumer = getConsumer("direct:statusPort");
+
+        Map<String, Object> props = new HashMap<>();
+        props.put("user", user);
+        props.put("statusMod", statusMod);
+
+        if (statusMod.isOnSyncope()) {
+            sendMessage("direct:suspendUser", user.getKey(), props);
+        } else {
+            WorkflowResult<Long> updated =
+                    new WorkflowResult<>(user.getKey(), null, 
statusMod.getType().name().toLowerCase());
+            sendMessage("direct:userStatusPropagation", updated, props);
+        }
+
+        Exchange exchange = pollingConsumer.receive();
+
+        if (exchange.getProperty(Exchange.EXCEPTION_CAUGHT) != null) {
+            throw (RuntimeException) 
exchange.getProperty(Exchange.EXCEPTION_CAUGHT);
+        }
+
+        return exchange.getIn().getBody(Map.Entry.class);
+    }
+
+    @Override
+    public Long link(final UserMod subjectMod) {
+        PollingConsumer pollingConsumer = getConsumer("direct:linkPort");
+
+        sendMessage("direct:linkUser", subjectMod);
+
+        Exchange exchange = pollingConsumer.receive();
+
+        if (exchange.getProperty(Exchange.EXCEPTION_CAUGHT) != null) {
+            throw (RuntimeException) 
exchange.getProperty(Exchange.EXCEPTION_CAUGHT);
+        }
+
+        
exchange.getIn().setBody((exchange.getIn().getBody(UserMod.class).getKey()));
+        return exchange.getIn().getBody(Long.class);
+    }
+
+    @Override
+    @SuppressWarnings("unchecked")
+    public List<PropagationStatus> deprovision(final Long user, final 
Collection<String> resources) {
+        PollingConsumer pollingConsumer = 
getConsumer("direct:deprovisionPort");
+
+        Map<String, Object> props = new HashMap<>();
+        props.put("resources", resources);
+
+        sendMessage("direct:deprovisionUser", user, props);
+
+        Exchange exchange = pollingConsumer.receive();
+
+        if (exchange.getProperty(Exchange.EXCEPTION_CAUGHT) != null) {
+            throw (RuntimeException) 
exchange.getProperty(Exchange.EXCEPTION_CAUGHT);
+        }
+
+        return exchange.getIn().getBody(List.class);
+    }
+
+    @Override
+    @SuppressWarnings("unchecked")
+    public Map.Entry<Long, List<PropagationStatus>> update(
+            final UserMod userMod, final Long key, final ProvisioningResult 
result,
+            final Boolean enabled, final Set<String> excludedResources) {
+
+        PollingConsumer pollingConsumer = 
getConsumer("direct:updateInSyncPort");
+
+        Map<String, Object> props = new HashMap<>();
+        props.put("key", key);
+        props.put("result", result);
+        props.put("enabled", enabled);
+        props.put("excludedResources", excludedResources);
+
+        sendMessage("direct:updateUserInSync", userMod, props);
+
+        Exchange exchange = pollingConsumer.receive();
+
+        Exception e;
+        if ((e = (Exception) exchange.getProperty(Exchange.EXCEPTION_CAUGHT)) 
!= null) {
+            LOG.error("Update of user {} failed, trying to sync its status 
anyway (if configured)", key, e);
+
+            result.setStatus(ProvisioningResult.Status.FAILURE);
+            result.setMessage("Update failed, trying to sync status anyway (if 
configured)\n" + e.getMessage());
+
+            WorkflowResult<Map.Entry<UserMod, Boolean>> updated = new 
WorkflowResult<Map.Entry<UserMod, Boolean>>(
+                    new AbstractMap.SimpleEntry<>(userMod, false), new 
PropagationByResource(),
+                    new HashSet<String>());
+            sendMessage("direct:userInSync", updated, props);
+            exchange = pollingConsumer.receive();
+        }
+
+        return exchange.getIn().getBody(Map.Entry.class);
+    }
+
+    @Override
+    public void innerSuspend(final User user, final boolean propagate) {
+        PollingConsumer pollingConsumer = 
getConsumer("direct:innerSuspendUserPort");
+
+        Map<String, Object> props = new HashMap<>();
+        props.put("propagate", propagate);
+
+        sendMessage("direct:innerSuspendUser", user, props);
+
+        Exchange exchange = pollingConsumer.receive();
+
+        if (exchange.getProperty(Exchange.EXCEPTION_CAUGHT) != null) {
+            throw (RuntimeException) 
exchange.getProperty(Exchange.EXCEPTION_CAUGHT);
+        }
+    }
+
+    @Override
+    public void requestPasswordReset(final Long userKey) {
+        PollingConsumer pollingConsumer = 
getConsumer("direct:requestPwdResetPort");
+
+        sendMessage("direct:requestPwdReset", userKey);
+
+        Exchange exchange = pollingConsumer.receive();
+
+        if (exchange.getProperty(Exchange.EXCEPTION_CAUGHT) != null) {
+            throw (RuntimeException) 
exchange.getProperty(Exchange.EXCEPTION_CAUGHT);
+        }
+    }
+
+    @Override
+    public void confirmPasswordReset(final User user, final String token, 
final String password) {
+        PollingConsumer pollingConsumer = 
getConsumer("direct:confirmPwdResetPort");
+
+        Map<String, Object> props = new HashMap<>();
+        props.put("user", user);
+        props.put("userKey", user.getKey());
+        props.put("token", token);
+        props.put("password", password);
+
+        sendMessage("direct:confirmPwdReset", user, props);
+
+        Exchange exchange = pollingConsumer.receive();
+
+        if (exchange.getProperty(Exchange.EXCEPTION_CAUGHT) != null) {
+            throw (RuntimeException) 
exchange.getProperty(Exchange.EXCEPTION_CAUGHT);
+        }
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/syncope/blob/d30c8526/syncope620/ext/camel/provisioning-camel/src/main/java/org/apache/syncope/core/provisioning/camel/SyncopeCamelContext.java
----------------------------------------------------------------------
diff --git 
a/syncope620/ext/camel/provisioning-camel/src/main/java/org/apache/syncope/core/provisioning/camel/SyncopeCamelContext.java
 
b/syncope620/ext/camel/provisioning-camel/src/main/java/org/apache/syncope/core/provisioning/camel/SyncopeCamelContext.java
new file mode 100644
index 0000000..ce15e5c
--- /dev/null
+++ 
b/syncope620/ext/camel/provisioning-camel/src/main/java/org/apache/syncope/core/provisioning/camel/SyncopeCamelContext.java
@@ -0,0 +1,123 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.syncope.core.provisioning.camel;
+
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.Unmarshaller;
+import org.apache.camel.model.Constants;
+import org.apache.camel.model.RouteDefinition;
+import org.apache.camel.spring.SpringCamelContext;
+import org.apache.commons.io.IOUtils;
+import org.apache.syncope.core.misc.spring.ApplicationContextProvider;
+import org.apache.syncope.core.persistence.api.dao.CamelRouteDAO;
+import org.apache.syncope.core.persistence.api.entity.CamelRoute;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+import org.w3c.dom.Node;
+import org.w3c.dom.bootstrap.DOMImplementationRegistry;
+import org.w3c.dom.ls.DOMImplementationLS;
+import org.w3c.dom.ls.LSInput;
+import org.w3c.dom.ls.LSParser;
+
+@Component
+public class SyncopeCamelContext {
+
+    private static final Logger LOG = 
LoggerFactory.getLogger(SyncopeCamelContext.class);
+
+    @Autowired
+    private CamelRouteDAO routeDAO;
+
+    private SpringCamelContext camelContext = null;
+
+    public SpringCamelContext getContext() {
+        synchronized (this) {
+            if (camelContext == null) {
+                camelContext = new 
SpringCamelContext(ApplicationContextProvider.getApplicationContext());
+            }
+        }
+
+        if (camelContext.getRouteDefinitions().isEmpty()) {
+            List<CamelRoute> routes = routeDAO.findAll();
+            LOG.debug("{} route(s) are going to be loaded ", routes.size());
+            loadContext(routes);
+            try {
+                camelContext.start();
+            } catch (Exception e) {
+                LOG.error("While starting Camel context", e);
+            }
+        }
+
+        return camelContext;
+    }
+
+    private void loadContext(final List<CamelRoute> routes) {
+        try {
+            DOMImplementationRegistry reg = 
DOMImplementationRegistry.newInstance();
+            DOMImplementationLS domImpl = (DOMImplementationLS) 
reg.getDOMImplementation("LS");
+            LSParser parser = 
domImpl.createLSParser(DOMImplementationLS.MODE_SYNCHRONOUS, null);
+
+            JAXBContext jaxbContext = 
JAXBContext.newInstance(Constants.JAXB_CONTEXT_PACKAGES);
+            Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();
+            List<RouteDefinition> routeDefs = new ArrayList<>();
+            for (CamelRoute route : routes) {
+                InputStream input = null;
+                try {
+                    input = IOUtils.toInputStream(route.getContent());
+                    LSInput lsinput = domImpl.createLSInput();
+                    lsinput.setByteStream(input);
+
+                    Node routeElement = 
parser.parse(lsinput).getDocumentElement();
+                    routeDefs.add(unmarshaller.unmarshal(routeElement, 
RouteDefinition.class).getValue());
+                } finally {
+                    IOUtils.closeQuietly(input);
+                }
+            }
+            camelContext.addRouteDefinitions(routeDefs);
+        } catch (Exception e) {
+            LOG.error("While loading Camel context {}", e);
+        }
+    }
+
+    public void updateContext(final String routeKey) {
+        if (camelContext == null) {
+            getContext();
+        } else {
+            if (!camelContext.getRouteDefinitions().isEmpty()) {
+                
camelContext.getRouteDefinitions().remove(camelContext.getRouteDefinition(routeKey));
+                
loadContext(Collections.singletonList(routeDAO.find(routeKey)));
+            }
+        }
+    }
+
+    public void restartContext() {
+        try {
+            camelContext.stop();
+            camelContext.start();
+        } catch (Exception e) {
+            LOG.error("While restarting Camel context", e);
+        }
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/syncope/blob/d30c8526/syncope620/ext/camel/provisioning-camel/src/main/java/org/apache/syncope/core/provisioning/camel/data/CamelRouteDataBinderImpl.java
----------------------------------------------------------------------
diff --git 
a/syncope620/ext/camel/provisioning-camel/src/main/java/org/apache/syncope/core/provisioning/camel/data/CamelRouteDataBinderImpl.java
 
b/syncope620/ext/camel/provisioning-camel/src/main/java/org/apache/syncope/core/provisioning/camel/data/CamelRouteDataBinderImpl.java
new file mode 100644
index 0000000..59113af
--- /dev/null
+++ 
b/syncope620/ext/camel/provisioning-camel/src/main/java/org/apache/syncope/core/provisioning/camel/data/CamelRouteDataBinderImpl.java
@@ -0,0 +1,48 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.syncope.core.provisioning.camel.data;
+
+import org.apache.syncope.common.lib.to.CamelRouteTO;
+import org.apache.syncope.core.misc.spring.BeanUtils;
+import org.apache.syncope.core.persistence.api.dao.CamelRouteDAO;
+import org.apache.syncope.core.persistence.api.entity.CamelRoute;
+import org.apache.syncope.core.provisioning.api.data.CamelRouteDataBinder;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+@Component
+public class CamelRouteDataBinderImpl implements CamelRouteDataBinder {
+
+    @Autowired
+    private CamelRouteDAO routeDAO;
+
+    @Override
+    public CamelRouteTO getRouteTO(final CamelRoute route) {
+        CamelRouteTO routeTO = new CamelRouteTO();
+        BeanUtils.copyProperties(route, routeTO);
+        return routeTO;
+    }
+
+    @Override
+    public void update(final CamelRoute route, final CamelRouteTO routeTO) {
+        route.setContent(routeTO.getContent());
+        routeDAO.save(route);
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/syncope/blob/d30c8526/syncope620/ext/camel/provisioning-camel/src/main/java/org/apache/syncope/core/provisioning/camel/processor/RoleCreateInSyncProcessor.java
----------------------------------------------------------------------
diff --git 
a/syncope620/ext/camel/provisioning-camel/src/main/java/org/apache/syncope/core/provisioning/camel/processor/RoleCreateInSyncProcessor.java
 
b/syncope620/ext/camel/provisioning-camel/src/main/java/org/apache/syncope/core/provisioning/camel/processor/RoleCreateInSyncProcessor.java
new file mode 100644
index 0000000..0e52082
--- /dev/null
+++ 
b/syncope620/ext/camel/provisioning-camel/src/main/java/org/apache/syncope/core/provisioning/camel/processor/RoleCreateInSyncProcessor.java
@@ -0,0 +1,72 @@
+package org.apache.syncope.core.provisioning.camel.processor;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+import java.util.AbstractMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import org.apache.camel.Exchange;
+import org.apache.camel.Processor;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.syncope.common.lib.to.AttrTO;
+import org.apache.syncope.common.lib.to.RoleTO;
+import org.apache.syncope.core.misc.security.AuthContextUtil;
+import org.apache.syncope.core.persistence.api.RoleEntitlementUtil;
+import org.apache.syncope.core.persistence.api.entity.task.PropagationTask;
+import org.apache.syncope.core.provisioning.api.WorkflowResult;
+import org.apache.syncope.core.provisioning.api.propagation.PropagationManager;
+import 
org.apache.syncope.core.provisioning.api.propagation.PropagationTaskExecutor;
+import org.springframework.stereotype.Component;
+
+@Component
+public class RoleCreateInSyncProcessor implements Processor {
+
+    @Autowired
+    protected PropagationManager propagationManager;
+
+    @Autowired
+    protected PropagationTaskExecutor taskExecutor;
+
+    @Override
+    @SuppressWarnings("unchecked")
+    public void process(final Exchange exchange) {
+        WorkflowResult<Long> created = (WorkflowResult) 
exchange.getIn().getBody();
+
+        RoleTO actual = exchange.getProperty("subject", RoleTO.class);
+        Map<Long, String> roleOwnerMap = exchange.getProperty("roleOwnerMap", 
Map.class);
+        Set<String> excludedResource = 
exchange.getProperty("excludedResources", Set.class);
+
+        AttrTO roleOwner = actual.getPlainAttrMap().get(StringUtils.EMPTY);
+        if (roleOwner != null) {
+            roleOwnerMap.put(created.getResult(), 
roleOwner.getValues().iterator().next());
+        }
+
+        AuthContextUtil.extendAuthContext(
+                created.getResult(), 
RoleEntitlementUtil.getEntitlementNameFromRoleKey(created.getResult()));
+
+        List<PropagationTask> tasks = propagationManager.getRoleCreateTaskIds(
+                created, actual.getVirAttrs(), excludedResource);
+
+        taskExecutor.execute(tasks);
+
+        exchange.getOut().setBody(new 
AbstractMap.SimpleEntry<>(created.getResult(), null));
+    }
+}

http://git-wip-us.apache.org/repos/asf/syncope/blob/d30c8526/syncope620/ext/camel/provisioning-camel/src/main/java/org/apache/syncope/core/provisioning/camel/processor/RoleCreateProcessor.java
----------------------------------------------------------------------
diff --git 
a/syncope620/ext/camel/provisioning-camel/src/main/java/org/apache/syncope/core/provisioning/camel/processor/RoleCreateProcessor.java
 
b/syncope620/ext/camel/provisioning-camel/src/main/java/org/apache/syncope/core/provisioning/camel/processor/RoleCreateProcessor.java
new file mode 100644
index 0000000..76df9f6
--- /dev/null
+++ 
b/syncope620/ext/camel/provisioning-camel/src/main/java/org/apache/syncope/core/provisioning/camel/processor/RoleCreateProcessor.java
@@ -0,0 +1,77 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.syncope.core.provisioning.camel.processor;
+
+import java.util.AbstractMap;
+import java.util.List;
+import java.util.Set;
+import org.apache.camel.Exchange;
+import org.apache.camel.Processor;
+import org.apache.syncope.common.lib.to.RoleTO;
+import org.apache.syncope.core.misc.security.AuthContextUtil;
+import org.apache.syncope.core.misc.spring.ApplicationContextProvider;
+import org.apache.syncope.core.persistence.api.RoleEntitlementUtil;
+import org.apache.syncope.core.persistence.api.entity.task.PropagationTask;
+import org.apache.syncope.core.provisioning.api.WorkflowResult;
+import 
org.apache.syncope.core.provisioning.api.propagation.PropagationException;
+import org.apache.syncope.core.provisioning.api.propagation.PropagationManager;
+import 
org.apache.syncope.core.provisioning.api.propagation.PropagationReporter;
+import 
org.apache.syncope.core.provisioning.api.propagation.PropagationTaskExecutor;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+@Component
+public class RoleCreateProcessor implements Processor {
+
+    private static final Logger LOG = 
LoggerFactory.getLogger(RoleCreateProcessor.class);
+
+    @Autowired
+    protected PropagationManager propagationManager;
+
+    @Autowired
+    protected PropagationTaskExecutor taskExecutor;
+
+    @SuppressWarnings("unchecked")
+    @Override
+    public void process(final Exchange exchange) {
+        WorkflowResult<Long> created = (WorkflowResult) 
exchange.getIn().getBody();
+        RoleTO subject = exchange.getProperty("subject", RoleTO.class);
+        Set<String> excludedResource = 
exchange.getProperty("excludedResources", Set.class);
+
+        AuthContextUtil.extendAuthContext(
+                created.getResult(), 
RoleEntitlementUtil.getEntitlementNameFromRoleKey(created.getResult()));
+
+        List<PropagationTask> tasks =
+                propagationManager.getRoleCreateTaskIds(created, 
subject.getVirAttrs(), excludedResource);
+        PropagationReporter propagationReporter =
+                
ApplicationContextProvider.getApplicationContext().getBean(PropagationReporter.class);
+        try {
+            taskExecutor.execute(tasks, propagationReporter);
+        } catch (PropagationException e) {
+            LOG.error("Error propagation primary resource", e);
+            propagationReporter.onPrimaryResourceFailure(tasks);
+        }
+
+        exchange.getOut().setBody(new AbstractMap.SimpleEntry<>(
+                created.getResult(), propagationReporter.getStatuses()));
+    }
+
+}

Reply via email to