aries-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From alien11...@apache.org
Subject svn commit: r1758278 - in /aries/trunk/blueprint/blueprint-maven-plugin/src: main/java/org/apache/aries/blueprint/plugin/ main/java/org/apache/aries/blueprint/plugin/javax/ main/java/org/apache/aries/blueprint/plugin/model/ main/java/org/apache/aries/b...
Date Mon, 29 Aug 2016 18:14:57 GMT
Author: alien11689
Date: Mon Aug 29 18:14:56 2016
New Revision: 1758278

URL: http://svn.apache.org/viewvc?rev=1758278&view=rev
Log:
[ARIES-1602] Refactor @Transactional to Bean and Method annotation handlers

Added:
    aries/trunk/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/BlueprintConfigurationImpl.java
    aries/trunk/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/spi/Activation.java
      - copied, changed from r1757990, aries/trunk/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/Activation.java
    aries/trunk/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/spi/BlueprintConfiguration.java
    aries/trunk/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/spi/XmlWriter.java
      - copied, changed from r1758211, aries/trunk/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/spi/BlueprintWriter.java
    aries/trunk/blueprint/blueprint-maven-plugin/src/test/java/org/apache/aries/blueprint/plugin/model/TransactionalDef.java
Removed:
    aries/trunk/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/Activation.java
    aries/trunk/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/model/AbstractTransactionalFactory.java
    aries/trunk/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/model/ExtensionTransactionFactory.java
    aries/trunk/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/model/TransactionalDef.java
    aries/trunk/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/spi/BlueprintWriter.java
    aries/trunk/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/spi/TransactionalFactory.java
    aries/trunk/blueprint/blueprint-maven-plugin/src/main/resources/META-INF/services/org.apache.aries.blueprint.plugin.spi.TransactionalFactory
Modified:
    aries/trunk/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/Extensions.java
    aries/trunk/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/GenerateMojo.java
    aries/trunk/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/Generator.java
    aries/trunk/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/javax/JavaxTransactionFactory.java
    aries/trunk/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/javax/PostConstructHandler.java
    aries/trunk/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/javax/PreDestroyHandler.java
    aries/trunk/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/model/Bean.java
    aries/trunk/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/model/BlueprinRegister.java
    aries/trunk/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/model/Context.java
    aries/trunk/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/model/ProducedBean.java
    aries/trunk/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/pax/OsgiServiceHandler.java
    aries/trunk/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/pax/OsgiServiceProviderHandler.java
    aries/trunk/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/spi/BeanEnricher.java
    aries/trunk/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/spi/ContextEnricher.java
    aries/trunk/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/spi/MethodAnnotationHandler.java
    aries/trunk/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/spring/SpringTransactionalFactory.java
    aries/trunk/blueprint/blueprint-maven-plugin/src/main/resources/META-INF/services/org.apache.aries.blueprint.plugin.spi.BeanAnnotationHandler
    aries/trunk/blueprint/blueprint-maven-plugin/src/main/resources/META-INF/services/org.apache.aries.blueprint.plugin.spi.MethodAnnotationHandler
    aries/trunk/blueprint/blueprint-maven-plugin/src/test/java/org/apache/aries/blueprint/plugin/GeneratorTest.java
    aries/trunk/blueprint/blueprint-maven-plugin/src/test/java/org/apache/aries/blueprint/plugin/model/BeanTest.java
    aries/trunk/blueprint/blueprint-maven-plugin/src/test/java/org/apache/aries/blueprint/plugin/model/ContextTest.java

Added: aries/trunk/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/BlueprintConfigurationImpl.java
URL: http://svn.apache.org/viewvc/aries/trunk/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/BlueprintConfigurationImpl.java?rev=1758278&view=auto
==============================================================================
--- aries/trunk/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/BlueprintConfigurationImpl.java (added)
+++ aries/trunk/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/BlueprintConfigurationImpl.java Mon Aug 29 18:14:56 2016
@@ -0,0 +1,31 @@
+package org.apache.aries.blueprint.plugin;
+
+import org.apache.aries.blueprint.plugin.spi.Activation;
+import org.apache.aries.blueprint.plugin.spi.BlueprintConfiguration;
+
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.Set;
+
+import static org.apache.aries.blueprint.plugin.Generator.NS_JPA2;
+import static org.apache.aries.blueprint.plugin.Generator.NS_TX2;
+
+public class BlueprintConfigurationImpl implements BlueprintConfiguration {
+    private final Set<String> namespaces;
+    private final Activation defaultActivation;
+
+    public BlueprintConfigurationImpl(Set<String> namespaces, Activation defaultActivation) {
+        this.namespaces = namespaces != null ? namespaces : new HashSet<>(Arrays.asList(NS_TX2, NS_JPA2));
+        this.defaultActivation = defaultActivation;
+    }
+
+    @Override
+    public Set<String> getNamespaces() {
+        return namespaces;
+    }
+
+    @Override
+    public Activation getDefaultActivation() {
+        return defaultActivation;
+    }
+}

Modified: aries/trunk/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/Extensions.java
URL: http://svn.apache.org/viewvc/aries/trunk/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/Extensions.java?rev=1758278&r1=1758277&r2=1758278&view=diff
==============================================================================
--- aries/trunk/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/Extensions.java (original)
+++ aries/trunk/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/Extensions.java Mon Aug 29 18:14:56 2016
@@ -18,8 +18,6 @@
  */
 package org.apache.aries.blueprint.plugin;
 
-import org.apache.aries.blueprint.plugin.model.AbstractTransactionalFactory;
-import org.apache.aries.blueprint.plugin.model.ExtensionTransactionFactory;
 import org.apache.aries.blueprint.plugin.spi.BeanFinder;
 import org.apache.aries.blueprint.plugin.spi.BeanAnnotationHandler;
 import org.apache.aries.blueprint.plugin.spi.CustomDependencyAnnotationHandler;
@@ -27,7 +25,6 @@ import org.apache.aries.blueprint.plugin
 import org.apache.aries.blueprint.plugin.spi.InjectLikeHandler;
 import org.apache.aries.blueprint.plugin.spi.MethodAnnotationHandler;
 import org.apache.aries.blueprint.plugin.spi.NamedLikeHandler;
-import org.apache.aries.blueprint.plugin.spi.TransactionalFactory;
 import org.apache.aries.blueprint.plugin.spi.ValueInjectionHandler;
 
 import java.lang.annotation.Annotation;
@@ -38,7 +35,6 @@ import java.util.ServiceLoader;
 public class Extensions {
     public static final List<Class<? extends Annotation>> beanMarkingAnnotationClasses = new ArrayList<>();
     public static final List<Class<? extends Annotation>> singletons = new ArrayList<>();
-    public static final List<AbstractTransactionalFactory> transactionalFactories = new ArrayList<>();
     public static final List<InjectLikeHandler<? extends Annotation>> beanInjectLikeHandlers = new ArrayList<>();
     public static final List<NamedLikeHandler> namedLikeHandlers = new ArrayList<>();
     public static final List<ValueInjectionHandler<? extends Annotation>> valueInjectionHandlers = new ArrayList<>();
@@ -55,10 +51,6 @@ public class Extensions {
             }
         }
 
-        for (TransactionalFactory transactionalFactory : ServiceLoader.load(TransactionalFactory.class)) {
-            transactionalFactories.add(new ExtensionTransactionFactory(transactionalFactory));
-        }
-
         for (InjectLikeHandler<? extends Annotation> injectLikeHandler : ServiceLoader.load(InjectLikeHandler.class)) {
             beanInjectLikeHandlers.add(injectLikeHandler);
         }

Modified: aries/trunk/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/GenerateMojo.java
URL: http://svn.apache.org/viewvc/aries/trunk/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/GenerateMojo.java?rev=1758278&r1=1758277&r2=1758278&view=diff
==============================================================================
--- aries/trunk/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/GenerateMojo.java (original)
+++ aries/trunk/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/GenerateMojo.java Mon Aug 29 18:14:56 2016
@@ -19,6 +19,8 @@
 package org.apache.aries.blueprint.plugin;
 
 import org.apache.aries.blueprint.plugin.model.Context;
+import org.apache.aries.blueprint.plugin.spi.Activation;
+import org.apache.aries.blueprint.plugin.spi.BlueprintConfiguration;
 import org.apache.maven.artifact.Artifact;
 import org.apache.maven.model.Resource;
 import org.apache.maven.plugin.AbstractMojo;
@@ -99,17 +101,20 @@ public class GenerateMojo extends Abstra
             ClassFinder finder = createProjectScopeFinder();
 
             Set<Class<?>> classes = FilteredClassFinder.findClasses(finder, scanPaths);
-            Context context = new Context(classes);
+
+            BlueprintConfiguration blueprintConfiguration = new BlueprintConfigurationImpl(namespaces, defaultActivation);
+
+            Context context = new Context(blueprintConfiguration, classes);
             context.resolve();
             if (context.getBeans().size() > 0) {
-                writeBlueprint(context);
+                writeBlueprint(context, blueprintConfiguration);
             }
         } catch (Exception e) {
             throw new MojoExecutionException("Error building commands help", e);
         }
     }
 
-    private void writeBlueprint(Context context) throws Exception {
+    private void writeBlueprint(Context context, BlueprintConfiguration blueprintConfiguration) throws Exception {
         String buildDir = project.getBuild().getDirectory();
         String generatedBaseDir = buildDir + "/generated-sources/blueprint";
         Resource resource = new Resource();
@@ -122,7 +127,7 @@ public class GenerateMojo extends Abstra
         System.out.println("Generating blueprint to " + file);
 
         OutputStream fos = buildContext.newFileOutputStream(file);
-        new Generator(context, fos, namespaces, defaultActivation).generate();
+        new Generator(context, fos, blueprintConfiguration).generate();
         fos.close();
     }
 

Modified: aries/trunk/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/Generator.java
URL: http://svn.apache.org/viewvc/aries/trunk/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/Generator.java?rev=1758278&r1=1758277&r2=1758278&view=diff
==============================================================================
--- aries/trunk/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/Generator.java (original)
+++ aries/trunk/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/Generator.java Mon Aug 29 18:14:56 2016
@@ -25,8 +25,8 @@ import org.apache.aries.blueprint.plugin
 import org.apache.aries.blueprint.plugin.model.ProducedBean;
 import org.apache.aries.blueprint.plugin.model.Property;
 import org.apache.aries.blueprint.plugin.model.PropertyWriter;
-import org.apache.aries.blueprint.plugin.model.TransactionalDef;
-import org.apache.aries.blueprint.plugin.spi.BlueprintWriter;
+import org.apache.aries.blueprint.plugin.spi.BlueprintConfiguration;
+import org.apache.aries.blueprint.plugin.spi.XmlWriter;
 
 import javax.persistence.PersistenceContext;
 import javax.persistence.PersistenceUnit;
@@ -35,11 +35,8 @@ import javax.xml.stream.XMLStreamExcepti
 import javax.xml.stream.XMLStreamWriter;
 import java.io.OutputStream;
 import java.lang.reflect.Field;
-import java.util.Arrays;
-import java.util.HashSet;
 import java.util.List;
 import java.util.Map;
-import java.util.Set;
 
 public class Generator implements PropertyWriter, ArgumentWriter {
     private static final String NS_BLUEPRINT = "http://www.osgi.org/xmlns/blueprint/v1.0.0";
@@ -50,14 +47,12 @@ public class Generator implements Proper
     public static final String NS_TX2 = "http://aries.apache.org/xmlns/transactions/v2.0.0";
 
     private final Context context;
+    private final BlueprintConfiguration blueprintConfiguration;
     private final XMLStreamWriter writer;
-    private final Set<String> namespaces;
-    private final Activation defaultActivation;
 
-    public Generator(Context context, OutputStream os, Set<String> namespaces, Activation defaultActivation) throws XMLStreamException {
+    public Generator(Context context, OutputStream os, BlueprintConfiguration blueprintConfiguration) throws XMLStreamException {
         this.context = context;
-        this.namespaces = namespaces != null ? namespaces : new HashSet<>(Arrays.asList(NS_TX2, NS_JPA2));
-        this.defaultActivation = defaultActivation;
+        this.blueprintConfiguration = blueprintConfiguration;
         XMLOutputFactory factory = XMLOutputFactory.newInstance();
         writer = factory.createXMLStreamWriter(os);
     }
@@ -69,18 +64,10 @@ public class Generator implements Proper
             writeBlueprint();
             writer.writeCharacters("\n");
 
-            if (namespaces.contains(NS_JPA2) && isJpaUsed()) {
+            if (blueprintConfiguration.getNamespaces().contains(NS_JPA2) && isJpaUsed()) {
                 writer.writeEmptyElement(NS_JPA2, "enable");
                 writer.writeCharacters("\n");
             }
-            if (namespaces.contains(NS_TX) && isJtaUsed()) {
-                writer.writeEmptyElement(NS_TX, "enable-annotations");
-                writer.writeCharacters("\n");
-            }
-            if (namespaces.contains(NS_TX2) && isJtaUsed()) {
-                writer.writeEmptyElement(NS_TX2, "enable");
-                writer.writeCharacters("\n");
-            }
             for (Bean bean : context.getBeans()) {
                 writeBeanStart(bean);
                 bean.writeArguments(this);
@@ -89,7 +76,7 @@ public class Generator implements Proper
                 writer.writeCharacters("\n");
             }
 
-            for (BlueprintWriter bw : context.getBlueprintWriters().values()) {
+            for (XmlWriter bw : context.getBlueprintWriters().values()) {
                 bw.write(writer);
             }
 
@@ -113,25 +100,16 @@ public class Generator implements Proper
         return jpaUsed;
     }
 
-    private boolean isJtaUsed() {
-        for (Bean bean : context.getBeans()) {
-            if (!bean.transactionDefs.isEmpty()) {
-                return true;
-            }
-        }
-        return false;
-    }
-
     private void writeBlueprint() throws XMLStreamException {
         writer.writeStartElement("blueprint");
         writer.writeDefaultNamespace(NS_BLUEPRINT);
         writer.writeNamespace("ext", NS_EXT);
-        for (String namespace : namespaces) {
+        for (String namespace : blueprintConfiguration.getNamespaces()) {
             String prefix = getPrefixForNamesapace(namespace);
             writer.writeNamespace(prefix, namespace);
         }
-        if (defaultActivation != null) {
-            writer.writeAttribute("default-activation", defaultActivation.name().toLowerCase());
+        if (blueprintConfiguration.getDefaultActivation() != null) {
+            writer.writeAttribute("default-activation", blueprintConfiguration.getDefaultActivation().name().toLowerCase());
         }
     }
 
@@ -165,12 +143,10 @@ public class Generator implements Proper
         }
         writer.writeCharacters("\n");
 
-        if (namespaces.contains(NS_TX)) {
-            for (TransactionalDef transactionalDef : bean.transactionDefs) {
-                writeTransactional(transactionalDef);
-            }
+        for (XmlWriter xmlWriter : bean.beanContentWriters.values()) {
+            xmlWriter.write(writer);
         }
-        if (namespaces.contains(NS_JPA)) {
+        if (blueprintConfiguration.getNamespaces().contains(NS_JPA)) {
             writePersistenceFields(bean.persistenceFields);
         }
     }
@@ -180,18 +156,6 @@ public class Generator implements Proper
         writer.writeAttribute("factory-method", bean.factoryMethod);
     }
 
-    private void writeTransactional(TransactionalDef transactionDef)
-        throws XMLStreamException {
-        if (transactionDef != null) {
-            writer.writeCharacters("    ");
-            writer.writeEmptyElement("tx", "transaction", NS_TX);
-            writer.writeAttribute("method", transactionDef.getMethod());
-            writer.writeAttribute("value", transactionDef.getType());
-            writer.writeCharacters("\n");
-        }
-    }
-
-
     private void writePersistenceFields(List<Field> fields) throws XMLStreamException {
         for (Field field : fields) {
             writePersistenceField(field);

Modified: aries/trunk/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/javax/JavaxTransactionFactory.java
URL: http://svn.apache.org/viewvc/aries/trunk/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/javax/JavaxTransactionFactory.java?rev=1758278&r1=1758277&r2=1758278&view=diff
==============================================================================
--- aries/trunk/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/javax/JavaxTransactionFactory.java (original)
+++ aries/trunk/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/javax/JavaxTransactionFactory.java Mon Aug 29 18:14:56 2016
@@ -19,29 +19,92 @@
 package org.apache.aries.blueprint.plugin.javax;
 
 import com.google.common.base.CaseFormat;
-import org.apache.aries.blueprint.plugin.model.TransactionalDef;
-import org.apache.aries.blueprint.plugin.spi.TransactionalFactory;
+import org.apache.aries.blueprint.plugin.spi.BeanAnnotationHandler;
+import org.apache.aries.blueprint.plugin.spi.BeanEnricher;
+import org.apache.aries.blueprint.plugin.spi.ContextEnricher;
+import org.apache.aries.blueprint.plugin.spi.MethodAnnotationHandler;
+import org.apache.aries.blueprint.plugin.spi.XmlWriter;
 
 import javax.transaction.Transactional;
-import javax.transaction.Transactional.TxType;
-import java.util.HashMap;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamWriter;
+import java.lang.reflect.AnnotatedElement;
+import java.lang.reflect.Method;
+import java.util.List;
 
-public class JavaxTransactionFactory implements TransactionalFactory<Transactional> {
-    private static HashMap<TxType, String> txTypeNames;
-    
-    static {
-        txTypeNames = new HashMap<TxType, String>();
-        txTypeNames.put(TxType.REQUIRED, TransactionalDef.TYPE_REQUIRED);
-        txTypeNames.put(TxType.REQUIRES_NEW, TransactionalDef.TYPE_REQUIRES_NEW);
+public class JavaxTransactionFactory implements BeanAnnotationHandler<Transactional>, MethodAnnotationHandler<Transactional> {
+    private static final String NS_TX = "http://aries.apache.org/xmlns/transactions/v1.2.0";
+    private static final String NS_TX2 = "http://aries.apache.org/xmlns/transactions/v2.0.0";
+    private String getTransactionTypeName(Transactional transactional) {
+        return CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.UPPER_CAMEL, transactional.value().name());
     }
 
     @Override
-    public String getTransactionTypeName(Transactional transactional) {
-        return CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.UPPER_CAMEL, transactional.value().name());
+    public Class<Transactional> getAnnotation() {
+        return Transactional.class;
     }
 
     @Override
-    public Class<Transactional> getTransactionalClass() {
-        return Transactional.class;
+    public void handleMethodAnnotation(Class<?> clazz, List<Method> methods, ContextEnricher contextEnricher, BeanEnricher beanEnricher) {
+
+        if (contextEnricher.getBlueprintConfiguration().getNamespaces().contains(NS_TX)) {
+            enableAnnotations(contextEnricher);
+            for (final Method method : methods) {
+                final Transactional transactional = method.getAnnotation(Transactional.class);
+                final String transactionTypeName = getTransactionTypeName(transactional);
+                final String name = method.getName();
+                beanEnricher.addBeanContentWriter("javax.transactional.method/" + clazz.getName() + "/" + name + "/" + transactionTypeName, new XmlWriter() {
+                    @Override
+                    public void write(XMLStreamWriter writer) throws XMLStreamException {
+                        writer.writeEmptyElement(NS_TX, "transaction");
+                        writer.writeAttribute("method", name);
+                        writer.writeAttribute("value", transactionTypeName);
+                        writer.writeCharacters("\n");
+                    }
+                });
+            }
+        }
+        if (contextEnricher.getBlueprintConfiguration().getNamespaces().contains(NS_TX2)) {
+            enableTransactionsTx2(contextEnricher);
+        }
+    }
+
+    private void enableAnnotations(ContextEnricher contextEnricher) {
+        contextEnricher.addBlueprintContentWriter("transaction/ennable-annotation", new XmlWriter() {
+            @Override
+            public void write(XMLStreamWriter writer) throws XMLStreamException {
+                writer.writeEmptyElement(NS_TX, "enable-annotations");
+            }
+        });
+    }
+
+    @Override
+    public void handleBeanAnnotation(AnnotatedElement annotatedElement, String id, ContextEnricher contextEnricher, BeanEnricher beanEnricher) {
+        if (contextEnricher.getBlueprintConfiguration().getNamespaces().contains(NS_TX)) {
+            enableAnnotations(contextEnricher);
+            final Transactional transactional = annotatedElement.getAnnotation(Transactional.class);
+            final String transactionTypeName = getTransactionTypeName(transactional);
+            beanEnricher.addBeanContentWriter("javax.transactional.method/" + annotatedElement + "/*/" + transactionTypeName, new XmlWriter() {
+                @Override
+                public void write(XMLStreamWriter writer) throws XMLStreamException {
+                    writer.writeEmptyElement(NS_TX, "transaction");
+                    writer.writeAttribute("method", "*");
+                    writer.writeAttribute("value", transactionTypeName);
+                    writer.writeCharacters("\n");
+                }
+            });
+        }
+        if (contextEnricher.getBlueprintConfiguration().getNamespaces().contains(NS_TX2)) {
+            enableTransactionsTx2(contextEnricher);
+        }
+    }
+
+    private void enableTransactionsTx2(ContextEnricher contextEnricher) {
+        contextEnricher.addBlueprintContentWriter("transaction/ennable-annotation", new XmlWriter() {
+            @Override
+            public void write(XMLStreamWriter writer) throws XMLStreamException {
+                writer.writeEmptyElement(NS_TX2, "enable");
+            }
+        });
     }
 }

Modified: aries/trunk/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/javax/PostConstructHandler.java
URL: http://svn.apache.org/viewvc/aries/trunk/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/javax/PostConstructHandler.java?rev=1758278&r1=1758277&r2=1758278&view=diff
==============================================================================
--- aries/trunk/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/javax/PostConstructHandler.java (original)
+++ aries/trunk/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/javax/PostConstructHandler.java Mon Aug 29 18:14:56 2016
@@ -19,6 +19,7 @@
 package org.apache.aries.blueprint.plugin.javax;
 
 import org.apache.aries.blueprint.plugin.spi.BeanEnricher;
+import org.apache.aries.blueprint.plugin.spi.ContextEnricher;
 import org.apache.aries.blueprint.plugin.spi.MethodAnnotationHandler;
 
 import javax.annotation.PostConstruct;
@@ -32,7 +33,7 @@ public class PostConstructHandler implem
     }
 
     @Override
-    public void handleMethodAnnotation(Class<?> clazz, List<Method> methods, BeanEnricher beanEnricher) {
+    public void handleMethodAnnotation(Class<?> clazz, List<Method> methods, ContextEnricher contextEnricher, BeanEnricher beanEnricher) {
         if(methods.size() > 1){
             throw new IllegalArgumentException("There can be only one method annotated with @PostConstruct in bean");
         }

Modified: aries/trunk/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/javax/PreDestroyHandler.java
URL: http://svn.apache.org/viewvc/aries/trunk/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/javax/PreDestroyHandler.java?rev=1758278&r1=1758277&r2=1758278&view=diff
==============================================================================
--- aries/trunk/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/javax/PreDestroyHandler.java (original)
+++ aries/trunk/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/javax/PreDestroyHandler.java Mon Aug 29 18:14:56 2016
@@ -19,6 +19,7 @@
 package org.apache.aries.blueprint.plugin.javax;
 
 import org.apache.aries.blueprint.plugin.spi.BeanEnricher;
+import org.apache.aries.blueprint.plugin.spi.ContextEnricher;
 import org.apache.aries.blueprint.plugin.spi.MethodAnnotationHandler;
 
 import javax.annotation.PreDestroy;
@@ -32,7 +33,7 @@ public class PreDestroyHandler implement
     }
 
     @Override
-    public void handleMethodAnnotation(Class<?> clazz, List<Method> methods, BeanEnricher beanEnricher) {
+    public void handleMethodAnnotation(Class<?> clazz, List<Method> methods, ContextEnricher contextEnricher, BeanEnricher beanEnricher) {
         if(methods.size() > 1){
             throw new IllegalArgumentException("There can be only one method annotated with @PreDestroy in bean");
         }

Modified: aries/trunk/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/model/Bean.java
URL: http://svn.apache.org/viewvc/aries/trunk/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/model/Bean.java?rev=1758278&r1=1758277&r2=1758278&view=diff
==============================================================================
--- aries/trunk/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/model/Bean.java (original)
+++ aries/trunk/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/model/Bean.java Mon Aug 29 18:14:56 2016
@@ -19,14 +19,14 @@
 package org.apache.aries.blueprint.plugin.model;
 
 import org.apache.aries.blueprint.plugin.Extensions;
+import org.apache.aries.blueprint.plugin.spi.BeanAnnotationHandler;
 import org.apache.aries.blueprint.plugin.spi.BeanEnricher;
-import org.apache.aries.blueprint.plugin.spi.BlueprintWriter;
 import org.apache.aries.blueprint.plugin.spi.ContextEnricher;
-import org.apache.aries.blueprint.plugin.spi.BeanAnnotationHandler;
 import org.apache.aries.blueprint.plugin.spi.CustomDependencyAnnotationHandler;
 import org.apache.aries.blueprint.plugin.spi.InjectLikeHandler;
 import org.apache.aries.blueprint.plugin.spi.MethodAnnotationHandler;
 import org.apache.aries.blueprint.plugin.spi.NamedLikeHandler;
+import org.apache.aries.blueprint.plugin.spi.XmlWriter;
 
 import javax.persistence.PersistenceContext;
 import javax.persistence.PersistenceUnit;
@@ -46,22 +46,21 @@ import java.util.TreeSet;
 
 import static org.apache.aries.blueprint.plugin.model.AnnotationHelper.findValue;
 
-public class Bean extends BeanRef implements ContextEnricher, BeanEnricher {
+public class Bean extends BeanRef implements BeanEnricher {
     public SortedSet<Property> properties = new TreeSet<>();
     public List<Argument> constructorArguments = new ArrayList<>();
     public List<Field> persistenceFields;
-    public Set<TransactionalDef> transactionDefs = new HashSet<>();
     public boolean isPrototype;
     public final Map<String, String> attributes = new HashMap<>();
     public final Set<BeanRef> refs = new HashSet<>();
-    public final Map<String, BlueprintWriter> blueprintWriters = new HashMap<>();
+    public final Map<String, XmlWriter> beanContentWriters = new HashMap<>();
+    protected final ContextEnricher contextEnricher;
 
-    public Bean(Class<?> clazz) {
+    public Bean(Class<?> clazz, ContextEnricher contextEnricher) {
         super(clazz, BeanRef.getBeanName(clazz));
+        this.contextEnricher = contextEnricher;
         Introspector introspector = new Introspector(clazz);
 
-        interpretTransactionalMethods(clazz);
-
         this.isPrototype = isPrototype(clazz);
         this.persistenceFields = findPersistenceFields(introspector);
 
@@ -72,11 +71,17 @@ public class Bean extends BeanRef implem
         handleMethodsAnnotation(introspector);
     }
 
+    public void resolve(BlueprinRegister blueprinRegister) {
+        resolveArguments(blueprinRegister);
+        resolveFields(blueprinRegister);
+        resolveMethods(blueprinRegister);
+    }
+
     private void handleMethodsAnnotation(Introspector introspector) {
         for (MethodAnnotationHandler methodAnnotationHandler : Extensions.methodAnnotationHandlers) {
             List<Method> methods = introspector.methodsWith(methodAnnotationHandler.getAnnotation());
             if (methods.size() > 0) {
-                methodAnnotationHandler.handleMethodAnnotation(clazz, methods, this);
+                methodAnnotationHandler.handleMethodAnnotation(clazz, methods, contextEnricher, this);
             }
         }
     }
@@ -85,7 +90,7 @@ public class Bean extends BeanRef implem
         for (BeanAnnotationHandler beanAnnotationHandler : Extensions.BEAN_ANNOTATION_HANDLERs) {
             Object annotation = AnnotationHelper.findAnnotation(clazz.getAnnotations(), beanAnnotationHandler.getAnnotation());
             if (annotation != null) {
-                beanAnnotationHandler.handleBeanAnnotation(clazz, id, this, this);
+                beanAnnotationHandler.handleBeanAnnotation(clazz, id, contextEnricher, this);
             }
         }
     }
@@ -94,12 +99,6 @@ public class Bean extends BeanRef implem
         return introspector.fieldsWith(PersistenceContext.class, PersistenceUnit.class);
     }
 
-    private void interpretTransactionalMethods(Class<?> clazz) {
-        for (AbstractTransactionalFactory transactionalFactory : Extensions.transactionalFactories) {
-            transactionDefs.addAll(transactionalFactory.create(clazz));
-        }
-    }
-
     private boolean isPrototype(Class<?> clazz) {
         return !findSingleton(clazz);
     }
@@ -113,11 +112,6 @@ public class Bean extends BeanRef implem
         return false;
     }
 
-    public void resolve(BlueprinRegister matcher) {
-        resolveArguments(matcher);
-        resolveFields(matcher);
-        resolveMethods(matcher);
-    }
 
     private void resolveMethods(BlueprinRegister blueprinRegister) {
         for (Method method : new Introspector(clazz).methodsWith(AnnotationHelper.injectDependencyAnnotations)) {
@@ -233,17 +227,12 @@ public class Bean extends BeanRef implem
     }
 
     @Override
-    public void addBean(String id, Class<?> clazz) {
-        refs.add(new BeanRef(clazz, id));
-    }
-
-    @Override
-    public void addBlueprintWriter(String id, BlueprintWriter blueprintWriter) {
-        blueprintWriters.put(id, blueprintWriter);
+    public void addAttribute(String key, String value) {
+        attributes.put(key, value);
     }
 
     @Override
-    public void addAttribute(String key, String value) {
-        attributes.put(key, value);
+    public void addBeanContentWriter(String id, XmlWriter blueprintWriter) {
+        beanContentWriters.put(id, blueprintWriter);
     }
 }

Modified: aries/trunk/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/model/BlueprinRegister.java
URL: http://svn.apache.org/viewvc/aries/trunk/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/model/BlueprinRegister.java?rev=1758278&r1=1758277&r2=1758278&view=diff
==============================================================================
--- aries/trunk/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/model/BlueprinRegister.java (original)
+++ aries/trunk/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/model/BlueprinRegister.java Mon Aug 29 18:14:56 2016
@@ -20,6 +20,6 @@ package org.apache.aries.blueprint.plugi
 
 import org.apache.aries.blueprint.plugin.spi.ContextEnricher;
 
-public interface BlueprinRegister extends ContextEnricher{
+public interface BlueprinRegister extends ContextEnricher {
     BeanRef getMatching(BeanRef template);
 }

Modified: aries/trunk/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/model/Context.java
URL: http://svn.apache.org/viewvc/aries/trunk/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/model/Context.java?rev=1758278&r1=1758277&r2=1758278&view=diff
==============================================================================
--- aries/trunk/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/model/Context.java (original)
+++ aries/trunk/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/model/Context.java Mon Aug 29 18:14:56 2016
@@ -19,9 +19,10 @@
 package org.apache.aries.blueprint.plugin.model;
 
 import org.apache.aries.blueprint.plugin.Extensions;
-import org.apache.aries.blueprint.plugin.spi.BlueprintWriter;
+import org.apache.aries.blueprint.plugin.spi.BlueprintConfiguration;
 import org.apache.aries.blueprint.plugin.spi.ContextEnricher;
 import org.apache.aries.blueprint.plugin.spi.CustomFactoryMethodAnnotationHandler;
+import org.apache.aries.blueprint.plugin.spi.XmlWriter;
 import org.osgi.framework.Bundle;
 import org.osgi.framework.BundleContext;
 import org.osgi.service.blueprint.container.BlueprintContainer;
@@ -39,13 +40,15 @@ import java.util.TreeSet;
 public class Context implements BlueprinRegister, ContextEnricher {
 
     SortedSet<BeanRef> reg = new TreeSet<BeanRef>();
-    private final Map<String, BlueprintWriter> blueprintWriters = new HashMap<>();
+    private final Map<String, XmlWriter> blueprintWriters = new HashMap<>();
+    private final BlueprintConfiguration blueprintConfiguration;
 
-    public Context(Class<?>... beanClasses) {
-        this(Arrays.asList(beanClasses));
+    public Context(BlueprintConfiguration blueprintConfiguration, Class<?>... beanClasses) {
+        this(blueprintConfiguration, Arrays.asList(beanClasses));
     }
 
-    public Context(Collection<Class<?>> beanClasses) {
+    public Context(BlueprintConfiguration blueprintConfiguration, Collection<Class<?>> beanClasses) {
+        this.blueprintConfiguration = blueprintConfiguration;
         addBlueprintRefs();
         addBeans(beanClasses);
     }
@@ -64,10 +67,9 @@ public class Context implements Blueprin
     }
 
     private void addBean(Class<?> clazz) {
-        Bean bean = new Bean(clazz);
+        Bean bean = new Bean(clazz, this);
         reg.add(bean);
         reg.addAll(bean.refs);
-        blueprintWriters.putAll(bean.blueprintWriters);
         addProducedBeans(bean);
     }
 
@@ -79,9 +81,9 @@ public class Context implements Blueprin
                 Class<?> producedClass = method.getReturnType();
                 ProducedBean producedBean;
                 if (name != null) {
-                    producedBean = new ProducedBean(producedClass, name, factoryBean, method);
+                    producedBean = new ProducedBean(producedClass, name, factoryBean, method, this);
                 } else {
-                    producedBean = new ProducedBean(producedClass, factoryBean, method);
+                    producedBean = new ProducedBean(producedClass, factoryBean, method, this);
                 }
                 if (AnnotationHelper.findSingletons(method.getAnnotations())) {
                     producedBean.setSingleton();
@@ -121,7 +123,7 @@ public class Context implements Blueprin
         return beans;
     }
 
-    public Map<String, BlueprintWriter> getBlueprintWriters() {
+    public Map<String, XmlWriter> getBlueprintWriters() {
         return blueprintWriters;
     }
 
@@ -132,7 +134,12 @@ public class Context implements Blueprin
     }
 
     @Override
-    public void addBlueprintWriter(String id, BlueprintWriter blueprintWriter) {
+    public void addBlueprintContentWriter(String id, XmlWriter blueprintWriter) {
         blueprintWriters.put(id, blueprintWriter);
     }
+
+    @Override
+    public BlueprintConfiguration getBlueprintConfiguration() {
+        return blueprintConfiguration;
+    }
 }

Modified: aries/trunk/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/model/ProducedBean.java
URL: http://svn.apache.org/viewvc/aries/trunk/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/model/ProducedBean.java?rev=1758278&r1=1758277&r2=1758278&view=diff
==============================================================================
--- aries/trunk/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/model/ProducedBean.java (original)
+++ aries/trunk/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/model/ProducedBean.java Mon Aug 29 18:14:56 2016
@@ -21,6 +21,7 @@ package org.apache.aries.blueprint.plugi
 
 import org.apache.aries.blueprint.plugin.Extensions;
 import org.apache.aries.blueprint.plugin.spi.BeanAnnotationHandler;
+import org.apache.aries.blueprint.plugin.spi.ContextEnricher;
 
 import java.lang.reflect.Method;
 
@@ -29,12 +30,12 @@ public class ProducedBean extends Bean {
     public BeanRef factoryBean;
     private Method producingMethod;
 
-    public ProducedBean(Class<?> clazz, BeanRef factoryBean, Method factoryMethod) {
-        this(clazz, null, factoryBean, factoryMethod);
+    public ProducedBean(Class<?> clazz, BeanRef factoryBean, Method factoryMethod, ContextEnricher contextEnricher) {
+        this(clazz, null, factoryBean, factoryMethod, contextEnricher);
     }
 
-    public ProducedBean(Class<?> clazz, String id, BeanRef factoryBean, Method factoryMethod) {
-        super(clazz);
+    public ProducedBean(Class<?> clazz, String id, BeanRef factoryBean, Method factoryMethod, ContextEnricher contextEnricher) {
+        super(clazz, contextEnricher);
         if (id != null) {
             this.id = id;
         }
@@ -48,7 +49,7 @@ public class ProducedBean extends Bean {
         for (BeanAnnotationHandler beanAnnotationHandler : Extensions.BEAN_ANNOTATION_HANDLERs) {
             Object annotation = AnnotationHelper.findAnnotation(producingMethod.getAnnotations(), beanAnnotationHandler.getAnnotation());
             if (annotation != null) {
-                beanAnnotationHandler.handleBeanAnnotation(producingMethod, id, this, this);
+                beanAnnotationHandler.handleBeanAnnotation(producingMethod, id, contextEnricher, this);
             }
         }
     }

Modified: aries/trunk/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/pax/OsgiServiceHandler.java
URL: http://svn.apache.org/viewvc/aries/trunk/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/pax/OsgiServiceHandler.java?rev=1758278&r1=1758277&r2=1758278&view=diff
==============================================================================
--- aries/trunk/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/pax/OsgiServiceHandler.java (original)
+++ aries/trunk/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/pax/OsgiServiceHandler.java Mon Aug 29 18:14:56 2016
@@ -18,9 +18,9 @@
  */
 package org.apache.aries.blueprint.plugin.pax;
 
-import org.apache.aries.blueprint.plugin.spi.BlueprintWriter;
 import org.apache.aries.blueprint.plugin.spi.ContextEnricher;
 import org.apache.aries.blueprint.plugin.spi.CustomDependencyAnnotationHandler;
+import org.apache.aries.blueprint.plugin.spi.XmlWriter;
 import org.ops4j.pax.cdi.api.OsgiService;
 
 import javax.xml.stream.XMLStreamException;
@@ -42,7 +42,7 @@ public class OsgiServiceHandler implemen
         final Class<?> clazz = getClass(annotatedElement);
 
         contextEnricher.addBean(id, getClass(annotatedElement));
-        contextEnricher.addBlueprintWriter(id, new BlueprintWriter() {
+        contextEnricher.addBlueprintContentWriter("osgiService/" + clazz.getName() + "/" + id, new XmlWriter() {
             @Override
             public void write(XMLStreamWriter writer) throws XMLStreamException {
                 writer.writeEmptyElement("reference");
@@ -66,7 +66,7 @@ public class OsgiServiceHandler implemen
         final String id = name != null ? name : generateReferenceId(clazz, serviceFilter);
 
         contextEnricher.addBean(id, clazz);
-        contextEnricher.addBlueprintWriter(id, new BlueprintWriter() {
+        contextEnricher.addBlueprintContentWriter("osgiService/" + clazz.getName() + "/" + id, new XmlWriter() {
             @Override
             public void write(XMLStreamWriter writer) throws XMLStreamException {
                 writer.writeEmptyElement("reference");

Modified: aries/trunk/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/pax/OsgiServiceProviderHandler.java
URL: http://svn.apache.org/viewvc/aries/trunk/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/pax/OsgiServiceProviderHandler.java?rev=1758278&r1=1758277&r2=1758278&view=diff
==============================================================================
--- aries/trunk/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/pax/OsgiServiceProviderHandler.java (original)
+++ aries/trunk/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/pax/OsgiServiceProviderHandler.java Mon Aug 29 18:14:56 2016
@@ -21,7 +21,7 @@ package org.apache.aries.blueprint.plugi
 import com.google.common.collect.Iterables;
 import com.google.common.collect.Lists;
 import org.apache.aries.blueprint.plugin.spi.BeanEnricher;
-import org.apache.aries.blueprint.plugin.spi.BlueprintWriter;
+import org.apache.aries.blueprint.plugin.spi.XmlWriter;
 import org.apache.aries.blueprint.plugin.spi.ContextEnricher;
 import org.apache.aries.blueprint.plugin.spi.BeanAnnotationHandler;
 import org.apache.aries.blueprint.plugin.spi.CustomFactoryMethodAnnotationHandler;
@@ -60,7 +60,7 @@ public class OsgiServiceProviderHandler
 
         final Map<String, String> propertiesAsMap = extractProperties(properties);
 
-        contextEnricher.addBlueprintWriter("OsgiServiceProvider/" + annotatedElement + "/" + id, new BlueprintWriter() {
+        contextEnricher.addBlueprintContentWriter("OsgiServiceProvider/" + annotatedElement + "/" + id, new XmlWriter() {
             @Override
             public void write(XMLStreamWriter writer) throws XMLStreamException {
                 writeService(writer, propertiesAsMap, interfaceNames, id);

Copied: aries/trunk/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/spi/Activation.java (from r1757990, aries/trunk/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/Activation.java)
URL: http://svn.apache.org/viewvc/aries/trunk/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/spi/Activation.java?p2=aries/trunk/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/spi/Activation.java&p1=aries/trunk/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/Activation.java&r1=1757990&r2=1758278&rev=1758278&view=diff
==============================================================================
--- aries/trunk/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/Activation.java (original)
+++ aries/trunk/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/spi/Activation.java Mon Aug 29 18:14:56 2016
@@ -16,7 +16,7 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-package org.apache.aries.blueprint.plugin;
+package org.apache.aries.blueprint.plugin.spi;
 
 public enum Activation {
     EAGER,

Modified: aries/trunk/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/spi/BeanEnricher.java
URL: http://svn.apache.org/viewvc/aries/trunk/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/spi/BeanEnricher.java?rev=1758278&r1=1758277&r2=1758278&view=diff
==============================================================================
--- aries/trunk/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/spi/BeanEnricher.java (original)
+++ aries/trunk/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/spi/BeanEnricher.java Mon Aug 29 18:14:56 2016
@@ -20,4 +20,5 @@ package org.apache.aries.blueprint.plugi
 
 public interface BeanEnricher {
     void addAttribute(String key, String value);
+    void addBeanContentWriter(String id, XmlWriter blueprintWriter);
 }

Added: aries/trunk/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/spi/BlueprintConfiguration.java
URL: http://svn.apache.org/viewvc/aries/trunk/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/spi/BlueprintConfiguration.java?rev=1758278&view=auto
==============================================================================
--- aries/trunk/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/spi/BlueprintConfiguration.java (added)
+++ aries/trunk/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/spi/BlueprintConfiguration.java Mon Aug 29 18:14:56 2016
@@ -0,0 +1,8 @@
+package org.apache.aries.blueprint.plugin.spi;
+
+import java.util.Set;
+
+public interface BlueprintConfiguration {
+    Set<String> getNamespaces();
+    Activation getDefaultActivation();
+}

Modified: aries/trunk/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/spi/ContextEnricher.java
URL: http://svn.apache.org/viewvc/aries/trunk/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/spi/ContextEnricher.java?rev=1758278&r1=1758277&r2=1758278&view=diff
==============================================================================
--- aries/trunk/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/spi/ContextEnricher.java (original)
+++ aries/trunk/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/spi/ContextEnricher.java Mon Aug 29 18:14:56 2016
@@ -20,5 +20,6 @@ package org.apache.aries.blueprint.plugi
 
 public interface ContextEnricher {
     void addBean(String id, Class<?> clazz);
-    void addBlueprintWriter(String id, BlueprintWriter blueprintWriter);
+    void addBlueprintContentWriter(String id, XmlWriter blueprintWriter);
+    BlueprintConfiguration getBlueprintConfiguration();
 }

Modified: aries/trunk/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/spi/MethodAnnotationHandler.java
URL: http://svn.apache.org/viewvc/aries/trunk/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/spi/MethodAnnotationHandler.java?rev=1758278&r1=1758277&r2=1758278&view=diff
==============================================================================
--- aries/trunk/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/spi/MethodAnnotationHandler.java (original)
+++ aries/trunk/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/spi/MethodAnnotationHandler.java Mon Aug 29 18:14:56 2016
@@ -6,9 +6,9 @@
  * to you under the Apache License, Version 2.0 (the
  * "License"); you may not use this file except in compliance
  * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
  * Unless required by applicable law or agreed to in writing,
  * software distributed under the License is distributed on an
  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@@ -25,5 +25,5 @@ import java.util.List;
 public interface MethodAnnotationHandler<A extends Annotation> {
     Class<A> getAnnotation();
 
-    void handleMethodAnnotation(Class<?> clazz, List<Method> methods, BeanEnricher beanEnricher);
+    void handleMethodAnnotation(Class<?> clazz, List<Method> methods, ContextEnricher contextEnricher, BeanEnricher beanEnricher);
 }

Copied: aries/trunk/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/spi/XmlWriter.java (from r1758211, aries/trunk/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/spi/BlueprintWriter.java)
URL: http://svn.apache.org/viewvc/aries/trunk/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/spi/XmlWriter.java?p2=aries/trunk/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/spi/XmlWriter.java&p1=aries/trunk/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/spi/BlueprintWriter.java&r1=1758211&r2=1758278&rev=1758278&view=diff
==============================================================================
--- aries/trunk/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/spi/BlueprintWriter.java (original)
+++ aries/trunk/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/spi/XmlWriter.java Mon Aug 29 18:14:56 2016
@@ -3,6 +3,6 @@ package org.apache.aries.blueprint.plugi
 import javax.xml.stream.XMLStreamException;
 import javax.xml.stream.XMLStreamWriter;
 
-public interface BlueprintWriter {
+public interface XmlWriter {
     void write(XMLStreamWriter xmlStreamWriter) throws XMLStreamException;
 }

Modified: aries/trunk/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/spring/SpringTransactionalFactory.java
URL: http://svn.apache.org/viewvc/aries/trunk/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/spring/SpringTransactionalFactory.java?rev=1758278&r1=1758277&r2=1758278&view=diff
==============================================================================
--- aries/trunk/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/spring/SpringTransactionalFactory.java (original)
+++ aries/trunk/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/spring/SpringTransactionalFactory.java Mon Aug 29 18:14:56 2016
@@ -6,9 +6,9 @@
  * to you under the Apache License, Version 2.0 (the
  * "License"); you may not use this file except in compliance
  * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
  * Unless required by applicable law or agreed to in writing,
  * software distributed under the License is distributed on an
  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@@ -19,13 +19,25 @@
 package org.apache.aries.blueprint.plugin.spring;
 
 import com.google.common.base.CaseFormat;
-import org.apache.aries.blueprint.plugin.spi.TransactionalFactory;
+import org.apache.aries.blueprint.plugin.spi.BeanAnnotationHandler;
+import org.apache.aries.blueprint.plugin.spi.BeanEnricher;
+import org.apache.aries.blueprint.plugin.spi.ContextEnricher;
+import org.apache.aries.blueprint.plugin.spi.MethodAnnotationHandler;
+import org.apache.aries.blueprint.plugin.spi.XmlWriter;
 import org.springframework.transaction.annotation.Propagation;
 import org.springframework.transaction.annotation.Transactional;
 
-public class SpringTransactionalFactory implements TransactionalFactory<Transactional> {
-    @Override
-    public String getTransactionTypeName(Transactional transactional) {
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamWriter;
+import java.lang.reflect.AnnotatedElement;
+import java.lang.reflect.Method;
+import java.util.List;
+
+public class SpringTransactionalFactory implements BeanAnnotationHandler<Transactional>, MethodAnnotationHandler<Transactional> {
+    private static final String NS_TX = "http://aries.apache.org/xmlns/transactions/v1.2.0";
+    private static final String NS_TX2 = "http://aries.apache.org/xmlns/transactions/v2.0.0";
+
+    private String getTransactionTypeName(Transactional transactional) {
         Propagation propagation = transactional.propagation();
         if (propagation == Propagation.NESTED) {
             throw new UnsupportedOperationException("Nested transactions not supported");
@@ -34,7 +46,70 @@ public class SpringTransactionalFactory
     }
 
     @Override
-    public Class<Transactional> getTransactionalClass() {
+    public Class<Transactional> getAnnotation() {
         return Transactional.class;
     }
+
+    @Override
+    public void handleMethodAnnotation(Class<?> clazz, List<Method> methods, ContextEnricher contextEnricher, BeanEnricher beanEnricher) {
+        if (contextEnricher.getBlueprintConfiguration().getNamespaces().contains(NS_TX)) {
+            enableAnnotations(contextEnricher);
+            for (final Method method : methods) {
+                final Transactional transactional = method.getAnnotation(Transactional.class);
+                final String transactionTypeName = getTransactionTypeName(transactional);
+                final String name = method.getName();
+                beanEnricher.addBeanContentWriter("javax.transactional.method/" + clazz.getName() + "/" + name + "/" + transactionTypeName, new XmlWriter() {
+                    @Override
+                    public void write(XMLStreamWriter writer) throws XMLStreamException {
+                        writer.writeEmptyElement(NS_TX, "transaction");
+                        writer.writeAttribute("method", name);
+                        writer.writeAttribute("value", transactionTypeName);
+                        writer.writeCharacters("\n");
+                    }
+                });
+            }
+        }
+        if (contextEnricher.getBlueprintConfiguration().getNamespaces().contains(NS_TX2)) {
+            enableTransactionsTx2(contextEnricher);
+        }
+    }
+
+    private void enableAnnotations(ContextEnricher contextEnricher) {
+        contextEnricher.addBlueprintContentWriter("transaction/ennable-annotation", new XmlWriter() {
+            @Override
+            public void write(XMLStreamWriter writer) throws XMLStreamException {
+                writer.writeEmptyElement(NS_TX, "enable-annotations");
+            }
+        });
+    }
+
+    @Override
+    public void handleBeanAnnotation(AnnotatedElement annotatedElement, String id, ContextEnricher contextEnricher, BeanEnricher beanEnricher) {
+        if (contextEnricher.getBlueprintConfiguration().getNamespaces().contains(NS_TX)) {
+            enableAnnotations(contextEnricher);
+            final Transactional transactional = annotatedElement.getAnnotation(Transactional.class);
+            final String transactionTypeName = getTransactionTypeName(transactional);
+            beanEnricher.addBeanContentWriter("javax.transactional.method/" + annotatedElement + "/*/" + transactionTypeName, new XmlWriter() {
+                @Override
+                public void write(XMLStreamWriter writer) throws XMLStreamException {
+                    writer.writeEmptyElement(NS_TX, "transaction");
+                    writer.writeAttribute("method", "*");
+                    writer.writeAttribute("value", transactionTypeName);
+                    writer.writeCharacters("\n");
+                }
+            });
+        }
+        if (contextEnricher.getBlueprintConfiguration().getNamespaces().contains(NS_TX2)) {
+            enableTransactionsTx2(contextEnricher);
+        }
+    }
+
+    private void enableTransactionsTx2(ContextEnricher contextEnricher) {
+        contextEnricher.addBlueprintContentWriter("transaction/ennable-annotation", new XmlWriter() {
+            @Override
+            public void write(XMLStreamWriter writer) throws XMLStreamException {
+                writer.writeEmptyElement(NS_TX2, "enable");
+            }
+        });
+    }
 }

Modified: aries/trunk/blueprint/blueprint-maven-plugin/src/main/resources/META-INF/services/org.apache.aries.blueprint.plugin.spi.BeanAnnotationHandler
URL: http://svn.apache.org/viewvc/aries/trunk/blueprint/blueprint-maven-plugin/src/main/resources/META-INF/services/org.apache.aries.blueprint.plugin.spi.BeanAnnotationHandler?rev=1758278&r1=1758277&r2=1758278&view=diff
==============================================================================
--- aries/trunk/blueprint/blueprint-maven-plugin/src/main/resources/META-INF/services/org.apache.aries.blueprint.plugin.spi.BeanAnnotationHandler (original)
+++ aries/trunk/blueprint/blueprint-maven-plugin/src/main/resources/META-INF/services/org.apache.aries.blueprint.plugin.spi.BeanAnnotationHandler Mon Aug 29 18:14:56 2016
@@ -17,4 +17,6 @@
 
 org.apache.aries.blueprint.plugin.pax.OsgiServiceProviderHandler
 org.apache.aries.blueprint.plugin.spring.LazyAttributeResolver
-org.apache.aries.blueprint.plugin.spring.DependsOnAttributeResolver
\ No newline at end of file
+org.apache.aries.blueprint.plugin.spring.DependsOnAttributeResolver
+org.apache.aries.blueprint.plugin.spring.SpringTransactionalFactory
+org.apache.aries.blueprint.plugin.javax.JavaxTransactionFactory
\ No newline at end of file

Modified: aries/trunk/blueprint/blueprint-maven-plugin/src/main/resources/META-INF/services/org.apache.aries.blueprint.plugin.spi.MethodAnnotationHandler
URL: http://svn.apache.org/viewvc/aries/trunk/blueprint/blueprint-maven-plugin/src/main/resources/META-INF/services/org.apache.aries.blueprint.plugin.spi.MethodAnnotationHandler?rev=1758278&r1=1758277&r2=1758278&view=diff
==============================================================================
--- aries/trunk/blueprint/blueprint-maven-plugin/src/main/resources/META-INF/services/org.apache.aries.blueprint.plugin.spi.MethodAnnotationHandler (original)
+++ aries/trunk/blueprint/blueprint-maven-plugin/src/main/resources/META-INF/services/org.apache.aries.blueprint.plugin.spi.MethodAnnotationHandler Mon Aug 29 18:14:56 2016
@@ -16,4 +16,6 @@
 #
 
 org.apache.aries.blueprint.plugin.javax.PostConstructHandler
-org.apache.aries.blueprint.plugin.javax.PreDestroyHandler
\ No newline at end of file
+org.apache.aries.blueprint.plugin.javax.PreDestroyHandler
+org.apache.aries.blueprint.plugin.spring.SpringTransactionalFactory
+org.apache.aries.blueprint.plugin.javax.JavaxTransactionFactory
\ No newline at end of file

Modified: aries/trunk/blueprint/blueprint-maven-plugin/src/test/java/org/apache/aries/blueprint/plugin/GeneratorTest.java
URL: http://svn.apache.org/viewvc/aries/trunk/blueprint/blueprint-maven-plugin/src/test/java/org/apache/aries/blueprint/plugin/GeneratorTest.java?rev=1758278&r1=1758277&r2=1758278&view=diff
==============================================================================
--- aries/trunk/blueprint/blueprint-maven-plugin/src/test/java/org/apache/aries/blueprint/plugin/GeneratorTest.java (original)
+++ aries/trunk/blueprint/blueprint-maven-plugin/src/test/java/org/apache/aries/blueprint/plugin/GeneratorTest.java Mon Aug 29 18:14:56 2016
@@ -62,11 +62,12 @@ public class GeneratorTest {
         ClassFinder classFinder = new ClassFinder(GeneratorTest.class.getClassLoader());
         String packageName = MyBean1.class.getPackage().getName();
         Set<Class<?>> beanClasses = findClasses(classFinder, Collections.singletonList(packageName));
-        Context context = new Context(beanClasses);
+        Set<String> namespaces = new HashSet<String>(Arrays.asList(Generator.NS_JPA, Generator.NS_TX));
+        BlueprintConfigurationImpl blueprintConfiguration = new BlueprintConfigurationImpl(namespaces, null);
+        Context context = new Context(blueprintConfiguration, beanClasses);
         context.resolve();
         ByteArrayOutputStream os = new ByteArrayOutputStream();
-        Set<String> namespaces = new HashSet<String>(Arrays.asList(Generator.NS_JPA, Generator.NS_TX));
-        new Generator(context, os, namespaces, null).generate();
+        new Generator(context, os, blueprintConfiguration).generate();
         System.out.println(os.toString("UTF-8"));
 
         document = readToDocument(os);

Modified: aries/trunk/blueprint/blueprint-maven-plugin/src/test/java/org/apache/aries/blueprint/plugin/model/BeanTest.java
URL: http://svn.apache.org/viewvc/aries/trunk/blueprint/blueprint-maven-plugin/src/test/java/org/apache/aries/blueprint/plugin/model/BeanTest.java?rev=1758278&r1=1758277&r2=1758278&view=diff
==============================================================================
--- aries/trunk/blueprint/blueprint-maven-plugin/src/test/java/org/apache/aries/blueprint/plugin/model/BeanTest.java (original)
+++ aries/trunk/blueprint/blueprint-maven-plugin/src/test/java/org/apache/aries/blueprint/plugin/model/BeanTest.java Mon Aug 29 18:14:56 2016
@@ -19,6 +19,8 @@
 package org.apache.aries.blueprint.plugin.model;
 
 import com.google.common.collect.Sets;
+import org.apache.aries.blueprint.plugin.BlueprintConfigurationImpl;
+import org.apache.aries.blueprint.plugin.Generator;
 import org.apache.aries.blueprint.plugin.bad.BadBean1;
 import org.apache.aries.blueprint.plugin.bad.BadBean2;
 import org.apache.aries.blueprint.plugin.bad.BadBean3;
@@ -31,25 +33,29 @@ import org.apache.aries.blueprint.plugin
 import org.apache.aries.blueprint.plugin.test.MyBean4;
 import org.apache.aries.blueprint.plugin.test.MyBean5;
 import org.apache.aries.blueprint.plugin.test.ServiceAImpl1;
-import org.junit.Assert;
 import org.junit.Test;
 
 import javax.inject.Named;
+import java.util.Arrays;
+import java.util.HashSet;
 import java.util.Set;
 
+import static junit.framework.Assert.assertFalse;
 import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertTrue;
 
 public class BeanTest {
+    private final Set<String> namespaces = new HashSet<String>(Arrays.asList(Generator.NS_JPA, Generator.NS_TX));
+    private final BlueprintConfigurationImpl blueprintConfiguration = new BlueprintConfigurationImpl(namespaces, null);
+    private final Context context = new Context(blueprintConfiguration);
 
     @Test
     public void testParseMyBean1() {
-        Bean bean = new Bean(MyBean1.class);
-        bean.resolve(new Context());
+        Bean bean = new Bean(MyBean1.class, context);
+        bean.resolve(context);
         assertEquals(MyBean1.class, bean.clazz);
         assertEquals("myBean1", bean.id); // Name derived from class name
-        Assert.assertEquals(2, bean.persistenceFields.size());
+        assertEquals(2, bean.persistenceFields.size());
         assertEquals("em", bean.persistenceFields.get(0).getName());
         assertEquals("emf", bean.persistenceFields.get(1).getName());
         assertEquals(1, bean.properties.size());
@@ -59,19 +65,19 @@ public class BeanTest {
         assertEquals("serviceA", prop.ref);
 
         Set<TransactionalDef> expectedTxs = Sets.newHashSet(new TransactionalDef("*", "RequiresNew"),
-                new TransactionalDef("txNotSupported", "NotSupported"),
-                new TransactionalDef("txMandatory", "Mandatory"),
-                new TransactionalDef("txNever", "Never"),
-                new TransactionalDef("txRequired", "Required"),
-                new TransactionalDef("txOverridenWithRequiresNew", "RequiresNew"),
-                new TransactionalDef("txSupports", "Supports"));
-        assertEquals(expectedTxs, bean.transactionDefs);
+            new TransactionalDef("txNotSupported", "NotSupported"),
+            new TransactionalDef("txMandatory", "Mandatory"),
+            new TransactionalDef("txNever", "Never"),
+            new TransactionalDef("txRequired", "Required"),
+            new TransactionalDef("txOverridenWithRequiresNew", "RequiresNew"),
+            new TransactionalDef("txSupports", "Supports"));
+        assertEquals(expectedTxs, getTransactionalDefs(bean));
     }
 
     @Test
     public void testParseMyBean3() {
-        Bean bean = new Bean(MyBean3.class);
-        bean.resolve(new Context());
+        Bean bean = new Bean(MyBean3.class, context);
+        bean.resolve(context);
         assertEquals(MyBean3.class, bean.clazz);
         assertEquals("myBean3", bean.id); // Name derived from class name
         assertEquals("There should be no persistence fields", 0, bean.persistenceFields.size());
@@ -79,80 +85,93 @@ public class BeanTest {
         assertTrue(bean.isPrototype);
 
         Set<TransactionalDef> expectedTxs = Sets.newHashSet(new TransactionalDef("*", "RequiresNew"),
-                new TransactionalDef("txNotSupported", "NotSupported"),
-                new TransactionalDef("txMandatory", "Mandatory"),
-                new TransactionalDef("txNever", "Never"),
-                new TransactionalDef("txRequired", "Required"),
-                new TransactionalDef("txRequiresNew", "RequiresNew"),
-                new TransactionalDef("txSupports", "Supports"));
-        assertEquals(expectedTxs, bean.transactionDefs);
+            new TransactionalDef("txNotSupported", "NotSupported"),
+            new TransactionalDef("txMandatory", "Mandatory"),
+            new TransactionalDef("txNever", "Never"),
+            new TransactionalDef("txRequired", "Required"),
+            new TransactionalDef("txRequiresNew", "RequiresNew"),
+            new TransactionalDef("txSupports", "Supports"));
+        assertEquals(expectedTxs, getTransactionalDefs(bean));
     }
 
     @Test
     public void testParseNamedBean() {
-        Bean bean = new Bean(ServiceAImpl1.class);
-        bean.resolve(new Context());
+        Bean bean = new Bean(ServiceAImpl1.class, context);
+        bean.resolve(context);
         String definedName = ServiceAImpl1.class.getAnnotation(Named.class).value();
         assertEquals("my1", definedName);
         assertEquals("Name should be defined using @Named", definedName, bean.id);
         assertEquals("There should be no persistence fields", 0, bean.persistenceFields.size());
-        assertTrue("There should be no transaction definition", bean.transactionDefs.isEmpty());
+        assertTrue("There should be no transaction definition", getTransactionalDefs(bean).isEmpty());
         assertEquals("There should be no properties", 0, bean.properties.size());
         assertTrue(bean.isPrototype);
     }
 
     @Test
     public void testBlueprintBundleContext() {
-        Bean bean = new Bean(MyBean4.class);
-        bean.resolve(new Context());
+        Bean bean = new Bean(MyBean4.class, context);
+        bean.resolve(context);
         Property bcProp = bean.properties.iterator().next();
         assertEquals("bundleContext", bcProp.name);
         assertEquals("blueprintBundleContext", bcProp.ref);
         assertFalse(bean.isPrototype);
 
         Set<TransactionalDef> expectedTxs = Sets.newHashSet(new TransactionalDef("txWithoutClassAnnotation", "Supports"));
-        assertEquals(expectedTxs, bean.transactionDefs);
+        assertEquals(expectedTxs, getTransactionalDefs(bean));
     }
 
+    private Set<TransactionalDef> getTransactionalDefs(Bean bean) {
+        Set<String> beanWriters = bean.beanContentWriters.keySet();
+        Set<TransactionalDef> transactionalDefs = new HashSet<>();
+        for (String beanWriter : beanWriters) {
+            if (beanWriter.startsWith("javax.transactional.method/")) {
+                String[] splitId = beanWriter.split("/");
+                transactionalDefs.add(new TransactionalDef(splitId[2], splitId[3]));
+            }
+        }
+        return transactionalDefs;
+    }
+
+
     @Test(expected = IllegalArgumentException.class)
     public void testMultipleInitMethods() {
-        new Bean(BadBean1.class);
+        new Bean(BadBean1.class, context);
     }
 
     @Test(expected = IllegalArgumentException.class)
     public void testMultipleDestroyMethods() {
-        new Bean(BadBean2.class);
+        new Bean(BadBean2.class, context);
     }
 
     @Test(expected = UnsupportedOperationException.class)
     public void testSpringNestedTransactionNotSupported() {
-        new Bean(BadBean3.class);
+        new Bean(BadBean3.class, context);
     }
 
     @Test(expected = UnsupportedOperationException.class)
     public void testBadFieldBean1() {
-        new Context(BadFieldBean1.class).resolve();
+        new Context(blueprintConfiguration, BadFieldBean1.class).resolve();
     }
 
     @Test(expected = UnsupportedOperationException.class)
     public void testBadFieldBean2() {
-        new Context(BadFieldBean2.class).resolve();
+        new Context(blueprintConfiguration, BadFieldBean2.class).resolve();
     }
 
     @Test(expected = UnsupportedOperationException.class)
     public void testBadFieldBean3() {
-        new Context(BadFieldBean3.class).resolve();
+        new Context(blueprintConfiguration, BadFieldBean3.class).resolve();
     }
 
     @Test
     public void testFieldBean4() {
-        new Context(FieldBean4.class).resolve();
+        new Context(blueprintConfiguration, FieldBean4.class).resolve();
     }
 
     @Test
     public void testParseBeanWithConstructorInject() {
-        Bean bean = new Bean(MyBean5.class);
-        bean.resolve(new Context());
+        Bean bean = new Bean(MyBean5.class, context);
+        bean.resolve(context);
         assertEquals(MyBean5.class, bean.clazz);
         assertEquals("myBean5", bean.id); // Name derived from class name
         assertTrue("There should be no persistenceUnit", bean.persistenceFields.isEmpty());
@@ -167,5 +186,4 @@ public class BeanTest {
         assertEquals("serviceA", bean.constructorArguments.get(6).getRef());
         assertEquals("produced2", bean.constructorArguments.get(7).getRef());
     }
-
 }

Modified: aries/trunk/blueprint/blueprint-maven-plugin/src/test/java/org/apache/aries/blueprint/plugin/model/ContextTest.java
URL: http://svn.apache.org/viewvc/aries/trunk/blueprint/blueprint-maven-plugin/src/test/java/org/apache/aries/blueprint/plugin/model/ContextTest.java?rev=1758278&r1=1758277&r2=1758278&view=diff
==============================================================================
--- aries/trunk/blueprint/blueprint-maven-plugin/src/test/java/org/apache/aries/blueprint/plugin/model/ContextTest.java (original)
+++ aries/trunk/blueprint/blueprint-maven-plugin/src/test/java/org/apache/aries/blueprint/plugin/model/ContextTest.java Mon Aug 29 18:14:56 2016
@@ -6,9 +6,9 @@
  * to you under the Apache License, Version 2.0 (the
  * "License"); you may not use this file except in compliance
  * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
  * Unless required by applicable law or agreed to in writing,
  * software distributed under the License is distributed on an
  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@@ -18,8 +18,12 @@
  */
 package org.apache.aries.blueprint.plugin.model;
 
+import org.apache.aries.blueprint.plugin.BlueprintConfigurationImpl;
+import org.apache.aries.blueprint.plugin.Generator;
+import org.apache.aries.blueprint.plugin.test.MyBean3;
 import org.apache.aries.blueprint.plugin.test.MyFactoryBean;
 import org.apache.aries.blueprint.plugin.test.MyProduced;
+import org.apache.aries.blueprint.plugin.test.ServiceReferences;
 import org.junit.Assert;
 import org.junit.Test;
 import org.osgi.framework.Bundle;
@@ -27,35 +31,44 @@ import org.osgi.framework.BundleContext;
 import org.osgi.service.blueprint.container.BlueprintContainer;
 import org.osgi.service.blueprint.container.Converter;
 
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.Set;
+
 import static org.junit.Assert.assertEquals;
 
 public class ContextTest {
+    private final Set<String> namespaces = new HashSet<String>(Arrays.asList(Generator.NS_JPA, Generator.NS_TX));
+    private final BlueprintConfigurationImpl blueprintConfiguration = new BlueprintConfigurationImpl(namespaces, null);
 
-//    @Test
-//    public void testLists()  {
-//        Context context = new Context(MyBean3.class);
-//        Assert.assertEquals(1, context.getBeans().size());
-//        Assert.assertEquals(0, context.getServiceRefs().size());
-//    }
-//
-//    @Test
-//    public void testLists2()  {
-//        Context context = new Context(ServiceReferences.class);
-//        Assert.assertEquals(1, context.getBeans().size());
-//        Assert.assertEquals(3, context.getServiceRefs().size());
-//    }
-
-//    @Test
-//    public void testMatching() throws NoSuchFieldException, SecurityException  {
-//        Context context = new Context(ServiceReferences.class);
-//        BeanRef matching = context.getMatching(new BeanRef(ServiceReferencesParent.class.getDeclaredField("serviceB")));
-//        Assert.assertEquals(OsgiServiceRef.class, matching.getClass());
-//        Assert.assertEquals(ServiceB.class, matching.clazz);
-//        Assert.assertEquals("serviceB-typeB1", matching.id);
-//    }
+    @Test
+    public void testLists() {
+        Context context = new Context(blueprintConfiguration, MyBean3.class);
+        Assert.assertEquals(1, context.getBeans().size());
+        Assert.assertEquals(0, getOsgiServices(context).size());
+    }
+
+    @Test
+    public void testLists2() {
+        Context context = new Context(blueprintConfiguration, ServiceReferences.class);
+        context.resolve();
+        Assert.assertEquals(1, context.getBeans().size());
+        Assert.assertEquals(3, getOsgiServices(context).size());
+    }
+
+    private Set<String> getOsgiServices(Context context) {
+        Set<String> blueprintWritersKeys = context.getBlueprintWriters().keySet();
+        Set<String> osgiServices = new HashSet<>();
+        for (String blueprintWritersKey : blueprintWritersKeys) {
+            if (blueprintWritersKey.startsWith("osgiService/")) {
+                osgiServices.add(blueprintWritersKey);
+            }
+        }
+        return osgiServices;
+    }
 
     private void assertSpecialRef(String expectedId, Class<?> clazz) {
-        Context context = new Context();
+        Context context = new Context(blueprintConfiguration);
         BeanRef ref = context.getMatching(new BeanRef(clazz));
         assertEquals(expectedId, ref.id);
     }
@@ -69,10 +82,10 @@ public class ContextTest {
     }
 
     @Test
-    public void testProduced() throws NoSuchFieldException, SecurityException  {
-        Context context = new Context(MyFactoryBean.class);
+    public void testProduced() throws NoSuchFieldException, SecurityException {
+        Context context = new Context(blueprintConfiguration, MyFactoryBean.class);
         context.resolve();
-        ProducedBean matching = (ProducedBean)context.getMatching(new BeanRef(MyProduced.class));
+        ProducedBean matching = (ProducedBean) context.getMatching(new BeanRef(MyProduced.class));
         Assert.assertEquals(MyProduced.class, matching.clazz);
         Assert.assertEquals("myFactoryBean", matching.factoryBean.id);
         Assert.assertEquals("create", matching.factoryMethod);

Added: aries/trunk/blueprint/blueprint-maven-plugin/src/test/java/org/apache/aries/blueprint/plugin/model/TransactionalDef.java
URL: http://svn.apache.org/viewvc/aries/trunk/blueprint/blueprint-maven-plugin/src/test/java/org/apache/aries/blueprint/plugin/model/TransactionalDef.java?rev=1758278&view=auto
==============================================================================
--- aries/trunk/blueprint/blueprint-maven-plugin/src/test/java/org/apache/aries/blueprint/plugin/model/TransactionalDef.java (added)
+++ aries/trunk/blueprint/blueprint-maven-plugin/src/test/java/org/apache/aries/blueprint/plugin/model/TransactionalDef.java Mon Aug 29 18:14:56 2016
@@ -0,0 +1,30 @@
+package org.apache.aries.blueprint.plugin.model;
+
+public class TransactionalDef {
+    final String method;
+    final String type;
+
+    public TransactionalDef(String method, String type) {
+        this.method = method;
+        this.type = type;
+    }
+
+    @Override
+    public boolean equals(Object o) {
+        if (this == o) return true;
+        if (!(o instanceof TransactionalDef)) return false;
+
+        TransactionalDef that = (TransactionalDef) o;
+
+        if (method != null ? !method.equals(that.method) : that.method != null) return false;
+        return type != null ? type.equals(that.type) : that.type == null;
+
+    }
+
+    @Override
+    public int hashCode() {
+        int result = method != null ? method.hashCode() : 0;
+        result = 31 * result + (type != null ? type.hashCode() : 0);
+        return result;
+    }
+}



Mime
View raw message