001/* 002 * (C) Copyright 2013 Nuxeo SA (http://nuxeo.com/) and others. 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 * 016 * Contributors: 017 * Benoit Delbosc 018 */ 019 020package org.nuxeo.ecm.core.storage.sql; 021 022import java.util.Properties; 023 024import javax.naming.NamingException; 025import javax.transaction.TransactionManager; 026 027import net.sf.ehcache.transaction.manager.TransactionManagerLookup; 028import net.sf.ehcache.transaction.xa.EhcacheXAResource; 029 030import org.apache.commons.logging.Log; 031import org.apache.commons.logging.LogFactory; 032import org.nuxeo.runtime.transaction.TransactionHelper; 033 034/** 035 * Help ehcache to find the Nuxeo transaction manager 036 */ 037public class NuxeoEhcacheTransactionManagerLookup implements TransactionManagerLookup { 038 private static final Log log = LogFactory.getLog(NuxeoEhcacheTransactionManagerLookup.class); 039 040 @Override 041 public TransactionManager getTransactionManager() { 042 try { 043 return TransactionHelper.lookupTransactionManager(); 044 } catch (NamingException e) { 045 log.error(e.getMessage(), e); 046 return null; 047 } 048 } 049 050 @Override 051 public void register(EhcacheXAResource resource) { 052 log.info("register XA resource"); 053 } 054 055 @Override 056 public void unregister(EhcacheXAResource resource) { 057 log.info("unregister XA resource"); 058 } 059 060 @Override 061 public void setProperties(Properties properties) { 062 log.info("set properties"); 063 } 064 065}