Author: alien11689
Date: Sat Feb 18 18:03:04 2017
New Revision: 1783576
URL: http://svn.apache.org/viewvc?rev=1783576&view=rev
Log:
[ARIES-1688] Generate beans and custom writers in alphabetical order
Modified:
aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/model/Bean.java
aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/model/Blueprint.java
Modified:
aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/model/Bean.java
URL:
http://svn.apache.org/viewvc/aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/model/Bean.java?rev=1783576&r1=1783575&r2=1783576&view=diff
==============================================================================
---
aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/model/Bean.java
(original)
+++
aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/model/Bean.java
Sat Feb 18 18:03:04 2017
@@ -35,6 +35,7 @@ import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -44,7 +45,7 @@ import java.util.TreeSet;
import static
org.apache.aries.blueprint.plugin.model.AnnotationHelper.findSingleton;
import static org.apache.aries.blueprint.plugin.model.NamingHelper.getBeanName;
-class Bean implements BeanEnricher, XmlWriter {
+class Bean implements BeanEnricher, XmlWriter, Comparable<Bean>{
private static final String NS_EXT =
"http://aries.apache.org/blueprint/xmlns/blueprint-ext/v1.0.0";
@@ -181,8 +182,10 @@ class Bean implements BeanEnricher, XmlW
}
private void writeCustomContent(XMLStreamWriter writer) throws
XMLStreamException {
- for (XmlWriter xmlWriter : beanContentWriters.values()) {
- xmlWriter.write(writer);
+ List<String> customWriterKeys = new
ArrayList<>(beanContentWriters.keySet());
+ Collections.sort(customWriterKeys);
+ for (String customWriterKey : customWriterKeys) {
+ beanContentWriters.get(customWriterKey).write(writer);
}
}
@@ -218,4 +221,9 @@ class Bean implements BeanEnricher, XmlW
BeanRef toBeanRef() {
return new BeanRef(clazz, id, clazz.getAnnotations());
}
+
+ @Override
+ public int compareTo(Bean o) {
+ return id.compareTo(o.id);
+ }
}
Modified:
aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/model/Blueprint.java
URL:
http://svn.apache.org/viewvc/aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/model/Blueprint.java?rev=1783576&r1=1783575&r2=1783576&view=diff
==============================================================================
---
aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/model/Blueprint.java
(original)
+++
aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/model/Blueprint.java
Sat Feb 18 18:03:04 2017
@@ -31,6 +31,8 @@ import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
+import java.util.Collections;
+import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -133,16 +135,24 @@ public class Blueprint implements Bluepr
public void write(XMLStreamWriter writer) throws XMLStreamException {
writeBlueprint(writer);
+ writeBeans(writer);
+ writeCustomWriters(writer);
+ writer.writeEndElement();
+ }
- for (Bean beanWriter : generatedBeans) {
- beanWriter.write(writer);
+ private void writeCustomWriters(XMLStreamWriter writer) throws
XMLStreamException {
+ List<String> customWriterKeys = new
ArrayList<>(customWriters.keySet());
+ Collections.sort(customWriterKeys);
+ for (String customWriterKey : customWriterKeys) {
+ customWriters.get(customWriterKey).write(writer);
}
+ }
- for (XmlWriter bw : customWriters.values()) {
- bw.write(writer);
+ private void writeBeans(XMLStreamWriter writer) throws XMLStreamException {
+ Collections.sort(generatedBeans);
+ for (Bean beanWriter : generatedBeans) {
+ beanWriter.write(writer);
}
-
- writer.writeEndElement();
}
private void writeBlueprint(XMLStreamWriter writer) throws
XMLStreamException {