FELIX-3550 : Reimplement the SCR Generator
git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@1354591 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/scrplugin/annotations/src/main/java/org/apache/felix/scrplugin/processing/SCRAnnotationProcessor.java b/scrplugin/annotations/src/main/java/org/apache/felix/scrplugin/processing/SCRAnnotationProcessor.java
index 584a4a2..7d8346b 100644
--- a/scrplugin/annotations/src/main/java/org/apache/felix/scrplugin/processing/SCRAnnotationProcessor.java
+++ b/scrplugin/annotations/src/main/java/org/apache/felix/scrplugin/processing/SCRAnnotationProcessor.java
@@ -294,8 +294,15 @@
ref.setName(ad.getStringValue("name",
(fieldAnnotation != null ? fieldAnnotation.getAnnotatedField().getName() : null)));
- ref.setInterfaceName(ad.getStringValue("referenceInterface", (fieldAnnotation != null ? fieldAnnotation
- .getAnnotatedField().getType().getName() : null)));
+ String defaultInterfaceName = null;
+ if ( fieldAnnotation != null ) {
+ if ( fieldAnnotation.getAnnotatedField().getType().isArray() ) {
+ defaultInterfaceName = fieldAnnotation.getAnnotatedField().getType().getComponentType().getName();
+ } else {
+ defaultInterfaceName = fieldAnnotation.getAnnotatedField().getType().getName();
+ }
+ }
+ ref.setInterfaceName(ad.getStringValue("referenceInterface", defaultInterfaceName));
ref.setTarget(ad.getStringValue("target", null));
ref.setCardinality(ReferenceCardinality.valueOf(ad.getEnumValue("cardinality",
ReferenceCardinality.MANDATORY_UNARY.name())));
diff --git a/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/annotations/ScannedAnnotation.java b/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/annotations/ScannedAnnotation.java
index 1a0c495..20acde1 100644
--- a/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/annotations/ScannedAnnotation.java
+++ b/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/annotations/ScannedAnnotation.java
@@ -134,7 +134,13 @@
public String getEnumValue(final String name, final String defaultValue) {
final Object val = this.getValue(name);
if ( val != null ) {
- return ((String[])val)[1];
+ if ( val instanceof String[] ) {
+ return ((String[])val)[1];
+ }
+ if ( val instanceof String[][] ) {
+ return ((String[][])val)[0][1];
+ }
+ return val.toString();
}
return defaultValue;
}
diff --git a/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/xml/ComponentDescriptorIO.java b/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/xml/ComponentDescriptorIO.java
index 882dfe8..4bf1daf 100644
--- a/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/xml/ComponentDescriptorIO.java
+++ b/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/xml/ComponentDescriptorIO.java
@@ -492,11 +492,13 @@
// now we can create the class description and attach the component description
// Set the implementation class name (mandatory)
final String className = attributes.getValue("class");
+ Class<?> cl = null;
try {
- this.currentClass = new ClassDescription(this.classLoader.loadClass(className), "classpath:" + className);
- } catch (final ClassNotFoundException e) {
- iLog.addError("Unable to load class " + className + " from dependencies.", this.location);
+ cl = this.classLoader.loadClass(className);
+ } catch (final Throwable e) {
+ iLog.addWarning("Unable to load class " + className + " from dependencies.", this.location);
}
+ this.currentClass = new ClassDescription(cl, "classpath:" + className);
this.currentClass.add(this.currentComponent);
} else if (localName.equals(PROPERTY)) {