Author: fmeschbe
Date: Wed Aug 29 07:06:57 2007
New Revision: 570816
URL: http://svn.apache.org/viewvc?rev=570816&view=rev
Log:
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)
Modified:
felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/SCRDescriptorMojo.java
felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/om/metatype/AttributeDefinition.java
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=570816&r1=570815&r2=570816&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
Wed Aug 29 07:06:57 2007
@@ -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 ) {
Modified:
felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/om/metatype/AttributeDefinition.java
URL:
http://svn.apache.org/viewvc/felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/om/metatype/AttributeDefinition.java?rev=570816&r1=570815&r2=570816&view=diff
==============================================================================
---
felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/om/metatype/AttributeDefinition.java
(original)
+++
felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/om/metatype/AttributeDefinition.java
Wed Aug 29 07:06:57 2007
@@ -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);
+ }
}
}