diff --git a/ipojo/handler/transaction/src/main/java/org/apache/felix/ipojo/transaction/TransactionHandler.java b/ipojo/handler/transaction/src/main/java/org/apache/felix/ipojo/transaction/TransactionHandler.java
new file mode 100644
index 0000000..31415d1
--- /dev/null
+++ b/ipojo/handler/transaction/src/main/java/org/apache/felix/ipojo/transaction/TransactionHandler.java
@@ -0,0 +1,291 @@
+package org.apache.felix.ipojo.transaction;
+
+import java.lang.reflect.InvocationTargetException;
+import java.util.ArrayList;
+import java.util.Dictionary;
+import java.util.List;
+
+import javax.transaction.Status;
+import javax.transaction.Synchronization;
+import javax.transaction.SystemException;
+import javax.transaction.Transaction;
+import javax.transaction.TransactionManager;
+
+import org.apache.felix.ipojo.ComponentInstance;
+import org.apache.felix.ipojo.ConfigurationException;
+import org.apache.felix.ipojo.PrimitiveHandler;
+import org.apache.felix.ipojo.metadata.Element;
+import org.apache.felix.ipojo.parser.FieldMetadata;
+import org.apache.felix.ipojo.parser.MethodMetadata;
+import org.apache.felix.ipojo.parser.ParseUtils;
+import org.apache.felix.ipojo.util.Callback;
+
+public class TransactionHandler extends PrimitiveHandler implements Synchronization {
+
+    public static final String NAMESPACE= "org.apache.felix.ipojo.transaction";
+
+    public static final String NAME= "transaction";
+
+    private static final String FIELD_ATTRIBUTE= "field";
+
+    private static final String ONCOMMIT_ATTRIBUTE= "oncommit";
+
+    private static final String ONROLLBACK_ATTRIBUTE= "onrollback";
+
+    private static final String TRANSACTIONNAL_ELEMENT = "transactionnal";
+
+    private static final String METHOD_ATTRIBUTE = "method";
+
+    private static final String TIMEOUT_ATTRIBUTE = "timeout";
+
+    private static final String PROPAGATION_ATTRIBUTE = "propagation";
+
+    private static final String EXCEPTIONONROLLBACK_ATTRIBUTE = "exceptiononrollback";
+
+    private static final String NOROLLBACKFOR_ATTRIBUTE = "norollbackfor";
+
+    public static final int DEFAULT_PROPAGATION = TransactionnalMethod.REQUIRES;
+
+
+    private TransactionManager m_transactionManager; // Service Dependency
+
+    private List<TransactionnalMethod> m_methods = new ArrayList<TransactionnalMethod>();
+
+    private Callback m_onRollback;
+
+    private Callback m_onCommit;
+
+    private List<Transaction> m_transactions = new ArrayList<Transaction>();
+
+
+    public void configure(Element arg0, Dictionary arg1)
+            throws ConfigurationException {
+        Element[] elements = arg0.getElements(NAME, NAMESPACE);
+        if (elements.length > 1) {
+            throw new ConfigurationException("The handler " + NAMESPACE + ":" + NAME + " cannot be declared several times");
+        }
+
+        String field = elements[0].getAttribute(FIELD_ATTRIBUTE);
+        if (field != null) {
+            FieldMetadata meta = getPojoMetadata().getField(field);
+            if (meta == null) {
+                throw new ConfigurationException("The transaction field does not exist in the pojo class : " + field);
+            }
+            if (! meta.getFieldType().equals(Transaction.class.getName())) {
+                throw new ConfigurationException("The transaction field type must be " + Transaction.class.getName());
+            }
+            // Register the interceptor
+            getInstanceManager().register(meta, this);
+
+        }
+
+        String oncommit = elements[0].getAttribute(ONCOMMIT_ATTRIBUTE);
+        if (oncommit != null) {
+            m_onCommit = new Callback(oncommit, new String[] { Transaction.class.getName() }, false, getInstanceManager());
+        }
+
+        String onrollback = elements[0].getAttribute(ONROLLBACK_ATTRIBUTE);
+        if (onrollback != null) {
+            m_onRollback = new Callback(onrollback, new String[] { Transaction.class.getName() }, false, getInstanceManager());
+        }
+
+
+        Element[] sub = elements[0].getElements(TRANSACTIONNAL_ELEMENT);
+        if (sub == null  || sub.length == 0) {
+            throw new ConfigurationException("The handler " + NAMESPACE + ":" + NAME + " must have " + TRANSACTIONNAL_ELEMENT + " subelement");
+        }
+
+        for (int i = 0; i < sub.length; i++) {
+            String method = sub[i].getAttribute(METHOD_ATTRIBUTE);
+            String to = sub[i].getAttribute(TIMEOUT_ATTRIBUTE);
+            String propa = sub[i].getAttribute(PROPAGATION_ATTRIBUTE);
+            String nrbf = sub[i].getAttribute(NOROLLBACKFOR_ATTRIBUTE);
+            String eorb = sub[i].getAttribute(EXCEPTIONONROLLBACK_ATTRIBUTE);
+
+            if (method == null) {
+                throw new ConfigurationException("A transactionnal element must specified the method attribute");
+            }
+            MethodMetadata meta = this.getPojoMetadata().getMethod(method);
+            if (meta == null) {
+                throw new ConfigurationException("A transactionnal method is not in the pojo class : " + method);
+            }
+
+            int timeout = 0;
+            if (to != null) {
+                timeout = new Integer(to).intValue();
+            }
+
+            int propagation = DEFAULT_PROPAGATION;
+            if (propa != null) {
+                propagation = parsePropagation(propa);
+            }
+
+            List<String> exceptions = new ArrayList<String>();
+            if (nrbf != null) {
+                exceptions = (List<String>) ParseUtils.parseArraysAsList(nrbf);
+            }
+
+            boolean exceptionOnRollback = false;
+            if (eorb != null) {
+                exceptionOnRollback = new Boolean(eorb).booleanValue();
+            }
+
+            TransactionnalMethod tm = new TransactionnalMethod(method, propagation, timeout, exceptions, exceptionOnRollback, this);
+            m_methods.add(tm);
+            this.getInstanceManager().register(meta, tm);
+        }
+
+    }
+
+    private int parsePropagation(String propa) throws ConfigurationException {
+       if (propa.equalsIgnoreCase("requires")) {
+           return TransactionnalMethod.REQUIRES;
+
+       } else if (propa.equalsIgnoreCase("mandatory")){
+           return TransactionnalMethod.MANDATORY;
+
+       } else if (propa.equalsIgnoreCase("notsupported")) {
+           return TransactionnalMethod.NOT_SUPPORTED;
+
+       } else if (propa.equalsIgnoreCase("supported")) {
+           return TransactionnalMethod.SUPPORTED;
+
+       } else if (propa.equalsIgnoreCase("never")) {
+           return TransactionnalMethod.NEVER;
+
+        } else if (propa.equalsIgnoreCase("requiresnew")) {
+            return TransactionnalMethod.REQUIRES_NEW;
+        }
+
+       throw new ConfigurationException("Unknown propgation policy : " + propa);
+    }
+
+    public void start() {
+        // Set transaction managers.
+        for (TransactionnalMethod method : m_methods) {
+            method.setTransactionManager(m_transactionManager);
+        }
+    }
+
+    public void stop() {
+        // Nothing to do.
+    }
+
+    public synchronized void bind(TransactionManager tm) {
+        for (TransactionnalMethod method : m_methods) {
+            method.setTransactionManager(tm);
+        }
+    }
+
+    public synchronized void unbind(TransactionManager tm) {
+        for (TransactionnalMethod method : m_methods) {
+            method.setTransactionManager(null);
+        }
+    }
+
+    public void transactionRolledback(Transaction t) {
+       if (m_onRollback != null) {
+            try {
+                m_onRollback.call(new Object[] { t });
+            } catch (NoSuchMethodException e1) {
+                error("Cannot invoke the onRollback method, method not found",
+                        e1);
+            } catch (IllegalAccessException e1) {
+                error(
+                        "Cannot invoke the onRollback method,cannot access the method",
+                        e1);
+            } catch (InvocationTargetException e1) {
+                error(
+                        "Cannot invoke the onRollback method,the method thrown an exception",
+                        e1.getTargetException());
+            }
+        }
+    }
+
+    public void transactionCommitted(Transaction t) {
+        if (m_onRollback != null) {
+            try {
+                m_onCommit.call(new Object[] { t });
+            } catch (NoSuchMethodException e1) {
+                error("Cannot invoke the onCommit callback, method not found",
+                        e1);
+            } catch (IllegalAccessException e1) {
+                error(
+                        "Cannot invoke the onCommit callback,cannot access the method",
+                        e1);
+            } catch (InvocationTargetException e1) {
+                error(
+                        "Cannot invoke the onCommit callback,the method thrown an exception",
+                        e1.getTargetException());
+            }
+        }
+
+    }
+
+    public void stateChanged(int newState) {
+        if (newState == ComponentInstance.INVALID) {
+            // rollback all owned transactions.
+            for (int i = 0; i < m_methods.size(); i++) {
+                m_methods.get(i).rollbackOwnedTransactions();
+            }
+
+            for (int i =0; i < m_transactions.size(); i++) {
+                try {
+                    m_transactions.get(i).setRollbackOnly();
+                } catch (Exception e) {
+                    error("Cannot set rollback only on a transaction : " + e.getMessage());
+                }
+            }
+        }
+    }
+
+    public synchronized Object onGet(Object pojo, String fieldName, Object value) {
+        try {
+            if (m_transactionManager != null) {
+                return m_transactionManager.getTransaction();
+            } else {
+                return null;
+            }
+        } catch (SystemException e) {
+            error("Cannot get the current transaction, internal error", e);
+            return null;
+        }
+    }
+
+    public void afterCompletion(int arg0) {
+        try {
+            if (m_transactionManager.getTransaction() != null) {
+                m_transactions .remove(m_transactionManager.getTransaction());
+                if (arg0 == Status.STATUS_ROLLEDBACK) {
+                    transactionRolledback(m_transactionManager.getTransaction());
+                } else if (arg0 == Status.STATUS_COMMITTED) {
+                    transactionCommitted(m_transactionManager.getTransaction());
+                }
+            }
+        } catch (SystemException e) {
+           error("Cannot remove the transaction from the transaction list : " + e.getMessage());
+        }
+    }
+
+    public void beforeCompletion() {
+
+    }
+
+    public void addTransaction(Transaction transaction) {
+        if (m_transactions.contains(transaction)) {
+            return;
+        }
+        try {
+            transaction.registerSynchronization(this);
+            m_transactions.add(transaction);
+        } catch (Exception e) {
+           error("Cannot add the transaction to the transaction list : " + e.getMessage());
+        }
+    }
+
+    public List<Transaction> getTransactions() {
+        return m_transactions;
+    }
+
+
+}
diff --git a/ipojo/handler/transaction/src/main/java/org/apache/felix/ipojo/transaction/TransactionnalMethod.java b/ipojo/handler/transaction/src/main/java/org/apache/felix/ipojo/transaction/TransactionnalMethod.java
new file mode 100644
index 0000000..27a45d0
--- /dev/null
+++ b/ipojo/handler/transaction/src/main/java/org/apache/felix/ipojo/transaction/TransactionnalMethod.java
@@ -0,0 +1,295 @@
+package org.apache.felix.ipojo.transaction;
+
+import java.lang.reflect.Method;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+
+import javax.transaction.HeuristicMixedException;
+import javax.transaction.HeuristicRollbackException;
+import javax.transaction.InvalidTransactionException;
+import javax.transaction.NotSupportedException;
+import javax.transaction.RollbackException;
+import javax.transaction.SystemException;
+import javax.transaction.Transaction;
+import javax.transaction.TransactionManager;
+
+import org.apache.felix.ipojo.MethodInterceptor;
+
+public class TransactionnalMethod implements MethodInterceptor {
+    
+    public static final int REQUIRES = 0;
+    
+    public static final int REQUIRES_NEW = 1;
+    
+    public static final int MANDATORY = 2;
+    
+    public static final int SUPPORTED = 3;
+    
+    public static final int NOT_SUPPORTED = 4;
+
+    public static final int NEVER = 5;
+  
+    private String method;
+    
+    private int propagation;
+    
+    private int timeout;
+    
+    private List<String> exceptions;
+
+    private TransactionManager manager;
+    
+    private Map <Thread, Transaction> m_owned = new HashMap<Thread, Transaction>();
+
+    private boolean exceptionOnRollback;
+    
+
+    private TransactionHandler handler;
+
+    private Transaction suspended;
+    
+    public TransactionnalMethod(String method, int propagation, int timeout, List<String> exception, boolean exceptionOnRollback, TransactionHandler handler) {
+        this.method = method;
+        this.propagation = propagation;
+        this.timeout = timeout;
+        this.exceptions = exception;
+        this.exceptionOnRollback = exceptionOnRollback;
+        this.handler = handler;
+    }
+    
+    public synchronized void setTransactionManager(TransactionManager tm) {
+        System.out.println("Set transaction manager to " + tm);
+        manager = tm;
+        if (manager == null) {
+            // Clear stored transactions.
+            m_owned.clear();
+            
+        }
+    }
+    
+    
+    public void onEntry() throws SystemException, NotSupportedException {
+        TransactionManager manager = null;
+        synchronized (this) {
+            if (this.manager != null) {
+                manager = this.manager; // Stack confinement
+            } else {
+                return; // Nothing can be done...
+            }
+        }
+        
+        Transaction transaction = manager.getTransaction();
+        switch (propagation) {
+            case REQUIRES:
+                // Are we already in a transaction?
+                if (transaction == null) {
+                    // No, create one
+                    System.out.println("Begin a new transaction !");
+
+                    if (timeout > 0) {
+                        manager.setTransactionTimeout(timeout);
+                    }
+                    manager.begin();
+                    m_owned.put(Thread.currentThread(), manager.getTransaction());
+                } else {
+                    // Add the transaction to the transaction list
+                    handler.addTransaction(transaction);
+                }
+                break;
+            case MANDATORY: 
+                if (transaction == null) {
+                    // Error
+                    throw new IllegalStateException("The method " + method + " must be called inside a transaction");
+                } else {
+                    // Add the transaction to the transaction list
+                    handler.addTransaction(transaction);
+                }
+                break;
+            case SUPPORTED:
+                // if transaction != null, register the callback, else do nothing
+                if (transaction != null) {
+                    handler.addTransaction(transaction);
+                } // Else do nothing.
+                break;
+            case NOT_SUPPORTED:
+                // Do nothing.
+                break;
+            case NEVER:
+                if (transaction != null) {
+                    throw new IllegalStateException("The method " + method + " must never be called inside a transaction");
+                }
+                break;
+            case REQUIRES_NEW:
+                if (transaction == null) {
+                    // No current transaction, Just creates a new one
+                    if (timeout > 0) {
+                        manager.setTransactionTimeout(timeout);
+                    }
+                    manager.begin();
+                    System.out.println("== Associate " + Thread.currentThread() + " to " + manager.getTransaction() + " ==");
+                    m_owned.put(Thread.currentThread(), manager.getTransaction());
+                } else {
+                    if (suspended == null) {
+                        suspended = manager.suspend();
+                        if (timeout > 0) {
+                            manager.setTransactionTimeout(timeout);
+                        }
+                        manager.begin();
+                        m_owned.put(Thread.currentThread(), manager.getTransaction());
+                    } else {
+                        throw new IllegalStateException("The method " + method + " requires to suspend a second times a transaction");
+                    }
+                }
+                break;
+            default:
+                throw new UnsupportedOperationException("Unknown or unsupported propagation policy for " + method + " :" + propagation);
+        
+        }
+    }
+    
+    public void onExit() throws SecurityException, HeuristicMixedException, HeuristicRollbackException, SystemException, InvalidTransactionException, IllegalStateException {
+        switch (propagation) {
+            case REQUIRES:
+                // Are we the owner of the transaction?
+                Transaction transaction = m_owned.get(Thread.currentThread());
+                if (transaction != null) { // Owner.
+                    try {
+                        transaction.commit(); // Commit the transaction
+                        m_owned.remove(Thread.currentThread());
+                        handler.transactionCommitted(transaction); // Manage potential notification.
+                    } catch ( RollbackException e) {
+                        m_owned.remove(Thread.currentThread());
+                        // The transaction was rolledback
+                        if (exceptionOnRollback) {
+                            throw new IllegalStateException("The transaction was rolledback : " + e.getMessage());
+                        }
+                        handler.transactionRolledback(transaction); // Manage potential notification.
+                    }
+                } // Else wait for commit.
+                break;
+            case MANDATORY: 
+                // We are never the owner, so just exits the transaction.
+                break;
+            case SUPPORTED:
+                // Do nothing.
+                break;
+            case NOT_SUPPORTED:
+                // Do nothing.
+                break;
+            case NEVER:
+                // Do nothing.
+                break;
+            case REQUIRES_NEW:
+                // We're necessary the owner.
+                transaction = m_owned.get(Thread.currentThread());
+                System.out.println("== Owned " + Thread.currentThread() + " to " + transaction + "==");
+                if (transaction == null) {
+                    throw new RuntimeException("Cannot apply the REQUIRES NEW propagation, we're not the transaction owner!"); 
+                }
+                try {
+                    transaction.commit(); // Commit the transaction
+                    m_owned.remove(Thread.currentThread());
+                    handler.transactionCommitted(transaction); // Manage potential notification.
+                    if (suspended != null) {
+                        manager.suspend(); // suspend the completed transaction.
+                        manager.resume(suspended);
+                        suspended = null;
+                    }
+                 } catch ( RollbackException e) { // The transaction was rolledback rather than committed
+                    m_owned.remove(Thread.currentThread());
+                    if (suspended != null) {
+                        manager.suspend(); // suspend the completed transaction.
+                        manager.resume(suspended); // The resume transaction is not rolledback, they are independent.
+                        suspended = null;
+                    }
+                    // The transaction was rolledback
+                    if (exceptionOnRollback) {
+                        throw new IllegalStateException("The transaction was rolledback : " + e.getMessage());
+                    }
+                    handler.transactionRolledback(transaction); // Manage potential notification.
+                }
+                break;
+            default:
+                throw new UnsupportedOperationException("Unknown or unsupported propagation policy for " + method + " :" + propagation);
+        
+        }
+    }
+    
+    public void onError(String exception) throws SystemException {
+        TransactionManager manager = null;
+        synchronized (this) {
+            if (this.manager != null) {
+                manager = this.manager; // Stack confinement
+            } else {
+                return; // Nothing can be done...
+            }
+        }
+        
+        // is the error something to exclude, and are we inside the transaction (owner or participant)? 
+        if (! exceptions.contains(exception)) {
+            Transaction tr = manager.getTransaction();
+            if (m_owned.containsValue(tr)  || handler.getTransactions().contains(tr)) {
+                // Set the transaction to rollback only
+                manager.getTransaction().setRollbackOnly();
+            }
+        }
+    }
+
+    public void onEntry(Object arg0, Method arg1, Object[] arg2) {
+        try {
+            onEntry();
+        } catch (Exception e) {
+            e.printStackTrace();
+            throw new RuntimeException("An issue occurs during transaction management of " + method + " : " + e.getMessage());
+        }
+        
+    }
+
+    public void onError(Object arg0, Method arg1, Throwable arg2) {
+        try {
+            System.out.println("Error in  a TM " + arg1.getName() + " " + arg2.getMessage());
+            arg2.printStackTrace();
+
+            onError(arg2.getClass().getName());
+        } catch (Exception e) {
+            e.printStackTrace();
+            throw new RuntimeException("An issue occurs during transaction management of " + method + " : " + e.getMessage());
+        }
+    }
+
+    public void onExit(Object arg0, Method arg1, Object arg2) {
+        // Wait for on finally.
+    }
+
+    public void onFinally(Object arg0, Method arg1) {
+        try {
+            System.out.println("Exits a TM " + arg1.getName());
+
+            onExit();
+        } catch (IllegalStateException e) {
+            throw e;
+        } catch (Exception e) {
+            throw new RuntimeException("An issue occurs during transaction management of " + method + " : " + e.getMessage());
+        }
+    }
+
+    public void rollbackOwnedTransactions() {
+        Iterator<Entry<Thread, Transaction>> entries = m_owned.entrySet().iterator();
+        while(entries.hasNext()) {
+            Entry<Thread, Transaction> entry = entries.next();
+            try {
+                entry.getValue().rollback();
+            } catch (IllegalStateException e) {
+                throw new RuntimeException("An issue occurs during transaction management of " + method + " : " + e.getMessage());
+            } catch (SystemException e) {
+                throw new RuntimeException("An issue occurs during transaction management of " + method + " : " + e.getMessage());
+            }
+        }
+        m_owned.clear();
+    }
+    
+    
+}
diff --git a/ipojo/handler/transaction/src/main/resources/metadata.xml b/ipojo/handler/transaction/src/main/resources/metadata.xml
new file mode 100644
index 0000000..55162a9
--- /dev/null
+++ b/ipojo/handler/transaction/src/main/resources/metadata.xml
@@ -0,0 +1,13 @@
+<ipojo xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+	xsi:schemaLocation="org.apache.felix.ipojo http://felix.apache.org/ipojo/schemas/CURRENT/core.xsd"
+	xmlns="org.apache.felix.ipojo">
+	
+	<handler name="transaction" namespace="org.apache.felix.ipojo.transaction" 
+		classname="org.apache.felix.ipojo.transaction.TransactionHandler">
+		<requires field="m_transactionManager">
+			<callback type="bind" method="bind"/>
+			<callback type="unbind" method="unbind"/>
+		</requires>
+	</handler>
+	
+</ipojo>
\ No newline at end of file
