You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@felix.apache.org by cz...@apache.org on 2009/04/14 10:38:21 UTC

svn commit: r764711 - in /felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin: Constants.java PropertyHandler.java SCRDescriptorMojo.java

Author: cziegeler
Date: Tue Apr 14 08:38:20 2009
New Revision: 764711

URL: http://svn.apache.org/viewvc?rev=764711&view=rev
Log:
FELIX-1038 : Rename attribute name for mulitple value references from refValues to valueRefs. Print a warning if old name is used.

Modified:
    felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/Constants.java
    felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/PropertyHandler.java
    felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/SCRDescriptorMojo.java

Modified: felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/Constants.java
URL: http://svn.apache.org/viewvc/felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/Constants.java?rev=764711&r1=764710&r2=764711&view=diff
==============================================================================
--- felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/Constants.java (original)
+++ felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/Constants.java Tue Apr 14 08:38:20 2009
@@ -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";
 

Modified: felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/PropertyHandler.java
URL: http://svn.apache.org/viewvc/felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/PropertyHandler.java?rev=764711&r1=764710&r2=764711&view=diff
==============================================================================
--- felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/PropertyHandler.java (original)
+++ felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/PropertyHandler.java Tue Apr 14 08:38:20 2009
@@ -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 ) {

Modified: felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/SCRDescriptorMojo.java
URL: http://svn.apache.org/viewvc/felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/SCRDescriptorMojo.java?rev=764711&r1=764710&r2=764711&view=diff
==============================================================================
--- felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/SCRDescriptorMojo.java (original)
+++ felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/SCRDescriptorMojo.java Tue Apr 14 08:38:20 2009
@@ -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;
     }
 
     /**