|
Michael Simacek |
a6b06a |
From 46db98329dc88e039948f58aa34d151c1aaa7a05 Mon Sep 17 00:00:00 2001
|
|
Michael Simacek |
a6b06a |
From: Michael Simacek <msimacek@redhat.com>
|
|
Michael Simacek |
a6b06a |
Date: Wed, 8 Jul 2015 13:46:30 +0200
|
|
Michael Simacek |
a6b06a |
Subject: [PATCH 3/3] Use equinox's annotations
|
|
Michael Simacek |
a6b06a |
|
|
Michael Simacek |
a6b06a |
---
|
|
Michael Simacek |
a6b06a |
.../src/aQute/bnd/component/AnnotationReader.java | 19 +++++--------------
|
|
Michael Simacek |
a6b06a |
.../src/aQute/bnd/component/ComponentDef.java | 13 ++++---------
|
|
Michael Simacek |
a6b06a |
.../src/aQute/bnd/component/HeaderReader.java | 1 -
|
|
Michael Simacek |
a6b06a |
.../src/aQute/bnd/component/ReferenceScope.java | 13 +++++++++++++
|
|
Michael Simacek |
a6b06a |
.../src/aQute/bnd/component/ServiceScope.java | 14 ++++++++++++++
|
|
Michael Simacek |
a6b06a |
.../src/aQute/bnd/metatype/DesignateReader.java | 13 +++----------
|
|
Michael Simacek |
a6b06a |
biz.aQute.bndlib/src/aQute/bnd/osgi/Builder.java | 3 ---
|
|
Michael Simacek |
a6b06a |
7 files changed, 39 insertions(+), 37 deletions(-)
|
|
Michael Simacek |
a6b06a |
create mode 100644 biz.aQute.bndlib/src/aQute/bnd/component/ReferenceScope.java
|
|
Michael Simacek |
a6b06a |
create mode 100644 biz.aQute.bndlib/src/aQute/bnd/component/ServiceScope.java
|
|
Michael Simacek |
a6b06a |
|
|
Michael Simacek |
a6b06a |
diff --git a/biz.aQute.bndlib/src/aQute/bnd/component/AnnotationReader.java b/biz.aQute.bndlib/src/aQute/bnd/component/AnnotationReader.java
|
|
Michael Simacek |
a6b06a |
index f979187..8505d8c 100644
|
|
Michael Simacek |
a6b06a |
--- a/biz.aQute.bndlib/src/aQute/bnd/component/AnnotationReader.java
|
|
Michael Simacek |
a6b06a |
+++ b/biz.aQute.bndlib/src/aQute/bnd/component/AnnotationReader.java
|
|
Michael Simacek |
a6b06a |
@@ -412,7 +412,7 @@ public class AnnotationReader extends ClassDataCollector {
|
|
Michael Simacek |
a6b06a |
String annoService = raw.get("service");
|
|
Michael Simacek |
a6b06a |
if (annoService != null)
|
|
Michael Simacek |
a6b06a |
annoService = Clazz.objectDescriptorToFQN(annoService);
|
|
Michael Simacek |
a6b06a |
- ReferenceScope scope = reference.scope();
|
|
Michael Simacek |
a6b06a |
+ ReferenceScope scope = ReferenceScope.BUNDLE;
|
|
Michael Simacek |
a6b06a |
|
|
Michael Simacek |
a6b06a |
String service = determineReferenceType(method.getDescriptor().toString(), def, annoService, scope);
|
|
Michael Simacek |
a6b06a |
|
|
Michael Simacek |
a6b06a |
@@ -446,7 +446,7 @@ public class AnnotationReader extends ClassDataCollector {
|
|
Michael Simacek |
a6b06a |
def.cardinality = reference.cardinality();
|
|
Michael Simacek |
a6b06a |
def.policy = reference.policy();
|
|
Michael Simacek |
a6b06a |
def.policyOption = reference.policyOption();
|
|
Michael Simacek |
a6b06a |
- def.scope = reference.scope();
|
|
Michael Simacek |
a6b06a |
+ def.scope = ReferenceScope.BUNDLE;
|
|
Michael Simacek |
a6b06a |
}
|
|
Michael Simacek |
a6b06a |
|
|
Michael Simacek |
a6b06a |
private String determineReferenceType(String methodDescriptor, ReferenceDef def, String annoService, ReferenceScope scope) {
|
|
Michael Simacek |
a6b06a |
@@ -545,20 +545,10 @@ public class AnnotationReader extends ClassDataCollector {
|
|
Michael Simacek |
a6b06a |
component.immediate = comp.immediate();
|
|
Michael Simacek |
a6b06a |
if (annotation.get("servicefactory") != null)
|
|
Michael Simacek |
a6b06a |
component.scope = comp.servicefactory()? ServiceScope.BUNDLE: ServiceScope.SINGLETON;
|
|
Michael Simacek |
a6b06a |
- if (annotation.get("scope") != null && comp.scope() != ServiceScope.DEFAULT) {
|
|
Michael Simacek |
a6b06a |
- component.scope = comp.scope();
|
|
Michael Simacek |
a6b06a |
- if (comp.scope() == ServiceScope.PROTOTYPE) {
|
|
Michael Simacek |
a6b06a |
- component.updateVersion(V1_3);
|
|
Michael Simacek |
a6b06a |
- }
|
|
Michael Simacek |
a6b06a |
- }
|
|
Michael Simacek |
a6b06a |
|
|
Michael Simacek |
a6b06a |
if (annotation.get("configurationPid") != null) {
|
|
Michael Simacek |
a6b06a |
component.configurationPid = comp.configurationPid();
|
|
Michael Simacek |
a6b06a |
- if (component.configurationPid.length > 1) {
|
|
Michael Simacek |
a6b06a |
- component.updateVersion(V1_3);
|
|
Michael Simacek |
a6b06a |
- } else {
|
|
Michael Simacek |
a6b06a |
component.updateVersion(V1_2);
|
|
Michael Simacek |
a6b06a |
- }
|
|
Michael Simacek |
a6b06a |
}
|
|
Michael Simacek |
a6b06a |
|
|
Michael Simacek |
a6b06a |
if (annotation.get("xmlns") != null)
|
|
Michael Simacek |
a6b06a |
@@ -601,6 +591,7 @@ public class AnnotationReader extends ClassDataCollector {
|
|
Michael Simacek |
a6b06a |
component.service[i] = ref;
|
|
Michael Simacek |
a6b06a |
}
|
|
Michael Simacek |
a6b06a |
}
|
|
Michael Simacek |
a6b06a |
+ /*
|
|
Michael Simacek |
a6b06a |
Object[] refAnnotations = annotation.get("reference");
|
|
Michael Simacek |
a6b06a |
if (refAnnotations != null) {
|
|
Michael Simacek |
a6b06a |
for (Object o: refAnnotations) {
|
|
Michael Simacek |
a6b06a |
@@ -613,11 +604,11 @@ public class AnnotationReader extends ClassDataCollector {
|
|
Michael Simacek |
a6b06a |
refdef.policy = ref.policy();
|
|
Michael Simacek |
a6b06a |
refdef.policyOption = ref.policyOption();
|
|
Michael Simacek |
a6b06a |
refdef.target = ref.target();
|
|
Michael Simacek |
a6b06a |
- refdef.scope = ref.scope();
|
|
Michael Simacek |
a6b06a |
+ refdef.scope = ReferenceScope.BUNDLE;
|
|
Michael Simacek |
a6b06a |
component.references.put(refdef.name, refdef);
|
|
Michael Simacek |
a6b06a |
}
|
|
Michael Simacek |
a6b06a |
}
|
|
Michael Simacek |
a6b06a |
-
|
|
Michael Simacek |
a6b06a |
+ */
|
|
Michael Simacek |
a6b06a |
}
|
|
Michael Simacek |
a6b06a |
|
|
Michael Simacek |
a6b06a |
/**
|
|
Michael Simacek |
a6b06a |
diff --git a/biz.aQute.bndlib/src/aQute/bnd/component/ComponentDef.java b/biz.aQute.bndlib/src/aQute/bnd/component/ComponentDef.java
|
|
Michael Simacek |
a6b06a |
index d5719c2..f975dda 100644
|
|
Michael Simacek |
a6b06a |
--- a/biz.aQute.bndlib/src/aQute/bnd/component/ComponentDef.java
|
|
Michael Simacek |
a6b06a |
+++ b/biz.aQute.bndlib/src/aQute/bnd/component/ComponentDef.java
|
|
Michael Simacek |
a6b06a |
@@ -39,7 +39,7 @@ class ComponentDef {
|
|
Michael Simacek |
a6b06a |
String modified;
|
|
Michael Simacek |
a6b06a |
Boolean enabled;
|
|
Michael Simacek |
a6b06a |
String xmlns;
|
|
Michael Simacek |
a6b06a |
- String[] configurationPid;
|
|
Michael Simacek |
a6b06a |
+ String configurationPid;
|
|
Michael Simacek |
a6b06a |
List<Tag> propertyTags = new ArrayList<Tag>();
|
|
Michael Simacek |
a6b06a |
|
|
Michael Simacek |
a6b06a |
/**
|
|
Michael Simacek |
a6b06a |
@@ -162,13 +162,8 @@ class ComponentDef {
|
|
Michael Simacek |
a6b06a |
|
|
Michael Simacek |
a6b06a |
if (configurationPid != null) {
|
|
Michael Simacek |
a6b06a |
StringBuilder b = new StringBuilder();
|
|
Michael Simacek |
a6b06a |
- String space = "";
|
|
Michael Simacek |
a6b06a |
- for (String pid: configurationPid) {
|
|
Michael Simacek |
a6b06a |
- if ("$".equals(pid))
|
|
Michael Simacek |
a6b06a |
- pid = name;
|
|
Michael Simacek |
a6b06a |
- b.append(space).append(pid);
|
|
Michael Simacek |
a6b06a |
- space = " ";
|
|
Michael Simacek |
a6b06a |
- }
|
|
Michael Simacek |
a6b06a |
+ if (configurationPid != null)
|
|
Michael Simacek |
a6b06a |
+ b.append("$".equals(configurationPid)?name:configurationPid);
|
|
Michael Simacek |
a6b06a |
component.addAttribute("configuration-pid", b.toString());
|
|
Michael Simacek |
a6b06a |
}
|
|
Michael Simacek |
a6b06a |
Tag impl = new Tag(component, "implementation");
|
|
Michael Simacek |
a6b06a |
@@ -252,4 +247,4 @@ class ComponentDef {
|
|
Michael Simacek |
a6b06a |
return b;
|
|
Michael Simacek |
a6b06a |
}
|
|
Michael Simacek |
a6b06a |
|
|
Michael Simacek |
a6b06a |
-}
|
|
Michael Simacek |
a6b06a |
\ No newline at end of file
|
|
Michael Simacek |
a6b06a |
+}
|
|
Michael Simacek |
a6b06a |
diff --git a/biz.aQute.bndlib/src/aQute/bnd/component/HeaderReader.java b/biz.aQute.bndlib/src/aQute/bnd/component/HeaderReader.java
|
|
Michael Simacek |
a6b06a |
index f2ed67f..17539d3 100644
|
|
Michael Simacek |
a6b06a |
--- a/biz.aQute.bndlib/src/aQute/bnd/component/HeaderReader.java
|
|
Michael Simacek |
a6b06a |
+++ b/biz.aQute.bndlib/src/aQute/bnd/component/HeaderReader.java
|
|
Michael Simacek |
a6b06a |
@@ -16,7 +16,6 @@ import org.osgi.service.component.annotations.ConfigurationPolicy;
|
|
Michael Simacek |
a6b06a |
import org.osgi.service.component.annotations.ReferenceCardinality;
|
|
Michael Simacek |
a6b06a |
import org.osgi.service.component.annotations.ReferencePolicy;
|
|
Michael Simacek |
a6b06a |
import org.osgi.service.component.annotations.ReferencePolicyOption;
|
|
Michael Simacek |
a6b06a |
-import org.osgi.service.component.annotations.ServiceScope;
|
|
Michael Simacek |
a6b06a |
|
|
Michael Simacek |
a6b06a |
import aQute.bnd.component.error.*;
|
|
Michael Simacek |
a6b06a |
import aQute.bnd.component.error.DeclarativeServicesAnnotationError.*;
|
|
Michael Simacek |
a6b06a |
diff --git a/biz.aQute.bndlib/src/aQute/bnd/component/ReferenceScope.java b/biz.aQute.bndlib/src/aQute/bnd/component/ReferenceScope.java
|
|
Michael Simacek |
a6b06a |
new file mode 100644
|
|
Michael Simacek |
a6b06a |
index 0000000..70f2b78
|
|
Michael Simacek |
a6b06a |
--- /dev/null
|
|
Michael Simacek |
a6b06a |
+++ b/biz.aQute.bndlib/src/aQute/bnd/component/ReferenceScope.java
|
|
Michael Simacek |
a6b06a |
@@ -0,0 +1,13 @@
|
|
Michael Simacek |
a6b06a |
+package aQute.bnd.component;
|
|
Michael Simacek |
a6b06a |
+enum ReferenceScope {
|
|
Michael Simacek |
a6b06a |
+ BUNDLE("bundle"),
|
|
Michael Simacek |
a6b06a |
+ PROTOTYPE("prototype"),
|
|
Michael Simacek |
a6b06a |
+ PROTOTYPE_REQUIRED("prototype_required");
|
|
Michael Simacek |
a6b06a |
+ private final String value;
|
|
Michael Simacek |
a6b06a |
+ ReferenceScope(String value) {
|
|
Michael Simacek |
a6b06a |
+ this.value = value;
|
|
Michael Simacek |
a6b06a |
+ }
|
|
Michael Simacek |
a6b06a |
+ public String toString() {
|
|
Michael Simacek |
a6b06a |
+ return value;
|
|
Michael Simacek |
a6b06a |
+ }
|
|
Michael Simacek |
a6b06a |
+}
|
|
Michael Simacek |
a6b06a |
diff --git a/biz.aQute.bndlib/src/aQute/bnd/component/ServiceScope.java b/biz.aQute.bndlib/src/aQute/bnd/component/ServiceScope.java
|
|
Michael Simacek |
a6b06a |
new file mode 100644
|
|
Michael Simacek |
a6b06a |
index 0000000..aa49766
|
|
Michael Simacek |
a6b06a |
--- /dev/null
|
|
Michael Simacek |
a6b06a |
+++ b/biz.aQute.bndlib/src/aQute/bnd/component/ServiceScope.java
|
|
Michael Simacek |
a6b06a |
@@ -0,0 +1,14 @@
|
|
Michael Simacek |
a6b06a |
+package aQute.bnd.component;
|
|
Michael Simacek |
a6b06a |
+enum ServiceScope {
|
|
Michael Simacek |
a6b06a |
+ SINGLETON("singleton"),
|
|
Michael Simacek |
a6b06a |
+ BUNDLE("bundle"),
|
|
Michael Simacek |
a6b06a |
+ PROTOTYPE("prototype"),
|
|
Michael Simacek |
a6b06a |
+ DEFAULT("<<default>>");
|
|
Michael Simacek |
a6b06a |
+ private final String value;
|
|
Michael Simacek |
a6b06a |
+ ServiceScope(String value) {
|
|
Michael Simacek |
a6b06a |
+ this.value = value;
|
|
Michael Simacek |
a6b06a |
+ }
|
|
Michael Simacek |
a6b06a |
+ public String toString() {
|
|
Michael Simacek |
a6b06a |
+ return value;
|
|
Michael Simacek |
a6b06a |
+ }
|
|
Michael Simacek |
a6b06a |
+}
|
|
Michael Simacek |
a6b06a |
diff --git a/biz.aQute.bndlib/src/aQute/bnd/metatype/DesignateReader.java b/biz.aQute.bndlib/src/aQute/bnd/metatype/DesignateReader.java
|
|
Michael Simacek |
a6b06a |
index 29ebbdb..f1dd9d4 100644
|
|
Michael Simacek |
a6b06a |
--- a/biz.aQute.bndlib/src/aQute/bnd/metatype/DesignateReader.java
|
|
Michael Simacek |
a6b06a |
+++ b/biz.aQute.bndlib/src/aQute/bnd/metatype/DesignateReader.java
|
|
Michael Simacek |
a6b06a |
@@ -13,7 +13,7 @@ public class DesignateReader extends ClassDataCollector {
|
|
Michael Simacek |
a6b06a |
private Clazz clazz;
|
|
Michael Simacek |
a6b06a |
private Map<String, OCDDef> classToOCDMap;
|
|
Michael Simacek |
a6b06a |
|
|
Michael Simacek |
a6b06a |
- private String[] pids;
|
|
Michael Simacek |
a6b06a |
+ private String pid;
|
|
Michael Simacek |
a6b06a |
private Annotation designate;
|
|
Michael Simacek |
a6b06a |
|
|
Michael Simacek |
a6b06a |
DesignateReader(Analyzer analyzer, Clazz clazz, Map<String, OCDDef> classToOCDMap) {
|
|
Michael Simacek |
a6b06a |
@@ -29,14 +29,7 @@ public class DesignateReader extends ClassDataCollector {
|
|
Michael Simacek |
a6b06a |
|
|
Michael Simacek |
a6b06a |
private DesignateDef getDef() throws Exception {
|
|
Michael Simacek |
a6b06a |
clazz.parseClassFileWithCollector(this);
|
|
Michael Simacek |
a6b06a |
- if (pids != null && designate != null) {
|
|
Michael Simacek |
a6b06a |
- if (pids.length != 1) {
|
|
Michael Simacek |
a6b06a |
- analyzer.error(
|
|
Michael Simacek |
a6b06a |
- "DS Component %s specifies multiple pids %s, and a Designate which requires exactly one pid",
|
|
Michael Simacek |
a6b06a |
- clazz.getClassName().getFQN(), Arrays.asList(pids));
|
|
Michael Simacek |
a6b06a |
- return null;
|
|
Michael Simacek |
a6b06a |
- }
|
|
Michael Simacek |
a6b06a |
- String pid = pids[0];
|
|
Michael Simacek |
a6b06a |
+ if (pid != null && designate != null) {
|
|
Michael Simacek |
a6b06a |
String ocdClass = ((String) designate.get("ocd"));
|
|
Michael Simacek |
a6b06a |
ocdClass = ocdClass.substring(1, ocdClass.length() - 1);
|
|
Michael Simacek |
a6b06a |
OCDDef ocd = classToOCDMap.get(ocdClass);
|
|
Michael Simacek |
a6b06a |
@@ -61,7 +54,7 @@ public class DesignateReader extends ClassDataCollector {
|
|
Michael Simacek |
a6b06a |
if (a instanceof Designate)
|
|
Michael Simacek |
a6b06a |
designate = annotation;
|
|
Michael Simacek |
a6b06a |
else if (a instanceof Component)
|
|
Michael Simacek |
a6b06a |
- pids = ((Component)a).configurationPid();
|
|
Michael Simacek |
a6b06a |
+ pid = ((Component)a).configurationPid();
|
|
Michael Simacek |
a6b06a |
}
|
|
Michael Simacek |
a6b06a |
catch (Exception e) {
|
|
Michael Simacek |
a6b06a |
e.printStackTrace();
|
|
Michael Simacek |
a6b06a |
diff --git a/biz.aQute.bndlib/src/aQute/bnd/osgi/Builder.java b/biz.aQute.bndlib/src/aQute/bnd/osgi/Builder.java
|
|
Michael Simacek |
a6b06a |
index b326c97..52d42c8 100755
|
|
Michael Simacek |
a6b06a |
--- a/biz.aQute.bndlib/src/aQute/bnd/osgi/Builder.java
|
|
Michael Simacek |
a6b06a |
+++ b/biz.aQute.bndlib/src/aQute/bnd/osgi/Builder.java
|
|
Michael Simacek |
a6b06a |
@@ -14,7 +14,6 @@ import aQute.bnd.make.*;
|
|
Michael Simacek |
a6b06a |
import aQute.bnd.make.component.*;
|
|
Michael Simacek |
a6b06a |
import aQute.bnd.make.metatype.*;
|
|
Michael Simacek |
a6b06a |
import aQute.bnd.maven.*;
|
|
Michael Simacek |
a6b06a |
-import aQute.bnd.metatype.*;
|
|
Michael Simacek |
a6b06a |
import aQute.bnd.osgi.Descriptors.PackageRef;
|
|
Michael Simacek |
a6b06a |
import aQute.bnd.osgi.Descriptors.TypeRef;
|
|
Michael Simacek |
a6b06a |
import aQute.bnd.service.*;
|
|
Michael Simacek |
a6b06a |
@@ -1548,7 +1547,6 @@ public class Builder extends Analyzer {
|
|
Michael Simacek |
a6b06a |
static ServiceComponent serviceComponent = new ServiceComponent();
|
|
Michael Simacek |
a6b06a |
static DSAnnotations dsAnnotations = new DSAnnotations();
|
|
Michael Simacek |
a6b06a |
static MetatypePlugin metatypePlugin = new MetatypePlugin();
|
|
Michael Simacek |
a6b06a |
- static MetatypeAnnotations metatypeAnnotations = new MetatypeAnnotations();
|
|
Michael Simacek |
a6b06a |
|
|
Michael Simacek |
a6b06a |
@Override
|
|
Michael Simacek |
a6b06a |
protected void setTypeSpecificPlugins(Set<Object> list) {
|
|
Michael Simacek |
a6b06a |
@@ -1557,7 +1555,6 @@ public class Builder extends Analyzer {
|
|
Michael Simacek |
a6b06a |
list.add(serviceComponent);
|
|
Michael Simacek |
a6b06a |
list.add(dsAnnotations);
|
|
Michael Simacek |
a6b06a |
list.add(metatypePlugin);
|
|
Michael Simacek |
a6b06a |
- list.add(metatypeAnnotations);
|
|
Michael Simacek |
a6b06a |
super.setTypeSpecificPlugins(list);
|
|
Michael Simacek |
a6b06a |
}
|
|
Michael Simacek |
a6b06a |
|
|
Michael Simacek |
a6b06a |
--
|
|
Michael Simacek |
a6b06a |
2.1.0
|
|
Michael Simacek |
a6b06a |
|