FELIX-1038 : Rename attribute name for mulitple value references from refValues to valueRefs. Print a warning if old name is used.
git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@764711 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/scrplugin/src/main/java/org/apache/felix/scrplugin/Constants.java b/scrplugin/src/main/java/org/apache/felix/scrplugin/Constants.java
index 4348559..e77dbc5 100644
--- a/scrplugin/src/main/java/org/apache/felix/scrplugin/Constants.java
+++ b/scrplugin/src/main/java/org/apache/felix/scrplugin/Constants.java
@@ -65,7 +65,11 @@
public static final String PROPERTY_VALUE_REF = "valueRef";
- public static final String PROPERTY_MULTIVALUE_REF_PREFIX = "refValues";
+ /** Property for multi value fields using references. */
+ public static final String PROPERTY_MULTIVALUE_REF_PREFIX = "valueRefs";
+
+ /** @deprecated */
+ public static final String OLD_PROPERTY_MULTIVALUE_REF_PREFIX = "refValues";
public static final String PROPERTY_TYPE = "type";
@@ -100,7 +104,7 @@
public static final String REFERENCE_UNDBIND = "unbind";
public static final String REFERENCE_CHECKED = "checked";
-
+
/** @since 1.0.9 */
public static final String REFERENCE_STRATEGY = "strategy";
diff --git a/scrplugin/src/main/java/org/apache/felix/scrplugin/PropertyHandler.java b/scrplugin/src/main/java/org/apache/felix/scrplugin/PropertyHandler.java
index 266148a..a9169dd 100644
--- a/scrplugin/src/main/java/org/apache/felix/scrplugin/PropertyHandler.java
+++ b/scrplugin/src/main/java/org/apache/felix/scrplugin/PropertyHandler.java
@@ -60,7 +60,8 @@
*/
protected void processProperty(JavaTag tag,
String name,
- JavaField javaField)
+ JavaField javaField,
+ final List<String> warnings)
throws MojoExecutionException {
final Property prop = new Property(tag);
prop.setName(name);
@@ -83,7 +84,14 @@
final String key = entry.getKey();
if (key.startsWith(Constants.PROPERTY_MULTIVALUE_PREFIX) ) {
values.add(entry.getValue());
- } else if ( key.startsWith(Constants.PROPERTY_MULTIVALUE_REF_PREFIX) ) {
+ } else if ( key.startsWith(Constants.PROPERTY_MULTIVALUE_REF_PREFIX)
+ || key.startsWith(Constants.OLD_PROPERTY_MULTIVALUE_REF_PREFIX) ) {
+ if ( key.startsWith(Constants.OLD_PROPERTY_MULTIVALUE_REF_PREFIX) ) {
+ warnings.add("@" + tag.getName() + ": " + "Deprecated attribute '" +
+ Constants.OLD_PROPERTY_MULTIVALUE_REF_PREFIX + "' used, use '" +
+ Constants.PROPERTY_MULTIVALUE_REF_PREFIX + "' instead "
+ + " (" + tag.getSourceLocation() + ")");
+ }
final String[] stringValues = this.getPropertyValueRef(tag, prop, entry.getValue());
if ( stringValues != null ) {
for(int i=0; i<stringValues.length; i++) {
@@ -332,16 +340,21 @@
/**
* Process all found properties for the component.
+ * @param globalProperties Global properties are set on all components.
+ * @param errors List of occured errors.
+ * @param warnings List of occured warnings
* @throws MojoExecutionException
*/
- public void processProperties(final Map<String, String> globalProperties)
+ public void processProperties(final Map<String, String> globalProperties,
+ final List<String> errors,
+ final List<String> warnings)
throws MojoExecutionException {
final Iterator<Map.Entry<String, PropertyDescription>> propIter = properties.entrySet().iterator();
while ( propIter.hasNext() ) {
final Map.Entry<String, PropertyDescription> entry = propIter.next();
final String propName = entry.getKey();
final PropertyDescription desc = entry.getValue();
- this.processProperty(desc.propertyTag, propName, desc.field);
+ this.processProperty(desc.propertyTag, propName, desc.field, warnings);
}
// apply pre configured global properties
if ( globalProperties != null ) {
diff --git a/scrplugin/src/main/java/org/apache/felix/scrplugin/SCRDescriptorMojo.java b/scrplugin/src/main/java/org/apache/felix/scrplugin/SCRDescriptorMojo.java
index f29b665..55e41a3 100644
--- a/scrplugin/src/main/java/org/apache/felix/scrplugin/SCRDescriptorMojo.java
+++ b/scrplugin/src/main/java/org/apache/felix/scrplugin/SCRDescriptorMojo.java
@@ -282,6 +282,9 @@
*/
protected Component createComponent(JavaClassDescription description, JavaTag componentTag, MetaData metaData)
throws MojoExecutionException {
+ // two lists for errors and warnings
+ final List<String> errors = new ArrayList<String>();
+ final List<String> warnings = new ArrayList<String>();
// create a new component
final Component component = new Component(componentTag);
@@ -327,7 +330,7 @@
} while (inherited && currentDescription != null);
// process properties
- propertyHandler.processProperties(this.properties);
+ propertyHandler.processProperties(this.properties, errors, warnings);
// process references
final Iterator<Map.Entry<String, Object[]>> refIter = references.entrySet().iterator();
@@ -357,25 +360,23 @@
}
}
- final List<String> issues = new ArrayList<String>();
- final List<String> warnings = new ArrayList<String>();
- component.validate(issues, warnings);
+ component.validate(errors, warnings);
// now log warnings and errors (warnings first)
// FELIX-997: In strictMode all warnings are regarded as errors
if ( this.strictMode ) {
- issues.addAll(warnings);
+ errors.addAll(warnings);
warnings.clear();
}
for(String warn : warnings) {
this.getLog().warn(warn);
}
- for(String err : issues) {
+ for(String err : errors) {
this.getLog().error(err);
}
// return nothing if validation fails
- return issues.size() == 0 ? component : null;
+ return errors.size() == 0 ? component : null;
}
/**