http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/c62f91d4/extensions/router/router-core/src/main/java/org/apache/unomi/router/core/route/ProfileImportToUnomiRouteBuilder.java
----------------------------------------------------------------------
diff --git 
a/extensions/router/router-core/src/main/java/org/apache/unomi/router/core/route/ProfileImportToUnomiRouteBuilder.java
 
b/extensions/router/router-core/src/main/java/org/apache/unomi/router/core/route/ProfileImportToUnomiRouteBuilder.java
index 94c1cef..d75977b 100644
--- 
a/extensions/router/router-core/src/main/java/org/apache/unomi/router/core/route/ProfileImportToUnomiRouteBuilder.java
+++ 
b/extensions/router/router-core/src/main/java/org/apache/unomi/router/core/route/ProfileImportToUnomiRouteBuilder.java
@@ -20,7 +20,7 @@ import org.apache.camel.LoggingLevel;
 import org.apache.camel.component.jackson.JacksonDataFormat;
 import org.apache.camel.component.kafka.KafkaEndpoint;
 import org.apache.camel.model.RouteDefinition;
-import org.apache.unomi.router.core.RouterConstants;
+import org.apache.unomi.router.api.RouterConstants;
 import org.apache.unomi.router.core.processor.RouteCompletionProcessor;
 import org.apache.unomi.router.core.processor.UnomiStorageProcessor;
 import org.apache.unomi.router.core.strategy.ArrayListAggregationStrategy;

http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/c62f91d4/extensions/router/router-core/src/main/resources/OSGI-INF/blueprint/blueprint.xml
----------------------------------------------------------------------
diff --git 
a/extensions/router/router-core/src/main/resources/OSGI-INF/blueprint/blueprint.xml
 
b/extensions/router/router-core/src/main/resources/OSGI-INF/blueprint/blueprint.xml
index 86bcf47..aa39b15 100644
--- 
a/extensions/router/router-core/src/main/resources/OSGI-INF/blueprint/blueprint.xml
+++ 
b/extensions/router/router-core/src/main/resources/OSGI-INF/blueprint/blueprint.xml
@@ -25,7 +25,9 @@
 
     <cm:property-placeholder persistent-id="org.apache.unomi.router" 
update-strategy="reload">
         <cm:default-properties>
-            <cm:property name="import.config.type" value="nobroker"/>
+            <cm:property name="config.type" value="nobroker"/>
+            <cm:property name="config.allowedEndpoints" value="file,ftp"/>
+            <cm:property name="config.internalPort" value="8233"/>
             <cm:property name="kafka.host" value="localhost"/>
             <cm:property name="kafka.port" value="9092"/>
             <cm:property name="kafka.import.topic" value="camel-deposit"/>
@@ -37,6 +39,17 @@
         </cm:default-properties>
     </cm:property-placeholder>
 
+    <bean id="configSharingServiceRB" 
class="org.apache.unomi.router.core.config.ConfigSharingServiceImpl" 
destroy-method="preDestroy">
+        <property name="oneshotImportUploadDir" 
value="${import.oneshot.uploadDir}"/>
+        <property name="bundleContext" ref="blueprintBundleContext"/>
+    </bean>
+
+    <service id="configSharingServiceRBE" ref="configSharingServiceRB" 
auto-export="interfaces">
+        <service-properties>
+            <entry key="bundleDiscriminator" value="ROUTER"/>
+        </service-properties>
+    </service>
+
     <bean id="unomiStorageProcessor" 
class="org.apache.unomi.router.core.processor.UnomiStorageProcessor">
         <property name="profileImportService" ref="profileImportService"/>
     </bean>
@@ -59,6 +72,11 @@
         <property name="library" value="Jackson"/>
     </bean>
 
+    <bean id="jacksonDataFormatExportConfig" 
class="org.apache.camel.model.dataformat.JsonDataFormat">
+        <property name="unmarshalType" 
value="org.apache.unomi.router.api.ExportConfiguration"/>
+        <property name="library" value="Jackson"/>
+    </bean>
+
     <bean id="jacksonDataFormatImportLineError" 
class="org.apache.camel.model.dataformat.JsonDataFormat">
         <property name="unmarshalType" 
value="org.apache.unomi.router.api.ImportLineError"/>
         <property name="library" value="Jackson"/>
@@ -67,7 +85,7 @@
     <bean class="org.apache.camel.component.servlet.osgi.OsgiServletRegisterer"
           init-method="register"
           destroy-method="unregister">
-        <property name="alias" value="/importConfigAdmin"/>
+        <property name="alias" value="/configUpdate"/>
         <property name="httpService" ref="httpService"/>
         <property name="servlet" ref="camelServlet"/>
     </bean>
@@ -75,9 +93,10 @@
     <bean id="camelServlet" 
class="org.apache.camel.component.servlet.CamelHttpTransportServlet"/>
 
 
-    <bean id="camelContext" 
class="org.apache.unomi.router.core.context.ProfileImportCamelContext"
+    <bean id="camelContext" 
class="org.apache.unomi.router.core.context.RouterCamelContext"
           init-method="initCamelContext" destroy-method="preDestroy">
-        <property name="configType" value="${import.config.type}"/>
+        <property name="configType" value="${config.type}"/>
+        <property name="allowedEndpoints" value="${config.allowedEndpoints}"/>
         <property name="kafkaProps">
             <map>
                 <entry key="kafkaHost" value="${kafka.host}"/>
@@ -93,20 +112,24 @@
         <property name="routeCompletionProcessor" 
ref="routeCompletionProcessor"/>
         <property name="importConfigByFileNameProcessor" 
ref="importConfigByFileNameProcessor"/>
         <property name="importConfigurationService" 
ref="importConfigurationService"/>
+        <property name="exportConfigurationService" 
ref="exportConfigurationService"/>
+        <property name="persistenceService" ref="persistenceService"/>
         <property name="jacksonDataFormat" ref="jacksonDataFormat"/>
         <property name="bundleContext" ref="blueprintBundleContext"/>
     </bean>
 
     <camel:camelContext id="httpEndpoint" 
xmlns="http://camel.apache.org/schema/blueprint";>
-        <camel:routeBuilder ref="profileImportConfigUpdateRouteBuilder" />
+        <camel:routeBuilder ref="configUpdateRouteBuilder" />
     </camel:camelContext>
 
-    <bean id="profileImportConfigUpdateRouteBuilder" 
class="org.apache.unomi.router.core.route.ProfileImportConfigUpdateRouteBuilder">
-        <property name="profileImportCamelContext" ref="camelContext"/>
+    <bean id="configUpdateRouteBuilder" 
class="org.apache.unomi.router.core.route.ConfigUpdateRouteBuilder">
+        <property name="routerCamelContext" ref="camelContext"/>
     </bean>
 
     <reference id="httpService" interface="org.osgi.service.http.HttpService"/>
     <reference id="profileImportService" 
interface="org.apache.unomi.router.api.services.ProfileImportService"/>
-    <reference id="importConfigurationService" 
interface="org.apache.unomi.router.api.services.ImportConfigurationService"/>
+    <reference id="persistenceService" 
interface="org.apache.unomi.persistence.spi.PersistenceService"/>
+    <reference id="importConfigurationService" 
interface="org.apache.unomi.router.api.services.ImportExportConfigurationService"
 filter="(configDiscriminator=IMPORT)"/>
+    <reference id="exportConfigurationService" 
interface="org.apache.unomi.router.api.services.ImportExportConfigurationService"
 filter="(configDiscriminator=EXPORT)"/>
 
 </blueprint>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/c62f91d4/extensions/router/router-core/src/main/resources/org.apache.unomi.router.cfg
----------------------------------------------------------------------
diff --git 
a/extensions/router/router-core/src/main/resources/org.apache.unomi.router.cfg 
b/extensions/router/router-core/src/main/resources/org.apache.unomi.router.cfg
index e301b58..2aa385f 100644
--- 
a/extensions/router/router-core/src/main/resources/org.apache.unomi.router.cfg
+++ 
b/extensions/router/router-core/src/main/resources/org.apache.unomi.router.cfg
@@ -32,4 +32,10 @@ import.config.type=nobroker
 import.oneshot.uploadDir=${karaf.data}/tmp/unomi_oneshot_import_configs/
 
 #Import executions history size
-import.executionsHistory.size=5
\ No newline at end of file
+import.executionsHistory.size=5
+
+#Allowed source endpoints
+config.allowedEndpoints=file,ftp
+
+#Internal Camel REST services port (Not public - DO NOT OPEN TO PUBLIC)
+config.internalPort=8233
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/c62f91d4/extensions/router/router-karaf-feature/pom.xml
----------------------------------------------------------------------
diff --git a/extensions/router/router-karaf-feature/pom.xml 
b/extensions/router/router-karaf-feature/pom.xml
index 213f607..0bb1b11 100644
--- a/extensions/router/router-karaf-feature/pom.xml
+++ b/extensions/router/router-karaf-feature/pom.xml
@@ -147,7 +147,7 @@
                 <groupId>org.apache.karaf.tooling</groupId>
                 <artifactId>karaf-maven-plugin</artifactId>
                 <configuration>
-                    <startLevel>90</startLevel>
+                    <startLevel>77</startLevel>
                 </configuration>
             </plugin>
         </plugins>

http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/c62f91d4/extensions/router/router-rest/src/main/java/org/apache/unomi/router/rest/AbstractConfigurationServiceEndpoint.java
----------------------------------------------------------------------
diff --git 
a/extensions/router/router-rest/src/main/java/org/apache/unomi/router/rest/AbstractConfigurationServiceEndpoint.java
 
b/extensions/router/router-rest/src/main/java/org/apache/unomi/router/rest/AbstractConfigurationServiceEndpoint.java
new file mode 100644
index 0000000..195cd68
--- /dev/null
+++ 
b/extensions/router/router-rest/src/main/java/org/apache/unomi/router/rest/AbstractConfigurationServiceEndpoint.java
@@ -0,0 +1,92 @@
+/*
+ * 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.unomi.router.rest;
+
+import org.apache.unomi.api.services.ConfigSharingService;
+import org.apache.unomi.router.api.services.ImportExportConfigurationService;
+
+import javax.jws.WebMethod;
+import javax.ws.rs.*;
+import javax.ws.rs.core.MediaType;
+import java.util.List;
+
+/**
+ * Created by amidani on 26/06/2017.
+ */
+public abstract class AbstractConfigurationServiceEndpoint<T> {
+
+    protected ImportExportConfigurationService<T> configurationService;
+    protected ConfigSharingService routerConfigSharingService;
+    protected ConfigSharingService clusterConfigSharingService;
+
+    @WebMethod(exclude = true)
+    public void setRouterConfigSharingService(ConfigSharingService 
routerConfigSharingService) {
+        this.routerConfigSharingService = routerConfigSharingService;
+    }
+
+    @WebMethod(exclude = true)
+    public void setClusterConfigSharingService(ConfigSharingService 
clusterConfigSharingService) {
+        this.clusterConfigSharingService = clusterConfigSharingService;
+    }
+
+    /**
+     * Retrieves all the configurations.
+     *
+     * @return all the configurations.
+     */
+    @GET
+    @Path("/")
+    @Produces(MediaType.APPLICATION_JSON)
+    @Consumes(MediaType.APPLICATION_JSON)
+    public List<T> getConfigurations() {
+        return this.configurationService.getAll();
+    }
+
+    @POST
+    @Path("/")
+    @Produces(MediaType.APPLICATION_JSON)
+    @Consumes(MediaType.APPLICATION_JSON)
+    public abstract T saveConfiguration(T configuration);
+
+    /**
+     * Retrieves a configuration by id.
+     *
+     * @return the configuration that matches the given id.
+     */
+    @GET
+    @Path("/{configId}")
+    @Produces(MediaType.APPLICATION_JSON)
+    @Consumes(MediaType.APPLICATION_JSON)
+    public T getConfiguration(@PathParam("configId") String configId) {
+        return this.configurationService.load(configId);
+    }
+
+    /**
+     * Delete a configuration by id.
+     *
+     * @return the deleted configuration.
+     */
+    @DELETE
+    @Path("/{configId}")
+    @Produces(MediaType.APPLICATION_JSON)
+    @Consumes(MediaType.APPLICATION_JSON)
+    public void deleteImportConfiguration(@PathParam("configId") String 
configId) {
+        this.configurationService.delete(configId);
+    }
+
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/c62f91d4/extensions/router/router-rest/src/main/java/org/apache/unomi/router/rest/ExportConfigurationServiceEndPoint.java
----------------------------------------------------------------------
diff --git 
a/extensions/router/router-rest/src/main/java/org/apache/unomi/router/rest/ExportConfigurationServiceEndPoint.java
 
b/extensions/router/router-rest/src/main/java/org/apache/unomi/router/rest/ExportConfigurationServiceEndPoint.java
new file mode 100644
index 0000000..d5130ba
--- /dev/null
+++ 
b/extensions/router/router-rest/src/main/java/org/apache/unomi/router/rest/ExportConfigurationServiceEndPoint.java
@@ -0,0 +1,86 @@
+/*
+ * 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.unomi.router.rest;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import org.apache.cxf.rs.security.cors.CrossOriginResourceSharing;
+import org.apache.http.HttpResponse;
+import org.apache.http.client.methods.HttpPut;
+import org.apache.http.entity.StringEntity;
+import org.apache.http.impl.client.CloseableHttpClient;
+import org.apache.http.impl.client.HttpClients;
+import org.apache.unomi.router.api.ExportConfiguration;
+import org.apache.unomi.router.api.RouterConstants;
+import org.apache.unomi.router.api.services.ImportExportConfigurationService;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.jws.WebMethod;
+import javax.jws.WebService;
+import javax.ws.rs.core.MediaType;
+import java.io.IOException;
+
+/**
+ * A JAX-RS endpoint to manage {@link ExportConfiguration}s.
+ */
+@WebService
+@CrossOriginResourceSharing(
+        allowAllOrigins = true,
+        allowCredentials = true
+)
+public class ExportConfigurationServiceEndPoint extends 
AbstractConfigurationServiceEndpoint<ExportConfiguration> {
+
+    private static final Logger logger = 
LoggerFactory.getLogger(ExportConfigurationServiceEndPoint.class.getName());
+
+    public ExportConfigurationServiceEndPoint() {
+        logger.info("Initializing export configuration service endpoint...");
+    }
+
+    @WebMethod(exclude = true)
+    public void 
setExportConfigurationService(ImportExportConfigurationService<ExportConfiguration>
 exportConfigurationService) {
+        configurationService = exportConfigurationService;
+    }
+
+    /**
+     * Save the given export configuration.
+     *
+     * @return the export configuration saved.
+     */
+    public ExportConfiguration saveConfiguration(ExportConfiguration 
exportConfiguration) {
+        ExportConfiguration exportConfigSaved = 
configurationService.save(exportConfiguration);
+        if 
(RouterConstants.IMPORT_EXPORT_CONFIG_TYPE_RECURRENT.equals(exportConfigSaved.getConfigType()))
 {
+            CloseableHttpClient httpClient = HttpClients.createDefault();
+            try {
+                HttpPut httpPut = new HttpPut("http://localhost:"; + 
clusterConfigSharingService.getInternalServerPort() + 
"/configUpdate/exportConfigAdmin");
+                StringEntity input = new StringEntity(new 
ObjectMapper().writeValueAsString(exportConfigSaved));
+                input.setContentType(MediaType.APPLICATION_JSON);
+                httpPut.setEntity(input);
+
+                HttpResponse response = httpClient.execute(httpPut);
+
+                if (response.getStatusLine().getStatusCode() != 200) {
+                    throw new RuntimeException("Failed : HTTP error code : "
+                            + response.getStatusLine().getStatusCode());
+                }
+            } catch (IOException e) {
+                logger.warn("Unable to update Camel route [{}]", 
exportConfiguration.getItemId());
+            }
+        }
+
+        return exportConfigSaved;
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/c62f91d4/extensions/router/router-rest/src/main/java/org/apache/unomi/router/rest/ImportConfigurationServiceEndPoint.java
----------------------------------------------------------------------
diff --git 
a/extensions/router/router-rest/src/main/java/org/apache/unomi/router/rest/ImportConfigurationServiceEndPoint.java
 
b/extensions/router/router-rest/src/main/java/org/apache/unomi/router/rest/ImportConfigurationServiceEndPoint.java
index 42670b2..e05167f 100644
--- 
a/extensions/router/router-rest/src/main/java/org/apache/unomi/router/rest/ImportConfigurationServiceEndPoint.java
+++ 
b/extensions/router/router-rest/src/main/java/org/apache/unomi/router/rest/ImportConfigurationServiceEndPoint.java
@@ -17,8 +17,8 @@
 package org.apache.unomi.router.rest;
 
 import com.fasterxml.jackson.databind.ObjectMapper;
-import org.apache.cxf.jaxrs.ext.multipart.Multipart;
 import org.apache.cxf.jaxrs.ext.multipart.Attachment;
+import org.apache.cxf.jaxrs.ext.multipart.Multipart;
 import org.apache.cxf.rs.security.cors.CrossOriginResourceSharing;
 import org.apache.http.HttpResponse;
 import org.apache.http.client.methods.HttpPut;
@@ -26,113 +26,56 @@ import org.apache.http.entity.StringEntity;
 import org.apache.http.impl.client.CloseableHttpClient;
 import org.apache.http.impl.client.HttpClients;
 import org.apache.unomi.router.api.ImportConfiguration;
-import org.apache.unomi.router.api.services.ImportConfigurationService;
+import org.apache.unomi.router.api.RouterConstants;
+import org.apache.unomi.router.api.services.ImportExportConfigurationService;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import javax.jws.WebMethod;
 import javax.jws.WebService;
-import javax.ws.rs.*;
+import javax.ws.rs.Consumes;
+import javax.ws.rs.POST;
+import javax.ws.rs.Path;
+import javax.ws.rs.Produces;
 import javax.ws.rs.core.MediaType;
 import javax.ws.rs.core.Response;
 import java.io.IOException;
 import java.io.InputStream;
 import java.nio.file.Files;
 import java.nio.file.Paths;
-import java.util.List;
 
 /**
- * A JAX-RS endpoint to manage {@link 
org.apache.unomi.router.api.ImportConfiguration}s.
+ * A JAX-RS endpoint to manage {@link ImportConfiguration}s.
  */
 @WebService
 @CrossOriginResourceSharing(
         allowAllOrigins = true,
         allowCredentials = true
 )
-public class ImportConfigurationServiceEndPoint {
+public class ImportConfigurationServiceEndPoint extends 
AbstractConfigurationServiceEndpoint<ImportConfiguration> {
 
     private static final Logger logger = 
LoggerFactory.getLogger(ImportConfigurationServiceEndPoint.class.getName());
-    private final String CONFIG_TYPE_RECURRENT = "recurrent";
 
-    private ImportConfigurationService importConfigurationService;
-    private String uploadDir;
-    private String serverPort;
-
-    public ImportConfigurationServiceEndPoint () {
+    public ImportConfigurationServiceEndPoint() {
         logger.info("Initializing import configuration service endpoint...");
     }
 
     @WebMethod(exclude = true)
-    public void setImportConfigurationService(ImportConfigurationService 
importConfigurationService) {
-        this.importConfigurationService = importConfigurationService;
-    }
-
-    @WebMethod(exclude = true)
-    public void setUploadDir(String uploadDir) {
-        this.uploadDir = uploadDir;
-    }
-
-    @WebMethod(exclude = true)
-    public void setServerPort(String serverPort) {
-        this.serverPort = serverPort;
-    }
-
-    /**
-     * Retrieves all the import configurations.
-     *
-     * @return all the import configurations.
-     */
-    @GET
-    @Path("/")
-    @Produces(MediaType.APPLICATION_JSON)
-    @Consumes(MediaType.APPLICATION_JSON)
-    public List<ImportConfiguration> getImportConfigurations() {
-        return importConfigurationService.getImportConfigurations();
-    }
-
-    /**
-     * Retrieves an import configuration by id.
-     *
-     * @return the import configuration that matches the given id.
-     */
-    @GET
-    @Path("/{configId}")
-    @Produces(MediaType.APPLICATION_JSON)
-    @Consumes(MediaType.APPLICATION_JSON)
-    public ImportConfiguration getImportConfiguration(@PathParam("configId") 
String configId) {
-        return importConfigurationService.load(configId);
-    }
-
-    /**
-     * Delete an import configuration by id.
-     *
-     * @return the deleted import configuration.
-     */
-    @DELETE
-    @Path("/{configId}")
-    @Produces(MediaType.APPLICATION_JSON)
-    @Consumes(MediaType.APPLICATION_JSON)
-    public void deleteImportConfiguration(@PathParam("configId") String 
configId) {
-        importConfigurationService.delete(configId);
+    public void 
setImportConfigurationService(ImportExportConfigurationService<ImportConfiguration>
 importConfigurationService) {
+        configurationService = importConfigurationService;
     }
 
-
-
     /**
      * Save the given import configuration.
      *
      * @return the import configuration saved.
      */
-    @POST
-    @Path("/")
-    @Produces(MediaType.APPLICATION_JSON)
-    @Consumes(MediaType.APPLICATION_JSON)
-    public ImportConfiguration saveImportConfiguration(ImportConfiguration 
importConfiguration) {
-        ImportConfiguration importConfigSaved = 
importConfigurationService.save(importConfiguration);
-        if(CONFIG_TYPE_RECURRENT.equals(importConfigSaved.getConfigType())) {
+    public ImportConfiguration saveConfiguration(ImportConfiguration 
importConfiguration) {
+        ImportConfiguration importConfigSaved = 
configurationService.save(importConfiguration);
+        if 
(RouterConstants.IMPORT_EXPORT_CONFIG_TYPE_RECURRENT.equals(importConfigSaved.getConfigType()))
 {
             CloseableHttpClient httpClient = HttpClients.createDefault();
             try {
-                HttpPut httpPut = new 
HttpPut("http://localhost:"+serverPort+"/importConfigAdmin/";);
+                HttpPut httpPut = new HttpPut("http://localhost:"; + 
clusterConfigSharingService.getInternalServerPort() + 
"/configUpdate/importConfigAdmin");
                 StringEntity input = new StringEntity(new 
ObjectMapper().writeValueAsString(importConfigSaved));
                 input.setContentType(MediaType.APPLICATION_JSON);
                 httpPut.setEntity(input);
@@ -153,6 +96,7 @@ public class ImportConfigurationServiceEndPoint {
     /**
      * Save/Update the given import configuration.
      * Prepare the file to be processed with Camel routes
+     *
      * @return OK / NOK Http Code.
      */
     @POST
@@ -161,7 +105,7 @@ public class ImportConfigurationServiceEndPoint {
     @Produces(MediaType.APPLICATION_JSON)
     public Response processOneshotImportConfigurationCSV(@Multipart(value = 
"importConfigId") String importConfigId, @Multipart(value = "file") Attachment 
file) {
         try {
-            java.nio.file.Path path = 
Paths.get(uploadDir+importConfigId+".csv");
+            java.nio.file.Path path = 
Paths.get(routerConfigSharingService.getOneshotImportUploadDir() + 
importConfigId + ".csv");
             Files.deleteIfExists(path);
             InputStream in = file.getObject(InputStream.class);
 

http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/c62f91d4/extensions/router/router-rest/src/main/resources/OSGI-INF/blueprint/blueprint.xml
----------------------------------------------------------------------
diff --git 
a/extensions/router/router-rest/src/main/resources/OSGI-INF/blueprint/blueprint.xml
 
b/extensions/router/router-rest/src/main/resources/OSGI-INF/blueprint/blueprint.xml
index 8728a7f..fd36e50 100644
--- 
a/extensions/router/router-rest/src/main/resources/OSGI-INF/blueprint/blueprint.xml
+++ 
b/extensions/router/router-rest/src/main/resources/OSGI-INF/blueprint/blueprint.xml
@@ -24,18 +24,6 @@
                               http://cxf.apache.org/blueprint/jaxrs 
http://cxf.apache.org/schemas/blueprint/jaxrs.xsd
                               http://cxf.apache.org/blueprint/core 
http://cxf.apache.org/schemas/blueprint/core.xsd
                               
http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.1.0 
http://aries.apache.org/schemas/blueprint-cm/blueprint-cm-1.1.0.xsd";>
-    <cm:property-placeholder persistent-id="org.apache.unomi.router" 
update-strategy="reload">
-        <cm:default-properties>
-            <cm:property name="import.oneshot.uploadDir" 
value="/tmp/oneshot_import_configs/"/>
-        </cm:default-properties>
-    </cm:property-placeholder>
-
-    <cm:property-placeholder persistent-id="org.apache.unomi.cluster"
-                             update-strategy="reload" 
placeholder-prefix="${cluster.">
-        <cm:default-properties>
-            <cm:property name="cluster.contextserver.port" value="8181"/>
-        </cm:default-properties>
-    </cm:property-placeholder>
 
     <cxf:bus id="cxsServiceBus">
         <cxf:features>
@@ -69,12 +57,40 @@
         </jaxrs:serviceBeans>
     </jaxrs:server>
 
-    <reference id="importConfigurationService" 
interface="org.apache.unomi.router.api.services.ImportConfigurationService"/>
+    <jaxrs:server address="/exportConfiguration" 
id="restExportConfigurationService">
+        <jaxrs:providers>
+            <ref component-id="json-provider"/>
+            <ref component-id="cors-filter"/>
+            <ref component-id="jaas-filter"/>
+        </jaxrs:providers>
+
+        <jaxrs:serviceBeans>
+            <ref component-id="exportConfigurationServiceEndPoint"/>
+        </jaxrs:serviceBeans>
+    </jaxrs:server>
+
+    <reference id="importConfigurationService" 
interface="org.apache.unomi.router.api.services.ImportExportConfigurationService"
+            filter="(configDiscriminator=IMPORT)"/>
+
+    <reference id="exportConfigurationService" 
interface="org.apache.unomi.router.api.services.ImportExportConfigurationService"
+               filter="(configDiscriminator=EXPORT)"/>
+
+    <reference id="configSharingServiceRouter" 
interface="org.apache.unomi.api.services.ConfigSharingService"
+               filter="(bundleDiscriminator=ROUTER)"/>
+
+    <reference id="configSharingServiceCluster" 
interface="org.apache.unomi.api.services.ConfigSharingService"
+               filter="(bundleDiscriminator=SERVICES)"/>
 
     <bean id="importConfigurationServiceEndPoint" 
class="org.apache.unomi.router.rest.ImportConfigurationServiceEndPoint">
         <property name="importConfigurationService" 
ref="importConfigurationService"/>
-        <property name="uploadDir" value="${import.oneshot.uploadDir}"/>
-        <property name="serverPort" value="${cluster.contextserver.port}"/>
+        <property name="routerConfigSharingService" 
ref="configSharingServiceRouter"/>
+        <property name="clusterConfigSharingService" 
ref="configSharingServiceCluster"/>
+    </bean>
+
+    <bean id="exportConfigurationServiceEndPoint" 
class="org.apache.unomi.router.rest.ExportConfigurationServiceEndPoint">
+        <property name="exportConfigurationService" 
ref="exportConfigurationService"/>
+        <property name="routerConfigSharingService" 
ref="configSharingServiceRouter"/>
+        <property name="clusterConfigSharingService" 
ref="configSharingServiceCluster"/>
     </bean>
 
 </blueprint>

http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/c62f91d4/extensions/router/router-service/src/main/java/org/apache/unomi/router/services/AbstractConfigurationServiceImpl.java
----------------------------------------------------------------------
diff --git 
a/extensions/router/router-service/src/main/java/org/apache/unomi/router/services/AbstractConfigurationServiceImpl.java
 
b/extensions/router/router-service/src/main/java/org/apache/unomi/router/services/AbstractConfigurationServiceImpl.java
new file mode 100644
index 0000000..3b87e85
--- /dev/null
+++ 
b/extensions/router/router-service/src/main/java/org/apache/unomi/router/services/AbstractConfigurationServiceImpl.java
@@ -0,0 +1,73 @@
+/*
+ * 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.unomi.router.services;
+
+import org.apache.unomi.persistence.spi.PersistenceService;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.BundleEvent;
+import org.osgi.framework.SynchronousBundleListener;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Created by amidani on 26/06/2017.
+ */
+public class AbstractConfigurationServiceImpl implements 
SynchronousBundleListener {
+
+    private static final Logger logger = 
LoggerFactory.getLogger(AbstractConfigurationServiceImpl.class.getName());
+
+    protected BundleContext bundleContext;
+    protected PersistenceService persistenceService;
+
+    public void setBundleContext(BundleContext bundleContext) {
+        this.bundleContext = bundleContext;
+    }
+
+    public void setPersistenceService(PersistenceService persistenceService) {
+        this.persistenceService = persistenceService;
+    }
+
+    public void postConstruct() {
+        logger.debug("postConstruct {" + bundleContext.getBundle() + "}");
+
+        processBundleStartup(bundleContext);
+        for (Bundle bundle : bundleContext.getBundles()) {
+            if (bundle.getBundleContext() != null) {
+                processBundleStartup(bundle.getBundleContext());
+            }
+        }
+        bundleContext.addBundleListener(this);
+        logger.info("Configuration service initialized.");
+    }
+
+    public void preDestroy() {
+        bundleContext.removeBundleListener(this);
+        logger.info("Configuration service shutdown.");
+    }
+
+    @Override
+    public void bundleChanged(BundleEvent bundleEvent) {
+
+    }
+
+    private void processBundleStartup(BundleContext bundleContext) {
+        if (bundleContext == null) {
+            return;
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/c62f91d4/extensions/router/router-service/src/main/java/org/apache/unomi/router/services/ExportConfigurationServiceImpl.java
----------------------------------------------------------------------
diff --git 
a/extensions/router/router-service/src/main/java/org/apache/unomi/router/services/ExportConfigurationServiceImpl.java
 
b/extensions/router/router-service/src/main/java/org/apache/unomi/router/services/ExportConfigurationServiceImpl.java
new file mode 100644
index 0000000..762a65f
--- /dev/null
+++ 
b/extensions/router/router-service/src/main/java/org/apache/unomi/router/services/ExportConfigurationServiceImpl.java
@@ -0,0 +1,61 @@
+/*
+ * 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.unomi.router.services;
+
+import org.apache.unomi.router.api.ExportConfiguration;
+import org.apache.unomi.router.api.services.ImportExportConfigurationService;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.List;
+import java.util.UUID;
+
+/**
+ * Created by amidani on 28/04/2017.
+ */
+public class ExportConfigurationServiceImpl extends 
AbstractConfigurationServiceImpl implements 
ImportExportConfigurationService<ExportConfiguration> {
+
+    private static final Logger logger = 
LoggerFactory.getLogger(ExportConfigurationServiceImpl.class.getName());
+
+    public ExportConfigurationServiceImpl() {
+        logger.info("Initializing export configuration service...");
+    }
+
+    @Override
+    public List<ExportConfiguration> getAll() {
+        return persistenceService.getAllItems(ExportConfiguration.class);
+    }
+
+    @Override
+    public ExportConfiguration load(String configId) {
+        return persistenceService.load(configId, ExportConfiguration.class);
+    }
+
+    @Override
+    public ExportConfiguration save(ExportConfiguration exportConfiguration) {
+        if (exportConfiguration.getItemId() == null) {
+            exportConfiguration.setItemId(UUID.randomUUID().toString());
+        }
+        persistenceService.save(exportConfiguration);
+        return persistenceService.load(exportConfiguration.getItemId(), 
ExportConfiguration.class);
+    }
+
+    @Override
+    public void delete(String configId) {
+        persistenceService.remove(configId, ExportConfiguration.class);
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/c62f91d4/extensions/router/router-service/src/main/java/org/apache/unomi/router/services/ImportConfigurationServiceImpl.java
----------------------------------------------------------------------
diff --git 
a/extensions/router/router-service/src/main/java/org/apache/unomi/router/services/ImportConfigurationServiceImpl.java
 
b/extensions/router/router-service/src/main/java/org/apache/unomi/router/services/ImportConfigurationServiceImpl.java
index 5283cce..5275919 100644
--- 
a/extensions/router/router-service/src/main/java/org/apache/unomi/router/services/ImportConfigurationServiceImpl.java
+++ 
b/extensions/router/router-service/src/main/java/org/apache/unomi/router/services/ImportConfigurationServiceImpl.java
@@ -14,16 +14,10 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-
 package org.apache.unomi.router.services;
 
 import org.apache.unomi.router.api.ImportConfiguration;
-import org.apache.unomi.router.api.services.ImportConfigurationService;
-import org.apache.unomi.persistence.spi.PersistenceService;
-import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.BundleEvent;
-import org.osgi.framework.SynchronousBundleListener;
+import org.apache.unomi.router.api.services.ImportExportConfigurationService;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -33,55 +27,16 @@ import java.util.UUID;
 /**
  * Created by amidani on 28/04/2017.
  */
-public class ImportConfigurationServiceImpl implements 
ImportConfigurationService,SynchronousBundleListener {
+public class ImportConfigurationServiceImpl extends 
AbstractConfigurationServiceImpl implements 
ImportExportConfigurationService<ImportConfiguration> {
 
     private static final Logger logger = 
LoggerFactory.getLogger(ImportConfigurationServiceImpl.class.getName());
 
-    private BundleContext bundleContext;
-    private PersistenceService persistenceService;
-
     public ImportConfigurationServiceImpl() {
         logger.info("Initializing import configuration service...");
     }
 
-    public void setBundleContext(BundleContext bundleContext) {
-        this.bundleContext = bundleContext;
-    }
-
-    public void setPersistenceService(PersistenceService persistenceService) {
-        this.persistenceService = persistenceService;
-    }
-
-    public void postConstruct() {
-        logger.debug("postConstruct {" + bundleContext.getBundle() + "}");
-
-        processBundleStartup(bundleContext);
-        for (Bundle bundle : bundleContext.getBundles()) {
-            if (bundle.getBundleContext() != null) {
-                processBundleStartup(bundle.getBundleContext());
-            }
-        }
-        bundleContext.addBundleListener(this);
-        logger.info("Import configuration service initialized.");
-    }
-
-    public void preDestroy() {
-        bundleContext.removeBundleListener(this);
-        logger.info("Import configuration service shutdown.");
-    }
-
-    private void processBundleStartup(BundleContext bundleContext) {
-        if (bundleContext == null) {
-            return;
-        }
-    }
-
-    private void processBundleStop(BundleContext bundleContext) {
-    }
-
-
     @Override
-    public List<ImportConfiguration> getImportConfigurations() {
+    public List<ImportConfiguration> getAll() {
         return persistenceService.getAllItems(ImportConfiguration.class);
     }
 
@@ -103,9 +58,4 @@ public class ImportConfigurationServiceImpl implements 
ImportConfigurationServic
     public void delete(String configId) {
         persistenceService.remove(configId, ImportConfiguration.class);
     }
-
-    @Override
-    public void bundleChanged(BundleEvent bundleEvent) {
-
-    }
 }

http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/c62f91d4/extensions/router/router-service/src/main/resources/OSGI-INF/blueprint/blueprint.xml
----------------------------------------------------------------------
diff --git 
a/extensions/router/router-service/src/main/resources/OSGI-INF/blueprint/blueprint.xml
 
b/extensions/router/router-service/src/main/resources/OSGI-INF/blueprint/blueprint.xml
index 61200f2..ac66f41 100644
--- 
a/extensions/router/router-service/src/main/resources/OSGI-INF/blueprint/blueprint.xml
+++ 
b/extensions/router/router-service/src/main/resources/OSGI-INF/blueprint/blueprint.xml
@@ -27,7 +27,22 @@
         <property name="persistenceService" ref="persistenceService"/>
         <property name="bundleContext" ref="blueprintBundleContext"/>
     </bean>
-    <service id="importConfigurationService" 
ref="importConfigurationServiceImpl" auto-export="interfaces"/>
+    <service id="importConfigurationService" 
ref="importConfigurationServiceImpl" auto-export="interfaces">
+        <service-properties>
+            <entry key="configDiscriminator" value="IMPORT"/>
+        </service-properties>
+    </service>
+
+    <bean id="exportConfigurationServiceImpl" 
class="org.apache.unomi.router.services.ExportConfigurationServiceImpl"
+          init-method="postConstruct" destroy-method="preDestroy">
+        <property name="persistenceService" ref="persistenceService"/>
+        <property name="bundleContext" ref="blueprintBundleContext"/>
+    </bean>
+    <service id="exportConfigurationService" 
ref="exportConfigurationServiceImpl" auto-export="interfaces">
+        <service-properties>
+            <entry key="configDiscriminator" value="EXPORT"/>
+        </service-properties>
+    </service>
 
     <bean id="profileImportServiceImpl" 
class="org.apache.unomi.router.services.ProfileImportServiceImpl"
           init-method="postConstruct" destroy-method="preDestroy">


Reply via email to