Three fixes:
  - The <AD.type> attribute must be created. If no explicite type is given, String is used as default
  - setDefaultValue and setDefaultMultiValue only do anything if the respective data is not null
    (otherwise setDefaultMultiValue would overwrite a scalar value if no multivalue is given)
  - Don't generate Metatype descriptors for wellknown service properties 
     (service.pid, service.description, service.id, service.ranking, service.vendor,
      service.bundleLocation, service.factoryPid)

git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@570816 13f79535-47bb-0310-9956-ffa450edef68
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 9d8be33..766cbcc 100644
--- a/scrplugin/src/main/java/org/apache/felix/scrplugin/SCRDescriptorMojo.java
+++ b/scrplugin/src/main/java/org/apache/felix/scrplugin/SCRDescriptorMojo.java
@@ -51,6 +51,7 @@
 import org.apache.maven.plugin.MojoFailureException;
 import org.apache.maven.project.MavenProject;
 import org.codehaus.plexus.util.StringUtils;
+import org.osgi.service.cm.ConfigurationAdmin;
 
 /**
  * The <code>SCRDescriptorMojo</code>
@@ -407,7 +408,18 @@
                 }
             }
 
-            final boolean isPrivate = this.getBoolean(property, Constants.PROPERTY_PRIVATE, false);
+            // property is private if explicitly marked or a well known
+            // service property such as service.pid
+            final boolean isPrivate = getBoolean(property,
+                Constants.PROPERTY_PRIVATE, false)
+                || name.equals(org.osgi.framework.Constants.SERVICE_PID)
+                || name.equals(org.osgi.framework.Constants.SERVICE_DESCRIPTION)
+                || name.equals(org.osgi.framework.Constants.SERVICE_ID)
+                || name.equals(org.osgi.framework.Constants.SERVICE_RANKING)
+                || name.equals(org.osgi.framework.Constants.SERVICE_VENDOR)
+                || name.equals(ConfigurationAdmin.SERVICE_BUNDLELOCATION)
+                || name.equals(ConfigurationAdmin.SERVICE_FACTORYPID);
+            
             // if this is a public property and the component is generating metatype info
             // store the information!
             if ( !isPrivate && ocd != null ) {
diff --git a/scrplugin/src/main/java/org/apache/felix/scrplugin/om/metatype/AttributeDefinition.java b/scrplugin/src/main/java/org/apache/felix/scrplugin/om/metatype/AttributeDefinition.java
index 954b5d6..2a96ba0 100644
--- a/scrplugin/src/main/java/org/apache/felix/scrplugin/om/metatype/AttributeDefinition.java
+++ b/scrplugin/src/main/java/org/apache/felix/scrplugin/om/metatype/AttributeDefinition.java
@@ -22,9 +22,11 @@
 
 public class AttributeDefinition {
 
+    public static final String DEFAULT_TYPE = "String";
+    
     protected String id;
 
-    protected String type;
+    protected String type = DEFAULT_TYPE;
 
     protected String defaultValue;
 
@@ -51,7 +53,10 @@
     }
 
     public void setType(String type) {
-        this.type = type;
+        // do not overwrite default or currently set type
+        if (type != null) {
+            this.type = type;
+        }
     }
 
     public Object getDefaultValue() {
@@ -59,15 +64,19 @@
     }
 
     public void setDefaultValue(String defaultValue) {
-        this.defaultValue = defaultValue;
-        this.defaultMultiValue = null;
+        if (defaultValue != null) {
+            this.defaultValue = defaultValue;
+            this.defaultMultiValue = null;
+        }
     }
 
     public void setDefaultMultiValue(String[] values) {
-        this.defaultValue = null;
-        this.defaultMultiValue = values;
-        if (values != null && values.length > 0 && this.cardinality == null ) {
-            this.cardinality = new Integer(Integer.MAX_VALUE);
+        if (values != null) {
+            this.defaultValue = null;
+            this.defaultMultiValue = values;
+            if (values != null && values.length > 0 && this.cardinality == null ) {
+                this.cardinality = new Integer(Integer.MAX_VALUE);
+            }
         }
     }