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 2012/08/31 10:04:24 UTC

svn commit: r1379346 - in /felix/trunk/scrplugin/generator/src/main/java/org/apache/felix/scrplugin: SCRDescriptorGenerator.java xml/ComponentDescriptorIO.java

Author: cziegeler
Date: Fri Aug 31 08:04:23 2012
New Revision: 1379346

URL: http://svn.apache.org/viewvc?rev=1379346&view=rev
Log:
FELIX-3641 :  Option to generate separate descriptor files 

Modified:
    felix/trunk/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/SCRDescriptorGenerator.java
    felix/trunk/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/xml/ComponentDescriptorIO.java

Modified: felix/trunk/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/SCRDescriptorGenerator.java
URL: http://svn.apache.org/viewvc/felix/trunk/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/SCRDescriptorGenerator.java?rev=1379346&r1=1379345&r2=1379346&view=diff
==============================================================================
--- felix/trunk/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/SCRDescriptorGenerator.java (original)
+++ felix/trunk/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/SCRDescriptorGenerator.java Fri Aug 31 08:04:23 2012
@@ -248,12 +248,7 @@ public class SCRDescriptorGenerator {
 
             // ignore component if it has errors
             if (iLog.getNumberOfErrors() == errorCount) {
-                if (!container.getComponentDescription().isCreateDs()) {
-                    logger.debug("Ignoring descriptor for DS : " + container);
-                } else if (!container.getComponentDescription().isAbstract()) {
-                    this.logger.debug("Adding descriptor for DS : " + container);
-                    module.add(container);
-                }
+                module.add(container);
             }
         }
         // log issues

Modified: felix/trunk/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/xml/ComponentDescriptorIO.java
URL: http://svn.apache.org/viewvc/felix/trunk/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/xml/ComponentDescriptorIO.java?rev=1379346&r1=1379345&r2=1379346&view=diff
==============================================================================
--- felix/trunk/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/xml/ComponentDescriptorIO.java (original)
+++ felix/trunk/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/xml/ComponentDescriptorIO.java Fri Aug 31 08:04:23 2012
@@ -709,12 +709,22 @@ public class ComponentDescriptorIO {
      */
     public static List<String> generateDescriptorFiles(final DescriptionContainer module, final Options options, final Log logger)
     throws SCRDescriptorException, SCRDescriptorFailureException {
+        final List<ComponentContainer> components = new ArrayList<ComponentContainer>();
+        for(final ComponentContainer container : module.getComponents()) {
+            if (!container.getComponentDescription().isCreateDs()) {
+                logger.debug("Ignoring descriptor for DS : " + container);
+            } else if (!container.getComponentDescription().isAbstract()) {
+                logger.debug("Adding descriptor for DS : " + container);
+                components.add(container);
+            }
+        }
+
         // check descriptor file
         final File descriptorDir = new File(options.getOutputDirectory(), PARENT_NAME);
         final File descriptorFile = StringUtils.isEmpty(options.getSCRName()) ? null : new File(descriptorDir, options.getSCRName());
 
         // terminate if there is nothing else to write
-        if (module.getComponents().isEmpty()) {
+        if (components.isEmpty()) {
             logger.debug("No Service Component Descriptors found in project.");
             // remove file if it exists
             if (descriptorFile != null && descriptorFile.exists()) {
@@ -729,7 +739,7 @@ public class ComponentDescriptorIO {
 
         final List<String> fileNames = new ArrayList<String>();
         if ( options.isGenerateSeparateDescriptors() ) {
-            for(final ComponentContainer component : module.getComponents() ) {
+            for(final ComponentContainer component : components ) {
                 final File file = new File(descriptorDir, component.getClassDescription().getDescribedClass().getName() + ".xml");
                 try {
                     ComponentDescriptorIO.generateXML(module, Collections.singletonList(component), file, logger);
@@ -743,7 +753,7 @@ public class ComponentDescriptorIO {
                 throw new SCRDescriptorFailureException("Descriptor file name must not be empty.");
             }
             try {
-                ComponentDescriptorIO.generateXML(module, module.getComponents(), descriptorFile, logger);
+                ComponentDescriptorIO.generateXML(module, components, descriptorFile, logger);
             } catch (final SAXException e) {
                 throw new SCRDescriptorException("Unable to generate xml", descriptorFile.toString(), e);
             }