FELIX-4973 : Relax exception handling when reading metatype XML
git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@1693436 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/metatype/src/main/java/org/apache/felix/metatype/MetaDataReader.java b/metatype/src/main/java/org/apache/felix/metatype/MetaDataReader.java
index fac81e1..eba2565 100644
--- a/metatype/src/main/java/org/apache/felix/metatype/MetaDataReader.java
+++ b/metatype/src/main/java/org/apache/felix/metatype/MetaDataReader.java
@@ -81,13 +81,15 @@
private KXmlParser parser = new KXmlParser();
private String namespace = NAMESPACE_1_0;
+ private URL documentURL;
+
/** Sets of attributes belonging to XML elements. */
- private static final Set AD_ATTRIBUTES = new HashSet(Arrays.asList(new String[] { "name", "description", "id", "type", "cardinality", "min", "max", "default", "required" }));
- private static final Set ATTRIBUTE_ATTRIBUTES = new HashSet(Arrays.asList(new String[] { "adref", "content" }));
- private static final Set DESIGNATE_ATTRIBUTES = new HashSet(Arrays.asList(new String[] { "pid", "factoryPid", "bundle", "optional", "merge" }));
- private static final Set DESIGNATEOBJECT_ATTRIBUTES = new HashSet(Arrays.asList(new String[] { "ocdref" }));
- private static final Set METADATA_ATTRIBUTES = new HashSet(Arrays.asList(new String[] { "localization" }));
- private static final Set OCD_ATTRIBUTES = new HashSet(Arrays.asList(new String[] { "name", "description", "id" }));
+ private static final Set<String> AD_ATTRIBUTES = new HashSet<String>(Arrays.asList(new String[] { "name", "description", "id", "type", "cardinality", "min", "max", "default", "required" }));
+ private static final Set<String> ATTRIBUTE_ATTRIBUTES = new HashSet<String>(Arrays.asList(new String[] { "adref", "content" }));
+ private static final Set<String> DESIGNATE_ATTRIBUTES = new HashSet<String>(Arrays.asList(new String[] { "pid", "factoryPid", "bundle", "optional", "merge" }));
+ private static final Set<String> DESIGNATEOBJECT_ATTRIBUTES = new HashSet<String>(Arrays.asList(new String[] { "ocdref" }));
+ private static final Set<String> METADATA_ATTRIBUTES = new HashSet<String>(Arrays.asList(new String[] { "localization" }));
+ private static final Set<String> OCD_ATTRIBUTES = new HashSet<String>(Arrays.asList(new String[] { "name", "description", "id" }));
/**
* Parses the XML document provided by the <code>url</code>. The XML document
@@ -107,6 +109,7 @@
*/
public MetaData parse(URL url) throws IOException
{
+ this.documentURL = url;
InputStream ins = null;
try
{
@@ -137,6 +140,7 @@
// ignore
}
}
+ this.documentURL = null;
}
}
@@ -637,9 +641,13 @@
return new XmlPullParserException(message, this.parser, null);
}
- private void logMissingElement(String elementName)
+ private void logMissingElement(final String elementName)
{
String message = "Missing element " + elementName + " in element " + this.parser.getName();
+ if ( documentURL != null )
+ {
+ message = message + " : " + this.documentURL;
+ }
Activator.log(LogService.LOG_ERROR, message);
}
diff --git a/metatype/src/main/java/org/apache/felix/metatype/internal/MetaTypeServiceImpl.java b/metatype/src/main/java/org/apache/felix/metatype/internal/MetaTypeServiceImpl.java
index e09c709..5401c93 100644
--- a/metatype/src/main/java/org/apache/felix/metatype/internal/MetaTypeServiceImpl.java
+++ b/metatype/src/main/java/org/apache/felix/metatype/internal/MetaTypeServiceImpl.java
@@ -140,7 +140,7 @@
}
MetaTypeInformationImpl impl = null;
- if ( bundle.getState() == Bundle.ACTIVE || bundle.getState() == Bundle.STARTING )
+ if ( bundle.getState() == Bundle.ACTIVE || bundle.getState() == Bundle.STARTING || bundle.getState() == Bundle.RESOLVED )
{
putMetaTypeInformationInternal( bundle, mti );
}