You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by cz...@apache.org on 2023/12/04 14:12:24 UTC
(sling-org-apache-sling-scripting-sightly) branch master updated: SLING-12176 : Replace usage of commons.osgi with osgi converter
This is an automated email from the ASF dual-hosted git repository.
cziegeler pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-scripting-sightly.git
The following commit(s) were added to refs/heads/master by this push:
new 6d94526 SLING-12176 : Replace usage of commons.osgi with osgi converter
6d94526 is described below
commit 6d94526f18855eec1bcda5d58d508a6b5fab81f4
Author: Carsten Ziegeler <cz...@apache.org>
AuthorDate: Mon Dec 4 13:35:11 2023 +0100
SLING-12176 : Replace usage of commons.osgi with osgi converter
---
pom.xml | 12 ++++++------
.../sightly/impl/engine/ExtensionRegistryService.java | 4 ++--
.../sightly/impl/engine/RuntimeExtensionReference.java | 15 ++++++++++-----
3 files changed, 18 insertions(+), 13 deletions(-)
diff --git a/pom.xml b/pom.xml
index 3dc8cdc..6d5b8b2 100644
--- a/pom.xml
+++ b/pom.xml
@@ -223,6 +223,12 @@
<artifactId>org.osgi.service.metatype.annotations</artifactId>
<scope>provided</scope>
</dependency>
+ <dependency>
+ <groupId>org.osgi</groupId>
+ <artifactId>org.osgi.util.converter</artifactId>
+ <version>1.0.9</version>
+ <scope>provided</scope>
+ </dependency>
<!-- Sling APIs -->
<dependency>
@@ -231,12 +237,6 @@
<version>2.25.0</version>
<scope>provided</scope>
</dependency>
- <dependency>
- <groupId>org.apache.sling</groupId>
- <artifactId>org.apache.sling.commons.osgi</artifactId>
- <version>2.1.0</version>
- <scope>provided</scope>
- </dependency>
<dependency>
<groupId>org.apache.sling</groupId>
<artifactId>org.apache.sling.scripting.api</artifactId>
diff --git a/src/main/java/org/apache/sling/scripting/sightly/impl/engine/ExtensionRegistryService.java b/src/main/java/org/apache/sling/scripting/sightly/impl/engine/ExtensionRegistryService.java
index 4c7ecbc..b5728c8 100644
--- a/src/main/java/org/apache/sling/scripting/sightly/impl/engine/ExtensionRegistryService.java
+++ b/src/main/java/org/apache/sling/scripting/sightly/impl/engine/ExtensionRegistryService.java
@@ -24,13 +24,13 @@ import java.util.Map;
import java.util.Set;
import java.util.TreeSet;
-import org.apache.sling.commons.osgi.PropertiesUtil;
import org.apache.sling.scripting.sightly.extension.RuntimeExtension;
import org.osgi.framework.ServiceReference;
import org.osgi.service.component.annotations.Component;
import org.osgi.service.component.annotations.Reference;
import org.osgi.service.component.annotations.ReferenceCardinality;
import org.osgi.service.component.annotations.ReferencePolicy;
+import org.osgi.util.converter.Converters;
/**
* Aggregator for all runtime extensions.
@@ -64,7 +64,7 @@ public class ExtensionRegistryService {
@SuppressWarnings("unused")
protected void unbindExtensionService(ServiceReference<RuntimeExtension> serviceReference) {
synchronized (extensions) {
- String name = PropertiesUtil.toString(serviceReference.getProperty(RuntimeExtension.NAME), "");
+ String name = Converters.standardConverter().convert(serviceReference.getProperty(RuntimeExtension.NAME)).defaultValue("").to(String.class);
Set<RuntimeExtensionReference> namedExtensions = extensions.get(name);
boolean changed = false;
if (namedExtensions != null) {
diff --git a/src/main/java/org/apache/sling/scripting/sightly/impl/engine/RuntimeExtensionReference.java b/src/main/java/org/apache/sling/scripting/sightly/impl/engine/RuntimeExtensionReference.java
index 96904b6..74413e6 100644
--- a/src/main/java/org/apache/sling/scripting/sightly/impl/engine/RuntimeExtensionReference.java
+++ b/src/main/java/org/apache/sling/scripting/sightly/impl/engine/RuntimeExtensionReference.java
@@ -18,23 +18,28 @@
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
package org.apache.sling.scripting.sightly.impl.engine;
-import org.apache.sling.commons.osgi.PropertiesUtil;
import org.apache.sling.scripting.sightly.extension.RuntimeExtension;
import org.jetbrains.annotations.NotNull;
import org.osgi.framework.Constants;
import org.osgi.framework.ServiceReference;
+import org.osgi.util.converter.Converters;
class RuntimeExtensionReference implements Comparable<RuntimeExtensionReference> {
private final int priority;
private final String name;
- private ServiceReference<RuntimeExtension> serviceReference;
- private RuntimeExtension runtimeExtension;
+ private final ServiceReference<RuntimeExtension> serviceReference;
+ private final RuntimeExtension runtimeExtension;
RuntimeExtensionReference(ServiceReference<RuntimeExtension> serviceReference, RuntimeExtension runtimeExtension) {
this.serviceReference = serviceReference;
this.runtimeExtension = runtimeExtension;
- priority = PropertiesUtil.toInteger(serviceReference.getProperty(Constants.SERVICE_RANKING), 0);
- name = PropertiesUtil.toString(serviceReference.getProperty(RuntimeExtension.NAME), "");
+ final Object ranking = serviceReference.getProperty(Constants.SERVICE_RANKING);
+ if ( ranking instanceof Integer ) {
+ this.priority = (Integer)ranking;
+ } else {
+ this.priority = 0;
+ }
+ this.name = Converters.standardConverter().convert(serviceReference.getProperty(RuntimeExtension.NAME)).defaultValue("").to(String.class);
}
@Override