felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: r722090 - in /felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin: tags/JavaClassDescriptorManager.java xml/ComponentDescriptorIO.java
Date Mon, 01 Dec 2008 15:06:11 GMT
Author: cziegeler
Date: Mon Dec  1 07:06:11 2008
New Revision: 722090

URL: http://svn.apache.org/viewvc?rev=722090&view=rev
Log:
FELIX-840: Ignore invalid scr files in dependent bundles.

Modified:
    felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/JavaClassDescriptorManager.java
    felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/xml/ComponentDescriptorIO.java

Modified: felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/JavaClassDescriptorManager.java
URL: http://svn.apache.org/viewvc/felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/JavaClassDescriptorManager.java?rev=722090&r1=722089&r2=722090&view=diff
==============================================================================
--- felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/JavaClassDescriptorManager.java
(original)
+++ felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/JavaClassDescriptorManager.java
Mon Dec  1 07:06:11 2008
@@ -158,7 +158,10 @@
                                     while ( st.hasMoreTokens() ) {
                                         final String entry = st.nextToken().trim();
                                         if ( entry.length() > 0 ) {
-                                            components.addAll(this.readServiceComponentDescriptor(artifact,
entry).getComponents());
+                                            final Components c = this.readServiceComponentDescriptor(artifact,
entry);
+                                            if ( c != null ) {
+                                                components.addAll(c.getComponents());
+                                            }
                                         }
                                     }
                                 } else {
@@ -242,18 +245,26 @@
      * @throws IOException
      * @throws MojoExecutionException
      */
-    protected Components readServiceComponentDescriptor(Artifact artifact, String entry)
-    throws IOException, MojoExecutionException {
+    protected Components readServiceComponentDescriptor(Artifact artifact, String entry)
{
         this.log.debug("Reading " + entry + " from " + artifact);
-        final File xml = this.getFile(artifact, entry);
-        if ( xml == null ) {
-            throw new MojoExecutionException("Artifact " + artifact + " does not contain
declared service component descriptor " + entry);
+        try {
+            final File xml = this.getFile(artifact, entry);
+            if ( xml == null ) {
+                throw new MojoExecutionException("Artifact " + artifact + " does not contain
declared service component descriptor " + entry);
+            }
+            return this.parseServiceComponentDescriptor(artifact, xml);
+        } catch (IOException mee) {
+            this.log.warn("Unable to read SCR descriptor file from artifact " + artifact
+ " at " + entry);
+            this.log.debug("Exception occurred during reading: " + mee.getMessage(), mee);
+        } catch (MojoExecutionException mee) {
+            this.log.warn("Unable to read SCR descriptor file from artifact " + artifact
+ " at " + entry);
+            this.log.debug("Exception occurred during reading: " + mee.getMessage(), mee);
         }
-        return this.parseServiceComponentDescriptor(artifact, xml);
+        return null;
     }
 
     protected Components parseServiceComponentDescriptor(Artifact artifact, File file)
-    throws IOException, MojoExecutionException {
+    throws MojoExecutionException {
         this.log.debug("Parsing " + file);
         final Components list = ComponentDescriptorIO.read(file);
         return list;

Modified: felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/xml/ComponentDescriptorIO.java
URL: http://svn.apache.org/viewvc/felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/xml/ComponentDescriptorIO.java?rev=722090&r1=722089&r2=722090&view=diff
==============================================================================
--- felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/xml/ComponentDescriptorIO.java
(original)
+++ felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/xml/ComponentDescriptorIO.java
Mon Dec  1 07:06:11 2008
@@ -78,7 +78,7 @@
             IOUtils.parse(file, xmlHandler);
             return xmlHandler.components;
         } catch (TransformerException e) {
-            throw new MojoExecutionException("Unable to read xml.", e);
+            throw new MojoExecutionException("Unable to read xml from " + file, e);
         } catch (IOException e) {
             throw new MojoExecutionException("Unable to read xml from " + file, e);
         }
@@ -283,14 +283,10 @@
         IOUtils.addAttribute(ai, "cardinality", reference.getCardinality());
         IOUtils.addAttribute(ai, "policy", reference.getPolicy());
         IOUtils.addAttribute(ai, "target", reference.getTarget());
-        
-        if (!reference.isLookupStrategy()) {
-            IOUtils.addAttribute(ai, "bind", reference.getBind());
-            IOUtils.addAttribute(ai, "unbind", reference.getUnbind());
-        }
+        IOUtils.addAttribute(ai, "bind", reference.getBind());
+        IOUtils.addAttribute(ai, "unbind", reference.getUnbind());
         if ( isScrPrivateFile ) {
             IOUtils.addAttribute(ai, "checked", String.valueOf(reference.isChecked()));
-            IOUtils.addAttribute(ai, "strategy", reference.getStrategy());
         }
         IOUtils.indent(contentHandler, 2);
         contentHandler.startElement(INNER_NAMESPACE_URI, ComponentDescriptorIO.REFERENCE,
ComponentDescriptorIO.REFERENCE_QNAME, ai);
@@ -424,7 +420,6 @@
                     ref.setTarget(attributes.getValue("target"));
                     ref.setBind(attributes.getValue("bind"));
                     ref.setUnbind(attributes.getValue("unbind"));
-                    ref.setStrategy(attributes.getValue("strategy"));
 
                     if ( attributes.getValue("checked") != null ) {
                         ref.setChecked(Boolean.valueOf(attributes.getValue("checked")).booleanValue());



Mime
View raw message