aries-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From alien11...@apache.org
Subject svn commit: r1780846 - in /aries/trunk/blueprint/plugin/blueprint-maven-plugin/src: main/java/org/apache/aries/blueprint/plugin/ main/java/org/apache/aries/blueprint/plugin/handlers/blueprint/ main/java/org/apache/aries/blueprint/plugin/model/ main/res...
Date Sun, 29 Jan 2017 19:20:06 GMT
Author: alien11689
Date: Sun Jan 29 19:20:06 2017
New Revision: 1780846

URL: http://svn.apache.org/viewvc?rev=1780846&view=rev
Log:
[MAINTENANCE] Hide blueprint model in Blueprint Maven Plugin

Added:
    aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/BlueprintFileWriter.java
      - copied, changed from r1780845, aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/model/BlueprintWriter.java
    aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/handlers/blueprint/
    aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/handlers/blueprint/BlueprintInitialization.java
      - copied, changed from r1780845, aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/model/BlueprintInitialization.java
    aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/test/java/org/apache/aries/blueprint/plugin/BlueprintFileWriterTest.java
      - copied, changed from r1780845, aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/test/java/org/apache/aries/blueprint/plugin/BlueprintWriterTest.java
Removed:
    aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/model/BlueprintInitialization.java
    aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/model/BlueprintWriter.java
    aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/test/java/org/apache/aries/blueprint/plugin/BlueprintWriterTest.java
Modified:
    aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/GenerateMojo.java
    aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/model/AnnotationHelper.java
    aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/model/Argument.java
    aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/model/BeanFromFactory.java
    aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/model/BeanRef.java
    aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/model/Context.java
    aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/model/Introspector.java
    aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/model/Property.java
    aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/main/resources/META-INF/services/org.apache.aries.blueprint.plugin.spi.ContextInitializationHandler

Copied: aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/BlueprintFileWriter.java
(from r1780845, aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/model/BlueprintWriter.java)
URL: http://svn.apache.org/viewvc/aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/BlueprintFileWriter.java?p2=aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/BlueprintFileWriter.java&p1=aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/model/BlueprintWriter.java&r1=1780845&r2=1780846&rev=1780846&view=diff
==============================================================================
--- aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/model/BlueprintWriter.java
(original)
+++ aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/BlueprintFileWriter.java
Sun Jan 29 19:20:06 2017
@@ -16,10 +16,10 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-package org.apache.aries.blueprint.plugin.model;
+package org.apache.aries.blueprint.plugin;
 
+import org.apache.aries.blueprint.plugin.model.Context;
 import org.apache.aries.blueprint.plugin.spi.BlueprintConfiguration;
-import org.apache.aries.blueprint.plugin.spi.XmlWriter;
 
 import javax.xml.stream.XMLOutputFactory;
 import javax.xml.stream.XMLStreamException;
@@ -33,24 +33,19 @@ import javax.xml.transform.stream.Stream
 import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
 import java.io.OutputStream;
-import java.util.Map;
 
-public class BlueprintWriter {
-    private static final String NS_BLUEPRINT = "http://www.osgi.org/xmlns/blueprint/v1.0.0";
-    private static final String NS_EXT = "http://aries.apache.org/blueprint/xmlns/blueprint-ext/v1.0.0";
+class BlueprintFileWriter {
 
-    private final BlueprintConfiguration blueprintConfiguration;
     private final XMLStreamWriter writer;
     private final OutputStream os;
     private final ByteArrayOutputStream temp = new ByteArrayOutputStream();
 
-    public BlueprintWriter(OutputStream os, BlueprintConfiguration blueprintConfiguration)
throws XMLStreamException {
-        this.blueprintConfiguration = blueprintConfiguration;
+    BlueprintFileWriter(OutputStream os) throws XMLStreamException {
         this.writer = XMLOutputFactory.newFactory().createXMLStreamWriter(temp);
         this.os = os;
     }
 
-    public void generate(Context context) {
+    void generate(Context context) {
         generateXml(context);
         printFormatted();
     }
@@ -58,20 +53,7 @@ public class BlueprintWriter {
     private void generateXml(Context context) {
         try {
             writer.writeStartDocument();
-            writeBlueprint();
-
-            for (Bean bean : context.getBeans()) {
-                writeBeanStart(bean);
-                bean.writeArguments(writer);
-                bean.writeProperties(writer);
-                writer.writeEndElement();
-            }
-
-            for (XmlWriter bw : context.getBlueprintWriters().values()) {
-                bw.write(writer);
-            }
-
-            writer.writeEndElement();
+            context.write(writer);
             writer.writeEndDocument();
             writer.close();
         } catch (XMLStreamException e) {
@@ -93,41 +75,4 @@ public class BlueprintWriter {
             throw new RuntimeException("Cannot print file", e);
         }
     }
-
-    private void writeBlueprint() throws XMLStreamException {
-        writer.writeStartElement("blueprint");
-        writer.writeDefaultNamespace(NS_BLUEPRINT);
-        writer.writeNamespace("ext", NS_EXT);
-        if (blueprintConfiguration.getDefaultActivation() != null) {
-            writer.writeAttribute("default-activation", blueprintConfiguration.getDefaultActivation().name().toLowerCase());
-        }
-    }
-
-    private void writeBeanStart(Bean bean) throws XMLStreamException {
-        writer.writeStartElement("bean");
-        writer.writeAttribute("id", bean.id);
-        writer.writeAttribute("class", bean.clazz.getName());
-        if (bean.needFieldInjection()) {
-            writer.writeAttribute("ext", NS_EXT, "field-injection", "true");
-        }
-        if (bean.isPrototype) {
-            writer.writeAttribute("scope", "prototype");
-        }
-
-        Map<String, String> attributes = bean.attributes;
-        for (Map.Entry<String, String> entry : attributes.entrySet()) {
-            writer.writeAttribute(entry.getKey(), entry.getValue());
-        }
-        if (bean instanceof BeanFromFactory) {
-            writeFactory((BeanFromFactory) bean);
-        }
-        for (XmlWriter xmlWriter : bean.beanContentWriters.values()) {
-            xmlWriter.write(writer);
-        }
-    }
-
-    private void writeFactory(BeanFromFactory bean) throws XMLStreamException {
-        writer.writeAttribute("factory-ref", bean.factoryBean.id);
-        writer.writeAttribute("factory-method", bean.factoryMethod);
-    }
 }

Modified: aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/GenerateMojo.java
URL: http://svn.apache.org/viewvc/aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/GenerateMojo.java?rev=1780846&r1=1780845&r2=1780846&view=diff
==============================================================================
--- aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/GenerateMojo.java
(original)
+++ aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/GenerateMojo.java
Sun Jan 29 19:20:06 2017
@@ -18,7 +18,6 @@
  */
 package org.apache.aries.blueprint.plugin;
 
-import org.apache.aries.blueprint.plugin.model.BlueprintWriter;
 import org.apache.aries.blueprint.plugin.model.Context;
 import org.apache.aries.blueprint.plugin.spi.Activation;
 import org.apache.aries.blueprint.plugin.spi.BlueprintConfiguration;
@@ -139,7 +138,7 @@ public class GenerateMojo extends Abstra
         getLog().info("Generating blueprint to " + file);
 
         OutputStream fos = buildContext.newFileOutputStream(file);
-        new BlueprintWriter(fos, blueprintConfiguration).generate(context);
+        new BlueprintFileWriter(fos).generate(context);
         fos.close();
     }
 

Copied: aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/handlers/blueprint/BlueprintInitialization.java
(from r1780845, aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/model/BlueprintInitialization.java)
URL: http://svn.apache.org/viewvc/aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/handlers/blueprint/BlueprintInitialization.java?p2=aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/handlers/blueprint/BlueprintInitialization.java&p1=aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/model/BlueprintInitialization.java&r1=1780845&r2=1780846&rev=1780846&view=diff
==============================================================================
--- aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/model/BlueprintInitialization.java
(original)
+++ aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/handlers/blueprint/BlueprintInitialization.java
Sun Jan 29 19:20:06 2017
@@ -16,7 +16,7 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-package org.apache.aries.blueprint.plugin.model;
+package org.apache.aries.blueprint.plugin.handlers.blueprint;
 
 import org.apache.aries.blueprint.plugin.spi.ContextEnricher;
 import org.apache.aries.blueprint.plugin.spi.ContextInitializationHandler;

Modified: aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/model/AnnotationHelper.java
URL: http://svn.apache.org/viewvc/aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/model/AnnotationHelper.java?rev=1780846&r1=1780845&r2=1780846&view=diff
==============================================================================
--- aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/model/AnnotationHelper.java
(original)
+++ aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/model/AnnotationHelper.java
Sun Jan 29 19:20:06 2017
@@ -27,8 +27,8 @@ import java.lang.annotation.Annotation;
 import java.util.ArrayList;
 import java.util.List;
 
-public class AnnotationHelper {
-    public static Class<? extends Annotation>[] injectDependencyAnnotations = findInjectDependencyAnnotations();
+class AnnotationHelper {
+    static Class<? extends Annotation>[] injectDependencyAnnotations = findInjectDependencyAnnotations();
 
     private static Class<? extends Annotation>[] findInjectDependencyAnnotations()
{
         List<Class<? extends Annotation>> classes = new ArrayList<>();
@@ -41,7 +41,7 @@ public class AnnotationHelper {
         return classes.toArray(new Class[classes.size()]);
     }
 
-    public static String findValue(Annotation[] annotations) {
+    static String findValue(Annotation[] annotations) {
         for (ValueInjectionHandler valueInjectionHandler : Handlers.valueInjectionHandlers)
{
             Object annotation = findAnnotation(annotations, valueInjectionHandler.getAnnotation());
             if (annotation != null) {
@@ -54,7 +54,7 @@ public class AnnotationHelper {
         return null;
     }
 
-    public static String findName(Annotation[] annotations) {
+    static String findName(Annotation[] annotations) {
         for (NamedLikeHandler namedLikeHandler : Handlers.namedLikeHandlers) {
             Object annotation = findAnnotation(annotations, namedLikeHandler.getAnnotation());
             if (annotation != null) {
@@ -67,7 +67,7 @@ public class AnnotationHelper {
         return null;
     }
 
-    public static <T> T findAnnotation(Annotation[] annotations, Class<T> annotation)
{
+    static <T> T findAnnotation(Annotation[] annotations, Class<T> annotation)
{
         for (Annotation a : annotations) {
             if (a.annotationType() == annotation) {
                 return annotation.cast(a);
@@ -76,7 +76,7 @@ public class AnnotationHelper {
         return null;
     }
 
-    public static boolean findSingletons(Annotation[] annotations) {
+    static boolean findSingletons(Annotation[] annotations) {
         for (Class<? extends Annotation> singletonAnnotation : Handlers.singletons)
{
             Object annotation = findAnnotation(annotations, singletonAnnotation);
             if (annotation != null) {

Modified: aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/model/Argument.java
URL: http://svn.apache.org/viewvc/aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/model/Argument.java?rev=1780846&r1=1780845&r2=1780846&view=diff
==============================================================================
--- aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/model/Argument.java
(original)
+++ aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/model/Argument.java
Sun Jan 29 19:20:06 2017
@@ -23,20 +23,20 @@ import org.apache.aries.blueprint.plugin
 import javax.xml.stream.XMLStreamException;
 import javax.xml.stream.XMLStreamWriter;
 
-public class Argument implements XmlWriter{
+class Argument implements XmlWriter{
     private final String ref;
     private final String value;
 
-    public Argument(String ref, String value) {
+    Argument(String ref, String value) {
         this.ref = ref;
         this.value = value;
     }
 
-    public String getRef() {
+    String getRef() {
         return this.ref;
     }
 
-    public String getValue() {
+    String getValue() {
         return this.value;
     }
 

Modified: aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/model/BeanFromFactory.java
URL: http://svn.apache.org/viewvc/aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/model/BeanFromFactory.java?rev=1780846&r1=1780845&r2=1780846&view=diff
==============================================================================
--- aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/model/BeanFromFactory.java
(original)
+++ aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/model/BeanFromFactory.java
Sun Jan 29 19:20:06 2017
@@ -25,16 +25,16 @@ import org.apache.aries.blueprint.plugin
 
 import java.lang.reflect.Method;
 
-public class BeanFromFactory extends Bean {
-    public String factoryMethod;
-    public BeanRef factoryBean;
+class BeanFromFactory extends Bean {
+    String factoryMethod;
+     BeanRef factoryBean;
     private Method producingMethod;
 
-    public BeanFromFactory(Class<?> clazz, BeanRef factoryBean, Method factoryMethod,
ContextEnricher contextEnricher) {
+    BeanFromFactory(Class<?> clazz, BeanRef factoryBean, Method factoryMethod, ContextEnricher
contextEnricher) {
         this(clazz, null, factoryBean, factoryMethod, contextEnricher);
     }
 
-    public BeanFromFactory(Class<?> clazz, String id, BeanRef factoryBean, Method factoryMethod,
ContextEnricher contextEnricher) {
+    BeanFromFactory(Class<?> clazz, String id, BeanRef factoryBean, Method factoryMethod,
ContextEnricher contextEnricher) {
         super(clazz, contextEnricher);
         if (id != null) {
             this.id = id;
@@ -54,7 +54,7 @@ public class BeanFromFactory extends Bea
         }
     }
 
-    public void setSingleton() {
+    void setSingleton() {
         this.isPrototype = false;
     }
 

Modified: aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/model/BeanRef.java
URL: http://svn.apache.org/viewvc/aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/model/BeanRef.java?rev=1780846&r1=1780845&r2=1780846&view=diff
==============================================================================
--- aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/model/BeanRef.java
(original)
+++ aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/model/BeanRef.java
Sun Jan 29 19:20:06 2017
@@ -28,29 +28,29 @@ import java.lang.reflect.Method;
 import java.util.HashMap;
 import java.util.Map;
 
-public class BeanRef implements Comparable<BeanRef> {
+class BeanRef implements Comparable<BeanRef> {
     public String id;
     public Class<?> clazz;
-    public Map<Class<? extends Annotation>, Annotation> qualifiers = new HashMap<>();
+    Map<Class<? extends Annotation>, Annotation> qualifiers = new HashMap<>();
 
     /**
      * @param clazz interface or implementation class
      */
-    public BeanRef(Class<?> clazz) {
+    BeanRef(Class<?> clazz) {
         this.clazz = clazz;
     }
 
-    public BeanRef(Class<?> clazz, String id) {
+    BeanRef(Class<?> clazz, String id) {
         this(clazz);
         this.id = id;
     }
 
-    public BeanRef(Field field) {
+    BeanRef(Field field) {
         this(field.getType());
         parseQualifiers(field);
     }
 
-    public BeanRef(Method method) {
+    BeanRef(Method method) {
         this(method.getParameterTypes()[0]);
         parseQualifiers(method);
     }
@@ -78,11 +78,11 @@ public class BeanRef implements Comparab
         return null;
     }
 
-    public static String getBeanName(Class<?> clazz) {
+    static String getBeanName(Class<?> clazz) {
         return getBeanName(clazz, clazz);
     }
 
-    public static String getBeanName(Class<?> clazz, AnnotatedElement annotatedElement)
{
+    static String getBeanName(Class<?> clazz, AnnotatedElement annotatedElement) {
         for (NamedLikeHandler namedLikeHandler : Handlers.namedLikeHandlers) {
             if (annotatedElement.getAnnotation(namedLikeHandler.getAnnotation()) != null)
{
                 String name = namedLikeHandler.getName(clazz, annotatedElement);
@@ -99,7 +99,7 @@ public class BeanRef implements Comparab
         return name.substring(0, 1).toLowerCase() + name.substring(1, name.length());
     }
 
-    public boolean matches(BeanRef template) {
+    boolean matches(BeanRef template) {
         boolean assignable = template.clazz.isAssignableFrom(this.clazz);
         if (template.id != null) {
             return template.id.equals(id);

Modified: aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/model/Context.java
URL: http://svn.apache.org/viewvc/aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/model/Context.java?rev=1780846&r1=1780845&r2=1780846&view=diff
==============================================================================
--- aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/model/Context.java
(original)
+++ aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/model/Context.java
Sun Jan 29 19:20:06 2017
@@ -24,6 +24,8 @@ import org.apache.aries.blueprint.plugin
 import org.apache.aries.blueprint.plugin.spi.ContextInitializationHandler;
 import org.apache.aries.blueprint.plugin.spi.XmlWriter;
 
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamWriter;
 import java.lang.annotation.Annotation;
 import java.lang.reflect.Method;
 import java.util.Arrays;
@@ -33,13 +35,15 @@ import java.util.Map;
 import java.util.SortedSet;
 import java.util.TreeSet;
 
-public class Context implements BlueprintRegister, ContextEnricher {
+public class Context implements BlueprintRegister, ContextEnricher, XmlWriter {
+    private static final String NS_BLUEPRINT = "http://www.osgi.org/xmlns/blueprint/v1.0.0";
+    private static final String NS_EXT = "http://aries.apache.org/blueprint/xmlns/blueprint-ext/v1.0.0";
 
     SortedSet<BeanRef> reg = new TreeSet<BeanRef>();
     private final Map<String, XmlWriter> blueprintWriters = new HashMap<>();
     private final BlueprintConfiguration blueprintConfiguration;
 
-    public Context(BlueprintConfiguration blueprintConfiguration, Class<?>... beanClasses)
{
+    Context(BlueprintConfiguration blueprintConfiguration, Class<?>... beanClasses)
{
         this(blueprintConfiguration, Arrays.asList(beanClasses));
     }
 
@@ -145,4 +149,58 @@ public class Context implements Blueprin
     public BlueprintConfiguration getBlueprintConfiguration() {
         return blueprintConfiguration;
     }
+
+    public void write(XMLStreamWriter writer) throws XMLStreamException {
+        writeBlueprint(writer);
+
+        for (Bean bean : getBeans()) {
+            writeBeanStart(writer, bean);
+            bean.writeArguments(writer);
+            bean.writeProperties(writer);
+            writer.writeEndElement();
+        }
+
+        for (XmlWriter bw : getBlueprintWriters().values()) {
+            bw.write(writer);
+        }
+
+        writer.writeEndElement();
+    }
+
+    private void writeBlueprint(XMLStreamWriter writer) throws XMLStreamException {
+        writer.writeStartElement("blueprint");
+        writer.writeDefaultNamespace(NS_BLUEPRINT);
+        writer.writeNamespace("ext", NS_EXT);
+        if (blueprintConfiguration.getDefaultActivation() != null) {
+            writer.writeAttribute("default-activation", blueprintConfiguration.getDefaultActivation().name().toLowerCase());
+        }
+    }
+
+    private void writeBeanStart(XMLStreamWriter writer, Bean bean) throws XMLStreamException
{
+        writer.writeStartElement("bean");
+        writer.writeAttribute("id", bean.id);
+        writer.writeAttribute("class", bean.clazz.getName());
+        if (bean.needFieldInjection()) {
+            writer.writeAttribute("ext", NS_EXT, "field-injection", "true");
+        }
+        if (bean.isPrototype) {
+            writer.writeAttribute("scope", "prototype");
+        }
+
+        Map<String, String> attributes = bean.attributes;
+        for (Map.Entry<String, String> entry : attributes.entrySet()) {
+            writer.writeAttribute(entry.getKey(), entry.getValue());
+        }
+        if (bean instanceof BeanFromFactory) {
+            writeFactory(writer, (BeanFromFactory) bean);
+        }
+        for (XmlWriter xmlWriter : bean.beanContentWriters.values()) {
+            xmlWriter.write(writer);
+        }
+    }
+
+    private void writeFactory(XMLStreamWriter writer, BeanFromFactory bean) throws XMLStreamException
{
+        writer.writeAttribute("factory-ref", bean.factoryBean.id);
+        writer.writeAttribute("factory-method", bean.factoryMethod);
+    }
 }

Modified: aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/model/Introspector.java
URL: http://svn.apache.org/viewvc/aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/model/Introspector.java?rev=1780846&r1=1780845&r2=1780846&view=diff
==============================================================================
--- aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/model/Introspector.java
(original)
+++ aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/model/Introspector.java
Sun Jan 29 19:20:06 2017
@@ -36,13 +36,13 @@ import java.util.Set;
 /**
  * Class to find uniquely-named fields declared in a class hierarchy with specified annotations.
  */
-public final class Introspector {
+final class Introspector {
     private Class<?> originalClazz;
 
     /**
      * @param clazz the class to introspect (including those defined in parent classes).
      */
-    public Introspector(Class<?> clazz) {
+    Introspector(Class<?> clazz) {
         this.originalClazz = clazz;
     }
 
@@ -53,7 +53,7 @@ public final class Introspector {
      * field declared elsewhere in the class hierarchy.
      */
     @SafeVarargs
-    public final List<Field> fieldsWith(Class<? extends Annotation>... requiredAnnotations)
{
+    final List<Field> fieldsWith(Class<? extends Annotation>... requiredAnnotations)
{
         Multimap<String, Field> fieldsByName = HashMultimap.create();
         Set<String> acceptedFieldNames = Sets.newHashSet();
         Class<?> clazz = originalClazz;
@@ -122,7 +122,7 @@ public final class Introspector {
     }
 
     @SafeVarargs
-    public final List<Method> methodsWith(Class<? extends Annotation>... annotationClasses)
{
+    final List<Method> methodsWith(Class<? extends Annotation>... annotationClasses)
{
         List<Method> methods = new ArrayList<>();
         for (Method method : originalClazz.getMethods()) {
             for(Class<? extends Annotation> annotationClass : annotationClasses) {

Modified: aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/model/Property.java
URL: http://svn.apache.org/viewvc/aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/model/Property.java?rev=1780846&r1=1780845&r2=1780846&view=diff
==============================================================================
--- aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/model/Property.java
(original)
+++ aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/model/Property.java
Sun Jan 29 19:20:06 2017
@@ -32,20 +32,20 @@ import java.lang.reflect.Method;
 
 import static org.apache.aries.blueprint.plugin.model.AnnotationHelper.findName;
 
-public class Property implements Comparable<Property>, XmlWriter {
+class Property implements Comparable<Property>, XmlWriter {
     public final String name;
     public final String ref;
     public final String value;
-    public final boolean isField;
+    final boolean isField;
 
-    public Property(String name, String ref, String value, boolean isField) {
+    private Property(String name, String ref, String value, boolean isField) {
         this.name = name;
         this.ref = ref;
         this.value = value;
         this.isField = isField;
     }
 
-    public static Property create(BlueprintRegister blueprintRegister, Field field) {
+    static Property create(BlueprintRegister blueprintRegister, Field field) {
         if (needsInject(field)) {
             String value = AnnotationHelper.findValue(field.getAnnotations());
             if (value != null) {
@@ -74,7 +74,7 @@ public class Property implements Compara
         }
     }
 
-    public static Property create(BlueprintRegister blueprintRegister, Method method) {
+    static Property create(BlueprintRegister blueprintRegister, Method method) {
         String propertyName = resolveProperty(method);
         if (propertyName == null) {
             return null;

Modified: aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/main/resources/META-INF/services/org.apache.aries.blueprint.plugin.spi.ContextInitializationHandler
URL: http://svn.apache.org/viewvc/aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/main/resources/META-INF/services/org.apache.aries.blueprint.plugin.spi.ContextInitializationHandler?rev=1780846&r1=1780845&r2=1780846&view=diff
==============================================================================
--- aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/main/resources/META-INF/services/org.apache.aries.blueprint.plugin.spi.ContextInitializationHandler
(original)
+++ aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/main/resources/META-INF/services/org.apache.aries.blueprint.plugin.spi.ContextInitializationHandler
Sun Jan 29 19:20:06 2017
@@ -15,4 +15,4 @@
 # limitations under the License.
 #
 
-org.apache.aries.blueprint.plugin.model.BlueprintInitialization
\ No newline at end of file
+org.apache.aries.blueprint.plugin.handlers.blueprint.BlueprintInitialization
\ No newline at end of file

Copied: aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/test/java/org/apache/aries/blueprint/plugin/BlueprintFileWriterTest.java
(from r1780845, aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/test/java/org/apache/aries/blueprint/plugin/BlueprintWriterTest.java)
URL: http://svn.apache.org/viewvc/aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/test/java/org/apache/aries/blueprint/plugin/BlueprintFileWriterTest.java?p2=aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/test/java/org/apache/aries/blueprint/plugin/BlueprintFileWriterTest.java&p1=aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/test/java/org/apache/aries/blueprint/plugin/BlueprintWriterTest.java&r1=1780845&r2=1780846&rev=1780846&view=diff
==============================================================================
--- aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/test/java/org/apache/aries/blueprint/plugin/BlueprintWriterTest.java
(original)
+++ aries/trunk/blueprint/plugin/blueprint-maven-plugin/src/test/java/org/apache/aries/blueprint/plugin/BlueprintFileWriterTest.java
Sun Jan 29 19:20:06 2017
@@ -20,7 +20,6 @@ package org.apache.aries.blueprint.plugi
 
 import com.google.common.collect.Sets;
 import org.apache.aries.blueprint.plugin.model.Context;
-import org.apache.aries.blueprint.plugin.model.BlueprintWriter;
 import org.apache.aries.blueprint.plugin.model.TransactionalDef;
 import org.apache.aries.blueprint.plugin.test.MyBean1;
 import org.apache.aries.blueprint.plugin.test.MyProduced;
@@ -64,7 +63,7 @@ import static org.apache.aries.blueprint
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
 
-public class BlueprintWriterTest {
+public class BlueprintFileWriterTest {
 
     private static final String NS_JPA = "http://aries.apache.org/xmlns/jpa/v1.1.0";
     private static final String NS_TX1 = "http://aries.apache.org/xmlns/transactions/v1.2.0";
@@ -75,7 +74,7 @@ public class BlueprintWriterTest {
 
     @BeforeClass
     public static void setUp() throws Exception {
-        ClassFinder classFinder = new ClassFinder(BlueprintWriterTest.class.getClassLoader());
+        ClassFinder classFinder = new ClassFinder(BlueprintFileWriterTest.class.getClassLoader());
         Set<Class<?>> beanClasses = findClasses(classFinder, Arrays.asList(
                 MyBean1.class.getPackage().getName(),
                 ReferenceListenerToProduceWithoutAnnotation.class.getPackage().getName()
@@ -88,7 +87,7 @@ public class BlueprintWriterTest {
         BlueprintConfigurationImpl blueprintConfiguration = new BlueprintConfigurationImpl(namespaces,
null, customParameters);
         Context context = new Context(blueprintConfiguration, beanClasses);
         ByteArrayOutputStream os = new ByteArrayOutputStream();
-        new BlueprintWriter(os, blueprintConfiguration).generate(context);
+        new BlueprintFileWriter(os).generate(context);
         System.out.println(os.toString("UTF-8"));
 
         xmlAsBytes = os.toByteArray();
@@ -615,20 +614,20 @@ public class BlueprintWriterTest {
         Document document = readToDocument(xmlAsBytes, true);
 
         Source[] schemas = new StreamSource[]{
-                new StreamSource(BlueprintWriterTest.class.getResourceAsStream("/schema/example.xsd")),
-                new StreamSource(BlueprintWriterTest.class.getResourceAsStream("/schema/org/apache/aries/blueprint/blueprint.xsd")),
-                new StreamSource(BlueprintWriterTest.class.getResourceAsStream("/schema/org/apache/aries/blueprint/ext/impl/blueprint-ext.xsd")),
-                new StreamSource(BlueprintWriterTest.class.getResourceAsStream("/schema/org/apache/aries/blueprint/ext/impl/blueprint-ext-1.1.xsd")),
-                new StreamSource(BlueprintWriterTest.class.getResourceAsStream("/schema/org/apache/aries/blueprint/ext/impl/blueprint-ext-1.2.xsd")),
-                new StreamSource(BlueprintWriterTest.class.getResourceAsStream("/schema/org/apache/aries/blueprint/ext/impl/blueprint-ext-1.3.xsd")),
-                new StreamSource(BlueprintWriterTest.class.getResourceAsStream("/schema/org/apache/aries/blueprint/ext/impl/blueprint-ext-1.4.xsd")),
-                new StreamSource(BlueprintWriterTest.class.getResourceAsStream("/schema/org/apache/aries/blueprint/ext/impl/blueprint-ext-1.5.xsd")),
-                new StreamSource(BlueprintWriterTest.class.getResourceAsStream("/schema/org/apache/aries/transaction/parsing/transactionv12.xsd")),
-                new StreamSource(BlueprintWriterTest.class.getResourceAsStream("/schema/org/apache/aries/jpa/blueprint/namespace/jpa_110.xsd")),
-                new StreamSource(BlueprintWriterTest.class.getResourceAsStream("/schema/org/apache/aries/blueprint/compendium/cm/blueprint-cm-1.0.0.xsd")),
-                new StreamSource(BlueprintWriterTest.class.getResourceAsStream("/schema/org/apache/aries/blueprint/compendium/cm/blueprint-cm-1.1.0.xsd")),
-                new StreamSource(BlueprintWriterTest.class.getResourceAsStream("/schema/org/apache/aries/blueprint/compendium/cm/blueprint-cm-1.3.0.xsd")),
-                new StreamSource(BlueprintWriterTest.class.getResourceAsStream("/schema/org/apache/aries/blueprint/compendium/cm/blueprint-cm-1.2.0.xsd"))
+                new StreamSource(BlueprintFileWriterTest.class.getResourceAsStream("/schema/example.xsd")),
+                new StreamSource(BlueprintFileWriterTest.class.getResourceAsStream("/schema/org/apache/aries/blueprint/blueprint.xsd")),
+                new StreamSource(BlueprintFileWriterTest.class.getResourceAsStream("/schema/org/apache/aries/blueprint/ext/impl/blueprint-ext.xsd")),
+                new StreamSource(BlueprintFileWriterTest.class.getResourceAsStream("/schema/org/apache/aries/blueprint/ext/impl/blueprint-ext-1.1.xsd")),
+                new StreamSource(BlueprintFileWriterTest.class.getResourceAsStream("/schema/org/apache/aries/blueprint/ext/impl/blueprint-ext-1.2.xsd")),
+                new StreamSource(BlueprintFileWriterTest.class.getResourceAsStream("/schema/org/apache/aries/blueprint/ext/impl/blueprint-ext-1.3.xsd")),
+                new StreamSource(BlueprintFileWriterTest.class.getResourceAsStream("/schema/org/apache/aries/blueprint/ext/impl/blueprint-ext-1.4.xsd")),
+                new StreamSource(BlueprintFileWriterTest.class.getResourceAsStream("/schema/org/apache/aries/blueprint/ext/impl/blueprint-ext-1.5.xsd")),
+                new StreamSource(BlueprintFileWriterTest.class.getResourceAsStream("/schema/org/apache/aries/transaction/parsing/transactionv12.xsd")),
+                new StreamSource(BlueprintFileWriterTest.class.getResourceAsStream("/schema/org/apache/aries/jpa/blueprint/namespace/jpa_110.xsd")),
+                new StreamSource(BlueprintFileWriterTest.class.getResourceAsStream("/schema/org/apache/aries/blueprint/compendium/cm/blueprint-cm-1.0.0.xsd")),
+                new StreamSource(BlueprintFileWriterTest.class.getResourceAsStream("/schema/org/apache/aries/blueprint/compendium/cm/blueprint-cm-1.1.0.xsd")),
+                new StreamSource(BlueprintFileWriterTest.class.getResourceAsStream("/schema/org/apache/aries/blueprint/compendium/cm/blueprint-cm-1.3.0.xsd")),
+                new StreamSource(BlueprintFileWriterTest.class.getResourceAsStream("/schema/org/apache/aries/blueprint/compendium/cm/blueprint-cm-1.2.0.xsd"))
         };
 
         Source xmlFile = new DOMSource(document);



Mime
View raw message