001/*
002 * Copyright (c) 2013 Nuxeo SA (http://nuxeo.com/) and others.
003 *
004 * All rights reserved. This program and the accompanying materials
005 * are made available under the terms of the Eclipse Public License v1.0
006 * which accompanies this distribution, and is available at
007 * http://www.eclipse.org/legal/epl-v10.html
008 *
009 * Contributors:
010 *     Benoit Delbosc
011 */
012
013package org.nuxeo.ecm.core.storage.sql;
014
015import java.util.Properties;
016
017import javax.naming.NamingException;
018import javax.transaction.TransactionManager;
019
020import net.sf.ehcache.transaction.manager.TransactionManagerLookup;
021import net.sf.ehcache.transaction.xa.EhcacheXAResource;
022
023import org.apache.commons.logging.Log;
024import org.apache.commons.logging.LogFactory;
025import org.nuxeo.runtime.transaction.TransactionHelper;
026
027/**
028 * Help ehcache to find the Nuxeo transaction manager
029 */
030public class NuxeoEhcacheTransactionManagerLookup implements TransactionManagerLookup {
031    private static final Log log = LogFactory.getLog(NuxeoEhcacheTransactionManagerLookup.class);
032
033    @Override
034    public TransactionManager getTransactionManager() {
035        try {
036            return TransactionHelper.lookupTransactionManager();
037        } catch (NamingException e) {
038            log.error(e.getMessage(), e);
039            return null;
040        }
041    }
042
043    @Override
044    public void register(EhcacheXAResource resource) {
045        log.info("register XA resource");
046    }
047
048    @Override
049    public void unregister(EhcacheXAResource resource) {
050        log.info("unregister XA resource");
051    }
052
053    @Override
054    public void setProperties(Properties properties) {
055        log.info("set properties");
056    }
057
058}