FELIX-507: Write all components into scr private file.
git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@634190 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 58179f1..f3e3938 100644
--- a/scrplugin/src/main/java/org/apache/felix/scrplugin/SCRDescriptorMojo.java
+++ b/scrplugin/src/main/java/org/apache/felix/scrplugin/SCRDescriptorMojo.java
@@ -113,6 +113,7 @@
} else {
this.getLog().debug("Adding descriptor " + comp);
components.addComponent(comp);
+ abstractComponents.addComponent(comp);
}
} else {
hasFailures = true;
@@ -146,12 +147,12 @@
this.getLog().info("Meta type file name is not set: meta type info is not written.");
}
- // if we have abstract descriptors, write them
+ // if we have descriptors, write them in our scr private file (for component inheritance)
final File adFile = new File(this.outputDirectory, Constants.ABSTRACT_DESCRIPTOR_RELATIVE_PATH);
if ( !abstractComponents.getComponents().isEmpty() ) {
this.getLog().info("Writing abstract service descriptor " + adFile + " with " + abstractComponents.getComponents().size() + " entries.");
adFile.getParentFile().mkdirs();
- ComponentDescriptorIO.write(abstractComponents, adFile);
+ ComponentDescriptorIO.write(abstractComponents, adFile, true);
addResources = true;
} else {
this.getLog().debug("No abstract SCR Descriptors found in project.");
@@ -185,7 +186,7 @@
this.getLog().info("Generating " + components.getComponents().size()
+ " Service Component Descriptors to " + descriptorFile);
- ComponentDescriptorIO.write(components, descriptorFile);
+ ComponentDescriptorIO.write(components, descriptorFile, false);
addResources = true;
// and set include accordingly
diff --git a/scrplugin/src/main/java/org/apache/felix/scrplugin/xml/ComponentDescriptorIO.java b/scrplugin/src/main/java/org/apache/felix/scrplugin/xml/ComponentDescriptorIO.java
index 6e0a9bb..f940ec1 100644
--- a/scrplugin/src/main/java/org/apache/felix/scrplugin/xml/ComponentDescriptorIO.java
+++ b/scrplugin/src/main/java/org/apache/felix/scrplugin/xml/ComponentDescriptorIO.java
@@ -88,10 +88,10 @@
* @param file
* @throws MojoExecutionException
*/
- public static void write(Components components, File file)
+ public static void write(Components components, File file, boolean isScrPrivateFile)
throws MojoExecutionException {
try {
- generateXML(components, IOUtils.getSerializer(file));
+ generateXML(components, IOUtils.getSerializer(file), isScrPrivateFile);
} catch (TransformerException e) {
throw new MojoExecutionException("Unable to write xml to " + file, e);
} catch (SAXException e) {
@@ -108,7 +108,7 @@
* @param contentHandler
* @throws SAXException
*/
- protected static void generateXML(Components components, ContentHandler contentHandler)
+ protected static void generateXML(Components components, ContentHandler contentHandler, boolean isScrPrivateFile)
throws SAXException {
contentHandler.startDocument();
contentHandler.startPrefixMapping(PREFIX, NAMESPACE_URI);
@@ -119,7 +119,7 @@
final Iterator i = components.getComponents().iterator();
while ( i.hasNext() ) {
final Component component = (Component)i.next();
- generateXML(component, contentHandler);
+ generateXML(component, contentHandler, isScrPrivateFile);
}
// end wrapper element
contentHandler.endElement("", ComponentDescriptorIO.COMPONENTS, ComponentDescriptorIO.COMPONENTS);
@@ -133,7 +133,7 @@
* @param contentHandler
* @throws SAXException
*/
- protected static void generateXML(Component component, ContentHandler contentHandler)
+ protected static void generateXML(Component component, ContentHandler contentHandler, boolean isScrPrivateFile)
throws SAXException {
final AttributesImpl ai = new AttributesImpl();
IOUtils.addAttribute(ai, "enabled", component.isEnabled());
@@ -150,7 +150,7 @@
final Iterator i = component.getProperties().iterator();
while ( i.hasNext() ) {
final Property property = (Property)i.next();
- generateXML(property, contentHandler, component.isAbstract());
+ generateXML(property, contentHandler, isScrPrivateFile);
}
}
if ( component.getReferences() != null ) {
@@ -218,14 +218,14 @@
* @param contentHandler
* @throws SAXException
*/
- protected static void generateXML(Property property, ContentHandler contentHandler, boolean isAbstract)
+ protected static void generateXML(Property property, ContentHandler contentHandler, boolean isScrPrivateFile)
throws SAXException {
final AttributesImpl ai = new AttributesImpl();
IOUtils.addAttribute(ai, "name", property.getName());
IOUtils.addAttribute(ai, "type", property.getType());
IOUtils.addAttribute(ai, "value", property.getValue());
- // we have to write more information if the component is abstract
- if ( isAbstract ) {
+ // we have to write more information if this is our scr private file
+ if ( isScrPrivateFile ) {
IOUtils.addAttribute(ai, "private", String.valueOf(property.isPrivate()));
if ( property.getLabel() != null ) {
IOUtils.addAttribute(ai, "label", String.valueOf(property.getLabel()));