diff --git a/ipojo/tests/handler/transaction/pom.xml b/ipojo/tests/handler/transaction/pom.xml
new file mode 100644
index 0000000..a7cb2d2
--- /dev/null
+++ b/ipojo/tests/handler/transaction/pom.xml
@@ -0,0 +1,134 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+  <groupId>org.apache.felix</groupId>
+  <artifactId>org.apache.felix.ipojo.transaction.test</artifactId>
+  <packaging>jar</packaging>
+  <version>1.3.0-SNAPSHOT</version>
+  <name>org.apache.felix.ipojo.transaction.test</name>
+  <url>http://maven.apache.org</url>
+  <dependencies>
+    <dependency>
+  		<groupId>org.apache.felix</groupId>
+  		<artifactId>org.apache.felix.ipojo</artifactId>
+  		<version>1.3.0-SNAPSHOT</version>
+  	</dependency>
+  	<dependency>
+  		<groupId>org.apache.felix</groupId>
+  		<artifactId>org.apache.felix.ipojo.metadata</artifactId>
+  		<version>1.3.0-SNAPSHOT</version>
+  	</dependency>
+  	<dependency>
+  		<groupId>org.apache.felix</groupId>
+  		<artifactId>org.apache.felix.transaction</artifactId>
+  		<version>0.9.0-SNAPSHOT</version>
+  	</dependency>
+  	  	<dependency>
+  		<groupId>org.apache.felix</groupId>
+  		<artifactId>org.apache.felix.ipojo.transaction</artifactId>
+  		<version>1.3.0-SNAPSHOT</version>
+  	</dependency>
+  <!--
+		Pax Exam API:
+	-->
+	<dependency>
+		<groupId>org.ops4j.pax.exam</groupId>
+		<artifactId>pax-exam</artifactId>
+		<version>0.4.0</version>
+	</dependency>
+	<!--
+		During runtime Pax Exam will discover the OSGi container to use by
+		searching metadata available into classpath. Pax Exam comes with a
+		default container that uses [Pax Runner] for implementing the
+		container requirements:
+	-->
+	<dependency>
+		<groupId>org.ops4j.pax.exam</groupId>
+		<artifactId>pax-exam-container-default
+		</artifactId>
+		<version>0.4.0</version>
+	</dependency>
+	<!--
+		If your test code is based on JUnit you will have to have the Junit
+		support artifact:
+	-->
+	<dependency>
+		<groupId>org.ops4j.pax.exam</groupId>
+		<artifactId>pax-exam-junit</artifactId>
+		<version>0.4.0</version>
+	</dependency>
+	<dependency>
+		<groupId>junit</groupId>
+		<artifactId>junit</artifactId>
+		<version>4.5</version>
+		<type>jar</type>
+		<scope>test</scope>
+	</dependency>
+	
+	<dependency>
+	  <groupId>org.apache.felix</groupId>
+  	  <artifactId>org.apache.felix.ipojo.pax.exam.target</artifactId>
+	  <version>0.9.0-SNAPSHOT</version>
+	</dependency>
+	<dependency>
+		<groupId>org.ops4j.pax.tinybundles</groupId>
+  		<artifactId>pax-tinybundles-core</artifactId>
+  		<version>0.5.0-SNAPSHOT</version>
+	</dependency>
+	 <dependency>
+			<groupId>xerces</groupId>
+			<artifactId>xercesImpl</artifactId>
+			<version>2.4.0</version>
+		</dependency>
+	 <dependency>
+	 	<groupId>org.ops4j.pax.logging</groupId>
+	 	<artifactId>pax-logging-api</artifactId>
+	 	<version>1.3.0</version>
+	 </dependency>
+	 <dependency>
+	 	<groupId>org.ops4j.pax.logging</groupId>
+	 	<artifactId>pax-logging-service</artifactId>
+	 	<version>1.3.0</version>
+	 </dependency>
+	
+	</dependencies>
+	
+	<repositories>
+		<repository>
+			<id>ops4j.releases</id>
+			<name>OPS4J Release</name>
+			<url> http://repository.ops4j.org/maven2/</url>
+			<releases>
+				<enabled>true</enabled>
+			</releases>
+			<snapshots>
+				<enabled>false</enabled>
+			</snapshots>
+		</repository>
+	</repositories>
+	
+		<build>
+		<plugins>
+			<plugin>
+				<groupId>org.apache.maven.plugins</groupId>
+				<artifactId>maven-compiler-plugin</artifactId>
+				<configuration>
+					<source>1.5</source>
+					<target>1.5</target>
+				</configuration>
+			</plugin>
+			<plugin>
+				<groupId>org.apache.servicemix.tooling</groupId>
+				<artifactId>depends-maven-plugin</artifactId>
+				<executions>
+					<execution>
+						<id>generate-depends-file</id>
+						<goals>
+							<goal>generate-depends-file</goal>
+						</goals>
+					</execution>
+				</executions>
+			</plugin>
+			</plugins>
+			</build>
+</project>
diff --git a/ipojo/tests/handler/transaction/src/test/java/org/apache/felix/ipojo/transaction/test/IPOJOHelper.java b/ipojo/tests/handler/transaction/src/test/java/org/apache/felix/ipojo/transaction/test/IPOJOHelper.java
new file mode 100644
index 0000000..0fbe4d9
--- /dev/null
+++ b/ipojo/tests/handler/transaction/src/test/java/org/apache/felix/ipojo/transaction/test/IPOJOHelper.java
@@ -0,0 +1,730 @@
+/* 
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * 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
+ *
+ * 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
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.felix.ipojo.transaction.test;
+
+import java.util.ArrayList;
+import java.util.Dictionary;
+import java.util.List;
+import java.util.Properties;
+
+import org.apache.felix.ipojo.ComponentInstance;
+import org.apache.felix.ipojo.Factory;
+import org.apache.felix.ipojo.Handler;
+import org.apache.felix.ipojo.HandlerFactory;
+import org.apache.felix.ipojo.ServiceContext;
+import org.apache.felix.ipojo.architecture.Architecture;
+import org.apache.felix.ipojo.metadata.Element;
+import org.apache.felix.ipojo.parser.ManifestMetadataParser;
+import org.apache.felix.ipojo.parser.ParseException;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.InvalidSyntaxException;
+import org.osgi.framework.ServiceReference;
+import org.osgi.service.cm.ManagedServiceFactory;
+
+/**
+ * iPOJO Helper.
+ * This helper helps getting {@link Factory}, and managing
+ * {@link ComponentInstance}.
+ * @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
+ */
+public class IPOJOHelper {
+
+    /**
+     * The bundle context.
+     */
+    private BundleContext m_context;
+
+
+    /**
+     * List of instances.
+     */
+    private List<ComponentInstance> m_instances;
+
+    /**
+     * Creates a IPOJOHelper.
+     * @param tc the OSGi Test Case
+     */
+    public IPOJOHelper(BundleContext context) {
+        m_context = context;
+        m_instances = new ArrayList<ComponentInstance>();
+    }
+
+    /**
+     * Disposes created instances.
+     * @see org.apache.felix.ipojo.junit4osgi.Helper#dispose()
+     */
+    public void dispose() {
+        for (int i = 0; i < m_instances.size(); i++) {
+            ((ComponentInstance) m_instances.get(i)).dispose();
+        }
+        m_instances.clear();
+    }
+
+    /**
+     * Gets a created instance from the instance name.
+     * @param name the instance name.
+     * @return the created {@link ComponentInstance} or <code>null</code>
+     * if the instance was not created during the session.
+     */
+    public ComponentInstance getInstanceByName(String name) {
+        for (int i = 0; i < m_instances.size(); i++) {
+            if (((ComponentInstance) m_instances.get(i)).getInstanceName()
+                    .equals(name)) {
+                return (ComponentInstance) m_instances.get(i);
+            }
+        }
+        return null;
+    }
+
+    /**
+     * Creates a new component instance with the given name (and empty
+     * configuration), from the factory specified in the given bundle.
+     * 
+     * @param bundle the bundle from which the component factory is defined.
+     * @param factoryName the name of the component factory, defined in the
+     *            specified bundle.
+     * @param instanceName the name of the component instance to create.
+     * @return the newly created component instance.
+     */
+    public static ComponentInstance createComponentInstance(Bundle bundle,
+            String factoryName, String instanceName) {
+
+        // Create the instance configuration
+        Properties configuration = new Properties();
+        configuration.put("instance.name", instanceName);
+
+        return createComponentInstance(bundle, factoryName, configuration);
+    }
+
+    /**
+     * Creates a new component instance with the given configuration, from the
+     * factory specified in the given bundle.
+     * 
+     * @param bundle the bundle from which the component factory is defined.
+     * @param factoryName the name of the component factory, defined in the
+     *            specified bundle.
+     * @param configuration the configuration of the component instance to
+     *            create.
+     * @return the newly created component instance.
+     */
+    public static ComponentInstance createComponentInstance(Bundle bundle,
+            String factoryName, Dictionary configuration) {
+
+        // Retrieve the component factory.
+        Factory fact = getFactory(bundle, factoryName);
+
+        if (fact == null) {
+            // Factory not found...
+            throw new IllegalArgumentException(
+                    "Cannot find the component factory (" + factoryName
+                            + ") in the specified bundle ("
+                            + bundle.getSymbolicName() + ").");
+        }
+
+        try {
+            return fact.createComponentInstance(configuration);
+        } catch (Exception e) {
+            throw new IllegalArgumentException(
+                    "Cannot create the component instance with the given configuration:"
+                            + e.getMessage());
+        }
+    }
+
+    /**
+     * Creates a new component instance with the given name and configuration,
+     * from the factory specified in the given bundle.
+     * 
+     * @param bundle the bundle from which the component factory is defined.
+     * @param factoryName the name of the component factory, defined in the
+     *            specified bundle.
+     * @param instanceName the name of the component instance to create.
+     * @param configuration the configuration of the instance to create.
+     * @return the newly created component instance.
+     */
+    public static ComponentInstance createComponentInstance(Bundle bundle,
+            String factoryName, String instanceName, Dictionary configuration) {
+
+        // Add the instance name to the configuration
+        configuration.put("instance.name", instanceName);
+
+        return createComponentInstance(bundle, factoryName, configuration);
+    }
+
+    /**
+     * Creates a new component instance with the given name (and an empty
+     * configuration), from the factory specified in the given service context.
+     * 
+     * @param serviceContext the service context in which the component factory
+     *            service is registered.
+     * @param factoryName the name of the component factory, defined in the
+     *            specified service context.
+     * @param instanceName the name of the component instance to create.
+     * @return the newly created component instance.
+     */
+    public static ComponentInstance createComponentInstance(
+            ServiceContext serviceContext, String factoryName,
+            String instanceName) {
+
+        // Create the instance configuration
+        Properties configuration = new Properties();
+        configuration.put("instance.name", instanceName);
+
+        return createComponentInstance(serviceContext, factoryName,
+                configuration);
+    }
+
+    /**
+     * Creates a new component instance with the given name and configuration,
+     * from the factory specified in the given service context.
+     * 
+     * @param serviceContext the service context in which the component factory
+     *            service is registered.
+     * @param factoryName the name of the component factory, defined in the
+     *            specified service context.
+     * @param configuration the configuration of the instance to create.
+     * @return the newly created component instance.
+     */
+    public static ComponentInstance createComponentInstance(
+            ServiceContext serviceContext, String factoryName,
+            Dictionary configuration) {
+
+        // Retrieve the component factory.
+        Factory fact = getFactory(serviceContext, factoryName);
+
+        if (fact == null) {
+            // Factory not found...
+            throw new IllegalArgumentException(
+                    "Cannot find the component factory (" + factoryName
+                            + ") in the specified service context.");
+        }
+
+        try {
+            return fact.createComponentInstance(configuration);
+        } catch (Exception e) {
+            throw new IllegalArgumentException(
+                    "Cannot create the component instance with the given configuration: "
+                            + e.getMessage());
+        }
+    }
+
+    /**
+     * Creates a new component instance with the given name and configuration,
+     * from the factory specified in the given service context.
+     * 
+     * @param serviceContext the service context in which the component factory
+     *            service is registered.
+     * @param factoryName the name of the component factory, defined in the
+     *            specified service context.
+     * @param instanceName the name of the component instance to create.
+     * @param configuration the configuration of the instance to create.
+     * @return the newly created component instance.
+     */
+    public static ComponentInstance createComponentInstance(
+            ServiceContext serviceContext, String factoryName,
+            String instanceName, Dictionary configuration) {
+
+        // Add the instance name to the configuration
+        configuration.put("instance.name", instanceName);
+
+        return createComponentInstance(serviceContext, factoryName,
+                configuration);
+    }
+
+    /**
+     * Creates a new component instance with the given name (and empty
+     * configuration), from the factory specified in the local bundle.
+     * 
+     * @param factoryName the name of the component factory, defined in the
+     *            local bundle.
+     * @param instanceName the name of the component instance to create.
+     * @return the newly created component instance.
+     */
+    public ComponentInstance createComponentInstance(String factoryName,
+            String instanceName) {
+        ComponentInstance ci = createComponentInstance(m_context.getBundle(),
+                factoryName, instanceName);
+        m_instances.add(ci);
+        return ci;
+    }
+
+    /**
+     * Creates a new component instance with the given configuration, from the
+     * factory specified in the local bundle.
+     * 
+     * @param factoryName the name of the component factory, in the local
+     *            bundle.
+     * @param configuration the configuration of the component instance to
+     *            create.
+     * @return the newly created component instance.
+     */
+    public ComponentInstance createComponentInstance(String factoryName,
+            Dictionary configuration) {
+        ComponentInstance ci = createComponentInstance(m_context.getBundle(),
+                factoryName, configuration);
+        m_instances.add(ci);
+        return ci;
+    }
+
+    /**
+     * Creates a new component instance with no configuration, from the factory
+     * specified in the local bundle.
+     * 
+     * @param factoryName the name of the component factory, in the local
+     *            bundle.
+     * @return the newly created component instance.
+     */
+    public ComponentInstance createComponentInstance(String factoryName) {
+        ComponentInstance ci = createComponentInstance(m_context.getBundle(),
+                factoryName, (Dictionary) null);
+        m_instances.add(ci);
+        return ci;
+    }
+
+    /**
+     * Creates a new component instance with the given name and configuration,
+     * from the factory specified in the given bundle.
+     * 
+     * @param factoryName the name of the component factory, defined in the
+     *            specified bundle.
+     * @param instanceName the name of the component instance to create.
+     * @param configuration the configuration of the instance to create.
+     * @return the newly created component instance.
+     */
+    public ComponentInstance createComponentInstance(String factoryName,
+            String instanceName, Dictionary configuration) {
+        ComponentInstance ci = createComponentInstance(m_context.getBundle(),
+                factoryName, instanceName, configuration);
+        m_instances.add(ci);
+        return ci;
+    }
+
+    /**
+     * Returns the component factory with the given name in the local bundle.
+     * 
+     * @param factoryName the name of the factory to retrieve.
+     * @return the component factory with the given name in the local bundle, or
+     *         {@code null} if not found.
+     */
+    public Factory getFactory(String factoryName) {
+        return getFactory(m_context.getBundle(), factoryName);
+    }
+
+    /**
+     * Returns the handler factory with the given name in the local bundle.
+     * 
+     * @param factoryName the name of the handler factory to retrieve.
+     * @return the handler factory with the given name in the local bundle, or
+     *         {@code null} if not found.
+     */
+    public HandlerFactory getHandlerFactory(String factoryName) {
+        return getHandlerFactory(m_context.getBundle(), factoryName);
+    }
+
+    /**
+     * Returns the metadata description of the component defined in this bundle.
+     * 
+     * @param component the name of the locally defined component.
+     * @return the metadata description of the component with the given name,
+     *         defined in this given bundle, or {@code null} if not found.
+     */
+    public Element getMetadata(String component) {
+        return getMetadata(m_context.getBundle(), component);
+    }
+
+    /**
+     * Returns the component factory with the given name in the given bundle.
+     * 
+     * @param bundle the bundle from which the component factory is defined.
+     * @param factoryName the name of the defined factory.
+     * @return the component factory with the given name in the given bundle, or
+     *         {@code null} if not found.
+     */
+    public static Factory getFactory(Bundle bundle, String factoryName) {
+        ServiceReference[] refs;
+        try {
+            // Retrieves the component factories services in the bundle.
+            refs = bundle.getBundleContext().getServiceReferences(
+                    Factory.class.getName(),
+                    "(factory.name=" + factoryName + ")");
+            if (refs != null) {
+                return (Factory) bundle.getBundleContext().getService(refs[0]);
+            }
+
+            // Factory not found...
+            return null;
+
+        } catch (InvalidSyntaxException e) {
+            throw new IllegalArgumentException(
+                    "Cannot get the component factory services: "
+                            + e.getMessage());
+        }
+    }
+
+    /**
+     * Returns the component factory with the given name, registered in the
+     * given service context.
+     * 
+     * @param serviceContext the service context in which the factory service is
+     *            defined.
+     * @param factoryName the name of the factory.
+     * @return the component factory with the given name, registered in the
+     *         given service context.
+     */
+    public static Factory getFactory(ServiceContext serviceContext,
+            String factoryName) {
+        ServiceReference[] refs;
+        try {
+            // Retrieves the component factories services in the service
+            // context.
+            refs = serviceContext.getServiceReferences(Factory.class.getName(),
+                    "(factory.name=" + factoryName + ")");
+            if (refs != null) {
+                return (Factory) serviceContext.getService(refs[0]);
+            }
+            return null;
+
+        } catch (InvalidSyntaxException e) {
+            System.err.println("Cannot get the factory " + factoryName + " : "
+                    + e.getMessage());
+            return null;
+        }
+    }
+
+    /**
+     * Returns the handler factory with the given name in the given bundle.
+     * 
+     * @param bundle the bundle from which the handler factory is defined.
+     * @param factoryName the name of the handler factory to retrieve.
+     * @return the handler factory with the given name in the given bundle, or
+     *         {@code null} if not found.
+     */
+    public static HandlerFactory getHandlerFactory(Bundle bundle,
+            String factoryName) {
+        ServiceReference[] refs;
+        try {
+            // Retrieves the handler factories services in the bundle.
+            refs = bundle.getBundleContext().getServiceReferences(
+                    HandlerFactory.class.getName(),
+                    "(" + Handler.HANDLER_NAME_PROPERTY + "=" + factoryName
+                            + ")");
+            if (refs != null) {
+                return (HandlerFactory) bundle.getBundleContext().getService(
+                        refs[0]);
+            }
+
+            // Factory not found...
+            return null;
+        } catch (InvalidSyntaxException e) {
+            throw new IllegalArgumentException(
+                    "Cannot get the handler factory services: "
+                            + e.getMessage());
+        }
+    }
+
+    /**
+     * Returns the metadata description of the component with the given name,
+     * defined in the given bundle.
+     * 
+     * @param bundle the bundle from which the component is defined.
+     * @param component the name of the defined component.
+     * @return the metadata description of the component with the given name,
+     *         defined in the given bundle, or {@code null} if not found.
+     */
+    public static Element getMetadata(Bundle bundle, String component) {
+
+        // Retrieves the component description from the bundle's manifest.
+        String elem = (String) bundle.getHeaders().get("iPOJO-Components");
+        if (elem == null) {
+            throw new IllegalArgumentException(
+                    "Cannot find iPOJO-Components descriptor in the specified bundle ("
+                            + bundle.getSymbolicName()
+                            + "). Not an iPOJO bundle.");
+        }
+
+        // Parses the retrieved description and find the component with the
+        // given name.
+        try {
+            Element element = ManifestMetadataParser.parseHeaderMetadata(elem);
+            Element[] childs = element.getElements("component");
+            for (int i = 0; i < childs.length; i++) {
+                String name = childs[i].getAttribute("name");
+                String clazz = childs[i].getAttribute("classname");
+                if (name != null && name.equalsIgnoreCase(component)) {
+                    return childs[i];
+                }
+                if (clazz.equalsIgnoreCase(component)) {
+                    return childs[i];
+                }
+            }
+
+            // Component not found...
+            return null;
+
+        } catch (ParseException e) {
+            throw new IllegalStateException(
+                    "Cannot parse the components from specified bundle ("
+                            + bundle.getSymbolicName() + "): " + e.getMessage());
+        }
+    }
+
+    /**
+     * Returns the service object of a service registered in the specified
+     * service context, offering the specified interface and matching the given
+     * filter.
+     * 
+     * @param serviceContext the service context in which the service is
+     *            searched.
+     * @param itf the interface provided by the searched service.
+     * @param filter an additional filter (can be {@code null}).
+     * @return the service object provided by the specified bundle, offering the
+     *         specified interface and matching the given filter.
+     */
+    public static Object getServiceObject(ServiceContext serviceContext,
+            String itf, String filter) {
+        ServiceReference ref = getServiceReference(serviceContext, itf, filter);
+        if (ref != null) {
+            return serviceContext.getService(ref);
+        } else {
+            return null;
+        }
+    }
+
+    /**
+     * Returns the service objects of the services registered in the specified
+     * service context, offering the specified interface and matching the given
+     * filter.
+     * 
+     * @param serviceContext the service context in which services are searched.
+     * @param itf the interface provided by the searched services.
+     * @param filter an additional filter (can be {@code null}).
+     * @return the service objects provided by the specified bundle, offering
+     *         the specified interface and matching the given filter.
+     */
+    public static Object[] getServiceObjects(ServiceContext serviceContext,
+            String itf, String filter) {
+        ServiceReference[] refs = getServiceReferences(serviceContext, itf,
+                filter);
+        if (refs != null) {
+            Object[] list = new Object[refs.length];
+            for (int i = 0; i < refs.length; i++) {
+                list[i] = serviceContext.getService(refs[i]);
+            }
+            return list;
+        } else {
+            return new Object[0];
+        }
+    }
+
+    /**
+     * Returns the service reference of a service registered in the specified
+     * service context, offering the specified interface and matching the given
+     * filter.
+     * 
+     * @param serviceContext the service context in which services are searched.
+     * @param itf the interface provided by the searched service.
+     * @param filter an additional filter (can be {@code null}).
+     * @return a service reference registered in the specified service context,
+     *         offering the specified interface and matching the given filter.
+     *         If no service is found, {@code null} is returned.
+     */
+    public static ServiceReference getServiceReference(
+            ServiceContext serviceContext, String itf, String filter) {
+        ServiceReference[] refs = getServiceReferences(serviceContext, itf,
+                filter);
+        if (refs.length != 0) {
+            return refs[0];
+        } else {
+            // No service found
+            return null;
+        }
+    }
+
+    /**
+     * Returns the service reference of the service registered in the specified
+     * service context, offering the specified interface and having the given
+     * persistent ID.
+     * 
+     * @param serviceContext the service context in which services are searched.
+     * @param itf the interface provided by the searched service.
+     * @param pid the persistent ID of the searched service.
+     * @return a service registered in the specified service context, offering
+     *         the specified interface and having the given persistent ID.
+     */
+    public static ServiceReference getServiceReferenceByPID(
+            ServiceContext serviceContext, String itf, String pid) {
+        String filter = "(" + "service.pid" + "=" + pid + ")";
+        ServiceReference[] refs = getServiceReferences(serviceContext, itf,
+                filter);
+        if (refs == null) {
+            return null;
+        } else if (refs.length == 1) {
+            return refs[0];
+        } else {
+            throw new IllegalStateException(
+                    "A service lookup by PID returned several providers ("
+                            + refs.length + ")" + " for " + itf + " with pid="
+                            + pid);
+        }
+    }
+
+    /**
+     * Returns the service reference of all the services registered in the
+     * specified service context, offering the specified interface and matching
+     * the given filter.
+     * 
+     * @param serviceContext the service context in which services are searched.
+     * @param itf the interface provided by the searched services.
+     * @param filter an additional filter (can be {@code null}).
+     * @return all the service references registered in the specified service
+     *         context, offering the specified interface and matching the given
+     *         filter. If no service matches, an empty array is returned.
+     */
+    public static ServiceReference[] getServiceReferences(
+            ServiceContext serviceContext, String itf, String filter) {
+        ServiceReference[] refs = null;
+        try {
+            // Get all the service references
+            refs = serviceContext.getServiceReferences(itf, filter);
+        } catch (InvalidSyntaxException e) {
+            throw new IllegalArgumentException(
+                    "Cannot get service references: " + e.getMessage());
+        }
+        if (refs == null) {
+            return new ServiceReference[0];
+        } else {
+            return refs;
+        }
+    }
+
+    /**
+     * Returns the service reference of a service registered in the specified
+     * service context, offering the specified interface and having the given
+     * name.
+     * 
+     * @param serviceContext the service context in which services are searched.
+     * @param itf the interface provided by the searched service.
+     * @param name the name of the searched service.
+     * @return a service registered in the specified service context, offering
+     *         the specified interface and having the given name.
+     */
+    public static ServiceReference getServiceReferenceByName(
+            ServiceContext serviceContext, String itf, String name) {
+        String filter = null;
+        if (itf.equals(Factory.class.getName())
+                || itf.equals(ManagedServiceFactory.class.getName())) {
+            filter = "(" + "factory.name" + "=" + name + ")";
+        } else if (itf.equals(Architecture.class.getName())) {
+            filter = "(" + "architecture.instance" + "=" + name + ")";
+        } else {
+            filter = "(" + "instance.name" + "=" + name + ")";
+        }
+        return getServiceReference(serviceContext, itf, filter);
+    }
+
+    /**
+     * Checks the availability of a service inside the given service context.
+     * @param sc the service context
+     * @param itf the service interface to found
+     * @return <code>true</code> if the service is available in the service
+     *         context, <code>false</code> otherwise.
+     */
+    public static boolean isServiceAvailable(ServiceContext sc, String itf) {
+        ServiceReference ref = getServiceReference(sc, itf, null);
+        return ref != null;
+    }
+
+    /**
+     * Checks the availability of a service inside the given service context.
+     * @param sc the service context
+     * @param itf the service interface to found
+     * @param name the service provider name
+     * @return <code>true</code> if the service is available in the service
+     *         context, <code>false</code> otherwise.
+     */
+    public static boolean isServiceAvailableByName(ServiceContext sc,
+            String itf, String name) {
+        ServiceReference ref = getServiceReferenceByName(sc, itf, name);
+        return ref != null;
+    }
+
+    /**
+     * Checks the availability of a service inside the given service context.
+     * @param sc the service context
+     * @param itf the service interface to found
+     * @param pid the pid of the service
+     * @return <code>true</code> if the service is available in the service
+     *         context, <code>false</code> otherwise.
+     */
+    public static boolean isServiceAvailableByPID(ServiceContext sc,
+            String itf, String pid) {
+        ServiceReference ref = getServiceReferenceByPID(sc, itf, pid);
+        return ref != null;
+    }
+
+    /**
+     * Returns the service reference of a service provided by the specified
+     * bundle, offering the specified interface and having the given name.
+     * 
+     * @param bundle the bundle from which the service is searched.
+     * @param itf the interface provided by the searched service.
+     * @param name the name of the searched service.
+     * @return a service provided by the specified bundle, offering the
+     *         specified interface and having the given name.
+     */
+    public static ServiceReference getServiceReferenceByName(Bundle bundle,
+            String itf, String name) {
+        String filter = null;
+        if (itf.equals(Factory.class.getName())
+                || itf.equals(ManagedServiceFactory.class.getName())) {
+            filter = "(" + "factory.name" + "=" + name + ")";
+        } else if (itf.equals(Architecture.class.getName())) {
+            filter = "(" + "architecture.instance" + "=" + name + ")";
+        } else {
+            filter = "(" + "instance.name" + "=" + name + ")";
+        }
+        return OSGiHelper.getServiceReference(bundle, itf, filter);
+    }
+
+    /**
+     * Returns the service reference of a service provided by the local bundle,
+     * offering the specified interface and having the given name.
+     * 
+     * @param itf the interface provided by the searched service.
+     * @param name the name of the searched service.
+     * @return a service provided by the specified bundle, offering the
+     *         specified interface and having the given name.
+     */
+    public ServiceReference getServiceReferenceByName(String itf, String name) {
+        return getServiceReferenceByName(m_context.getBundle(), itf, name);
+    }
+
+    /**
+     * Checks if the service is available.
+     * @param itf the service interface
+     * @param name the service provider name
+     * @return <code>true</code> if the service is available, <code>false</code>
+     *         otherwise.
+     */
+    public boolean isServiceAvailableByName(String itf, String name) {
+        ServiceReference ref = getServiceReferenceByName(itf, name);
+        return ref != null;
+    }
+
+}
diff --git a/ipojo/tests/handler/transaction/src/test/java/org/apache/felix/ipojo/transaction/test/OSGiHelper.java b/ipojo/tests/handler/transaction/src/test/java/org/apache/felix/ipojo/transaction/test/OSGiHelper.java
new file mode 100644
index 0000000..604ee18
--- /dev/null
+++ b/ipojo/tests/handler/transaction/src/test/java/org/apache/felix/ipojo/transaction/test/OSGiHelper.java
@@ -0,0 +1,456 @@
+package org.apache.felix.ipojo.transaction.test;
+
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.BundleException;
+import org.osgi.framework.InvalidSyntaxException;
+import org.osgi.framework.ServiceReference;
+import org.osgi.service.packageadmin.PackageAdmin;
+
+import static org.junit.Assert.fail;
+
+
+public class OSGiHelper {
+    
+    /**
+     * The bundle context.
+     */
+    private BundleContext context;
+    
+    /**
+     * List of get references.
+     */
+    private List<ServiceReference> m_references = new ArrayList<ServiceReference>();
+    
+    public OSGiHelper(BundleContext context) {
+        this.context = context;
+    }
+    
+    public void dispose() {
+        // Unget services
+        for (int i = 0; i < m_references.size(); i++) {
+            context.ungetService((ServiceReference) m_references.get(i));
+        }
+        m_references.clear();
+    }
+    
+    /**
+     * Gets the Bundle Context.
+     * @return the bundle context.
+     */
+    public BundleContext getContext() {
+        return context;
+    }
+    
+    /**
+     * Returns the service object of a service provided by the specified bundle,
+     * offering the specified interface and matching the given filter.
+     * 
+     * @param bundle the bundle from which the service is searched.
+     * @param itf the interface provided by the searched service.
+     * @param filter an additional filter (can be {@code null}).
+     * @return the service object provided by the specified bundle, offering the
+     *         specified interface and matching the given filter.
+     */
+    public static Object getServiceObject(Bundle bundle, String itf,
+            String filter) {
+        ServiceReference ref = getServiceReference(bundle, itf, filter);
+        if (ref != null) {
+            return bundle.getBundleContext().getService(ref);
+        } else {
+            return null;
+        }
+    }
+
+    /**
+     * Returns the service objects of the services provided by the specified
+     * bundle, offering the specified interface and matching the given filter.
+     * 
+     * @param bundle the bundle from which services are searched.
+     * @param itf the interface provided by the searched services.
+     * @param filter an additional filter (can be {@code null}).
+     * @return the service objects provided by the specified bundle, offering
+     *         the specified interface and matching the given filter.
+     */
+    public static Object[] getServiceObjects(Bundle bundle, String itf,
+            String filter) {
+        ServiceReference[] refs = getServiceReferences(bundle, itf, filter);
+        if (refs != null) {
+            Object[] list = new Object[refs.length];
+            for (int i = 0; i < refs.length; i++) {
+                list[i] = bundle.getBundleContext().getService(refs[i]);
+            }
+            return list;
+        } else {
+            return new Object[0];
+        }
+    }
+
+    /**
+     * Returns the service reference of a service provided by the specified
+     * bundle, offering the specified interface and matching the given filter.
+     * 
+     * @param bundle the bundle from which the service is searched.
+     * @param itf the interface provided by the searched service.
+     * @param filter an additional filter (can be {@code null}).
+     * @return a service reference provided by the specified bundle, offering
+     *         the specified interface and matching the given filter. If no
+     *         service is found, {@code null} is returned.
+     */
+    public static ServiceReference getServiceReference(Bundle bundle,
+            String itf, String filter) {
+        ServiceReference[] refs = getServiceReferences(bundle, itf, filter);
+        if (refs.length != 0) {
+            return refs[0];
+        } else {
+            // No service found
+            return null;
+        }
+    }
+
+    /**
+     * Checks if the service is available.
+     * @param itf the service interface
+     * @return <code>true</code> if the service is available, <code>false</code>
+     *         otherwise.
+     */
+    public boolean isServiceAvailable(String itf) {
+        ServiceReference ref = getServiceReference(itf, null);
+        return ref != null;
+    }
+
+    /**
+     * Checks if the service is available.
+     * @param itf the service interface
+     * @param pid the service pid
+     * @return <code>true</code> if the service is available, <code>false</code>
+     *         otherwise.
+     */
+    public boolean isServiceAvailableByPID(String itf, String pid) {
+        ServiceReference ref = getServiceReferenceByPID(itf, pid);
+        return ref != null;
+    }
+
+    /**
+     * Returns the service reference of the service provided by the specified
+     * bundle, offering the specified interface and having the given persistent
+     * ID.
+     * 
+     * @param bundle the bundle from which the service is searched.
+     * @param itf the interface provided by the searched service.
+     * @param pid the persistent ID of the searched service.
+     * @return a service provided by the specified bundle, offering the
+     *         specified interface and having the given persistent ID.
+     */
+    public static ServiceReference getServiceReferenceByPID(Bundle bundle,
+            String itf, String pid) {
+        String filter = "(" + "service.pid" + "=" + pid + ")";
+        ServiceReference[] refs = getServiceReferences(bundle, itf, filter);
+        if (refs == null) {
+            return null;
+        } else if (refs.length == 1) {
+            return refs[0];
+        } else {
+            throw new IllegalStateException(
+                    "A service lookup by PID returned several providers ("
+                            + refs.length + ")" + " for " + itf + " with pid="
+                            + pid);
+        }
+    }
+
+    /**
+     * Returns the service reference of all the services provided in the
+     * specified bundle, offering the specified interface and matching the given
+     * filter.
+     * 
+     * @param bundle the bundle from which services are searched.
+     * @param itf the interface provided by the searched services.
+     * @param filter an additional filter (can be {@code null}).
+     * @return all the service references provided in the specified bundle,
+     *         offering the specified interface and matching the given filter.
+     *         If no service matches, an empty array is returned.
+     */
+    public static ServiceReference[] getServiceReferences(Bundle bundle,
+            String itf, String filter) {
+        ServiceReference[] refs = null;
+        try {
+            // Get all the service references
+            refs = bundle.getBundleContext().getServiceReferences(itf, filter);
+        } catch (InvalidSyntaxException e) {
+            throw new IllegalArgumentException(
+                    "Cannot get service references: " + e.getMessage());
+        }
+        if (refs == null) {
+            return new ServiceReference[0];
+        } else {
+            return refs;
+        }
+    }
+
+    /**
+     * Returns the service object of a service provided by the local bundle,
+     * offering the specified interface and matching the given filter.
+     * 
+     * @param itf the interface provided by the searched service.
+     * @param filter an additional filter (can be {@code null}).
+     * @return the service object provided by the local bundle, offering the
+     *         specified interface and matching the given filter.
+     */
+    public Object getServiceObject(String itf, String filter) {
+        ServiceReference ref = getServiceReference(itf, filter);
+        if (ref != null) {
+            m_references.add(ref);
+            return context.getService(ref);
+        } else {
+            return null;
+        }
+    }
+
+    /**
+     * Returns the service object associated with this service reference.
+     * 
+     * @param ref service reference
+     * @return the service object.
+     */
+    public Object getServiceObject(ServiceReference ref) {
+        if (ref != null) {
+            m_references.add(ref);
+            return context.getService(ref);
+        } else {
+            return null;
+        }
+    }
+
+    /**
+     * Returns the service objects of the services provided by the local bundle,
+     * offering the specified interface and matching the given filter.
+     * 
+     * @param itf the interface provided by the searched services.
+     * @param filter an additional filter (can be {@code null}).
+     * @return the service objects provided by the local bundle, offering the
+     *         specified interface and matching the given filter.
+     */
+    public Object[] getServiceObjects(String itf, String filter) {
+        ServiceReference[] refs = getServiceReferences(itf, filter);
+        if (refs != null) {
+            Object[] list = new Object[refs.length];
+            for (int i = 0; i < refs.length; i++) {
+                m_references.add(refs[i]);
+                list[i] = context.getService(refs[i]);
+            }
+            return list;
+        } else {
+            return new Object[0];
+        }
+    }
+
+    /**
+     * Returns the service reference of a service provided by the local bundle,
+     * offering the specified interface and matching the given filter.
+     * 
+     * @param itf the interface provided by the searched service.
+     * @param filter an additional filter (can be {@code null}).
+     * @return a service reference provided by the local bundle, offering the
+     *         specified interface and matching the given filter. If no service
+     *         is found, {@code null} is returned.
+     */
+    public ServiceReference getServiceReference(String itf, String filter) {
+        return getServiceReference(context.getBundle(), itf, filter);
+    }
+
+    /**
+     * Returns the service reference of a service provided offering the
+     * specified interface.
+     * 
+     * @param itf the interface provided by the searched service.
+     * @return a service reference provided by the local bundle, offering the
+     *         specified interface and matching the given filter. If no service
+     *         is found, {@code null} is returned.
+     */
+    public ServiceReference getServiceReference(String itf) {
+        return getServiceReference(context.getBundle(), itf, null);
+    }
+
+    /**
+     * Returns the service reference of the service provided by the local
+     * bundle, offering the specified interface and having the given persistent
+     * ID.
+     * 
+     * @param itf the interface provided by the searched service.
+     * @param pid the persistent ID of the searched service.
+     * @return a service provided by the local bundle, offering the specified
+     *         interface and having the given persistent ID.
+     */
+    public ServiceReference getServiceReferenceByPID(String itf, String pid) {
+        return getServiceReferenceByPID(context.getBundle(), itf, pid);
+    }
+
+    /**
+     * Returns the service reference of all the services provided in the local
+     * bundle, offering the specified interface and matching the given filter.
+     * 
+     * @param itf the interface provided by the searched services.
+     * @param filter an additional filter (can be {@code null}).
+     * @return all the service references provided in the local bundle, offering
+     *         the specified interface and matching the given filter. If no
+     *         service matches, an empty array is returned.
+     */
+    public ServiceReference[] getServiceReferences(String itf, String filter) {
+        return getServiceReferences(context.getBundle(), itf, filter);
+    }
+    
+    /**
+     * Gets the package admin exposed by the framework.
+     * Fails if the package admin is not available. 
+     * @return the package admin service.
+     */
+    public PackageAdmin getPackageAdmin() {
+        PackageAdmin pa = (PackageAdmin) getServiceObject(PackageAdmin.class.getName(), null);
+        if (pa == null) {
+            fail("No package admin available");
+        }
+        return pa;
+    }
+    
+    /**
+     * Refresh the packages.
+     * Fails if the package admin service is not available.
+     */
+    public void refresh() {
+        getPackageAdmin().refreshPackages(null);
+    }
+    
+    /**
+     * Waits for a service. Fails on timeout.
+     * If timeout is set to 0, it sets the timeout to 10s.
+     * @param itf the service interface
+     * @param filter  the filter
+     * @param timeout the timeout
+     */
+    public void waitForService(String itf, String filter, long timeout) {
+        if (timeout == 0) {
+            timeout = 10000; // Default 10 secondes.
+        }
+        ServiceReference[] refs = getServiceReferences(itf, filter);
+        long begin = System.currentTimeMillis();
+        if (refs.length != 0) {
+            return;
+        } else {
+            while(refs.length == 0) {
+                try {
+                    Thread.sleep(5);
+                } catch (InterruptedException e) {
+                    // Interrupted
+                }
+                long now = System.currentTimeMillis();
+                
+                if ((now - begin) > timeout) {
+                    fail("Timeout ... no services matching with the request after " + timeout + "ms");
+                }
+                refs = getServiceReferences(itf, filter);
+            }
+        }
+    }
+    
+    
+    /**
+     * Installs a bundle.
+     * Fails if the bundle cannot be installed.
+     * Be aware that you have to uninstall the bundle yourself.
+     * @param url bundle url
+     * @return the installed bundle
+     */
+    public Bundle installBundle(String url) {
+        try {
+            return context.installBundle(url);
+        } catch (BundleException e) {
+            fail("Cannot install the bundle " + url + " : " + e.getMessage());
+        }
+        return null; // Can not happen
+    }
+    
+    /**
+     * Installs a bundle.
+     * Fails if the bundle cannot be installed.
+     * Be aware that you have to uninstall the bundle yourself.
+     * @param url bundle url
+     * @param stream input stream containing the bundle
+     * @return the installed bundle
+     */
+    public Bundle installBundle(String url, InputStream stream) {
+        try {
+            return context.installBundle(url, stream);
+        } catch (BundleException e) {
+            fail("Cannot install the bundle " + url + " : " + e.getMessage());
+        }
+        return null; // Can not happen
+    }
+    
+    /**
+     * Installs and starts a bundle.
+     * Fails if the bundle cannot be installed or an error occurs
+     * during startup. Be aware that you have to uninstall the bundle
+     * yourself.
+     * @param url the bundle url
+     * @return the Bundle object.
+     */
+    public Bundle installAndStart(String url) {
+        Bundle bundle = installBundle(url);
+        try {
+            bundle.start();
+        } catch (BundleException e) {
+           fail("Cannot start the bundle " + url + " : " + e.getMessage());
+        }
+        return bundle;
+    }
+    
+    /**
+     * Installs and starts a bundle.
+     * Fails if the bundle cannot be installed or an error occurs
+     * during startup. Be aware that you have to uninstall the bundle
+     * yourself.
+     * @param url the bundle url
+     * @param stream input stream containing the bundle
+     * @return the Bundle object.
+     */
+    public Bundle installAndStart(String url, InputStream stream) {
+        Bundle bundle = installBundle(url, stream);
+        try {
+            bundle.start();
+        } catch (BundleException e) {
+           fail("Cannot start the bundle " + url + " : " + e.getMessage());
+        }
+        return bundle;
+    }
+    
+    /**
+     * Get the bundle by its id.
+     * @param bundleId the bundle id.
+     * @return the bundle with the given id.
+     */
+    public Bundle getBundle(long bundleId) {
+        return context.getBundle(bundleId);
+    }
+    
+    /**
+     * Gets a bundle by its symbolic name.
+     * Fails if no bundle matches.
+     * @param name the symbolic name of the bundle
+     * @return the bundle object.
+     */
+    public Bundle getBundle(String name) {
+        Bundle[] bundles = context.getBundles();
+        for (int i = 0; i < bundles.length; i++) {
+            if (name.equals(bundles[i].getSymbolicName())) {
+                return bundles[i];
+            }
+        }
+        fail("No bundles with the given symbolic name " + name);
+        return null; // should not happen
+    }
+
+}
diff --git a/ipojo/tests/handler/transaction/src/test/java/org/apache/felix/ipojo/transaction/test/TestInstallation.java b/ipojo/tests/handler/transaction/src/test/java/org/apache/felix/ipojo/transaction/test/TestInstallation.java
new file mode 100644
index 0000000..0803abd
--- /dev/null
+++ b/ipojo/tests/handler/transaction/src/test/java/org/apache/felix/ipojo/transaction/test/TestInstallation.java
@@ -0,0 +1,157 @@
+package org.apache.felix.ipojo.transaction.test;
+
+import static org.ops4j.pax.exam.CoreOptions.bundle;
+import static org.ops4j.pax.exam.CoreOptions.mavenBundle;
+import static org.ops4j.pax.exam.CoreOptions.options;
+import static org.ops4j.pax.exam.CoreOptions.provision;
+import static org.ops4j.pax.exam.MavenUtils.asInProject;
+import static org.ops4j.pax.tinybundles.core.TinyBundles.with;
+
+import java.io.File;
+import java.net.URL;
+
+import javax.transaction.HeuristicMixedException;
+import javax.transaction.HeuristicRollbackException;
+import javax.transaction.NotSupportedException;
+import javax.transaction.RollbackException;
+import javax.transaction.SystemException;
+import javax.transaction.TransactionManager;
+
+import org.apache.felix.ipojo.ComponentInstance;
+import org.apache.felix.ipojo.HandlerFactory;
+import org.apache.felix.ipojo.pax.exam.target.BundleAsiPOJO;
+import org.apache.felix.ipojo.transaction.test.component.FooDelegator;
+import org.apache.felix.ipojo.transaction.test.component.FooImpl;
+import org.apache.felix.ipojo.transaction.test.service.CheckService;
+import org.apache.felix.ipojo.transaction.test.service.Foo;
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.ops4j.pax.exam.Inject;
+import org.ops4j.pax.exam.Option;
+import org.ops4j.pax.exam.junit.Configuration;
+import org.ops4j.pax.exam.junit.JUnit4TestRunner;
+import org.ops4j.pax.tinybundles.core.TinyBundles;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.Constants;
+import org.osgi.framework.ServiceReference;
+
+@RunWith( JUnit4TestRunner.class )
+public class TestInstallation {
+    
+    @Inject
+    private BundleContext context;
+    
+    private OSGiHelper osgi;
+    
+    private IPOJOHelper ipojo;
+    
+    public static final File ROOT = new File("target/tmp");
+    public static final File TEST = new File("src/test/resources");
+
+    
+    @Before
+    public void init() {
+        osgi = new OSGiHelper(context);
+        ipojo = new IPOJOHelper(context);
+    }
+    
+    @After
+    public void stop() {
+        ipojo.dispose();
+        osgi.dispose();
+    }
+    
+    @Configuration
+    public static Option[] configure() {    
+        ROOT.mkdirs();
+
+        URL service = TinyBundles.newBundle()
+            .addClass(CheckService.class)
+            .addClass(Foo.class)
+           .prepare( 
+                with()
+                .set(Constants.BUNDLE_SYMBOLICNAME,"Service")
+                .set(Constants.EXPORT_PACKAGE, "org.apache.felix.ipojo.transaction.test.service")
+                )
+            .build( TinyBundles.asURL());
+            
+        String fooimpl = TinyBundles.newBundle()
+            .addClass(FooImpl.class)
+            .prepare( 
+                    with()
+                    .set(Constants.BUNDLE_SYMBOLICNAME,"Foo Provider")
+                    .set(Constants.IMPORT_PACKAGE, "org.apache.felix.ipojo.transaction.test.service")
+                )
+                .build( new BundleAsiPOJO(new File(ROOT, "FooImpl.jar"), new File(TEST, "foo.xml"))  ).toExternalForm();
+        
+        String test = TinyBundles.newBundle()
+        .addClass(FooDelegator.class)
+        .prepare( 
+                with()
+                .set(Constants.BUNDLE_SYMBOLICNAME,"Required Transaction Propgatation")
+                .set(Constants.IMPORT_PACKAGE, "org.apache.felix.ipojo.transaction.test.service, javax.transaction")
+            )
+            .build( new BundleAsiPOJO(new File(ROOT, "requires.jar"), new File(TEST, "requires.xml"))  ).toExternalForm();
+    
+        
+        Option[] opt =  options(
+ 
+                provision(
+                        mavenBundle().groupId("org.ops4j.pax.logging").artifactId("pax-logging-api").version(asInProject()),
+                        mavenBundle().groupId("org.apache.felix").artifactId("org.apache.felix.ipojo").version(asInProject()),
+                        mavenBundle().groupId("org.apache.felix").artifactId("org.apache.felix.ipojo.transaction").version(asInProject()),
+                        mavenBundle().groupId("org.apache.felix").artifactId("org.apache.felix.transaction").version(asInProject()),
+                        mavenBundle()
+                        .groupId( "org.ops4j.pax.tinybundles" )
+                        .artifactId( "pax-tinybundles-core" )
+                        .version( "0.5.0-SNAPSHOT" ),
+                        bundle(service.toExternalForm()),
+                        bundle(fooimpl),
+                        bundle(test)
+                    )
+                )
+
+                ;
+        return opt;
+    }
+    
+    @Test
+    public void install() throws NotSupportedException, SystemException, IllegalStateException, SecurityException, HeuristicMixedException, HeuristicRollbackException, RollbackException {
+        Bundle[] bundles = context.getBundles();
+        for (Bundle b : bundles) {
+            Assert.assertTrue(b.getSymbolicName(), b.getState() == Bundle.ACTIVE);
+        }
+        
+        // Transaction Service available
+        osgi.isServiceAvailable(TransactionManager.class.getName());
+        TransactionManager tm = (TransactionManager) osgi.getServiceObject(TransactionManager.class.getName(), null);
+        tm.begin();
+        Assert.assertNotNull(tm.getTransaction());
+        tm.commit();
+        
+        tm.begin();
+        Assert.assertNotNull(tm.getTransaction());
+        tm.rollback();
+        
+        // Handler exposed
+        ServiceReference ref = osgi.getServiceReference(HandlerFactory.class.getName(), "(&(handler.name=transaction)(handler.namespace=org.apache.felix.ipojo.transaction))");
+        Assert.assertNotNull(ref);
+        
+        // Create an install of the components
+        ComponentInstance prov = ipojo.createComponentInstance("org.apache.felix.ipojo.transaction.test.component.FooImpl");
+        ComponentInstance under = ipojo.createComponentInstance("requires-ok");
+        
+        Assert.assertEquals(ComponentInstance.VALID, prov.getState());
+        Assert.assertEquals(ComponentInstance.VALID, under.getState());
+        
+        ref = ipojo.getServiceReferenceByName(CheckService.class.getName(), under.getInstanceName());
+        Assert.assertNotNull(ref);
+
+        ((CheckService) osgi.getServiceObject(ref)).doSomethingGood();
+    }
+
+}
diff --git a/ipojo/tests/handler/transaction/src/test/java/org/apache/felix/ipojo/transaction/test/TestInvalidation.java b/ipojo/tests/handler/transaction/src/test/java/org/apache/felix/ipojo/transaction/test/TestInvalidation.java
new file mode 100644
index 0000000..a57a2a8
--- /dev/null
+++ b/ipojo/tests/handler/transaction/src/test/java/org/apache/felix/ipojo/transaction/test/TestInvalidation.java
@@ -0,0 +1,166 @@
+package org.apache.felix.ipojo.transaction.test;
+
+import static org.ops4j.pax.exam.CoreOptions.bundle;
+import static org.ops4j.pax.exam.CoreOptions.mavenBundle;
+import static org.ops4j.pax.exam.CoreOptions.options;
+import static org.ops4j.pax.exam.CoreOptions.provision;
+import static org.ops4j.pax.exam.MavenUtils.asInProject;
+import static org.ops4j.pax.tinybundles.core.TinyBundles.with;
+
+import java.io.File;
+import java.net.URL;
+
+import javax.transaction.HeuristicMixedException;
+import javax.transaction.HeuristicRollbackException;
+import javax.transaction.NotSupportedException;
+import javax.transaction.RollbackException;
+import javax.transaction.Status;
+import javax.transaction.SystemException;
+import javax.transaction.Transaction;
+import javax.transaction.TransactionManager;
+
+import org.apache.felix.ipojo.ComponentInstance;
+import org.apache.felix.ipojo.pax.exam.target.BundleAsiPOJO;
+import org.apache.felix.ipojo.transaction.test.component.FooDelegator;
+import org.apache.felix.ipojo.transaction.test.component.FooImpl;
+import org.apache.felix.ipojo.transaction.test.service.CheckService;
+import org.apache.felix.ipojo.transaction.test.service.Foo;
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.ops4j.pax.exam.Inject;
+import org.ops4j.pax.exam.Option;
+import org.ops4j.pax.exam.junit.Configuration;
+import org.ops4j.pax.exam.junit.JUnit4TestRunner;
+import org.ops4j.pax.tinybundles.core.TinyBundles;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.Constants;
+import org.osgi.framework.ServiceReference;
+
+@RunWith( JUnit4TestRunner.class )
+public class TestInvalidation {
+    
+    @Inject
+    private BundleContext context;
+    
+    private OSGiHelper osgi;
+    
+    private IPOJOHelper ipojo;
+    
+    public static final File ROOT = new File("target/tmp");
+    public static final File TEST = new File("src/test/resources");
+
+    
+    @Before
+    public void init() {
+        osgi = new OSGiHelper(context);
+        ipojo = new IPOJOHelper(context);
+    }
+    
+    @After
+    public void stop() {
+        ipojo.dispose();
+        osgi.dispose();
+    }
+    
+    @Configuration
+    public static Option[] configure() {    
+        ROOT.mkdirs();
+
+        
+        URL service = TinyBundles.newBundle()
+            .addClass(CheckService.class)
+            .addClass(Foo.class)
+           .prepare( 
+                with()
+                .set(Constants.BUNDLE_SYMBOLICNAME,"Service")
+                .set(Constants.EXPORT_PACKAGE, "org.apache.felix.ipojo.transaction.test.service")
+                .set(Constants.IMPORT_PACKAGE, "javax.transaction")
+                )
+            .build( TinyBundles.asURL());
+            
+        String fooimpl = TinyBundles.newBundle()
+            .addClass(FooImpl.class)
+            .prepare( 
+                    with()
+                    .set(Constants.BUNDLE_SYMBOLICNAME,"Foo Provider")
+                    .set(Constants.IMPORT_PACKAGE, "org.apache.felix.ipojo.transaction.test.service")
+                )
+                .build( new BundleAsiPOJO(new File(ROOT, "FooImpl.jar"), new File(TEST, "foo.xml"))  ).toExternalForm();
+        
+        String test = TinyBundles.newBundle()
+        .addClass(FooDelegator.class)
+        .prepare( 
+                with()
+                .set(Constants.BUNDLE_SYMBOLICNAME,"Required Transaction Propgatation")
+                .set(Constants.IMPORT_PACKAGE, "org.apache.felix.ipojo.transaction.test.service, javax.transaction")
+            )
+            .build( new BundleAsiPOJO(new File(ROOT, "requires.jar"), new File(TEST, "requires.xml"))  ).toExternalForm();
+    
+        
+        Option[] opt =  options(
+ 
+                provision(
+                        mavenBundle().groupId("org.ops4j.pax.logging").artifactId("pax-logging-api").version(asInProject()),
+                        mavenBundle().groupId("org.apache.felix").artifactId("org.apache.felix.ipojo").version(asInProject()),
+                        mavenBundle().groupId("org.apache.felix").artifactId("org.apache.felix.ipojo.transaction").version(asInProject()),
+                        mavenBundle().groupId("org.apache.felix").artifactId("org.apache.felix.transaction").version(asInProject()),
+                        mavenBundle()
+                        .groupId( "org.ops4j.pax.tinybundles" )
+                        .artifactId( "pax-tinybundles-core" )
+                        .version( "0.5.0-SNAPSHOT" ),
+                        bundle(service.toExternalForm()),
+                        bundle(fooimpl),
+                        bundle(test)
+                    )
+                )
+
+                ;
+        return opt;
+    }
+    
+    
+    
+    
+    @Test
+    public void testInvalidation() throws NotSupportedException, SystemException, SecurityException, HeuristicMixedException, HeuristicRollbackException, RollbackException {
+        final ComponentInstance prov = ipojo.createComponentInstance("org.apache.felix.ipojo.transaction.test.component.FooImpl");
+        ComponentInstance under = ipojo.createComponentInstance("requires-ok");
+        
+        Assert.assertEquals(ComponentInstance.VALID, prov.getState());
+        Assert.assertEquals(ComponentInstance.VALID, under.getState());
+        
+        ServiceReference ref = ipojo.getServiceReferenceByName(CheckService.class.getName(), under.getInstanceName());
+        Assert.assertNotNull(ref);
+        
+        CheckService cs = (CheckService) osgi.getServiceObject(ref);
+        TransactionManager tm = (TransactionManager) osgi.getServiceObject(TransactionManager.class.getName(), null);
+        
+        Thread thread = new Thread (new Runnable() {
+           public void run() {
+               try {
+                Thread.sleep(2000);
+            } catch (InterruptedException e) {
+                e.printStackTrace();
+            }
+               prov.dispose();
+           }
+        });
+        
+        thread.start();
+        
+        tm.begin();
+        Transaction t = tm.getTransaction();
+        cs.doSomethingLong(); // 5s, so prov should be disposed during this time and under becomes invalid
+        
+        Assert.assertEquals(ComponentInstance.INVALID, under.getState());
+        
+        Assert.assertEquals(Status.STATUS_MARKED_ROLLBACK, t.getStatus());
+        
+        t.rollback();
+    }
+    
+   
+}
diff --git a/ipojo/tests/handler/transaction/src/test/java/org/apache/felix/ipojo/transaction/test/TestMandatory.java b/ipojo/tests/handler/transaction/src/test/java/org/apache/felix/ipojo/transaction/test/TestMandatory.java
new file mode 100644
index 0000000..66772e2
--- /dev/null
+++ b/ipojo/tests/handler/transaction/src/test/java/org/apache/felix/ipojo/transaction/test/TestMandatory.java
@@ -0,0 +1,430 @@
+package org.apache.felix.ipojo.transaction.test;
+
+import static org.ops4j.pax.exam.CoreOptions.bundle;
+import static org.ops4j.pax.exam.CoreOptions.mavenBundle;
+import static org.ops4j.pax.exam.CoreOptions.options;
+import static org.ops4j.pax.exam.CoreOptions.provision;
+import static org.ops4j.pax.exam.MavenUtils.asInProject;
+import static org.ops4j.pax.tinybundles.core.TinyBundles.with;
+
+import java.io.File;
+import java.net.URL;
+
+import javax.transaction.HeuristicMixedException;
+import javax.transaction.HeuristicRollbackException;
+import javax.transaction.NotSupportedException;
+import javax.transaction.RollbackException;
+import javax.transaction.Status;
+import javax.transaction.SystemException;
+import javax.transaction.Transaction;
+import javax.transaction.TransactionManager;
+
+import org.apache.felix.ipojo.ComponentInstance;
+import org.apache.felix.ipojo.pax.exam.target.BundleAsiPOJO;
+import org.apache.felix.ipojo.transaction.test.component.FooDelegator;
+import org.apache.felix.ipojo.transaction.test.component.FooImpl;
+import org.apache.felix.ipojo.transaction.test.service.CheckService;
+import org.apache.felix.ipojo.transaction.test.service.Foo;
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.ops4j.pax.exam.Inject;
+import org.ops4j.pax.exam.Option;
+import org.ops4j.pax.exam.junit.Configuration;
+import org.ops4j.pax.exam.junit.JUnit4TestRunner;
+import org.ops4j.pax.tinybundles.core.TinyBundles;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.Constants;
+import org.osgi.framework.ServiceReference;
+
+@RunWith( JUnit4TestRunner.class )
+public class TestMandatory {
+    
+    @Inject
+    private BundleContext context;
+    
+    private OSGiHelper osgi;
+    
+    private IPOJOHelper ipojo;
+    
+    public static final File ROOT = new File("target/tmp");
+    public static final File TEST = new File("src/test/resources");
+
+    
+    @Before
+    public void init() {
+        osgi = new OSGiHelper(context);
+        ipojo = new IPOJOHelper(context);
+    }
+    
+    @After
+    public void stop() {
+        ipojo.dispose();
+        osgi.dispose();
+    }
+    
+    @Configuration
+    public static Option[] configure() {    
+        ROOT.mkdirs();
+
+        URL service = TinyBundles.newBundle()
+            .addClass(CheckService.class)
+            .addClass(Foo.class)
+           .prepare( 
+                with()
+                .set(Constants.BUNDLE_SYMBOLICNAME,"Service")
+                .set(Constants.EXPORT_PACKAGE, "org.apache.felix.ipojo.transaction.test.service")
+                .set(Constants.IMPORT_PACKAGE, "javax.transaction")
+                )
+            .build( TinyBundles.asURL());
+            
+        String fooimpl = TinyBundles.newBundle()
+            .addClass(FooImpl.class)
+            .prepare( 
+                    with()
+                    .set(Constants.BUNDLE_SYMBOLICNAME,"Foo Provider")
+                    .set(Constants.IMPORT_PACKAGE, "org.apache.felix.ipojo.transaction.test.service")
+                )
+                .build( new BundleAsiPOJO(new File(ROOT, "FooImpl.jar"), new File(TEST, "foo.xml"))  ).toExternalForm();
+        
+        String test = TinyBundles.newBundle()
+        .addClass(FooDelegator.class)
+        .prepare( 
+                with()
+                .set(Constants.BUNDLE_SYMBOLICNAME,"Mandatory Transaction Propgatation")
+                .set(Constants.IMPORT_PACKAGE, "org.apache.felix.ipojo.transaction.test.service, javax.transaction")
+            )
+            .build( new BundleAsiPOJO(new File(ROOT, "mandatory.jar"), new File(TEST, "mandatory.xml"))  ).toExternalForm();
+    
+        
+        Option[] opt =  options(
+ 
+                provision(
+                        mavenBundle().groupId("org.ops4j.pax.logging").artifactId("pax-logging-api").version(asInProject()),
+                        mavenBundle().groupId("org.apache.felix").artifactId("org.apache.felix.ipojo").version(asInProject()),
+                        mavenBundle().groupId("org.apache.felix").artifactId("org.apache.felix.ipojo.transaction").version(asInProject()),
+                        mavenBundle().groupId("org.apache.felix").artifactId("org.apache.felix.transaction").version(asInProject()),
+                        mavenBundle()
+                        .groupId( "org.ops4j.pax.tinybundles" )
+                        .artifactId( "pax-tinybundles-core" )
+                        .version( "0.5.0-SNAPSHOT" ),
+                        bundle(service.toExternalForm()),
+                        bundle(fooimpl),
+                        bundle(test)
+                    )
+                )
+
+                ;
+        return opt;
+    }
+    
+    
+    @Test(expected=RuntimeException.class)
+    public void testOkOutsideTransaction() {
+        ComponentInstance prov = ipojo.createComponentInstance("org.apache.felix.ipojo.transaction.test.component.FooImpl");
+        ComponentInstance under = ipojo.createComponentInstance("mandatory-ok");
+        
+        Assert.assertEquals(ComponentInstance.VALID, prov.getState());
+        Assert.assertEquals(ComponentInstance.VALID, under.getState());
+        
+        ServiceReference ref = ipojo.getServiceReferenceByName(CheckService.class.getName(), under.getInstanceName());
+        Assert.assertNotNull(ref);
+
+        ((CheckService) osgi.getServiceObject(ref)).doSomethingGood(); // Fail !
+    }
+    
+    @Test
+    public void testOkInsideTransaction() throws NotSupportedException, SystemException, SecurityException, HeuristicMixedException, HeuristicRollbackException, RollbackException {
+        ComponentInstance prov = ipojo.createComponentInstance("org.apache.felix.ipojo.transaction.test.component.FooImpl");
+        ComponentInstance under = ipojo.createComponentInstance("mandatory-ok");
+        
+        Assert.assertEquals(ComponentInstance.VALID, prov.getState());
+        Assert.assertEquals(ComponentInstance.VALID, under.getState());
+        
+        ServiceReference ref = ipojo.getServiceReferenceByName(CheckService.class.getName(), under.getInstanceName());
+        Assert.assertNotNull(ref);
+        
+        CheckService cs = (CheckService) osgi.getServiceObject(ref);
+        TransactionManager tm = (TransactionManager) osgi.getServiceObject(TransactionManager.class.getName(), null);
+        tm.begin();
+        Transaction t = tm.getTransaction();
+        cs.doSomethingGood();
+        Transaction t2 = cs.getCurrentTransaction();
+        Assert.assertSame(t2, t);
+        t.commit();
+    }
+    
+    @Test(expected=RuntimeException.class)
+    public void testExceptionOutsideTransaction() {
+        ComponentInstance prov = ipojo.createComponentInstance("org.apache.felix.ipojo.transaction.test.component.FooImpl");
+        ComponentInstance under = ipojo.createComponentInstance("mandatory-ok");
+        
+        Assert.assertEquals(ComponentInstance.VALID, prov.getState());
+        Assert.assertEquals(ComponentInstance.VALID, under.getState());
+        
+        ServiceReference ref = ipojo.getServiceReferenceByName(CheckService.class.getName(), under.getInstanceName());
+        Assert.assertNotNull(ref);
+
+        ((CheckService) osgi.getServiceObject(ref)).doSomethingBad(); // Fail, RTE thrown before the other exception
+    }
+    
+    @Test(expected=RollbackException.class)
+    public void testExceptionInsideTransaction() throws NotSupportedException, SystemException, SecurityException, HeuristicMixedException, HeuristicRollbackException, RollbackException {
+        ComponentInstance prov = ipojo.createComponentInstance("org.apache.felix.ipojo.transaction.test.component.FooImpl");
+        ComponentInstance under = ipojo.createComponentInstance("mandatory-ok");
+        
+        Assert.assertEquals(ComponentInstance.VALID, prov.getState());
+        Assert.assertEquals(ComponentInstance.VALID, under.getState());
+        
+        ServiceReference ref = ipojo.getServiceReferenceByName(CheckService.class.getName(), under.getInstanceName());
+        Assert.assertNotNull(ref);
+        
+        CheckService cs = (CheckService) osgi.getServiceObject(ref);
+        TransactionManager tm = (TransactionManager) osgi.getServiceObject(TransactionManager.class.getName(), null);
+        tm.begin();
+        Transaction t = tm.getTransaction();
+        try {
+            cs.doSomethingBad();
+            Assert.fail("NullPointerException expected");
+        } catch(Exception e) {
+            Assert.assertTrue(e instanceof NullPointerException);
+        }
+        Transaction t2 = cs.getCurrentTransaction();
+        Assert.assertSame(t2, t);
+        Assert.assertEquals(Status.STATUS_MARKED_ROLLBACK, t.getStatus());
+        
+        t.commit(); // Throws a rollback exception.
+    }
+    
+    @Test
+    public void testExceptionInsideTransactionRB() throws NotSupportedException, SystemException, SecurityException, HeuristicMixedException, HeuristicRollbackException, RollbackException {
+        ComponentInstance prov = ipojo.createComponentInstance("org.apache.felix.ipojo.transaction.test.component.FooImpl");
+        ComponentInstance under = ipojo.createComponentInstance("mandatory-ok");
+        
+        Assert.assertEquals(ComponentInstance.VALID, prov.getState());
+        Assert.assertEquals(ComponentInstance.VALID, under.getState());
+        
+        ServiceReference ref = ipojo.getServiceReferenceByName(CheckService.class.getName(), under.getInstanceName());
+        Assert.assertNotNull(ref);
+        
+        CheckService cs = (CheckService) osgi.getServiceObject(ref);
+        TransactionManager tm = (TransactionManager) osgi.getServiceObject(TransactionManager.class.getName(), null);
+        tm.begin();
+        Transaction t = tm.getTransaction();
+        try {
+            cs.doSomethingBad();
+            Assert.fail("NullPointerException expected");
+        } catch(Exception e) {
+            Assert.assertTrue(e instanceof NullPointerException);
+        }
+        Transaction t2 = cs.getCurrentTransaction();
+        Assert.assertSame(t2, t);
+        Assert.assertEquals(Status.STATUS_MARKED_ROLLBACK, t.getStatus());
+        
+        t.rollback();
+    }
+    
+    @Test(expected=RuntimeException.class)
+    public void testExpectedExceptionOutsideTransaction() {
+        ComponentInstance prov = ipojo.createComponentInstance("org.apache.felix.ipojo.transaction.test.component.FooImpl");
+        ComponentInstance under = ipojo.createComponentInstance("mandatory-ok");
+        
+        Assert.assertEquals(ComponentInstance.VALID, prov.getState());
+        Assert.assertEquals(ComponentInstance.VALID, under.getState());
+        
+        ServiceReference ref = ipojo.getServiceReferenceByName(CheckService.class.getName(), under.getInstanceName());
+        Assert.assertNotNull(ref);
+
+        ((CheckService) osgi.getServiceObject(ref)).doSomethingBad2(); // Throws a RTE
+    }
+    
+    @Test
+    public void testExpectedExceptionInsideTransaction() throws NotSupportedException, SystemException, SecurityException, HeuristicMixedException, HeuristicRollbackException, RollbackException {
+        ComponentInstance prov = ipojo.createComponentInstance("org.apache.felix.ipojo.transaction.test.component.FooImpl");
+        ComponentInstance under = ipojo.createComponentInstance("mandatory-ok");
+        
+        Assert.assertEquals(ComponentInstance.VALID, prov.getState());
+        Assert.assertEquals(ComponentInstance.VALID, under.getState());
+        
+        ServiceReference ref = ipojo.getServiceReferenceByName(CheckService.class.getName(), under.getInstanceName());
+        Assert.assertNotNull(ref);
+        
+        CheckService cs = (CheckService) osgi.getServiceObject(ref);
+        TransactionManager tm = (TransactionManager) osgi.getServiceObject(TransactionManager.class.getName(), null);
+        tm.begin();
+        Transaction t = tm.getTransaction();
+        try {
+            cs.doSomethingBad2();
+            Assert.fail("UnsupportedOperationException expected");
+        } catch(Exception e) {
+            Assert.assertTrue(e instanceof UnsupportedOperationException);
+        }
+        Transaction t2 = cs.getCurrentTransaction();
+        Assert.assertSame(t2, t);
+        Assert.assertEquals(Status.STATUS_ACTIVE, t.getStatus());
+        
+        t.commit();
+    }
+    
+    @Test(expected=RuntimeException.class)
+    public void testOkOutsideTransactionWithCallback() {
+        ComponentInstance prov = ipojo.createComponentInstance("org.apache.felix.ipojo.transaction.test.component.FooImpl");
+        ComponentInstance under = ipojo.createComponentInstance("mandatory-cb");
+        
+        Assert.assertEquals(ComponentInstance.VALID, prov.getState());
+        Assert.assertEquals(ComponentInstance.VALID, under.getState());
+        
+        ServiceReference ref = ipojo.getServiceReferenceByName(CheckService.class.getName(), under.getInstanceName());
+        Assert.assertNotNull(ref);
+
+        
+        CheckService cs = (CheckService) osgi.getServiceObject(ref);
+
+        cs.doSomethingGood(); // Throws a RTE.
+        
+    }
+    
+    @Test
+    public void testOkInsideTransactionWithCallback() throws NotSupportedException, SystemException, SecurityException, HeuristicMixedException, HeuristicRollbackException, RollbackException {
+        ComponentInstance prov = ipojo.createComponentInstance("org.apache.felix.ipojo.transaction.test.component.FooImpl");
+        ComponentInstance under = ipojo.createComponentInstance("mandatory-cb");
+        
+        Assert.assertEquals(ComponentInstance.VALID, prov.getState());
+        Assert.assertEquals(ComponentInstance.VALID, under.getState());
+        
+        ServiceReference ref = ipojo.getServiceReferenceByName(CheckService.class.getName(), under.getInstanceName());
+        Assert.assertNotNull(ref);
+        
+        CheckService cs = (CheckService) osgi.getServiceObject(ref);
+        TransactionManager tm = (TransactionManager) osgi.getServiceObject(TransactionManager.class.getName(), null);
+        tm.begin();
+        Transaction t = tm.getTransaction();
+        cs.doSomethingGood();
+        Transaction t2 = cs.getCurrentTransaction();
+        Assert.assertSame(t2, t);
+        t.commit();
+        
+        Assert.assertNull(cs.getLastRolledBack());
+        Assert.assertNotNull(cs.getLastCommitted());
+        Assert.assertEquals(1, cs.getNumberOfCommit());
+        Assert.assertEquals(0, cs.getNumberOfRollback());
+        
+        Assert.assertSame(t, cs.getLastCommitted());
+    }
+    
+    @Test(expected=RuntimeException.class)
+    public void testExceptionOutsideTransactionWithCallback() {
+        ComponentInstance prov = ipojo.createComponentInstance("org.apache.felix.ipojo.transaction.test.component.FooImpl");
+        ComponentInstance under = ipojo.createComponentInstance("mandatory-cb");
+        
+        Assert.assertEquals(ComponentInstance.VALID, prov.getState());
+        Assert.assertEquals(ComponentInstance.VALID, under.getState());
+        
+        ServiceReference ref = ipojo.getServiceReferenceByName(CheckService.class.getName(), under.getInstanceName());
+        Assert.assertNotNull(ref);
+
+        CheckService cs = (CheckService) osgi.getServiceObject(ref);
+
+        cs.doSomethingBad(); // Thows a RTE.
+       
+    }
+    
+    @Test
+    public void testExceptionInsideTransactionWithCallback() throws NotSupportedException, SystemException, SecurityException, HeuristicMixedException, HeuristicRollbackException, RollbackException {
+        ComponentInstance prov = ipojo.createComponentInstance("org.apache.felix.ipojo.transaction.test.component.FooImpl");
+        ComponentInstance under = ipojo.createComponentInstance("mandatory-cb");
+        
+        Assert.assertEquals(ComponentInstance.VALID, prov.getState());
+        Assert.assertEquals(ComponentInstance.VALID, under.getState());
+        
+        ServiceReference ref = ipojo.getServiceReferenceByName(CheckService.class.getName(), under.getInstanceName());
+        Assert.assertNotNull(ref);
+        
+        CheckService cs = (CheckService) osgi.getServiceObject(ref);
+        TransactionManager tm = (TransactionManager) osgi.getServiceObject(TransactionManager.class.getName(), null);
+        tm.begin();
+        Transaction t = tm.getTransaction();
+        try {
+            cs.doSomethingBad();
+            Assert.fail("NullPointerException expected");
+        } catch(Exception e) {
+            Assert.assertTrue(e instanceof NullPointerException);
+        }
+        Transaction t2 = cs.getCurrentTransaction();
+        Assert.assertSame(t2, t);
+        Assert.assertEquals(Status.STATUS_MARKED_ROLLBACK, t.getStatus());
+        
+        try {
+            t.commit(); // Throw a rollback exception.
+        } catch (RollbackException e) {
+            // Expected
+        } catch (Throwable e) {
+            Assert.fail(e.getMessage()); // Unexpected
+        }
+        
+        Assert.assertNotNull(cs.getLastRolledBack());
+        Assert.assertNull(cs.getLastCommitted());
+        Assert.assertEquals(0, cs.getNumberOfCommit());
+        Assert.assertEquals(1, cs.getNumberOfRollback());
+        
+        Assert.assertSame(t, cs.getLastRolledBack());
+    }
+    
+    @Test(expected=RuntimeException.class)
+    public void testExpectedExceptionOutsideTransactionWithCallback() {
+        ComponentInstance prov = ipojo.createComponentInstance("org.apache.felix.ipojo.transaction.test.component.FooImpl");
+        ComponentInstance under = ipojo.createComponentInstance("mandatory-cb");
+        
+        Assert.assertEquals(ComponentInstance.VALID, prov.getState());
+        Assert.assertEquals(ComponentInstance.VALID, under.getState());
+        
+        ServiceReference ref = ipojo.getServiceReferenceByName(CheckService.class.getName(), under.getInstanceName());
+        Assert.assertNotNull(ref);
+
+        CheckService cs = (CheckService) osgi.getServiceObject(ref);
+
+        cs.doSomethingBad2();
+        
+      
+    }
+    
+    @Test
+    public void testExpectedExceptionInsideTransactionWithCallback() throws NotSupportedException, SystemException, SecurityException, HeuristicMixedException, HeuristicRollbackException, RollbackException {
+        ComponentInstance prov = ipojo.createComponentInstance("org.apache.felix.ipojo.transaction.test.component.FooImpl");
+        ComponentInstance under = ipojo.createComponentInstance("mandatory-cb");
+        
+        Assert.assertEquals(ComponentInstance.VALID, prov.getState());
+        Assert.assertEquals(ComponentInstance.VALID, under.getState());
+        
+        ServiceReference ref = ipojo.getServiceReferenceByName(CheckService.class.getName(), under.getInstanceName());
+        Assert.assertNotNull(ref);
+        
+        CheckService cs = (CheckService) osgi.getServiceObject(ref);
+        TransactionManager tm = (TransactionManager) osgi.getServiceObject(TransactionManager.class.getName(), null);
+        tm.begin();
+        Transaction t = tm.getTransaction();
+        try {
+            cs.doSomethingBad2();
+            Assert.fail("UnsupportedOperationException expected");
+        } catch(Exception e) {
+            Assert.assertTrue(e instanceof UnsupportedOperationException);
+        }
+        Transaction t2 = cs.getCurrentTransaction();
+        Assert.assertSame(t2, t);
+        Assert.assertEquals(Status.STATUS_ACTIVE, t.getStatus());
+        
+        t.commit();
+        
+        Assert.assertNull(cs.getLastRolledBack());
+        Assert.assertNotNull(cs.getLastCommitted());
+        Assert.assertEquals(1, cs.getNumberOfCommit());
+        Assert.assertEquals(0, cs.getNumberOfRollback());
+        
+        Assert.assertSame(t, cs.getLastCommitted());
+    }
+    
+
+    
+}
diff --git a/ipojo/tests/handler/transaction/src/test/java/org/apache/felix/ipojo/transaction/test/TestNever.java b/ipojo/tests/handler/transaction/src/test/java/org/apache/felix/ipojo/transaction/test/TestNever.java
new file mode 100644
index 0000000..21d6369
--- /dev/null
+++ b/ipojo/tests/handler/transaction/src/test/java/org/apache/felix/ipojo/transaction/test/TestNever.java
@@ -0,0 +1,210 @@
+package org.apache.felix.ipojo.transaction.test;
+
+import static org.ops4j.pax.exam.CoreOptions.bundle;
+import static org.ops4j.pax.exam.CoreOptions.mavenBundle;
+import static org.ops4j.pax.exam.CoreOptions.options;
+import static org.ops4j.pax.exam.CoreOptions.provision;
+import static org.ops4j.pax.exam.MavenUtils.asInProject;
+import static org.ops4j.pax.tinybundles.core.TinyBundles.with;
+
+import java.io.File;
+import java.net.URL;
+
+import javax.transaction.HeuristicMixedException;
+import javax.transaction.HeuristicRollbackException;
+import javax.transaction.NotSupportedException;
+import javax.transaction.RollbackException;
+import javax.transaction.Status;
+import javax.transaction.SystemException;
+import javax.transaction.Transaction;
+import javax.transaction.TransactionManager;
+
+import org.apache.felix.ipojo.ComponentInstance;
+import org.apache.felix.ipojo.pax.exam.target.BundleAsiPOJO;
+import org.apache.felix.ipojo.transaction.test.component.FooDelegator;
+import org.apache.felix.ipojo.transaction.test.component.FooImpl;
+import org.apache.felix.ipojo.transaction.test.service.CheckService;
+import org.apache.felix.ipojo.transaction.test.service.Foo;
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.ops4j.pax.exam.Inject;
+import org.ops4j.pax.exam.Option;
+import org.ops4j.pax.exam.junit.Configuration;
+import org.ops4j.pax.exam.junit.JUnit4TestRunner;
+import org.ops4j.pax.tinybundles.core.TinyBundles;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.Constants;
+import org.osgi.framework.ServiceReference;
+
+@RunWith( JUnit4TestRunner.class )
+public class TestNever {
+    
+    @Inject
+    private BundleContext context;
+    
+    private OSGiHelper osgi;
+    
+    private IPOJOHelper ipojo;
+    public static final File ROOT = new File("target/tmp");
+    public static final File TEST = new File("src/test/resources");
+
+    
+    @Before
+    public void init() {
+        osgi = new OSGiHelper(context);
+        ipojo = new IPOJOHelper(context);
+    }
+    
+    @After
+    public void stop() {
+        ipojo.dispose();
+        osgi.dispose();
+    }
+    
+    @Configuration
+    public static Option[] configure() {    
+        ROOT.mkdirs();
+
+        URL service = TinyBundles.newBundle()
+            .addClass(CheckService.class)
+            .addClass(Foo.class)
+           .prepare( 
+                with()
+                .set(Constants.BUNDLE_SYMBOLICNAME,"Service")
+                .set(Constants.EXPORT_PACKAGE, "org.apache.felix.ipojo.transaction.test.service")
+                .set(Constants.IMPORT_PACKAGE, "javax.transaction")
+                )
+            .build( TinyBundles.asURL());
+            
+        String fooimpl = TinyBundles.newBundle()
+            .addClass(FooImpl.class)
+            .prepare( 
+                    with()
+                    .set(Constants.BUNDLE_SYMBOLICNAME,"Foo Provider")
+                    .set(Constants.IMPORT_PACKAGE, "org.apache.felix.ipojo.transaction.test.service")
+                )
+                .build( new BundleAsiPOJO(new File(ROOT,"FooImpl.jar"), new File(TEST, "foo.xml"))  ).toExternalForm();
+        
+        String test = TinyBundles.newBundle()
+        .addClass(FooDelegator.class)
+        .prepare( 
+                with()
+                .set(Constants.BUNDLE_SYMBOLICNAME,"Mandatory Transaction Propgatation")
+                .set(Constants.IMPORT_PACKAGE, "org.apache.felix.ipojo.transaction.test.service, javax.transaction")
+            )
+            .build( new BundleAsiPOJO(new File(ROOT, "never.jar"), new File(TEST, "never.xml"))  ).toExternalForm();
+    
+        
+        Option[] opt =  options(
+ 
+                provision(
+                        mavenBundle().groupId("org.ops4j.pax.logging").artifactId("pax-logging-api").version(asInProject()),
+                        mavenBundle().groupId("org.apache.felix").artifactId("org.apache.felix.ipojo").version(asInProject()),
+                        mavenBundle().groupId("org.apache.felix").artifactId("org.apache.felix.ipojo.transaction").version(asInProject()),
+                        mavenBundle().groupId("org.apache.felix").artifactId("org.apache.felix.transaction").version(asInProject()),
+                        mavenBundle()
+                        .groupId( "org.ops4j.pax.tinybundles" )
+                        .artifactId( "pax-tinybundles-core" )
+                        .version( "0.5.0-SNAPSHOT" ),
+                        bundle(service.toExternalForm()),
+                        bundle(fooimpl),
+                        bundle(test)
+                    )
+                )
+
+                ;
+        return opt;
+    }
+    
+    
+    @Test
+    public void testOkOutsideTransaction() {
+        ComponentInstance prov = ipojo.createComponentInstance("org.apache.felix.ipojo.transaction.test.component.FooImpl");
+        ComponentInstance under = ipojo.createComponentInstance("never-ok");
+        
+        Assert.assertEquals(ComponentInstance.VALID, prov.getState());
+        Assert.assertEquals(ComponentInstance.VALID, under.getState());
+        
+        ServiceReference ref = ipojo.getServiceReferenceByName(CheckService.class.getName(), under.getInstanceName());
+        Assert.assertNotNull(ref);
+
+        ((CheckService) osgi.getServiceObject(ref)).doSomethingGood();
+    }
+    
+    @Test(expected=RuntimeException.class)
+    public void testOkInsideTransaction() throws NotSupportedException, SystemException, SecurityException, HeuristicMixedException, HeuristicRollbackException, RollbackException {
+        ComponentInstance prov = ipojo.createComponentInstance("org.apache.felix.ipojo.transaction.test.component.FooImpl");
+        ComponentInstance under = ipojo.createComponentInstance("never-ok");
+        
+        Assert.assertEquals(ComponentInstance.VALID, prov.getState());
+        Assert.assertEquals(ComponentInstance.VALID, under.getState());
+        
+        ServiceReference ref = ipojo.getServiceReferenceByName(CheckService.class.getName(), under.getInstanceName());
+        Assert.assertNotNull(ref);
+        
+        CheckService cs = (CheckService) osgi.getServiceObject(ref);
+        TransactionManager tm = (TransactionManager) osgi.getServiceObject(TransactionManager.class.getName(), null);
+        tm.begin();
+        cs.doSomethingGood(); // Fail
+    }
+    
+    @Test(expected=NullPointerException.class)
+    public void testExceptionOutsideTransaction() {
+        ComponentInstance prov = ipojo.createComponentInstance("org.apache.felix.ipojo.transaction.test.component.FooImpl");
+        ComponentInstance under = ipojo.createComponentInstance("never-ok");
+        
+        Assert.assertEquals(ComponentInstance.VALID, prov.getState());
+        Assert.assertEquals(ComponentInstance.VALID, under.getState());
+        
+        ServiceReference ref = ipojo.getServiceReferenceByName(CheckService.class.getName(), under.getInstanceName());
+        Assert.assertNotNull(ref);
+
+        ((CheckService) osgi.getServiceObject(ref)).doSomethingBad(); // Throws an NPE 
+    }
+    
+    @Test
+    public void testExceptionInsideTransaction() throws NotSupportedException, SystemException, SecurityException, HeuristicMixedException, HeuristicRollbackException, RollbackException {
+        ComponentInstance prov = ipojo.createComponentInstance("org.apache.felix.ipojo.transaction.test.component.FooImpl");
+        ComponentInstance under = ipojo.createComponentInstance("never-ok");
+        
+        Assert.assertEquals(ComponentInstance.VALID, prov.getState());
+        Assert.assertEquals(ComponentInstance.VALID, under.getState());
+        
+        ServiceReference ref = ipojo.getServiceReferenceByName(CheckService.class.getName(), under.getInstanceName());
+        Assert.assertNotNull(ref);
+        
+        CheckService cs = (CheckService) osgi.getServiceObject(ref);
+        TransactionManager tm = (TransactionManager) osgi.getServiceObject(TransactionManager.class.getName(), null);
+        tm.begin();
+        Transaction t = tm.getTransaction();
+        try {
+            cs.doSomethingBad(); // Fail
+            Assert.fail("RuntimeException expected");
+        } catch(RuntimeException e) {
+            Assert.assertTrue(e instanceof RuntimeException);
+        }
+        Assert.assertEquals(Status.STATUS_ACTIVE, t.getStatus());
+        
+        t.rollback(); 
+    }
+    
+    @Test(expected=UnsupportedOperationException.class)
+    public void testExpectedExceptionOutsideTransaction() {
+        ComponentInstance prov = ipojo.createComponentInstance("org.apache.felix.ipojo.transaction.test.component.FooImpl");
+        ComponentInstance under = ipojo.createComponentInstance("never-ok");
+        
+        Assert.assertEquals(ComponentInstance.VALID, prov.getState());
+        Assert.assertEquals(ComponentInstance.VALID, under.getState());
+        
+        ServiceReference ref = ipojo.getServiceReferenceByName(CheckService.class.getName(), under.getInstanceName());
+        Assert.assertNotNull(ref);
+
+        ((CheckService) osgi.getServiceObject(ref)).doSomethingBad2(); 
+    }
+    
+   
+    
+}
diff --git a/ipojo/tests/handler/transaction/src/test/java/org/apache/felix/ipojo/transaction/test/TestNotSupported.java b/ipojo/tests/handler/transaction/src/test/java/org/apache/felix/ipojo/transaction/test/TestNotSupported.java
new file mode 100644
index 0000000..bd866fc
--- /dev/null
+++ b/ipojo/tests/handler/transaction/src/test/java/org/apache/felix/ipojo/transaction/test/TestNotSupported.java
@@ -0,0 +1,436 @@
+package org.apache.felix.ipojo.transaction.test;
+
+import static org.ops4j.pax.exam.CoreOptions.bundle;
+import static org.ops4j.pax.exam.CoreOptions.mavenBundle;
+import static org.ops4j.pax.exam.CoreOptions.options;
+import static org.ops4j.pax.exam.CoreOptions.provision;
+import static org.ops4j.pax.exam.MavenUtils.asInProject;
+import static org.ops4j.pax.tinybundles.core.TinyBundles.with;
+
+import java.io.File;
+import java.net.URL;
+
+import javax.transaction.HeuristicMixedException;
+import javax.transaction.HeuristicRollbackException;
+import javax.transaction.NotSupportedException;
+import javax.transaction.RollbackException;
+import javax.transaction.Status;
+import javax.transaction.SystemException;
+import javax.transaction.Transaction;
+import javax.transaction.TransactionManager;
+
+import org.apache.felix.ipojo.ComponentInstance;
+import org.apache.felix.ipojo.pax.exam.target.BundleAsiPOJO;
+import org.apache.felix.ipojo.transaction.test.component.FooDelegator;
+import org.apache.felix.ipojo.transaction.test.component.FooImpl;
+import org.apache.felix.ipojo.transaction.test.service.CheckService;
+import org.apache.felix.ipojo.transaction.test.service.Foo;
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.ops4j.pax.exam.Inject;
+import org.ops4j.pax.exam.Option;
+import org.ops4j.pax.exam.junit.Configuration;
+import org.ops4j.pax.exam.junit.JUnit4TestRunner;
+import org.ops4j.pax.tinybundles.core.TinyBundles;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.Constants;
+import org.osgi.framework.ServiceReference;
+
+@RunWith( JUnit4TestRunner.class )
+public class TestNotSupported {
+    
+    @Inject
+    private BundleContext context;
+    
+    private OSGiHelper osgi;
+    
+    private IPOJOHelper ipojo;
+    public static final File ROOT = new File("target/tmp");
+    public static final File TEST = new File("src/test/resources");
+
+    
+    @Before
+    public void init() {
+        osgi = new OSGiHelper(context);
+        ipojo = new IPOJOHelper(context);
+    }
+    
+    @After
+    public void stop() {
+        ipojo.dispose();
+        osgi.dispose();
+    }
+    
+    @Configuration
+    public static Option[] configure() {    
+        ROOT.mkdirs();
+
+        URL service = TinyBundles.newBundle()
+            .addClass(CheckService.class)
+            .addClass(Foo.class)
+           .prepare( 
+                with()
+                .set(Constants.BUNDLE_SYMBOLICNAME,"Service")
+                .set(Constants.EXPORT_PACKAGE, "org.apache.felix.ipojo.transaction.test.service")
+                .set(Constants.IMPORT_PACKAGE, "javax.transaction")
+                )
+            .build( TinyBundles.asURL());
+            
+        String fooimpl = TinyBundles.newBundle()
+            .addClass(FooImpl.class)
+            .prepare( 
+                    with()
+                    .set(Constants.BUNDLE_SYMBOLICNAME,"Foo Provider")
+                    .set(Constants.IMPORT_PACKAGE, "org.apache.felix.ipojo.transaction.test.service")
+                )
+                .build( new BundleAsiPOJO(new File(ROOT, "FooImpl.jar"), new File(TEST, "foo.xml"))  ).toExternalForm();
+        
+        String test = TinyBundles.newBundle()
+        .addClass(FooDelegator.class)
+        .prepare( 
+                with()
+                .set(Constants.BUNDLE_SYMBOLICNAME,"Required Transaction Propgatation")
+                .set(Constants.IMPORT_PACKAGE, "org.apache.felix.ipojo.transaction.test.service, javax.transaction")
+            )
+            .build( new BundleAsiPOJO(new File(ROOT, "notsupported.jar"), new File(TEST, "notsupported.xml"))  ).toExternalForm();
+    
+        
+        Option[] opt =  options(
+ 
+                provision(
+                        mavenBundle().groupId("org.ops4j.pax.logging").artifactId("pax-logging-api").version(asInProject()),
+                        mavenBundle().groupId("org.apache.felix").artifactId("org.apache.felix.ipojo").version(asInProject()),
+                        mavenBundle().groupId("org.apache.felix").artifactId("org.apache.felix.ipojo.transaction").version(asInProject()),
+                        mavenBundle().groupId("org.apache.felix").artifactId("org.apache.felix.transaction").version(asInProject()),
+                        mavenBundle()
+                        .groupId( "org.ops4j.pax.tinybundles" )
+                        .artifactId( "pax-tinybundles-core" )
+                        .version( "0.5.0-SNAPSHOT" ),
+                        bundle(service.toExternalForm()),
+                        bundle(fooimpl),
+                        bundle(test)
+                    )
+                )
+
+                ;
+        return opt;
+    }
+    
+    
+    @Test
+    public void testOkOutsideTransaction() {
+        ComponentInstance prov = ipojo.createComponentInstance("org.apache.felix.ipojo.transaction.test.component.FooImpl");
+        ComponentInstance under = ipojo.createComponentInstance("notsupported-ok");
+        
+        Assert.assertEquals(ComponentInstance.VALID, prov.getState());
+        Assert.assertEquals(ComponentInstance.VALID, under.getState());
+        
+        ServiceReference ref = ipojo.getServiceReferenceByName(CheckService.class.getName(), under.getInstanceName());
+        Assert.assertNotNull(ref);
+
+        CheckService cs = ((CheckService) osgi.getServiceObject(ref));
+        cs.doSomethingGood();
+        // No transaction.
+    }
+    
+    @Test
+    public void testOkInsideTransaction() throws NotSupportedException, SystemException, SecurityException, HeuristicMixedException, HeuristicRollbackException, RollbackException {
+        ComponentInstance prov = ipojo.createComponentInstance("org.apache.felix.ipojo.transaction.test.component.FooImpl");
+        ComponentInstance under = ipojo.createComponentInstance("notsupported-ok");
+        
+        Assert.assertEquals(ComponentInstance.VALID, prov.getState());
+        Assert.assertEquals(ComponentInstance.VALID, under.getState());
+        
+        ServiceReference ref = ipojo.getServiceReferenceByName(CheckService.class.getName(), under.getInstanceName());
+        Assert.assertNotNull(ref);
+        
+        CheckService cs = (CheckService) osgi.getServiceObject(ref);
+        TransactionManager tm = (TransactionManager) osgi.getServiceObject(TransactionManager.class.getName(), null);
+        tm.begin();
+        Transaction t = tm.getTransaction();
+        cs.doSomethingGood();
+        Transaction t2 = cs.getCurrentTransaction(); // Is executed in the transaction despite it's not supported.
+        Assert.assertSame(t2, t);
+        t.commit();
+    }
+    
+    @Test(expected=NullPointerException.class)
+    public void testExceptionOutsideTransaction() {
+        ComponentInstance prov = ipojo.createComponentInstance("org.apache.felix.ipojo.transaction.test.component.FooImpl");
+        ComponentInstance under = ipojo.createComponentInstance("notsupported-ok");
+        
+        Assert.assertEquals(ComponentInstance.VALID, prov.getState());
+        Assert.assertEquals(ComponentInstance.VALID, under.getState());
+        
+        ServiceReference ref = ipojo.getServiceReferenceByName(CheckService.class.getName(), under.getInstanceName());
+        Assert.assertNotNull(ref);
+
+        ((CheckService) osgi.getServiceObject(ref)).doSomethingBad();
+    }
+    
+    @Test
+    public void testExceptionInsideTransaction() throws NotSupportedException, SystemException, SecurityException, HeuristicMixedException, HeuristicRollbackException, RollbackException {
+        ComponentInstance prov = ipojo.createComponentInstance("org.apache.felix.ipojo.transaction.test.component.FooImpl");
+        ComponentInstance under = ipojo.createComponentInstance("notsupported-ok");
+        
+        Assert.assertEquals(ComponentInstance.VALID, prov.getState());
+        Assert.assertEquals(ComponentInstance.VALID, under.getState());
+        
+        ServiceReference ref = ipojo.getServiceReferenceByName(CheckService.class.getName(), under.getInstanceName());
+        Assert.assertNotNull(ref);
+        
+        CheckService cs = (CheckService) osgi.getServiceObject(ref);
+        TransactionManager tm = (TransactionManager) osgi.getServiceObject(TransactionManager.class.getName(), null);
+        tm.begin();
+        Transaction t = tm.getTransaction();
+        try {
+            cs.doSomethingBad();
+            Assert.fail("NullPointerException expected");
+        } catch(Exception e) {
+            Assert.assertTrue(e instanceof NullPointerException);
+        }
+        Transaction t2 = cs.getCurrentTransaction();
+        Assert.assertSame(t2, t);
+        Assert.assertEquals(Status.STATUS_ACTIVE, t.getStatus()); // No impact on the transaction.
+        
+        t.commit(); // Ok.
+    }
+    
+    @Test
+    public void testExceptionInsideTransactionRB() throws NotSupportedException, SystemException, SecurityException, HeuristicMixedException, HeuristicRollbackException, RollbackException {
+        ComponentInstance prov = ipojo.createComponentInstance("org.apache.felix.ipojo.transaction.test.component.FooImpl");
+        ComponentInstance under = ipojo.createComponentInstance("notsupported-ok");
+        
+        Assert.assertEquals(ComponentInstance.VALID, prov.getState());
+        Assert.assertEquals(ComponentInstance.VALID, under.getState());
+        
+        ServiceReference ref = ipojo.getServiceReferenceByName(CheckService.class.getName(), under.getInstanceName());
+        Assert.assertNotNull(ref);
+        
+        CheckService cs = (CheckService) osgi.getServiceObject(ref);
+        TransactionManager tm = (TransactionManager) osgi.getServiceObject(TransactionManager.class.getName(), null);
+        tm.begin();
+        Transaction t = tm.getTransaction();
+        try {
+            cs.doSomethingBad();
+            Assert.fail("NullPointerException expected");
+        } catch(Exception e) {
+            Assert.assertTrue(e instanceof NullPointerException);
+        }
+        Transaction t2 = cs.getCurrentTransaction();
+        Assert.assertSame(t2, t);
+        Assert.assertEquals(Status.STATUS_ACTIVE, t.getStatus()); // No impact on the transaction.
+        
+        t.rollback(); // Ok.
+    }
+    
+    @Test(expected=UnsupportedOperationException.class)
+    public void testExpectedExceptionOutsideTransaction() {
+        ComponentInstance prov = ipojo.createComponentInstance("org.apache.felix.ipojo.transaction.test.component.FooImpl");
+        ComponentInstance under = ipojo.createComponentInstance("notsupported-ok");
+        
+        Assert.assertEquals(ComponentInstance.VALID, prov.getState());
+        Assert.assertEquals(ComponentInstance.VALID, under.getState());
+        
+        ServiceReference ref = ipojo.getServiceReferenceByName(CheckService.class.getName(), under.getInstanceName());
+        Assert.assertNotNull(ref);
+
+        ((CheckService) osgi.getServiceObject(ref)).doSomethingBad2();
+    }
+    
+    @Test
+    public void testExpectedExceptionInsideTransaction() throws NotSupportedException, SystemException, SecurityException, HeuristicMixedException, HeuristicRollbackException, RollbackException {
+        ComponentInstance prov = ipojo.createComponentInstance("org.apache.felix.ipojo.transaction.test.component.FooImpl");
+        ComponentInstance under = ipojo.createComponentInstance("notsupported-ok");
+        
+        Assert.assertEquals(ComponentInstance.VALID, prov.getState());
+        Assert.assertEquals(ComponentInstance.VALID, under.getState());
+        
+        ServiceReference ref = ipojo.getServiceReferenceByName(CheckService.class.getName(), under.getInstanceName());
+        Assert.assertNotNull(ref);
+        
+        CheckService cs = (CheckService) osgi.getServiceObject(ref);
+        TransactionManager tm = (TransactionManager) osgi.getServiceObject(TransactionManager.class.getName(), null);
+        tm.begin();
+        Transaction t = tm.getTransaction();
+        try {
+            cs.doSomethingBad2();
+            Assert.fail("UnsupportedOperationException expected");
+        } catch(Exception e) {
+            Assert.assertTrue(e instanceof UnsupportedOperationException);
+        }
+        Transaction t2 = cs.getCurrentTransaction();
+        Assert.assertSame(t2, t);
+        Assert.assertEquals(Status.STATUS_ACTIVE, t.getStatus());
+        
+        t.commit();
+    }
+    
+    @Test
+    public void testOkOutsideTransactionWithCallback() {
+        ComponentInstance prov = ipojo.createComponentInstance("org.apache.felix.ipojo.transaction.test.component.FooImpl");
+        ComponentInstance under = ipojo.createComponentInstance("notsupported-cb");
+        
+        Assert.assertEquals(ComponentInstance.VALID, prov.getState());
+        Assert.assertEquals(ComponentInstance.VALID, under.getState());
+        
+        ServiceReference ref = ipojo.getServiceReferenceByName(CheckService.class.getName(), under.getInstanceName());
+        Assert.assertNotNull(ref);
+
+        
+        CheckService cs = (CheckService) osgi.getServiceObject(ref);
+
+        cs.doSomethingGood();
+        
+        Assert.assertNull(cs.getLastRolledBack());
+        Assert.assertNull(cs.getLastCommitted());
+        Assert.assertEquals(0, cs.getNumberOfCommit());
+        Assert.assertEquals(0, cs.getNumberOfRollback());
+    }
+    
+    @Test
+    public void testOkInsideTransactionWithCallback() throws NotSupportedException, SystemException, SecurityException, HeuristicMixedException, HeuristicRollbackException, RollbackException {
+        ComponentInstance prov = ipojo.createComponentInstance("org.apache.felix.ipojo.transaction.test.component.FooImpl");
+        ComponentInstance under = ipojo.createComponentInstance("notsupported-cb");
+        
+        Assert.assertEquals(ComponentInstance.VALID, prov.getState());
+        Assert.assertEquals(ComponentInstance.VALID, under.getState());
+        
+        ServiceReference ref = ipojo.getServiceReferenceByName(CheckService.class.getName(), under.getInstanceName());
+        Assert.assertNotNull(ref);
+        
+        CheckService cs = (CheckService) osgi.getServiceObject(ref);
+        TransactionManager tm = (TransactionManager) osgi.getServiceObject(TransactionManager.class.getName(), null);
+        tm.begin();
+        Transaction t = tm.getTransaction();
+        cs.doSomethingGood();
+        Transaction t2 = cs.getCurrentTransaction();
+        Assert.assertSame(t2, t);
+        t.commit();
+        
+        Assert.assertNull(cs.getLastRolledBack());
+        Assert.assertNull(cs.getLastCommitted());
+        Assert.assertEquals(0, cs.getNumberOfCommit());
+        Assert.assertEquals(0, cs.getNumberOfRollback());
+    }
+    
+    @Test(expected=NullPointerException.class)
+    public void testExceptionOutsideTransactionWithCallback() {
+        ComponentInstance prov = ipojo.createComponentInstance("org.apache.felix.ipojo.transaction.test.component.FooImpl");
+        ComponentInstance under = ipojo.createComponentInstance("notsupported-cb");
+        
+        Assert.assertEquals(ComponentInstance.VALID, prov.getState());
+        Assert.assertEquals(ComponentInstance.VALID, under.getState());
+        
+        ServiceReference ref = ipojo.getServiceReferenceByName(CheckService.class.getName(), under.getInstanceName());
+        Assert.assertNotNull(ref);
+
+        CheckService cs = (CheckService) osgi.getServiceObject(ref);
+
+        cs.doSomethingBad();
+        
+        Assert.assertNull(cs.getLastRolledBack());
+        Assert.assertNull(cs.getLastCommitted());
+        Assert.assertEquals(0, cs.getNumberOfCommit());
+        Assert.assertEquals(0, cs.getNumberOfRollback());
+    }
+    
+    @Test
+    public void testExceptionInsideTransactionWithCallback() throws NotSupportedException, SystemException, SecurityException, HeuristicMixedException, HeuristicRollbackException, RollbackException {
+        ComponentInstance prov = ipojo.createComponentInstance("org.apache.felix.ipojo.transaction.test.component.FooImpl");
+        ComponentInstance under = ipojo.createComponentInstance("notsupported-cb");
+        
+        Assert.assertEquals(ComponentInstance.VALID, prov.getState());
+        Assert.assertEquals(ComponentInstance.VALID, under.getState());
+        
+        ServiceReference ref = ipojo.getServiceReferenceByName(CheckService.class.getName(), under.getInstanceName());
+        Assert.assertNotNull(ref);
+        
+        CheckService cs = (CheckService) osgi.getServiceObject(ref);
+        TransactionManager tm = (TransactionManager) osgi.getServiceObject(TransactionManager.class.getName(), null);
+        tm.begin();
+        Transaction t = tm.getTransaction();
+        try {
+            cs.doSomethingBad();
+            Assert.fail("NullPointerException expected");
+        } catch(Exception e) {
+            Assert.assertTrue(e instanceof NullPointerException);
+        }
+        Transaction t2 = cs.getCurrentTransaction();
+        Assert.assertSame(t2, t);
+        Assert.assertEquals(Status.STATUS_ACTIVE, t.getStatus()); // No effect on the transaction
+        
+        try {
+            t.commit(); // Throw a rollback exception.
+        } catch (RollbackException e) {
+            // Expected
+        } catch (Throwable e) {
+            Assert.fail(e.getMessage()); // Unexpected
+        }
+        
+        Assert.assertNull(cs.getLastRolledBack());
+        Assert.assertNull(cs.getLastCommitted());
+        Assert.assertEquals(0, cs.getNumberOfCommit());
+        Assert.assertEquals(0, cs.getNumberOfRollback());
+    }
+    
+    @Test(expected=UnsupportedOperationException.class)
+    public void testExpectedExceptionOutsideTransactionWithCallback() {
+        ComponentInstance prov = ipojo.createComponentInstance("org.apache.felix.ipojo.transaction.test.component.FooImpl");
+        ComponentInstance under = ipojo.createComponentInstance("notsupported-cb");
+        
+        Assert.assertEquals(ComponentInstance.VALID, prov.getState());
+        Assert.assertEquals(ComponentInstance.VALID, under.getState());
+        
+        ServiceReference ref = ipojo.getServiceReferenceByName(CheckService.class.getName(), under.getInstanceName());
+        Assert.assertNotNull(ref);
+
+        CheckService cs = (CheckService) osgi.getServiceObject(ref);
+
+        cs.doSomethingBad2();
+        
+        Assert.assertNull(cs.getLastRolledBack());
+        Assert.assertNull(cs.getLastCommitted());
+        Assert.assertEquals(0, cs.getNumberOfCommit());
+        Assert.assertEquals(0, cs.getNumberOfRollback());
+    }
+    
+    @Test
+    public void testExpectedExceptionInsideTransactionWithCallback() throws NotSupportedException, SystemException, SecurityException, HeuristicMixedException, HeuristicRollbackException, RollbackException {
+        ComponentInstance prov = ipojo.createComponentInstance("org.apache.felix.ipojo.transaction.test.component.FooImpl");
+        ComponentInstance under = ipojo.createComponentInstance("notsupported-cb");
+        
+        Assert.assertEquals(ComponentInstance.VALID, prov.getState());
+        Assert.assertEquals(ComponentInstance.VALID, under.getState());
+        
+        ServiceReference ref = ipojo.getServiceReferenceByName(CheckService.class.getName(), under.getInstanceName());
+        Assert.assertNotNull(ref);
+        
+        CheckService cs = (CheckService) osgi.getServiceObject(ref);
+        TransactionManager tm = (TransactionManager) osgi.getServiceObject(TransactionManager.class.getName(), null);
+        tm.begin();
+        Transaction t = tm.getTransaction();
+        try {
+            cs.doSomethingBad2();
+            Assert.fail("UnsupportedOperationException expected");
+        } catch(Exception e) {
+            Assert.assertTrue(e instanceof UnsupportedOperationException);
+        }
+        Transaction t2 = cs.getCurrentTransaction();
+        Assert.assertSame(t2, t);
+        Assert.assertEquals(Status.STATUS_ACTIVE, t.getStatus());
+        
+        t.commit();
+        
+        Assert.assertNull(cs.getLastRolledBack());
+        Assert.assertNull(cs.getLastCommitted());
+        Assert.assertEquals(0, cs.getNumberOfCommit());
+        Assert.assertEquals(0, cs.getNumberOfRollback());
+    }
+    
+
+    
+}
diff --git a/ipojo/tests/handler/transaction/src/test/java/org/apache/felix/ipojo/transaction/test/TestRequires.java b/ipojo/tests/handler/transaction/src/test/java/org/apache/felix/ipojo/transaction/test/TestRequires.java
new file mode 100644
index 0000000..75839a3
--- /dev/null
+++ b/ipojo/tests/handler/transaction/src/test/java/org/apache/felix/ipojo/transaction/test/TestRequires.java
@@ -0,0 +1,441 @@
+package org.apache.felix.ipojo.transaction.test;
+
+import static org.ops4j.pax.exam.CoreOptions.bundle;
+import static org.ops4j.pax.exam.CoreOptions.mavenBundle;
+import static org.ops4j.pax.exam.CoreOptions.options;
+import static org.ops4j.pax.exam.CoreOptions.provision;
+import static org.ops4j.pax.exam.MavenUtils.asInProject;
+import static org.ops4j.pax.tinybundles.core.TinyBundles.with;
+
+import java.io.File;
+import java.net.URL;
+
+import javax.transaction.HeuristicMixedException;
+import javax.transaction.HeuristicRollbackException;
+import javax.transaction.NotSupportedException;
+import javax.transaction.RollbackException;
+import javax.transaction.Status;
+import javax.transaction.SystemException;
+import javax.transaction.Transaction;
+import javax.transaction.TransactionManager;
+
+import org.apache.felix.ipojo.ComponentInstance;
+import org.apache.felix.ipojo.pax.exam.target.BundleAsiPOJO;
+import org.apache.felix.ipojo.transaction.test.component.FooDelegator;
+import org.apache.felix.ipojo.transaction.test.component.FooImpl;
+import org.apache.felix.ipojo.transaction.test.service.CheckService;
+import org.apache.felix.ipojo.transaction.test.service.Foo;
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.ops4j.pax.exam.Inject;
+import org.ops4j.pax.exam.Option;
+import org.ops4j.pax.exam.junit.Configuration;
+import org.ops4j.pax.exam.junit.JUnit4TestRunner;
+import org.ops4j.pax.tinybundles.core.TinyBundles;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.Constants;
+import org.osgi.framework.ServiceReference;
+
+@RunWith( JUnit4TestRunner.class )
+public class TestRequires {
+    
+    @Inject
+    private BundleContext context;
+    
+    private OSGiHelper osgi;
+    
+    private IPOJOHelper ipojo;
+    
+    public static final File ROOT = new File("target/tmp");
+    public static final File TEST = new File("src/test/resources");
+
+    
+    @Before
+    public void init() {
+        osgi = new OSGiHelper(context);
+        ipojo = new IPOJOHelper(context);
+    }
+    
+    @After
+    public void stop() {
+        ipojo.dispose();
+        osgi.dispose();
+    }
+    
+    @Configuration
+    public static Option[] configure() {    
+        ROOT.mkdirs();
+
+        URL service = TinyBundles.newBundle()
+            .addClass(CheckService.class)
+            .addClass(Foo.class)
+           .prepare( 
+                with()
+                .set(Constants.BUNDLE_SYMBOLICNAME,"Service")
+                .set(Constants.EXPORT_PACKAGE, "org.apache.felix.ipojo.transaction.test.service")
+                .set(Constants.IMPORT_PACKAGE, "javax.transaction")
+                )
+            .build( TinyBundles.asURL());
+            
+        String fooimpl = TinyBundles.newBundle()
+            .addClass(FooImpl.class)
+            .prepare( 
+                    with()
+                    .set(Constants.BUNDLE_SYMBOLICNAME,"Foo Provider")
+                    .set(Constants.IMPORT_PACKAGE, "org.apache.felix.ipojo.transaction.test.service")
+                )
+                .build( new BundleAsiPOJO(new File(ROOT, "FooImpl.jar"), new File(TEST, "foo.xml"))  ).toExternalForm();
+        
+        String test = TinyBundles.newBundle()
+        .addClass(FooDelegator.class)
+        .prepare( 
+                with()
+                .set(Constants.BUNDLE_SYMBOLICNAME,"Required Transaction Propgatation")
+                .set(Constants.IMPORT_PACKAGE, "org.apache.felix.ipojo.transaction.test.service, javax.transaction")
+            )
+            .build( new BundleAsiPOJO(new File(ROOT, "requires.jar"), new File(TEST, "requires.xml"))  ).toExternalForm();
+    
+        
+        Option[] opt =  options(
+ 
+                provision(
+                        mavenBundle().groupId("org.ops4j.pax.logging").artifactId("pax-logging-api").version(asInProject()),
+                        mavenBundle().groupId("org.apache.felix").artifactId("org.apache.felix.ipojo").version(asInProject()),
+                        mavenBundle().groupId("org.apache.felix").artifactId("org.apache.felix.ipojo.transaction").version(asInProject()),
+                        mavenBundle().groupId("org.apache.felix").artifactId("org.apache.felix.transaction").version(asInProject()),
+                        mavenBundle()
+                        .groupId( "org.ops4j.pax.tinybundles" )
+                        .artifactId( "pax-tinybundles-core" )
+                        .version( "0.5.0-SNAPSHOT" ),
+                        bundle(service.toExternalForm()),
+                        bundle(fooimpl),
+                        bundle(test)
+                    )
+                )
+
+                ;
+        return opt;
+    }
+    
+    
+    @Test
+    public void testOkOutsideTransaction() {
+        ComponentInstance prov = ipojo.createComponentInstance("org.apache.felix.ipojo.transaction.test.component.FooImpl");
+        ComponentInstance under = ipojo.createComponentInstance("requires-ok");
+        
+        Assert.assertEquals(ComponentInstance.VALID, prov.getState());
+        Assert.assertEquals(ComponentInstance.VALID, under.getState());
+        
+        ServiceReference ref = ipojo.getServiceReferenceByName(CheckService.class.getName(), under.getInstanceName());
+        Assert.assertNotNull(ref);
+
+        ((CheckService) osgi.getServiceObject(ref)).doSomethingGood();
+    }
+    
+    @Test
+    public void testOkInsideTransaction() throws NotSupportedException, SystemException, SecurityException, HeuristicMixedException, HeuristicRollbackException, RollbackException {
+        ComponentInstance prov = ipojo.createComponentInstance("org.apache.felix.ipojo.transaction.test.component.FooImpl");
+        ComponentInstance under = ipojo.createComponentInstance("requires-ok");
+        
+        Assert.assertEquals(ComponentInstance.VALID, prov.getState());
+        Assert.assertEquals(ComponentInstance.VALID, under.getState());
+        
+        ServiceReference ref = ipojo.getServiceReferenceByName(CheckService.class.getName(), under.getInstanceName());
+        Assert.assertNotNull(ref);
+        
+        CheckService cs = (CheckService) osgi.getServiceObject(ref);
+        TransactionManager tm = (TransactionManager) osgi.getServiceObject(TransactionManager.class.getName(), null);
+        tm.begin();
+        Transaction t = tm.getTransaction();
+        cs.doSomethingGood();
+        Transaction t2 = cs.getCurrentTransaction();
+        Assert.assertSame(t2, t);
+        t.commit();
+    }
+    
+    @Test(expected=NullPointerException.class)
+    public void testExceptionOutsideTransaction() {
+        ComponentInstance prov = ipojo.createComponentInstance("org.apache.felix.ipojo.transaction.test.component.FooImpl");
+        ComponentInstance under = ipojo.createComponentInstance("requires-ok");
+        
+        Assert.assertEquals(ComponentInstance.VALID, prov.getState());
+        Assert.assertEquals(ComponentInstance.VALID, under.getState());
+        
+        ServiceReference ref = ipojo.getServiceReferenceByName(CheckService.class.getName(), under.getInstanceName());
+        Assert.assertNotNull(ref);
+
+        ((CheckService) osgi.getServiceObject(ref)).doSomethingBad();
+    }
+    
+    @Test(expected=RollbackException.class)
+    public void testExceptionInsideTransaction() throws NotSupportedException, SystemException, SecurityException, HeuristicMixedException, HeuristicRollbackException, RollbackException {
+        ComponentInstance prov = ipojo.createComponentInstance("org.apache.felix.ipojo.transaction.test.component.FooImpl");
+        ComponentInstance under = ipojo.createComponentInstance("requires-ok");
+        
+        Assert.assertEquals(ComponentInstance.VALID, prov.getState());
+        Assert.assertEquals(ComponentInstance.VALID, under.getState());
+        
+        ServiceReference ref = ipojo.getServiceReferenceByName(CheckService.class.getName(), under.getInstanceName());
+        Assert.assertNotNull(ref);
+        
+        CheckService cs = (CheckService) osgi.getServiceObject(ref);
+        TransactionManager tm = (TransactionManager) osgi.getServiceObject(TransactionManager.class.getName(), null);
+        tm.begin();
+        Transaction t = tm.getTransaction();
+        try {
+            cs.doSomethingBad();
+            Assert.fail("NullPointerException expected");
+        } catch(Exception e) {
+            Assert.assertTrue(e instanceof NullPointerException);
+        }
+        Transaction t2 = cs.getCurrentTransaction();
+        Assert.assertSame(t2, t);
+        Assert.assertEquals(Status.STATUS_MARKED_ROLLBACK, t.getStatus());
+        
+        t.commit(); // Throw a rollback exception.
+    }
+    
+    @Test
+    public void testExceptionInsideTransactionRB() throws NotSupportedException, SystemException, SecurityException, HeuristicMixedException, HeuristicRollbackException, RollbackException {
+        ComponentInstance prov = ipojo.createComponentInstance("org.apache.felix.ipojo.transaction.test.component.FooImpl");
+        ComponentInstance under = ipojo.createComponentInstance("requires-ok");
+        
+        Assert.assertEquals(ComponentInstance.VALID, prov.getState());
+        Assert.assertEquals(ComponentInstance.VALID, under.getState());
+        
+        ServiceReference ref = ipojo.getServiceReferenceByName(CheckService.class.getName(), under.getInstanceName());
+        Assert.assertNotNull(ref);
+        
+        CheckService cs = (CheckService) osgi.getServiceObject(ref);
+        TransactionManager tm = (TransactionManager) osgi.getServiceObject(TransactionManager.class.getName(), null);
+        tm.begin();
+        Transaction t = tm.getTransaction();
+        try {
+            cs.doSomethingBad();
+            Assert.fail("NullPointerException expected");
+        } catch(Exception e) {
+            Assert.assertTrue(e instanceof NullPointerException);
+        }
+        Transaction t2 = cs.getCurrentTransaction();
+        Assert.assertSame(t2, t);
+        Assert.assertEquals(Status.STATUS_MARKED_ROLLBACK, t.getStatus());
+        
+        t.rollback();
+    }
+    
+    @Test(expected=UnsupportedOperationException.class)
+    public void testExpectedExceptionOutsideTransaction() {
+        ComponentInstance prov = ipojo.createComponentInstance("org.apache.felix.ipojo.transaction.test.component.FooImpl");
+        ComponentInstance under = ipojo.createComponentInstance("requires-ok");
+        
+        Assert.assertEquals(ComponentInstance.VALID, prov.getState());
+        Assert.assertEquals(ComponentInstance.VALID, under.getState());
+        
+        ServiceReference ref = ipojo.getServiceReferenceByName(CheckService.class.getName(), under.getInstanceName());
+        Assert.assertNotNull(ref);
+
+        ((CheckService) osgi.getServiceObject(ref)).doSomethingBad2();
+    }
+    
+    @Test
+    public void testExpectedExceptionInsideTransaction() throws NotSupportedException, SystemException, SecurityException, HeuristicMixedException, HeuristicRollbackException, RollbackException {
+        ComponentInstance prov = ipojo.createComponentInstance("org.apache.felix.ipojo.transaction.test.component.FooImpl");
+        ComponentInstance under = ipojo.createComponentInstance("requires-ok");
+        
+        Assert.assertEquals(ComponentInstance.VALID, prov.getState());
+        Assert.assertEquals(ComponentInstance.VALID, under.getState());
+        
+        ServiceReference ref = ipojo.getServiceReferenceByName(CheckService.class.getName(), under.getInstanceName());
+        Assert.assertNotNull(ref);
+        
+        CheckService cs = (CheckService) osgi.getServiceObject(ref);
+        TransactionManager tm = (TransactionManager) osgi.getServiceObject(TransactionManager.class.getName(), null);
+        tm.begin();
+        Transaction t = tm.getTransaction();
+        try {
+            cs.doSomethingBad2();
+            Assert.fail("UnsupportedOperationException expected");
+        } catch(Exception e) {
+            Assert.assertTrue(e instanceof UnsupportedOperationException);
+        }
+        Transaction t2 = cs.getCurrentTransaction();
+        Assert.assertSame(t2, t);
+        Assert.assertEquals(Status.STATUS_ACTIVE, t.getStatus());
+        
+        t.commit();
+    }
+    
+    @Test
+    public void testOkOutsideTransactionWithCallback() {
+        ComponentInstance prov = ipojo.createComponentInstance("org.apache.felix.ipojo.transaction.test.component.FooImpl");
+        ComponentInstance under = ipojo.createComponentInstance("requires-cb");
+        
+        Assert.assertEquals(ComponentInstance.VALID, prov.getState());
+        Assert.assertEquals(ComponentInstance.VALID, under.getState());
+        
+        ServiceReference ref = ipojo.getServiceReferenceByName(CheckService.class.getName(), under.getInstanceName());
+        Assert.assertNotNull(ref);
+
+        
+        CheckService cs = (CheckService) osgi.getServiceObject(ref);
+
+        cs.doSomethingGood();
+        
+        Assert.assertNull(cs.getLastRolledBack());
+        Assert.assertNotNull(cs.getLastCommitted());
+        Assert.assertEquals(1, cs.getNumberOfCommit());
+        Assert.assertEquals(0, cs.getNumberOfRollback());
+    }
+    
+    @Test
+    public void testOkInsideTransactionWithCallback() throws NotSupportedException, SystemException, SecurityException, HeuristicMixedException, HeuristicRollbackException, RollbackException {
+        ComponentInstance prov = ipojo.createComponentInstance("org.apache.felix.ipojo.transaction.test.component.FooImpl");
+        ComponentInstance under = ipojo.createComponentInstance("requires-cb");
+        
+        Assert.assertEquals(ComponentInstance.VALID, prov.getState());
+        Assert.assertEquals(ComponentInstance.VALID, under.getState());
+        
+        ServiceReference ref = ipojo.getServiceReferenceByName(CheckService.class.getName(), under.getInstanceName());
+        Assert.assertNotNull(ref);
+        
+        CheckService cs = (CheckService) osgi.getServiceObject(ref);
+        TransactionManager tm = (TransactionManager) osgi.getServiceObject(TransactionManager.class.getName(), null);
+        tm.begin();
+        Transaction t = tm.getTransaction();
+        cs.doSomethingGood();
+        Transaction t2 = cs.getCurrentTransaction();
+        Assert.assertSame(t2, t);
+        t.commit();
+        
+        Assert.assertNull(cs.getLastRolledBack());
+        Assert.assertNotNull(cs.getLastCommitted());
+        Assert.assertEquals(1, cs.getNumberOfCommit());
+        Assert.assertEquals(0, cs.getNumberOfRollback());
+        
+        Assert.assertSame(t, cs.getLastCommitted());
+    }
+    
+    @Test(expected=NullPointerException.class)
+    public void testExceptionOutsideTransactionWithCallback() {
+        ComponentInstance prov = ipojo.createComponentInstance("org.apache.felix.ipojo.transaction.test.component.FooImpl");
+        ComponentInstance under = ipojo.createComponentInstance("requires-cb");
+        
+        Assert.assertEquals(ComponentInstance.VALID, prov.getState());
+        Assert.assertEquals(ComponentInstance.VALID, under.getState());
+        
+        ServiceReference ref = ipojo.getServiceReferenceByName(CheckService.class.getName(), under.getInstanceName());
+        Assert.assertNotNull(ref);
+
+        CheckService cs = (CheckService) osgi.getServiceObject(ref);
+
+        cs.doSomethingBad();
+        
+        Assert.assertNotNull(cs.getLastRolledBack());
+        Assert.assertNull(cs.getLastCommitted());
+        Assert.assertEquals(0, cs.getNumberOfCommit());
+        Assert.assertEquals(1, cs.getNumberOfRollback());
+    }
+    
+    @Test
+    public void testExceptionInsideTransactionWithCallback() throws NotSupportedException, SystemException, SecurityException, HeuristicMixedException, HeuristicRollbackException, RollbackException {
+        ComponentInstance prov = ipojo.createComponentInstance("org.apache.felix.ipojo.transaction.test.component.FooImpl");
+        ComponentInstance under = ipojo.createComponentInstance("requires-cb");
+        
+        Assert.assertEquals(ComponentInstance.VALID, prov.getState());
+        Assert.assertEquals(ComponentInstance.VALID, under.getState());
+        
+        ServiceReference ref = ipojo.getServiceReferenceByName(CheckService.class.getName(), under.getInstanceName());
+        Assert.assertNotNull(ref);
+        
+        CheckService cs = (CheckService) osgi.getServiceObject(ref);
+        TransactionManager tm = (TransactionManager) osgi.getServiceObject(TransactionManager.class.getName(), null);
+        tm.begin();
+        Transaction t = tm.getTransaction();
+        try {
+            cs.doSomethingBad();
+            Assert.fail("NullPointerException expected");
+        } catch(Exception e) {
+            Assert.assertTrue(e instanceof NullPointerException);
+        }
+        Transaction t2 = cs.getCurrentTransaction();
+        Assert.assertSame(t2, t);
+        Assert.assertEquals(Status.STATUS_MARKED_ROLLBACK, t.getStatus());
+        
+        try {
+            t.commit(); // Throw a rollback exception.
+        } catch (RollbackException e) {
+            // Expected
+        } catch (Throwable e) {
+            Assert.fail(e.getMessage()); // Unexpected
+        }
+        
+        Assert.assertNotNull(cs.getLastRolledBack());
+        Assert.assertNull(cs.getLastCommitted());
+        Assert.assertEquals(0, cs.getNumberOfCommit());
+        Assert.assertEquals(1, cs.getNumberOfRollback());
+        
+        Assert.assertSame(t, cs.getLastRolledBack());
+    }
+    
+    @Test(expected=UnsupportedOperationException.class)
+    public void testExpectedExceptionOutsideTransactionWithCallback() {
+        ComponentInstance prov = ipojo.createComponentInstance("org.apache.felix.ipojo.transaction.test.component.FooImpl");
+        ComponentInstance under = ipojo.createComponentInstance("requires-cb");
+        
+        Assert.assertEquals(ComponentInstance.VALID, prov.getState());
+        Assert.assertEquals(ComponentInstance.VALID, under.getState());
+        
+        ServiceReference ref = ipojo.getServiceReferenceByName(CheckService.class.getName(), under.getInstanceName());
+        Assert.assertNotNull(ref);
+
+        CheckService cs = (CheckService) osgi.getServiceObject(ref);
+
+        cs.doSomethingBad2();
+        
+        Assert.assertNull(cs.getLastRolledBack());
+        Assert.assertNotNull(cs.getLastCommitted());
+        Assert.assertEquals(1, cs.getNumberOfCommit());
+        Assert.assertEquals(0, cs.getNumberOfRollback());
+    }
+    
+    @Test
+    public void testExpectedExceptionInsideTransactionWithCallback() throws NotSupportedException, SystemException, SecurityException, HeuristicMixedException, HeuristicRollbackException, RollbackException {
+        ComponentInstance prov = ipojo.createComponentInstance("org.apache.felix.ipojo.transaction.test.component.FooImpl");
+        ComponentInstance under = ipojo.createComponentInstance("requires-cb");
+        
+        Assert.assertEquals(ComponentInstance.VALID, prov.getState());
+        Assert.assertEquals(ComponentInstance.VALID, under.getState());
+        
+        ServiceReference ref = ipojo.getServiceReferenceByName(CheckService.class.getName(), under.getInstanceName());
+        Assert.assertNotNull(ref);
+        
+        CheckService cs = (CheckService) osgi.getServiceObject(ref);
+        TransactionManager tm = (TransactionManager) osgi.getServiceObject(TransactionManager.class.getName(), null);
+        tm.begin();
+        Transaction t = tm.getTransaction();
+        try {
+            cs.doSomethingBad2();
+            Assert.fail("UnsupportedOperationException expected");
+        } catch(Exception e) {
+            Assert.assertTrue(e instanceof UnsupportedOperationException);
+        }
+        Transaction t2 = cs.getCurrentTransaction();
+        Assert.assertSame(t2, t);
+        Assert.assertEquals(Status.STATUS_ACTIVE, t.getStatus());
+        
+        t.commit();
+        
+        Assert.assertNull(cs.getLastRolledBack());
+        Assert.assertNotNull(cs.getLastCommitted());
+        Assert.assertEquals(1, cs.getNumberOfCommit());
+        Assert.assertEquals(0, cs.getNumberOfRollback());
+        
+        Assert.assertSame(t, cs.getLastCommitted());
+    }
+    
+
+    
+}
diff --git a/ipojo/tests/handler/transaction/src/test/java/org/apache/felix/ipojo/transaction/test/TestRequiresNew.java b/ipojo/tests/handler/transaction/src/test/java/org/apache/felix/ipojo/transaction/test/TestRequiresNew.java
new file mode 100644
index 0000000..974fca9
--- /dev/null
+++ b/ipojo/tests/handler/transaction/src/test/java/org/apache/felix/ipojo/transaction/test/TestRequiresNew.java
@@ -0,0 +1,254 @@
+package org.apache.felix.ipojo.transaction.test;
+
+import static org.ops4j.pax.exam.CoreOptions.bundle;
+import static org.ops4j.pax.exam.CoreOptions.mavenBundle;
+import static org.ops4j.pax.exam.CoreOptions.options;
+import static org.ops4j.pax.exam.CoreOptions.provision;
+import static org.ops4j.pax.exam.MavenUtils.asInProject;
+import static org.ops4j.pax.tinybundles.core.TinyBundles.with;
+
+import java.io.File;
+import java.net.URL;
+
+import javax.transaction.HeuristicMixedException;
+import javax.transaction.HeuristicRollbackException;
+import javax.transaction.NotSupportedException;
+import javax.transaction.RollbackException;
+import javax.transaction.Status;
+import javax.transaction.SystemException;
+import javax.transaction.Transaction;
+import javax.transaction.TransactionManager;
+
+import org.apache.felix.ipojo.ComponentInstance;
+import org.apache.felix.ipojo.pax.exam.target.BundleAsiPOJO;
+import org.apache.felix.ipojo.transaction.test.component.FooDelegator;
+import org.apache.felix.ipojo.transaction.test.component.FooImpl;
+import org.apache.felix.ipojo.transaction.test.service.CheckService;
+import org.apache.felix.ipojo.transaction.test.service.Foo;
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.ops4j.pax.exam.Inject;
+import org.ops4j.pax.exam.Option;
+import org.ops4j.pax.exam.junit.Configuration;
+import org.ops4j.pax.exam.junit.JUnit4TestRunner;
+import org.ops4j.pax.tinybundles.core.TinyBundles;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.Constants;
+import org.osgi.framework.ServiceReference;
+
+@RunWith( JUnit4TestRunner.class )
+public class TestRequiresNew {
+    
+    @Inject
+    private BundleContext context;
+    
+    private OSGiHelper osgi;
+    
+    private IPOJOHelper ipojo;
+    
+    public static final File ROOT = new File("target/tmp");
+    public static final File TEST = new File("src/test/resources");
+
+    
+    @Before
+    public void init() {
+        osgi = new OSGiHelper(context);
+        ipojo = new IPOJOHelper(context);
+    }
+    
+    @After
+    public void stop() {
+        ipojo.dispose();
+        osgi.dispose();
+    }
+    
+    @Configuration
+    public static Option[] configure() {    
+        ROOT.mkdirs();
+
+        URL service = TinyBundles.newBundle()
+            .addClass(CheckService.class)
+            .addClass(Foo.class)
+           .prepare( 
+                with()
+                .set(Constants.BUNDLE_SYMBOLICNAME,"Service")
+                .set(Constants.EXPORT_PACKAGE, "org.apache.felix.ipojo.transaction.test.service")
+                .set(Constants.IMPORT_PACKAGE, "javax.transaction")
+                )
+            .build( TinyBundles.asURL());
+            
+        String fooimpl = TinyBundles.newBundle()
+            .addClass(FooImpl.class)
+            .prepare( 
+                    with()
+                    .set(Constants.BUNDLE_SYMBOLICNAME,"Foo Provider")
+                    .set(Constants.IMPORT_PACKAGE, "org.apache.felix.ipojo.transaction.test.service")
+                )
+                .build( new BundleAsiPOJO(new File(ROOT, "FooImpl.jar"), new File(TEST, "foo.xml"))  ).toExternalForm();
+        
+        String test = TinyBundles.newBundle()
+        .addClass(FooDelegator.class)
+        .prepare( 
+                with()
+                .set(Constants.BUNDLE_SYMBOLICNAME,"Required Transaction Propgatation")
+                .set(Constants.IMPORT_PACKAGE, "org.apache.felix.ipojo.transaction.test.service, javax.transaction")
+            )
+            .build( new BundleAsiPOJO(new File(ROOT, "requiresnew.jar"), new File(TEST, "requiresnew.xml"))  ).toExternalForm();
+    
+        
+        Option[] opt =  options(
+ 
+                provision(
+                        mavenBundle().groupId("org.ops4j.pax.logging").artifactId("pax-logging-api").version(asInProject()),
+                        mavenBundle().groupId("org.apache.felix").artifactId("org.apache.felix.ipojo").version(asInProject()),
+                        mavenBundle().groupId("org.apache.felix").artifactId("org.apache.felix.ipojo.transaction").version(asInProject()),
+                        mavenBundle().groupId("org.apache.felix").artifactId("org.apache.felix.transaction").version(asInProject()),
+                        mavenBundle()
+                        .groupId( "org.ops4j.pax.tinybundles" )
+                        .artifactId( "pax-tinybundles-core" )
+                        .version( "0.5.0-SNAPSHOT" ),
+                        bundle(service.toExternalForm()),
+                        bundle(fooimpl),
+                        bundle(test)
+                    )
+                )
+
+                ;
+        return opt;
+    }
+    
+    
+    @Test
+    public void testOkOutsideTransaction() {
+        ComponentInstance prov = ipojo.createComponentInstance("org.apache.felix.ipojo.transaction.test.component.FooImpl");
+        ComponentInstance under = ipojo.createComponentInstance("requiresnew-ok");
+        
+        Assert.assertEquals(ComponentInstance.VALID, prov.getState());
+        Assert.assertEquals(ComponentInstance.VALID, under.getState());
+        
+        ServiceReference ref = ipojo.getServiceReferenceByName(CheckService.class.getName(), under.getInstanceName());
+        Assert.assertNotNull(ref);
+
+        ((CheckService) osgi.getServiceObject(ref)).doSomethingGood(); // Ok
+    }
+    
+    @Test
+    public void testOkInsideTransaction() throws NotSupportedException, SystemException, SecurityException, HeuristicMixedException, HeuristicRollbackException, RollbackException {
+        ComponentInstance prov = ipojo.createComponentInstance("org.apache.felix.ipojo.transaction.test.component.FooImpl");
+        ComponentInstance under = ipojo.createComponentInstance("requiresnew-ok");
+        
+        Assert.assertEquals(ComponentInstance.VALID, prov.getState());
+        Assert.assertEquals(ComponentInstance.VALID, under.getState());
+        
+        ServiceReference ref = ipojo.getServiceReferenceByName(CheckService.class.getName(), under.getInstanceName());
+        Assert.assertNotNull(ref);
+        
+        CheckService cs = (CheckService) osgi.getServiceObject(ref);
+        TransactionManager tm = (TransactionManager) osgi.getServiceObject(TransactionManager.class.getName(), null);
+        tm.begin();
+        Transaction t = tm.getTransaction();
+        cs.doSomethingGood();
+        Transaction t2 = cs.getCurrentTransaction();
+        Assert.assertNotSame(t2, t); // Two different transactions
+        // Check that t2 is commited => no transaction
+        Assert.assertEquals(Status.STATUS_NO_TRANSACTION, t2.getStatus());
+        t.commit();
+    }
+    
+    @Test
+    public void testExceptionOutsideTransaction() {
+        ComponentInstance prov = ipojo.createComponentInstance("org.apache.felix.ipojo.transaction.test.component.FooImpl");
+        ComponentInstance under = ipojo.createComponentInstance("requiresnew-ok");
+        
+        Assert.assertEquals(ComponentInstance.VALID, prov.getState());
+        Assert.assertEquals(ComponentInstance.VALID, under.getState());
+        
+        ServiceReference ref = ipojo.getServiceReferenceByName(CheckService.class.getName(), under.getInstanceName());
+        Assert.assertNotNull(ref);
+
+        try {
+            ((CheckService) osgi.getServiceObject(ref)).doSomethingBad(); // throws an exception on rollback
+            Assert.fail("Exception expected on rollback");
+        } catch (IllegalStateException e) {
+            // Ok.
+        } catch (Exception  e) {
+            Assert.fail("IllegalStateException expected on rollback");
+        }
+    }
+    
+    @Test
+    public void testExceptionInsideTransaction() throws NotSupportedException, SystemException, SecurityException, HeuristicMixedException, HeuristicRollbackException, RollbackException {
+        ComponentInstance prov = ipojo.createComponentInstance("org.apache.felix.ipojo.transaction.test.component.FooImpl");
+        ComponentInstance under = ipojo.createComponentInstance("requiresnew-ok");
+        
+        Assert.assertEquals(ComponentInstance.VALID, prov.getState());
+        Assert.assertEquals(ComponentInstance.VALID, under.getState());
+        
+        ServiceReference ref = ipojo.getServiceReferenceByName(CheckService.class.getName(), under.getInstanceName());
+        Assert.assertNotNull(ref);
+        
+        CheckService cs = (CheckService) osgi.getServiceObject(ref);
+        TransactionManager tm = (TransactionManager) osgi.getServiceObject(TransactionManager.class.getName(), null);
+        tm.begin();
+        Transaction t = tm.getTransaction();
+        try {
+            cs.doSomethingBad();
+            Assert.fail("IllegalStateException expected");  // throws an exception on rollback
+        } catch(Exception e) {
+            Assert.assertTrue(e instanceof IllegalStateException);
+        }
+        Transaction t2 = cs.getCurrentTransaction();
+        Assert.assertNotSame(t2, t);
+        // Check that t2 is rolledback
+        Assert.assertEquals(Status.STATUS_NO_TRANSACTION, t2.getStatus());
+        Assert.assertEquals(Status.STATUS_ACTIVE, t.getStatus());
+        
+        t.commit();
+    }
+    
+    @Test(expected=UnsupportedOperationException.class)
+    public void testExpectedExceptionOutsideTransaction() {
+        ComponentInstance prov = ipojo.createComponentInstance("org.apache.felix.ipojo.transaction.test.component.FooImpl");
+        ComponentInstance under = ipojo.createComponentInstance("requiresnew-ok");
+        
+        Assert.assertEquals(ComponentInstance.VALID, prov.getState());
+        Assert.assertEquals(ComponentInstance.VALID, under.getState());
+        
+        ServiceReference ref = ipojo.getServiceReferenceByName(CheckService.class.getName(), under.getInstanceName());
+        Assert.assertNotNull(ref);
+
+        ((CheckService) osgi.getServiceObject(ref)).doSomethingBad2();
+    }
+    
+    @Test
+    public void testExpectedExceptionInsideTransaction() throws NotSupportedException, SystemException, SecurityException, HeuristicMixedException, HeuristicRollbackException, RollbackException {
+        ComponentInstance prov = ipojo.createComponentInstance("org.apache.felix.ipojo.transaction.test.component.FooImpl");
+        ComponentInstance under = ipojo.createComponentInstance("requiresnew-ok");
+        
+        Assert.assertEquals(ComponentInstance.VALID, prov.getState());
+        Assert.assertEquals(ComponentInstance.VALID, under.getState());
+        
+        ServiceReference ref = ipojo.getServiceReferenceByName(CheckService.class.getName(), under.getInstanceName());
+        Assert.assertNotNull(ref);
+        
+        CheckService cs = (CheckService) osgi.getServiceObject(ref);
+        TransactionManager tm = (TransactionManager) osgi.getServiceObject(TransactionManager.class.getName(), null);
+        tm.begin();
+        Transaction t = tm.getTransaction();
+        try {
+            cs.doSomethingBad2();
+            Assert.fail("UnsupportedOperationException expected");
+        } catch(Exception e) {
+            Assert.assertTrue(e instanceof UnsupportedOperationException);
+        }
+        Transaction t2 = cs.getCurrentTransaction();
+        Assert.assertNotSame(t2, t);
+        Assert.assertEquals(Status.STATUS_NO_TRANSACTION, t2.getStatus());
+        Assert.assertEquals(Status.STATUS_ACTIVE, t.getStatus());
+        
+        t.commit();
+    }
+}
diff --git a/ipojo/tests/handler/transaction/src/test/java/org/apache/felix/ipojo/transaction/test/TestSupported.java b/ipojo/tests/handler/transaction/src/test/java/org/apache/felix/ipojo/transaction/test/TestSupported.java
new file mode 100644
index 0000000..962ab17
--- /dev/null
+++ b/ipojo/tests/handler/transaction/src/test/java/org/apache/felix/ipojo/transaction/test/TestSupported.java
@@ -0,0 +1,442 @@
+package org.apache.felix.ipojo.transaction.test;
+
+import static org.ops4j.pax.exam.CoreOptions.bundle;
+import static org.ops4j.pax.exam.CoreOptions.mavenBundle;
+import static org.ops4j.pax.exam.CoreOptions.options;
+import static org.ops4j.pax.exam.CoreOptions.provision;
+import static org.ops4j.pax.exam.MavenUtils.asInProject;
+import static org.ops4j.pax.tinybundles.core.TinyBundles.with;
+
+import java.io.File;
+import java.net.URL;
+
+import javax.transaction.HeuristicMixedException;
+import javax.transaction.HeuristicRollbackException;
+import javax.transaction.NotSupportedException;
+import javax.transaction.RollbackException;
+import javax.transaction.Status;
+import javax.transaction.SystemException;
+import javax.transaction.Transaction;
+import javax.transaction.TransactionManager;
+
+import org.apache.felix.ipojo.ComponentInstance;
+import org.apache.felix.ipojo.pax.exam.target.BundleAsiPOJO;
+import org.apache.felix.ipojo.transaction.test.component.FooDelegator;
+import org.apache.felix.ipojo.transaction.test.component.FooImpl;
+import org.apache.felix.ipojo.transaction.test.service.CheckService;
+import org.apache.felix.ipojo.transaction.test.service.Foo;
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.ops4j.pax.exam.Inject;
+import org.ops4j.pax.exam.Option;
+import org.ops4j.pax.exam.junit.Configuration;
+import org.ops4j.pax.exam.junit.JUnit4TestRunner;
+import org.ops4j.pax.tinybundles.core.TinyBundles;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.Constants;
+import org.osgi.framework.ServiceReference;
+
+@RunWith( JUnit4TestRunner.class )
+public class TestSupported {
+    
+    @Inject
+    private BundleContext context;
+    
+    private OSGiHelper osgi;
+    
+    private IPOJOHelper ipojo;
+    public static final File ROOT = new File("target/tmp");
+    public static final File TEST = new File("src/test/resources");
+
+    
+    @Before
+    public void init() {
+        osgi = new OSGiHelper(context);
+        ipojo = new IPOJOHelper(context);
+    }
+    
+    @After
+    public void stop() {
+        ipojo.dispose();
+        osgi.dispose();
+    }
+    
+    @Configuration
+    public static Option[] configure() {    
+        ROOT.mkdirs();
+
+        URL service = TinyBundles.newBundle()
+            .addClass(CheckService.class)
+            .addClass(Foo.class)
+           .prepare( 
+                with()
+                .set(Constants.BUNDLE_SYMBOLICNAME,"Service")
+                .set(Constants.EXPORT_PACKAGE, "org.apache.felix.ipojo.transaction.test.service")
+                .set(Constants.IMPORT_PACKAGE, "javax.transaction")
+                )
+            .build( TinyBundles.asURL());
+            
+        String fooimpl = TinyBundles.newBundle()
+            .addClass(FooImpl.class)
+            .prepare( 
+                    with()
+                    .set(Constants.BUNDLE_SYMBOLICNAME,"Foo Provider")
+                    .set(Constants.IMPORT_PACKAGE, "org.apache.felix.ipojo.transaction.test.service")
+                )
+                .build( new BundleAsiPOJO(new File(ROOT, "FooImpl.jar"), new File(TEST, "foo.xml"))  ).toExternalForm();
+        
+        String test = TinyBundles.newBundle()
+        .addClass(FooDelegator.class)
+        .prepare( 
+                with()
+                .set(Constants.BUNDLE_SYMBOLICNAME,"Required Transaction Propgatation")
+                .set(Constants.IMPORT_PACKAGE, "org.apache.felix.ipojo.transaction.test.service, javax.transaction")
+            )
+            .build( new BundleAsiPOJO(new File(ROOT, "supported.jar"), new File(TEST, "supported.xml"))  ).toExternalForm();
+    
+        
+        Option[] opt =  options(
+ 
+                provision(
+                        mavenBundle().groupId("org.ops4j.pax.logging").artifactId("pax-logging-api").version(asInProject()),
+                        mavenBundle().groupId("org.apache.felix").artifactId("org.apache.felix.ipojo").version(asInProject()),
+                        mavenBundle().groupId("org.apache.felix").artifactId("org.apache.felix.ipojo.transaction").version(asInProject()),
+                        mavenBundle().groupId("org.apache.felix").artifactId("org.apache.felix.transaction").version(asInProject()),
+                        mavenBundle()
+                        .groupId( "org.ops4j.pax.tinybundles" )
+                        .artifactId( "pax-tinybundles-core" )
+                        .version( "0.5.0-SNAPSHOT" ),
+                        bundle(service.toExternalForm()),
+                        bundle(fooimpl),
+                        bundle(test)
+                    )
+                )
+
+                ;
+        return opt;
+    }
+    
+    
+    @Test
+    public void testOkOutsideTransaction() {
+        ComponentInstance prov = ipojo.createComponentInstance("org.apache.felix.ipojo.transaction.test.component.FooImpl");
+        ComponentInstance under = ipojo.createComponentInstance("supported-ok");
+        
+        Assert.assertEquals(ComponentInstance.VALID, prov.getState());
+        Assert.assertEquals(ComponentInstance.VALID, under.getState());
+        
+        ServiceReference ref = ipojo.getServiceReferenceByName(CheckService.class.getName(), under.getInstanceName());
+        Assert.assertNotNull(ref);
+
+        CheckService cs = ((CheckService) osgi.getServiceObject(ref));
+        cs.doSomethingGood();
+        // No transaction.
+    }
+    
+    @Test
+    public void testOkInsideTransaction() throws NotSupportedException, SystemException, SecurityException, HeuristicMixedException, HeuristicRollbackException, RollbackException {
+        ComponentInstance prov = ipojo.createComponentInstance("org.apache.felix.ipojo.transaction.test.component.FooImpl");
+        ComponentInstance under = ipojo.createComponentInstance("supported-ok");
+        
+        Assert.assertEquals(ComponentInstance.VALID, prov.getState());
+        Assert.assertEquals(ComponentInstance.VALID, under.getState());
+        
+        ServiceReference ref = ipojo.getServiceReferenceByName(CheckService.class.getName(), under.getInstanceName());
+        Assert.assertNotNull(ref);
+        
+        CheckService cs = (CheckService) osgi.getServiceObject(ref);
+        TransactionManager tm = (TransactionManager) osgi.getServiceObject(TransactionManager.class.getName(), null);
+        tm.begin();
+        Transaction t = tm.getTransaction();
+        cs.doSomethingGood();
+        Transaction t2 = cs.getCurrentTransaction();
+        Assert.assertSame(t2, t);
+        t.commit();
+    }
+    
+    @Test(expected=NullPointerException.class)
+    public void testExceptionOutsideTransaction() {
+        ComponentInstance prov = ipojo.createComponentInstance("org.apache.felix.ipojo.transaction.test.component.FooImpl");
+        ComponentInstance under = ipojo.createComponentInstance("supported-ok");
+        
+        Assert.assertEquals(ComponentInstance.VALID, prov.getState());
+        Assert.assertEquals(ComponentInstance.VALID, under.getState());
+        
+        ServiceReference ref = ipojo.getServiceReferenceByName(CheckService.class.getName(), under.getInstanceName());
+        Assert.assertNotNull(ref);
+
+        ((CheckService) osgi.getServiceObject(ref)).doSomethingBad();
+    }
+    
+    @Test(expected=RollbackException.class)
+    public void testExceptionInsideTransaction() throws NotSupportedException, SystemException, SecurityException, HeuristicMixedException, HeuristicRollbackException, RollbackException {
+        ComponentInstance prov = ipojo.createComponentInstance("org.apache.felix.ipojo.transaction.test.component.FooImpl");
+        ComponentInstance under = ipojo.createComponentInstance("supported-ok");
+        
+        Assert.assertEquals(ComponentInstance.VALID, prov.getState());
+        Assert.assertEquals(ComponentInstance.VALID, under.getState());
+        
+        ServiceReference ref = ipojo.getServiceReferenceByName(CheckService.class.getName(), under.getInstanceName());
+        Assert.assertNotNull(ref);
+        
+        CheckService cs = (CheckService) osgi.getServiceObject(ref);
+        TransactionManager tm = (TransactionManager) osgi.getServiceObject(TransactionManager.class.getName(), null);
+        tm.begin();
+        Transaction t = tm.getTransaction();
+        try {
+            cs.doSomethingBad();
+            Assert.fail("NullPointerException expected");
+        } catch(Exception e) {
+            Assert.assertTrue(e instanceof NullPointerException);
+        }
+        Transaction t2 = cs.getCurrentTransaction();
+        Assert.assertSame(t2, t);
+        Assert.assertEquals(Status.STATUS_MARKED_ROLLBACK, t.getStatus());
+        
+        t.commit(); // Throw a rollback exception.
+    }
+    
+    @Test
+    public void testExceptionInsideTransactionRB() throws NotSupportedException, SystemException, SecurityException, HeuristicMixedException, HeuristicRollbackException, RollbackException {
+        ComponentInstance prov = ipojo.createComponentInstance("org.apache.felix.ipojo.transaction.test.component.FooImpl");
+        ComponentInstance under = ipojo.createComponentInstance("supported-ok");
+        
+        Assert.assertEquals(ComponentInstance.VALID, prov.getState());
+        Assert.assertEquals(ComponentInstance.VALID, under.getState());
+        
+        ServiceReference ref = ipojo.getServiceReferenceByName(CheckService.class.getName(), under.getInstanceName());
+        Assert.assertNotNull(ref);
+        
+        CheckService cs = (CheckService) osgi.getServiceObject(ref);
+        TransactionManager tm = (TransactionManager) osgi.getServiceObject(TransactionManager.class.getName(), null);
+        tm.begin();
+        Transaction t = tm.getTransaction();
+        try {
+            cs.doSomethingBad();
+            Assert.fail("NullPointerException expected");
+        } catch(Exception e) {
+            Assert.assertTrue(e instanceof NullPointerException);
+        }
+        Transaction t2 = cs.getCurrentTransaction();
+        Assert.assertSame(t2, t);
+        Assert.assertEquals(Status.STATUS_MARKED_ROLLBACK, t.getStatus());
+        
+        t.rollback();
+    }
+    
+    @Test(expected=UnsupportedOperationException.class)
+    public void testExpectedExceptionOutsideTransaction() {
+        ComponentInstance prov = ipojo.createComponentInstance("org.apache.felix.ipojo.transaction.test.component.FooImpl");
+        ComponentInstance under = ipojo.createComponentInstance("supported-ok");
+        
+        Assert.assertEquals(ComponentInstance.VALID, prov.getState());
+        Assert.assertEquals(ComponentInstance.VALID, under.getState());
+        
+        ServiceReference ref = ipojo.getServiceReferenceByName(CheckService.class.getName(), under.getInstanceName());
+        Assert.assertNotNull(ref);
+
+        ((CheckService) osgi.getServiceObject(ref)).doSomethingBad2();
+    }
+    
+    @Test
+    public void testExpectedExceptionInsideTransaction() throws NotSupportedException, SystemException, SecurityException, HeuristicMixedException, HeuristicRollbackException, RollbackException {
+        ComponentInstance prov = ipojo.createComponentInstance("org.apache.felix.ipojo.transaction.test.component.FooImpl");
+        ComponentInstance under = ipojo.createComponentInstance("supported-ok");
+        
+        Assert.assertEquals(ComponentInstance.VALID, prov.getState());
+        Assert.assertEquals(ComponentInstance.VALID, under.getState());
+        
+        ServiceReference ref = ipojo.getServiceReferenceByName(CheckService.class.getName(), under.getInstanceName());
+        Assert.assertNotNull(ref);
+        
+        CheckService cs = (CheckService) osgi.getServiceObject(ref);
+        TransactionManager tm = (TransactionManager) osgi.getServiceObject(TransactionManager.class.getName(), null);
+        tm.begin();
+        Transaction t = tm.getTransaction();
+        try {
+            cs.doSomethingBad2();
+            Assert.fail("UnsupportedOperationException expected");
+        } catch(Exception e) {
+            Assert.assertTrue(e instanceof UnsupportedOperationException);
+        }
+        Transaction t2 = cs.getCurrentTransaction();
+        Assert.assertSame(t2, t);
+        Assert.assertEquals(Status.STATUS_ACTIVE, t.getStatus());
+        
+        t.commit();
+    }
+    
+    @Test
+    public void testOkOutsideTransactionWithCallback() {
+        ComponentInstance prov = ipojo.createComponentInstance("org.apache.felix.ipojo.transaction.test.component.FooImpl");
+        ComponentInstance under = ipojo.createComponentInstance("supported-cb");
+        
+        Assert.assertEquals(ComponentInstance.VALID, prov.getState());
+        Assert.assertEquals(ComponentInstance.VALID, under.getState());
+        
+        ServiceReference ref = ipojo.getServiceReferenceByName(CheckService.class.getName(), under.getInstanceName());
+        Assert.assertNotNull(ref);
+
+        
+        CheckService cs = (CheckService) osgi.getServiceObject(ref);
+
+        cs.doSomethingGood();
+        
+        Assert.assertNull(cs.getLastRolledBack());
+        Assert.assertNull(cs.getLastCommitted());
+        Assert.assertEquals(0, cs.getNumberOfCommit());
+        Assert.assertEquals(0, cs.getNumberOfRollback());
+    }
+    
+    @Test
+    public void testOkInsideTransactionWithCallback() throws NotSupportedException, SystemException, SecurityException, HeuristicMixedException, HeuristicRollbackException, RollbackException {
+        ComponentInstance prov = ipojo.createComponentInstance("org.apache.felix.ipojo.transaction.test.component.FooImpl");
+        ComponentInstance under = ipojo.createComponentInstance("supported-cb");
+        
+        Assert.assertEquals(ComponentInstance.VALID, prov.getState());
+        Assert.assertEquals(ComponentInstance.VALID, under.getState());
+        
+        ServiceReference ref = ipojo.getServiceReferenceByName(CheckService.class.getName(), under.getInstanceName());
+        Assert.assertNotNull(ref);
+        
+        CheckService cs = (CheckService) osgi.getServiceObject(ref);
+        TransactionManager tm = (TransactionManager) osgi.getServiceObject(TransactionManager.class.getName(), null);
+        tm.begin();
+        Transaction t = tm.getTransaction();
+        cs.doSomethingGood();
+        Transaction t2 = cs.getCurrentTransaction();
+        Assert.assertSame(t2, t);
+        t.commit();
+        
+        Assert.assertNull(cs.getLastRolledBack());
+        Assert.assertNotNull(cs.getLastCommitted());
+        Assert.assertEquals(1, cs.getNumberOfCommit());
+        Assert.assertEquals(0, cs.getNumberOfRollback());
+        
+        Assert.assertSame(t, cs.getLastCommitted());
+    }
+    
+    @Test(expected=NullPointerException.class)
+    public void testExceptionOutsideTransactionWithCallback() {
+        ComponentInstance prov = ipojo.createComponentInstance("org.apache.felix.ipojo.transaction.test.component.FooImpl");
+        ComponentInstance under = ipojo.createComponentInstance("supported-cb");
+        
+        Assert.assertEquals(ComponentInstance.VALID, prov.getState());
+        Assert.assertEquals(ComponentInstance.VALID, under.getState());
+        
+        ServiceReference ref = ipojo.getServiceReferenceByName(CheckService.class.getName(), under.getInstanceName());
+        Assert.assertNotNull(ref);
+
+        CheckService cs = (CheckService) osgi.getServiceObject(ref);
+
+        cs.doSomethingBad();
+        
+        Assert.assertNull(cs.getLastRolledBack());
+        Assert.assertNull(cs.getLastCommitted());
+        Assert.assertEquals(0, cs.getNumberOfCommit());
+        Assert.assertEquals(0, cs.getNumberOfRollback());
+    }
+    
+    @Test
+    public void testExceptionInsideTransactionWithCallback() throws NotSupportedException, SystemException, SecurityException, HeuristicMixedException, HeuristicRollbackException, RollbackException {
+        ComponentInstance prov = ipojo.createComponentInstance("org.apache.felix.ipojo.transaction.test.component.FooImpl");
+        ComponentInstance under = ipojo.createComponentInstance("supported-cb");
+        
+        Assert.assertEquals(ComponentInstance.VALID, prov.getState());
+        Assert.assertEquals(ComponentInstance.VALID, under.getState());
+        
+        ServiceReference ref = ipojo.getServiceReferenceByName(CheckService.class.getName(), under.getInstanceName());
+        Assert.assertNotNull(ref);
+        
+        CheckService cs = (CheckService) osgi.getServiceObject(ref);
+        TransactionManager tm = (TransactionManager) osgi.getServiceObject(TransactionManager.class.getName(), null);
+        tm.begin();
+        Transaction t = tm.getTransaction();
+        try {
+            cs.doSomethingBad();
+            Assert.fail("NullPointerException expected");
+        } catch(Exception e) {
+            Assert.assertTrue(e instanceof NullPointerException);
+        }
+        Transaction t2 = cs.getCurrentTransaction();
+        Assert.assertSame(t2, t);
+        Assert.assertEquals(Status.STATUS_MARKED_ROLLBACK, t.getStatus());
+        
+        try {
+            t.commit(); // Throw a rollback exception.
+        } catch (RollbackException e) {
+            // Expected
+        } catch (Throwable e) {
+            Assert.fail(e.getMessage()); // Unexpected
+        }
+        
+        Assert.assertNotNull(cs.getLastRolledBack());
+        Assert.assertNull(cs.getLastCommitted());
+        Assert.assertEquals(0, cs.getNumberOfCommit());
+        Assert.assertEquals(1, cs.getNumberOfRollback());
+        
+        Assert.assertSame(t, cs.getLastRolledBack());
+    }
+    
+    @Test(expected=UnsupportedOperationException.class)
+    public void testExpectedExceptionOutsideTransactionWithCallback() {
+        ComponentInstance prov = ipojo.createComponentInstance("org.apache.felix.ipojo.transaction.test.component.FooImpl");
+        ComponentInstance under = ipojo.createComponentInstance("supported-cb");
+        
+        Assert.assertEquals(ComponentInstance.VALID, prov.getState());
+        Assert.assertEquals(ComponentInstance.VALID, under.getState());
+        
+        ServiceReference ref = ipojo.getServiceReferenceByName(CheckService.class.getName(), under.getInstanceName());
+        Assert.assertNotNull(ref);
+
+        CheckService cs = (CheckService) osgi.getServiceObject(ref);
+
+        cs.doSomethingBad2();
+        
+        Assert.assertNull(cs.getLastRolledBack());
+        Assert.assertNull(cs.getLastCommitted());
+        Assert.assertEquals(0, cs.getNumberOfCommit());
+        Assert.assertEquals(0, cs.getNumberOfRollback());
+    }
+    
+    @Test
+    public void testExpectedExceptionInsideTransactionWithCallback() throws NotSupportedException, SystemException, SecurityException, HeuristicMixedException, HeuristicRollbackException, RollbackException {
+        ComponentInstance prov = ipojo.createComponentInstance("org.apache.felix.ipojo.transaction.test.component.FooImpl");
+        ComponentInstance under = ipojo.createComponentInstance("supported-cb");
+        
+        Assert.assertEquals(ComponentInstance.VALID, prov.getState());
+        Assert.assertEquals(ComponentInstance.VALID, under.getState());
+        
+        ServiceReference ref = ipojo.getServiceReferenceByName(CheckService.class.getName(), under.getInstanceName());
+        Assert.assertNotNull(ref);
+        
+        CheckService cs = (CheckService) osgi.getServiceObject(ref);
+        TransactionManager tm = (TransactionManager) osgi.getServiceObject(TransactionManager.class.getName(), null);
+        tm.begin();
+        Transaction t = tm.getTransaction();
+        try {
+            cs.doSomethingBad2();
+            Assert.fail("UnsupportedOperationException expected");
+        } catch(Exception e) {
+            Assert.assertTrue(e instanceof UnsupportedOperationException);
+        }
+        Transaction t2 = cs.getCurrentTransaction();
+        Assert.assertSame(t2, t);
+        Assert.assertEquals(Status.STATUS_ACTIVE, t.getStatus());
+        
+        t.commit();
+        
+        Assert.assertNull(cs.getLastRolledBack());
+        Assert.assertNotNull(cs.getLastCommitted());
+        Assert.assertEquals(1, cs.getNumberOfCommit());
+        Assert.assertEquals(0, cs.getNumberOfRollback());
+        
+        Assert.assertSame(t, cs.getLastCommitted());
+    }
+    
+
+    
+}
diff --git a/ipojo/tests/handler/transaction/src/test/java/org/apache/felix/ipojo/transaction/test/component/FooDelegator.java b/ipojo/tests/handler/transaction/src/test/java/org/apache/felix/ipojo/transaction/test/component/FooDelegator.java
new file mode 100644
index 0000000..7f8665b
--- /dev/null
+++ b/ipojo/tests/handler/transaction/src/test/java/org/apache/felix/ipojo/transaction/test/component/FooDelegator.java
@@ -0,0 +1,85 @@
+package org.apache.felix.ipojo.transaction.test.component;
+
+import javax.transaction.Transaction;
+
+import org.apache.felix.ipojo.transaction.test.service.CheckService;
+import org.apache.felix.ipojo.transaction.test.service.Foo;
+
+public class FooDelegator implements CheckService {
+    
+    private Foo foo;
+    
+    private int commit;
+    
+    private int rollback;
+    
+    Transaction transaction;
+    
+    Transaction lastCommitted;
+    
+    Transaction lastRolledback;
+    
+    Transaction current;
+
+    
+    public void onCommit(String method) {
+        commit ++;
+    }
+    
+    public void onRollback(String method, Exception e) {
+        rollback ++;
+    }
+
+    public void doSomethingBad() throws NullPointerException {
+        current = transaction;
+        foo.doSomethingBad();
+    }
+
+    public void doSomethingBad2() throws UnsupportedOperationException {
+       current = transaction;
+       foo.doSomethingBad2();
+
+    }
+
+    public void doSomethingGood() {
+        current = transaction;
+        foo.doSomethingGood();
+    }
+
+    public void doSomethingLong() {
+       current = transaction;
+       foo.doSomethingLong();
+    }
+
+    public Transaction getCurrentTransaction() {
+       return current;
+    }
+
+    public int getNumberOfCommit() {
+       return commit;
+    }
+
+    public int getNumberOfRollback() {
+       return rollback;
+    }
+    
+    public Transaction getLastRolledBack() {
+        return lastRolledback;
+    }
+    
+    public Transaction getLastCommitted() {
+        return lastCommitted;
+    }
+    
+    public void onRollback(Transaction t) {
+        lastRolledback = t;
+        rollback ++;
+    }
+    
+
+    public void onCommit(Transaction t) {
+        lastCommitted = t;
+        commit ++;
+    }
+
+}
diff --git a/ipojo/tests/handler/transaction/src/test/java/org/apache/felix/ipojo/transaction/test/component/FooImpl.java b/ipojo/tests/handler/transaction/src/test/java/org/apache/felix/ipojo/transaction/test/component/FooImpl.java
new file mode 100644
index 0000000..addb9f3
--- /dev/null
+++ b/ipojo/tests/handler/transaction/src/test/java/org/apache/felix/ipojo/transaction/test/component/FooImpl.java
@@ -0,0 +1,28 @@
+package org.apache.felix.ipojo.transaction.test.component;
+
+import org.apache.felix.ipojo.transaction.test.service.Foo;
+
+public class FooImpl implements Foo {
+
+    public void doSomethingBad() throws NullPointerException {
+       throw new NullPointerException("NULL");
+    }
+
+    public void doSomethingBad2() throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Expected exception");
+
+    }
+
+    public void doSomethingGood() {
+       // Good...
+    }
+
+    public void doSomethingLong() {
+        try {
+            Thread.sleep(5000);
+        } catch (InterruptedException e) {
+            e.printStackTrace();
+        }
+    }
+
+}
diff --git a/ipojo/tests/handler/transaction/src/test/java/org/apache/felix/ipojo/transaction/test/service/CheckService.java b/ipojo/tests/handler/transaction/src/test/java/org/apache/felix/ipojo/transaction/test/service/CheckService.java
new file mode 100644
index 0000000..bb95994
--- /dev/null
+++ b/ipojo/tests/handler/transaction/src/test/java/org/apache/felix/ipojo/transaction/test/service/CheckService.java
@@ -0,0 +1,25 @@
+package org.apache.felix.ipojo.transaction.test.service;
+
+import javax.transaction.Transaction;
+
+public interface CheckService {
+    
+    public void doSomethingGood();
+    
+    public void doSomethingBad() throws NullPointerException;
+    
+    public void doSomethingBad2() throws UnsupportedOperationException;
+    
+    public void doSomethingLong();
+    
+    public int getNumberOfCommit();
+    
+    public int getNumberOfRollback();
+    
+    public Transaction getCurrentTransaction();
+    
+    public Transaction getLastRolledBack();
+    
+    public Transaction getLastCommitted();
+
+}
diff --git a/ipojo/tests/handler/transaction/src/test/java/org/apache/felix/ipojo/transaction/test/service/Foo.java b/ipojo/tests/handler/transaction/src/test/java/org/apache/felix/ipojo/transaction/test/service/Foo.java
new file mode 100644
index 0000000..b1ba75a
--- /dev/null
+++ b/ipojo/tests/handler/transaction/src/test/java/org/apache/felix/ipojo/transaction/test/service/Foo.java
@@ -0,0 +1,13 @@
+package org.apache.felix.ipojo.transaction.test.service;
+
+public interface Foo {
+    
+    public void doSomethingGood();
+    
+    public void doSomethingBad() throws NullPointerException;
+    
+    public void doSomethingBad2() throws UnsupportedOperationException;
+    
+    public void doSomethingLong();
+
+}
diff --git a/ipojo/tests/handler/transaction/src/test/resources/foo.xml b/ipojo/tests/handler/transaction/src/test/resources/foo.xml
new file mode 100644
index 0000000..19f1ed8
--- /dev/null
+++ b/ipojo/tests/handler/transaction/src/test/resources/foo.xml
@@ -0,0 +1,5 @@
+<ipojo>
+	<component classname="org.apache.felix.ipojo.transaction.test.component.FooImpl">
+		<provides/>
+	</component>
+</ipojo>
\ No newline at end of file
diff --git a/ipojo/tests/handler/transaction/src/test/resources/mandatory.xml b/ipojo/tests/handler/transaction/src/test/resources/mandatory.xml
new file mode 100644
index 0000000..bb977ba
--- /dev/null
+++ b/ipojo/tests/handler/transaction/src/test/resources/mandatory.xml
@@ -0,0 +1,25 @@
+<ipojo xmlns:tr="org.apache.felix.ipojo.transaction">
+	<component classname="org.apache.felix.ipojo.transaction.test.component.FooDelegator" name="mandatory-ok">
+		<provides/>
+		<requires field="foo"/>
+		<tr:transaction field="transaction">
+			<transactionnal method="doSomethingGood" propagation="mandatory"/>
+			<transactionnal method="getCurrentTransaction" propagation="mandatory"/>
+			<transactionnal method="doSomethingBad" propagation="mandatory"/>
+			<transactionnal method="doSomethingBad2" norollbackfor="java.lang.UnsupportedOperationException" propagation="mandatory"/>
+			<transactionnal method="doSomethingLong" propagation="mandatory"/>
+		</tr:transaction>
+	</component>
+	
+	<component classname="org.apache.felix.ipojo.transaction.test.component.FooDelegator" name="mandatory-cb">
+		<provides/>
+		<requires field="foo" />
+		<tr:transaction field="transaction" onCommit="onCommit" onRollback="onRollback">
+			<transactionnal method="doSomethingGood" propagation="mandatory"/>
+			<transactionnal method="getCurrentTransaction" propagation="mandatory"/>
+			<transactionnal method="doSomethingBad" propagation="mandatory"/>
+			<transactionnal method="doSomethingBad2" norollbackfor="java.lang.UnsupportedOperationException" propagation="mandatory"/>
+			<transactionnal method="doSomethingLong" propagation="mandatory"/>
+		</tr:transaction>
+	</component>
+</ipojo>
\ No newline at end of file
diff --git a/ipojo/tests/handler/transaction/src/test/resources/never.xml b/ipojo/tests/handler/transaction/src/test/resources/never.xml
new file mode 100644
index 0000000..0a58abc
--- /dev/null
+++ b/ipojo/tests/handler/transaction/src/test/resources/never.xml
@@ -0,0 +1,25 @@
+<ipojo xmlns:tr="org.apache.felix.ipojo.transaction">
+	<component classname="org.apache.felix.ipojo.transaction.test.component.FooDelegator" name="never-ok">
+		<provides/>
+		<requires field="foo"/>
+		<tr:transaction field="transaction">
+			<transactionnal method="doSomethingGood" propagation="never"/>
+			<transactionnal method="getCurrentTransaction" propagation="never"/>
+			<transactionnal method="doSomethingBad" propagation="never"/>
+			<transactionnal method="doSomethingBad2" norollbackfor="java.lang.UnsupportedOperationException" propagation="never"/>
+			<transactionnal method="doSomethingLong" propagation="never"/>
+		</tr:transaction>
+	</component>
+	
+	<component classname="org.apache.felix.ipojo.transaction.test.component.FooDelegator" name="never-cb">
+		<provides/>
+		<requires field="foo" />
+		<tr:transaction field="transaction" onCommit="onCommit" onRollback="onRollback">
+			<transactionnal method="doSomethingGood" propagation="never"/>
+			<transactionnal method="getCurrentTransaction" propagation="never"/>
+			<transactionnal method="doSomethingBad" propagation="never"/>
+			<transactionnal method="doSomethingBad2" norollbackfor="java.lang.UnsupportedOperationException" propagation="never"/>
+			<transactionnal method="doSomethingLong" propagation="never"/>
+		</tr:transaction>
+	</component>
+</ipojo>
\ No newline at end of file
diff --git a/ipojo/tests/handler/transaction/src/test/resources/notsupported.xml b/ipojo/tests/handler/transaction/src/test/resources/notsupported.xml
new file mode 100644
index 0000000..fb44c93
--- /dev/null
+++ b/ipojo/tests/handler/transaction/src/test/resources/notsupported.xml
@@ -0,0 +1,25 @@
+<ipojo xmlns:tr="org.apache.felix.ipojo.transaction">
+	<component classname="org.apache.felix.ipojo.transaction.test.component.FooDelegator" name="notsupported-ok">
+		<provides/>
+		<requires field="foo"/>
+		<tr:transaction field="transaction">
+			<transactionnal method="doSomethingGood" propagation="notsupported"/>
+			<transactionnal method="getCurrentTransaction" propagation="notsupported"/>
+			<transactionnal method="doSomethingBad" propagation="notsupported"/>
+			<transactionnal method="doSomethingBad2" norollbackfor="java.lang.UnsupportedOperationException" propagation="notsupported"/>
+			<transactionnal method="doSomethingLong" propagation="notsupported"/>
+		</tr:transaction>
+	</component>
+	
+	<component classname="org.apache.felix.ipojo.transaction.test.component.FooDelegator" name="notsupported-cb">
+		<provides/>
+		<requires field="foo" />
+		<tr:transaction field="transaction" onCommit="onCommit" onRollback="onRollback">
+			<transactionnal method="doSomethingGood" propagation="notsupported"/>
+			<transactionnal method="getCurrentTransaction" propagation="notsupported"/>
+			<transactionnal method="doSomethingBad" propagation="notsupported"/>
+			<transactionnal method="doSomethingBad2" norollbackfor="java.lang.UnsupportedOperationException" propagation="notsupported"/>
+			<transactionnal method="doSomethingLong" propagation="notsupported"/>
+		</tr:transaction>
+	</component>
+</ipojo>
\ No newline at end of file
diff --git a/ipojo/tests/handler/transaction/src/test/resources/requires.xml b/ipojo/tests/handler/transaction/src/test/resources/requires.xml
new file mode 100644
index 0000000..ccd3221
--- /dev/null
+++ b/ipojo/tests/handler/transaction/src/test/resources/requires.xml
@@ -0,0 +1,25 @@
+<ipojo xmlns:tr="org.apache.felix.ipojo.transaction">
+	<component classname="org.apache.felix.ipojo.transaction.test.component.FooDelegator" name="requires-ok">
+		<provides/>
+		<requires field="foo"/>
+		<tr:transaction field="transaction">
+			<transactionnal method="doSomethingGood"/>
+			<transactionnal method="getCurrentTransaction"/>
+			<transactionnal method="doSomethingBad"/>
+			<transactionnal method="doSomethingBad2" norollbackfor="java.lang.UnsupportedOperationException"/>
+			<transactionnal method="doSomethingLong"/>
+		</tr:transaction>
+	</component>
+	
+	<component classname="org.apache.felix.ipojo.transaction.test.component.FooDelegator" name="requires-cb">
+		<provides/>
+		<requires field="foo" />
+		<tr:transaction field="transaction" onCommit="onCommit" onRollback="onRollback">
+			<transactionnal method="doSomethingGood"/>
+			<transactionnal method="getCurrentTransaction"/>
+			<transactionnal method="doSomethingBad"/>
+			<transactionnal method="doSomethingBad2" norollbackfor="java.lang.UnsupportedOperationException"/>
+			<transactionnal method="doSomethingLong"/>
+		</tr:transaction>
+	</component>
+</ipojo>
\ No newline at end of file
diff --git a/ipojo/tests/handler/transaction/src/test/resources/requiresnew.xml b/ipojo/tests/handler/transaction/src/test/resources/requiresnew.xml
new file mode 100644
index 0000000..d91aa58
--- /dev/null
+++ b/ipojo/tests/handler/transaction/src/test/resources/requiresnew.xml
@@ -0,0 +1,25 @@
+<ipojo xmlns:tr="org.apache.felix.ipojo.transaction">
+	<component classname="org.apache.felix.ipojo.transaction.test.component.FooDelegator" name="requiresnew-ok">
+		<provides/>
+		<requires field="foo"/>
+		<tr:transaction field="transaction">
+			<transactionnal method="doSomethingGood" propagation="requiresnew"/>
+			<transactionnal method="getCurrentTransaction" propagation="requiresnew"/>
+			<transactionnal method="doSomethingBad" propagation="requiresnew" exceptiononrollback="true"/>
+			<transactionnal method="doSomethingBad2" norollbackfor="java.lang.UnsupportedOperationException" propagation="requiresnew"/>
+			<transactionnal method="doSomethingLong" propagation="requiresnew"/>
+		</tr:transaction>
+	</component>
+	
+	<component classname="org.apache.felix.ipojo.transaction.test.component.FooDelegator" name="requiresnew-cb">
+		<provides/>
+		<requires field="foo" />
+		<tr:transaction field="transaction" onCommit="onCommit" onRollback="onRollback">
+			<transactionnal method="doSomethingGood" propagation="requiresnew"/>
+			<transactionnal method="getCurrentTransaction" propagation="requiresnew"/>
+			<transactionnal method="doSomethingBad" propagation="requiresnew"/>
+			<transactionnal method="doSomethingBad2" norollbackfor="java.lang.UnsupportedOperationException" propagation="requiresnew"/>
+			<transactionnal method="doSomethingLong" propagation="requiresnew"/>
+		</tr:transaction>
+	</component>
+</ipojo>
\ No newline at end of file
diff --git a/ipojo/tests/handler/transaction/src/test/resources/supported.xml b/ipojo/tests/handler/transaction/src/test/resources/supported.xml
new file mode 100644
index 0000000..d4fc6b5
--- /dev/null
+++ b/ipojo/tests/handler/transaction/src/test/resources/supported.xml
@@ -0,0 +1,25 @@
+<ipojo xmlns:tr="org.apache.felix.ipojo.transaction">
+	<component classname="org.apache.felix.ipojo.transaction.test.component.FooDelegator" name="supported-ok">
+		<provides/>
+		<requires field="foo"/>
+		<tr:transaction field="transaction">
+			<transactionnal method="doSomethingGood" propagation="supported"/>
+			<transactionnal method="getCurrentTransaction" propagation="supported"/>
+			<transactionnal method="doSomethingBad" propagation="supported"/>
+			<transactionnal method="doSomethingBad2" norollbackfor="java.lang.UnsupportedOperationException" propagation="supported"/>
+			<transactionnal method="doSomethingLong" propagation="supported"/>
+		</tr:transaction>
+	</component>
+	
+	<component classname="org.apache.felix.ipojo.transaction.test.component.FooDelegator" name="supported-cb">
+		<provides/>
+		<requires field="foo" />
+		<tr:transaction field="transaction" onCommit="onCommit" onRollback="onRollback">
+			<transactionnal method="doSomethingGood" propagation="supported"/>
+			<transactionnal method="getCurrentTransaction" propagation="supported"/>
+			<transactionnal method="doSomethingBad" propagation="supported"/>
+			<transactionnal method="doSomethingBad2" norollbackfor="java.lang.UnsupportedOperationException" propagation="supported"/>
+			<transactionnal method="doSomethingLong" propagation="supported"/>
+		</tr:transaction>
+	</component>
+</ipojo>
\ No newline at end of file
