Use felix-annotations

This commit is contained in:
Michael Simacek 2016-09-26 10:23:47 +02:00
parent 0d9fe0c96f
commit a16fbef3be
4 changed files with 248 additions and 14 deletions

View File

@ -1,7 +1,7 @@
From 7b48ce7a5a1534d12598ddef711628824054f312 Mon Sep 17 00:00:00 2001
From a8e35193386a52fc560bc2da907df2868819a9e3 Mon Sep 17 00:00:00 2001
From: Michael Simacek <msimacek@redhat.com>
Date: Thu, 26 May 2016 15:43:14 +0200
Subject: [PATCH 1/2] Port to Java 8
Subject: [PATCH 1/3] Port to Java 8
---
aQute.libg/src/aQute/lib/collections/DoubleKeyMap.java | 14 --------------
@ -72,5 +72,5 @@ index 6f5f107..b35d2e1 100644
projectProperties.putAll(builder.getProperties());
builder.setProperties(projectProperties);
--
2.5.5
2.7.4

View File

@ -1,7 +1,7 @@
From d8c6cbf2aa85fb742d6db307812ccff8ce483658 Mon Sep 17 00:00:00 2001
From bfeef908b83862b6364dfcc856a26caf3be1765e Mon Sep 17 00:00:00 2001
From: Michael Simacek <msimacek@redhat.com>
Date: Thu, 26 May 2016 16:57:46 +0200
Subject: [PATCH 2/2] Remove unavailable parts
Subject: [PATCH 2/3] Remove unavailable parts
---
biz.aQute.bnd/src/aQute/bnd/main/bnd.java | 30 -----------------
@ -580,5 +580,5 @@ index 05d9023..c90b42e 100644
name = null;
--
2.5.5
2.7.4

View File

@ -0,0 +1,218 @@
From 05d71f56ce6194bc32cf65f6589e7e035af02454 Mon Sep 17 00:00:00 2001
From: Michael Simacek <msimacek@redhat.com>
Date: Mon, 26 Sep 2016 10:08:36 +0200
Subject: [PATCH 3/3] Use felix annotations
---
.../src/aQute/bnd/component/AnnotationReader.java | 27 +++++++++++-----------
.../src/aQute/bnd/component/ComponentDef.java | 3 +--
.../src/aQute/bnd/component/DSAnnotations.java | 9 ++++----
.../src/aQute/bnd/component/HeaderReader.java | 17 +++++++-------
.../src/aQute/bnd/component/ReferenceDef.java | 7 +++---
5 files changed, 30 insertions(+), 33 deletions(-)
diff --git a/biz.aQute.bndlib/src/aQute/bnd/component/AnnotationReader.java b/biz.aQute.bndlib/src/aQute/bnd/component/AnnotationReader.java
index 2a890fc..c1d6a3f 100644
--- a/biz.aQute.bndlib/src/aQute/bnd/component/AnnotationReader.java
+++ b/biz.aQute.bndlib/src/aQute/bnd/component/AnnotationReader.java
@@ -12,14 +12,6 @@ import java.util.Map.Entry;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
-import org.osgi.service.component.annotations.Activate;
-import org.osgi.service.component.annotations.Component;
-import org.osgi.service.component.annotations.Deactivate;
-import org.osgi.service.component.annotations.Modified;
-import org.osgi.service.component.annotations.Reference;
-import org.osgi.service.component.annotations.ReferenceCardinality;
-import org.osgi.service.component.annotations.ReferencePolicy;
-
import aQute.bnd.annotation.xml.XMLAttribute;
import aQute.bnd.component.DSAnnotations.Options;
import aQute.bnd.component.error.DeclarativeServicesAnnotationError;
@@ -36,6 +28,13 @@ import aQute.bnd.osgi.Verifier;
import aQute.bnd.version.Version;
import aQute.bnd.xmlattribute.XMLAttributeFinder;
import aQute.lib.collections.MultiMap;
+import org.apache.felix.scr.annotations.Activate;
+import org.apache.felix.scr.annotations.Component;
+import org.apache.felix.scr.annotations.Deactivate;
+import org.apache.felix.scr.annotations.Modified;
+import org.apache.felix.scr.annotations.Reference;
+import org.apache.felix.scr.annotations.ReferenceCardinality;
+import org.apache.felix.scr.annotations.ReferencePolicy;
/**
* Processes spec DS annotations into xml.
@@ -621,11 +620,11 @@ public class AnnotationReader extends ClassDataCollector {
}
if (isCollection) {
if (def.cardinality == null)
- def.cardinality = ReferenceCardinality.MULTIPLE;
+ def.cardinality = ReferenceCardinality.OPTIONAL_MULTIPLE;
def.fieldCollectionType = fieldCollectionType;
}
- if (def.policy == ReferencePolicy.DYNAMIC && (def.cardinality == ReferenceCardinality.MULTIPLE
- || def.cardinality == ReferenceCardinality.AT_LEAST_ONE) && member.isFinal()) {
+ if (def.policy == ReferencePolicy.DYNAMIC && (def.cardinality == ReferenceCardinality.MANDATORY_MULTIPLE
+ || def.cardinality == ReferenceCardinality.MANDATORY_UNARY) && member.isFinal()) {
if (def.fieldOption == FieldOption.REPLACE)
analyzer.error(
"In component %s, collection type field: %s is final and dynamic but marked with 'replace' fieldOption. Changing this to 'update'.",
@@ -838,7 +837,7 @@ public class AnnotationReader extends ClassDataCollector {
component.implementation = clazz.getClassName();
component.name = comp.name();
component.factory = comp.factory();
- component.configurationPolicy = comp.configurationPolicy();
+ component.configurationPolicy = comp.policy();
if (annotation.get("enabled") != null)
component.enabled = comp.enabled();
if (annotation.get("factory") != null)
@@ -861,8 +860,9 @@ public class AnnotationReader extends ClassDataCollector {
} else {
component.updateVersion(V1_2);
}
- }
+ }
+ /*
if (annotation.get("xmlns") != null)
component.xmlns = comp.xmlns();
@@ -882,6 +882,7 @@ public class AnnotationReader extends ClassDataCollector {
}
doProperty(comp.property());
+ */
Object[] x = annotation.get("service");
if (x == null) {
diff --git a/biz.aQute.bndlib/src/aQute/bnd/component/ComponentDef.java b/biz.aQute.bndlib/src/aQute/bnd/component/ComponentDef.java
index ba53142..2cdc58d 100644
--- a/biz.aQute.bndlib/src/aQute/bnd/component/ComponentDef.java
+++ b/biz.aQute.bndlib/src/aQute/bnd/component/ComponentDef.java
@@ -8,8 +8,6 @@ import java.util.List;
import java.util.Map;
import java.util.TreeMap;
-import org.osgi.service.component.annotations.ConfigurationPolicy;
-
import aQute.bnd.osgi.Analyzer;
import aQute.bnd.osgi.Descriptors.TypeRef;
import aQute.bnd.version.Version;
@@ -18,6 +16,7 @@ import aQute.bnd.xmlattribute.Namespaces;
import aQute.bnd.xmlattribute.XMLAttributeFinder;
import aQute.lib.collections.MultiMap;
import aQute.lib.tag.Tag;
+import org.apache.felix.scr.annotations.ConfigurationPolicy;
/**
* This class just holds the information for the component, implementation, and
diff --git a/biz.aQute.bndlib/src/aQute/bnd/component/DSAnnotations.java b/biz.aQute.bndlib/src/aQute/bnd/component/DSAnnotations.java
index b48f5b9..74e3426 100644
--- a/biz.aQute.bndlib/src/aQute/bnd/component/DSAnnotations.java
+++ b/biz.aQute.bndlib/src/aQute/bnd/component/DSAnnotations.java
@@ -9,8 +9,6 @@ import java.util.Map;
import java.util.Set;
import java.util.TreeSet;
-import org.osgi.service.component.annotations.ReferenceCardinality;
-
import aQute.bnd.header.Attrs;
import aQute.bnd.header.OSGiHeader;
import aQute.bnd.header.Parameters;
@@ -25,6 +23,7 @@ import aQute.bnd.service.AnalyzerPlugin;
import aQute.bnd.version.Version;
import aQute.bnd.xmlattribute.XMLAttributeFinder;
import aQute.lib.strings.Strings;
+import org.apache.felix.scr.annotations.ReferenceCardinality;
/**
* Analyze the class space for any classes that have an OSGi annotation for DS.
@@ -138,9 +137,9 @@ public class DSAnnotations implements AnalyzerPlugin {
private void addServiceRequirement(ReferenceDef ref, MergedRequirement requires) {
String objectClass = ref.service;
ReferenceCardinality cardinality = ref.cardinality;
- boolean optional = cardinality == ReferenceCardinality.OPTIONAL || cardinality == ReferenceCardinality.MULTIPLE;
- boolean multiple = cardinality == ReferenceCardinality.MULTIPLE
- || cardinality == ReferenceCardinality.AT_LEAST_ONE;
+ boolean optional = cardinality == ReferenceCardinality.OPTIONAL_MULTIPLE || cardinality == ReferenceCardinality.OPTIONAL_UNARY;
+ boolean multiple = cardinality == ReferenceCardinality.MANDATORY_MULTIPLE
+ || cardinality == ReferenceCardinality.OPTIONAL_MULTIPLE;
String filter = "(objectClass=" + objectClass + ")";
requires.put(filter, "active", optional, multiple);
diff --git a/biz.aQute.bndlib/src/aQute/bnd/component/HeaderReader.java b/biz.aQute.bndlib/src/aQute/bnd/component/HeaderReader.java
index b070fbd..e1079b8 100644
--- a/biz.aQute.bndlib/src/aQute/bnd/component/HeaderReader.java
+++ b/biz.aQute.bndlib/src/aQute/bnd/component/HeaderReader.java
@@ -12,11 +12,6 @@ import java.util.StringTokenizer;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
-import org.osgi.service.component.annotations.ConfigurationPolicy;
-import org.osgi.service.component.annotations.ReferenceCardinality;
-import org.osgi.service.component.annotations.ReferencePolicy;
-import org.osgi.service.component.annotations.ReferencePolicyOption;
-
import aQute.bnd.component.error.DeclarativeServicesAnnotationError;
import aQute.bnd.component.error.DeclarativeServicesAnnotationError.ErrorType;
import aQute.bnd.osgi.Analyzer;
@@ -29,6 +24,10 @@ import aQute.bnd.osgi.Processor;
import aQute.bnd.osgi.Verifier;
import aQute.bnd.version.Version;
import aQute.lib.tag.Tag;
+import org.apache.felix.scr.annotations.ConfigurationPolicy;
+import org.apache.felix.scr.annotations.ReferenceCardinality;
+import org.apache.felix.scr.annotations.ReferencePolicy;
+import org.apache.felix.scr.annotations.ReferencePolicyOption;
public class HeaderReader extends Processor {
final static Pattern PROPERTY_PATTERN = Pattern
@@ -475,15 +474,15 @@ public class HeaderReader extends Processor {
if (optional.contains(referenceName)) {
if (multiple.contains(referenceName)) {
- rd.cardinality = ReferenceCardinality.MULTIPLE;
+ rd.cardinality = ReferenceCardinality.OPTIONAL_MULTIPLE;
} else {
- rd.cardinality = ReferenceCardinality.OPTIONAL;
+ rd.cardinality = ReferenceCardinality.OPTIONAL_UNARY;
}
} else {
if (multiple.contains(referenceName)) {
- rd.cardinality = ReferenceCardinality.AT_LEAST_ONE;
+ rd.cardinality = ReferenceCardinality.MANDATORY_MULTIPLE;
} else {
- rd.cardinality = ReferenceCardinality.MANDATORY;
+ rd.cardinality = ReferenceCardinality.MANDATORY_UNARY;
}
}
if (bind != null) {
diff --git a/biz.aQute.bndlib/src/aQute/bnd/component/ReferenceDef.java b/biz.aQute.bndlib/src/aQute/bnd/component/ReferenceDef.java
index d21d63b..679ff45 100644
--- a/biz.aQute.bndlib/src/aQute/bnd/component/ReferenceDef.java
+++ b/biz.aQute.bndlib/src/aQute/bnd/component/ReferenceDef.java
@@ -1,9 +1,5 @@
package aQute.bnd.component;
-import org.osgi.service.component.annotations.ReferenceCardinality;
-import org.osgi.service.component.annotations.ReferencePolicy;
-import org.osgi.service.component.annotations.ReferencePolicyOption;
-
import aQute.bnd.osgi.Analyzer;
import aQute.bnd.osgi.Verifier;
import aQute.bnd.version.Version;
@@ -11,6 +7,9 @@ import aQute.bnd.xmlattribute.ExtensionDef;
import aQute.bnd.xmlattribute.Namespaces;
import aQute.bnd.xmlattribute.XMLAttributeFinder;
import aQute.lib.tag.Tag;
+import org.apache.felix.scr.annotations.ReferenceCardinality;
+import org.apache.felix.scr.annotations.ReferencePolicy;
+import org.apache.felix.scr.annotations.ReferencePolicyOption;
/**
* Holds the information in the reference element.
--
2.7.4

View File

@ -1,6 +1,6 @@
Name: aqute-bnd
Version: 3.2.0
Release: 3%{?dist}
Release: 4%{?dist}
Summary: BND Tool
License: ASL 2.0
URL: http://bnd.bndtools.org/
@ -20,16 +20,27 @@ Source6: https://repo1.maven.org/maven2/biz/aQute/bnd/biz.aQute.bnd.annot
Patch0: 0001-Port-to-Java-8.patch
Patch1: 0002-Remove-unavailable-parts.patch
Patch2: 0003-Use-felix-annotations.patch
BuildRequires: maven-local
BuildRequires: mvn(ant:ant)
BuildRequires: mvn(org.eclipse.osgi:org.eclipse.osgi)
BuildRequires: mvn(org.eclipse.osgi:org.eclipse.osgi.services)
BuildRequires: mvn(org.osgi:org.osgi.annotation)
BuildRequires: mvn(org.slf4j:slf4j-api)
BuildRequires: mvn(junit:junit)
BuildRequires: mvn(org.apache.felix:org.apache.felix.framework)
BuildRequires: mvn(org.apache.felix:org.apache.felix.scr.annotations)
BuildRequires: mvn(org.apache.felix:org.osgi.compendium)
BuildRequires: mvn(org.apache.maven:maven-artifact)
BuildRequires: mvn(org.apache.maven:maven-compat)
BuildRequires: mvn(org.apache.maven:maven-core)
BuildRequires: mvn(org.apache.maven:maven-plugin-api)
BuildRequires: mvn(org.apache.maven.plugins:maven-plugin-plugin)
BuildRequires: mvn(org.apache.maven.plugins:maven-source-plugin)
BuildRequires: mvn(org.apache.maven.plugins:maven-javadoc-plugin)
BuildRequires: mvn(org.apache.maven.plugin-tools:maven-plugin-annotations)
BuildRequires: mvn(org.eclipse.aether:aether-api)
BuildRequires: mvn(org.osgi:org.osgi.annotation)
BuildRequires: mvn(org.slf4j:slf4j-api)
BuildRequires: mvn(org.sonatype.plexus:plexus-build-api)
%description
The bnd tool helps you create and diagnose OSGi bundles.
@ -69,6 +80,7 @@ rm gradlew*
%patch0 -p1
%patch1 -p1
%patch2 -p1
# unavailable dependencies
rm -r biz.aQute.bndlib/src/aQute/bnd/{metatype,service/message,osgi/repository}
@ -102,9 +114,10 @@ pushd biz.aQute.bndlib
cp -p %{SOURCE5} pom.xml
%pom_add_parent biz.aQute.bnd:parent:%{version}
%pom_add_dep org.eclipse.osgi:org.eclipse.osgi
%pom_add_dep org.eclipse.osgi:org.eclipse.osgi.services
%pom_add_dep org.apache.felix:org.apache.felix.scr.annotations
%pom_add_dep org.apache.felix:org.osgi.compendium
%pom_add_dep org.osgi:org.osgi.annotation
%pom_add_dep org.apache.felix:org.apache.felix.framework
%pom_add_dep org.slf4j:slf4j-api
%pom_add_dep biz.aQute.bnd:aQute.libg:%{version}
%pom_add_dep biz.aQute.bnd:biz.aQute.bnd.annotation:%{version}
@ -142,7 +155,7 @@ popd
%mvn_install
install -d -m 755 %{buildroot}%{_sysconfdir}/ant.d
echo "aqute-bnd slf4j/api slf4j/simple eclipse/osgi.services" >%{buildroot}%{_sysconfdir}/ant.d/%{name}
echo "aqute-bnd slf4j/api slf4j/simple" >%{buildroot}%{_sysconfdir}/ant.d/%{name}
%jpackage_script aQute.bnd.main.bnd "" "" aqute-bnd:slf4j/slf4j-api:slf4j/slf4j-simple bnd 1
@ -160,6 +173,9 @@ echo "aqute-bnd slf4j/api slf4j/simple eclipse/osgi.services" >%{buildroot}%{_sy
%license LICENSE
%changelog
* Mon Sep 26 2016 Michael Simacek <msimacek@redhat.com> - 3.2.0-4
- Use felix-annotations
* Wed Sep 14 2016 Mikolaj Izdebski <mizdebsk@redhat.com> - 3.2.0-3
- Build and install Maven plugins
- Resolves: rhbz#1375904