summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRyan Goulding <ryandgoulding@gmail.com>2017-09-14 12:37:10 -0400
committerRyan Goulding <ryandgoulding@gmail.com>2017-09-14 12:40:13 -0400
commiteb790498dacf46fc594b93bf62a6e17f686af62e (patch)
tree3acba84982203162bc41758391183ae12851b082
parentbd920facad4f9ce5e8651acb6c477446106e892f (diff)
Fix SDNC service registration
Instead of registgering services via BundleActivator(s), use blueprint instead. This change deletes the RecordingActivator, as it was just used to kickstart the service registration using felix dm. The idea here is to instead use blueprint through recording-blueprint.xml. The decision was also made to register the Service(s) using the implementation class name instead of the interface class name for backwards compatibility reasons. In all reality, registering Service(s) under the implementation name is less future proof since clients are no longer able to easily swap in a separate implementation Service. In the future, we should consider finding usages of this Service and ensuring that they poll for the interface rather than the implementation. However, that is separate from this change and is considered future work. Issue-Id: SDNC-54 Change-Id: I757bb90f91d114668c153ec5debb5c65af44452a Signed-off-by: Ryan Goulding <ryandgoulding@gmail.com>
-rwxr-xr-xsli/recording/pom.xml2
-rw-r--r--sli/recording/src/main/java/org/onap/ccsdk/sli/core/sli/recording/RecordingActivator.java75
-rw-r--r--sli/recording/src/main/resources/org/opendaylight/blueprint/recording-blueprint.xml20
3 files changed, 20 insertions, 77 deletions
diff --git a/sli/recording/pom.xml b/sli/recording/pom.xml
index 97c99188..f0bc0970 100755
--- a/sli/recording/pom.xml
+++ b/sli/recording/pom.xml
@@ -59,9 +59,7 @@
<extensions>true</extensions>
<configuration>
<instructions>
- <Bundle-Activator>org.onap.ccsdk.sli.core.sli.recording.RecordingActivator</Bundle-Activator>
<Export-Package>org.onap.ccsdk.sli.core.sli.recording;version=${project.version}</Export-Package>
- <Import-Package>*</Import-Package>
<Embed-Transitive>true</Embed-Transitive>
</instructions>
diff --git a/sli/recording/src/main/java/org/onap/ccsdk/sli/core/sli/recording/RecordingActivator.java b/sli/recording/src/main/java/org/onap/ccsdk/sli/core/sli/recording/RecordingActivator.java
deleted file mode 100644
index fd857f56..00000000
--- a/sli/recording/src/main/java/org/onap/ccsdk/sli/core/sli/recording/RecordingActivator.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP : CCSDK
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights
- * reserved.
- * ================================================================================
- * Licensed 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.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.ccsdk.sli.core.sli.recording;
-
-import java.util.LinkedList;
-
-import org.osgi.framework.BundleActivator;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.ServiceReference;
-import org.osgi.framework.ServiceRegistration;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-
-public class RecordingActivator implements BundleActivator {
-
- private LinkedList<ServiceRegistration> registrations = new LinkedList<>();
-
- private static final Logger LOG = LoggerFactory
- .getLogger(RecordingActivator.class);
-
- @Override
- public void start(BundleContext ctx) throws Exception {
-
- if (registrations == null)
- {
- registrations = new LinkedList<>();
- }
-
-
- FileRecorder fileRecorder = new FileRecorder();
- String regName = fileRecorder.getClass().getName();
- LOG.debug("Registering FileRecorder service "+regName);
- ServiceRegistration reg =ctx.registerService(regName, fileRecorder, null);
- registrations.add(reg);
-
- Slf4jRecorder slf4jRecorder = new Slf4jRecorder();
- regName = slf4jRecorder.getClass().getName();
- LOG.debug("Registering Slf4jRecorder service "+regName);
- reg =ctx.registerService(regName, slf4jRecorder, null);
- registrations.add(reg);
-
- }
-
- @Override
- public void stop(BundleContext arg0) throws Exception {
- if (registrations != null) {
- for (ServiceRegistration reg : registrations) {
- ServiceReference regRef = reg.getReference();
- reg.unregister();
- }
- registrations = null;
- }
- }
-
-}
diff --git a/sli/recording/src/main/resources/org/opendaylight/blueprint/recording-blueprint.xml b/sli/recording/src/main/resources/org/opendaylight/blueprint/recording-blueprint.xml
new file mode 100644
index 00000000..d8035376
--- /dev/null
+++ b/sli/recording/src/main/resources/org/opendaylight/blueprint/recording-blueprint.xml
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
+ xmlns:odl="http://opendaylight.org/xmlns/blueprint/v1.0.0"
+ odl:use-default-for-reference-types="true">
+
+ <bean id="fileRecorder" class="org.onap.ccsdk.sli.core.sli.recording.FileRecorder" />
+ <!-- Implementation name was chosen over interface name due to the fact that this Service
+ was previously registered using the implementation name rather than the interface name.
+ To ensure backwards compatibility with abstractions polling the Service Registry for the
+ fileRecorder, the implementation name was chosen here. -->
+ <service ref="fileRecorder" interface="org.onap.ccsdk.sli.core.sli.recording.FileRecorder" />
+
+ <bean id="slf4jRecorder" class="org.onap.ccsdk.sli.core.sli.recording.Slf4jRecorder" />
+ <!-- Implementation name was chosen over interface name due to the fact that this Service
+ was previously registered using the implementation name rather than the interface name.
+ To ensure backwards compatibility with abstractions polling the Service Registry for the
+ slf4jRecorder, the implementation name was chosen here. -->
+ <service ref="slf4jRecorder" class="org.onap.ccsdk.sli.core.sli.recording.Slf4jRecorder" />
+
+</blueprint> \ No newline at end of file