Repository: incubator-unomi
Updated Branches:
  refs/heads/feature-UNOMI-102 c62f91d4b -> cb83301ff


UNOMI-106 : Expose a service to share cfg properties with other bundles


Project: http://git-wip-us.apache.org/repos/asf/incubator-unomi/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-unomi/commit/cb83301f
Tree: http://git-wip-us.apache.org/repos/asf/incubator-unomi/tree/cb83301f
Diff: http://git-wip-us.apache.org/repos/asf/incubator-unomi/diff/cb83301f

Branch: refs/heads/feature-UNOMI-102
Commit: cb83301ffdaa6fb0fef9969fbaf4582c0d1df2b4
Parents: c62f91d4
Author: Abdelkader Midani <amid...@apache.org>
Authored: Wed Jun 28 02:31:06 2017 +0200
Committer: Abdelkader Midani <amid...@apache.org>
Committed: Wed Jun 28 02:31:06 2017 +0200

----------------------------------------------------------------------
 .../services/ConfigSharingServiceImpl.java      | 80 ++++++++++++++++++++
 .../resources/OSGI-INF/blueprint/blueprint.xml  | 11 +++
 2 files changed, 91 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/cb83301f/services/src/main/java/org/apache/unomi/services/services/ConfigSharingServiceImpl.java
----------------------------------------------------------------------
diff --git 
a/services/src/main/java/org/apache/unomi/services/services/ConfigSharingServiceImpl.java
 
b/services/src/main/java/org/apache/unomi/services/services/ConfigSharingServiceImpl.java
new file mode 100644
index 0000000..2b7da8a
--- /dev/null
+++ 
b/services/src/main/java/org/apache/unomi/services/services/ConfigSharingServiceImpl.java
@@ -0,0 +1,80 @@
+/*
+ * 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.services.services;
+
+import org.apache.unomi.api.services.ConfigSharingService;
+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 27/06/2017.
+ */
+public class ConfigSharingServiceImpl implements ConfigSharingService, 
SynchronousBundleListener {
+
+    private static final Logger logger = 
LoggerFactory.getLogger(ConfigSharingServiceImpl.class);
+
+    private String internalServerPort;
+
+    private BundleContext bundleContext;
+
+    public void setBundleContext(BundleContext bundleContext) {
+        this.bundleContext = bundleContext;
+    }
+
+    @Override
+    public String getInternalServerPort() {
+        return this.internalServerPort;
+    }
+
+    @Override
+    public void setInternalServerPort(String internalServerPort) {
+        this.internalServerPort = internalServerPort;
+    }
+
+    /**
+     * Methods below not used in services bundle implementation of the 
ConfigSharingService
+     **/
+
+    @Override
+    public String getOneshotImportUploadDir() {
+        return null;
+    }
+
+    @Override
+    public void setOneshotImportUploadDir(String oneshotImportUploadDir) {
+    }
+
+    public void preDestroy() throws Exception {
+        bundleContext.removeBundleListener(this);
+        logger.info("Config sharing service for Service is shutdown.");
+    }
+
+    private void processBundleStartup(BundleContext bundleContext) {
+        if (bundleContext == null) {
+            return;
+        }
+    }
+
+    @Override
+    public void bundleChanged(BundleEvent bundleEvent) {
+
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/cb83301f/services/src/main/resources/OSGI-INF/blueprint/blueprint.xml
----------------------------------------------------------------------
diff --git a/services/src/main/resources/OSGI-INF/blueprint/blueprint.xml 
b/services/src/main/resources/OSGI-INF/blueprint/blueprint.xml
index fa2d3dd..b6c4f6c 100644
--- a/services/src/main/resources/OSGI-INF/blueprint/blueprint.xml
+++ b/services/src/main/resources/OSGI-INF/blueprint/blueprint.xml
@@ -235,4 +235,15 @@
         </bean>
     </service>
 
+    <bean id="configSharingServiceCB" 
class="org.apache.unomi.services.services.ConfigSharingServiceImpl" 
destroy-method="preDestroy">
+        <property name="internalServerPort" 
value="${cluster.contextserver.port}"/>
+        <property name="bundleContext" ref="blueprintBundleContext"/>
+    </bean>
+
+    <service id="configSharingServiceCBE" ref="configSharingServiceCB" 
auto-export="interfaces">
+        <service-properties>
+            <entry key="bundleDiscriminator" value="SERVICES"/>
+        </service-properties>
+    </service>
+
 </blueprint>

Reply via email to