001/* 002 * HA-JDBC: High-Availability JDBC 003 * Copyright (C) 2012 Paul Ferraro 004 * 005 * This program is free software: you can redistribute it and/or modify 006 * it under the terms of the GNU Lesser General Public License as published by 007 * the Free Software Foundation, either version 3 of the License, or 008 * (at your option) any later version. 009 * 010 * This program is distributed in the hope that it will be useful, 011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 013 * GNU Lesser General Public License for more details. 014 * 015 * You should have received a copy of the GNU Lesser General Public License 016 * along with this program. If not, see <http://www.gnu.org/licenses/>. 017 */ 018package net.sf.hajdbc.durability.none; 019 020import java.util.Map; 021 022import net.sf.hajdbc.Database; 023import net.sf.hajdbc.ExceptionFactory; 024import net.sf.hajdbc.durability.Durability; 025import net.sf.hajdbc.durability.InvocationEvent; 026import net.sf.hajdbc.durability.InvokerEvent; 027import net.sf.hajdbc.invocation.InvocationStrategy; 028import net.sf.hajdbc.invocation.Invoker; 029import net.sf.hajdbc.logging.Level; 030import net.sf.hajdbc.logging.Logger; 031import net.sf.hajdbc.logging.LoggerFactory; 032 033/** 034 * {@link Durability} implementation that does not track anything. 035 * This durability level cannot detect, nor recover from mid-commit crashes. 036 * @author Paul Ferraro 037 */ 038public class NoDurability<Z, D extends Database<Z>> implements Durability<Z, D> 039{ 040 private Logger logger = LoggerFactory.getLogger(this.getClass()); 041 042 /** 043 * {@inheritDoc} 044 * @see net.sf.hajdbc.durability.Durability#getInvocationStrategy(net.sf.hajdbc.invocation.InvocationStrategy, net.sf.hajdbc.durability.Durability.Phase, java.lang.Object) 045 */ 046 @Override 047 public InvocationStrategy getInvocationStrategy(InvocationStrategy strategy, Phase phase, Object transactionId) 048 { 049 return strategy; 050 } 051 052 /** 053 * {@inheritDoc} 054 * @see net.sf.hajdbc.durability.Durability#getInvoker(net.sf.hajdbc.invocation.Invoker, net.sf.hajdbc.durability.Durability.Phase, java.lang.Object, net.sf.hajdbc.ExceptionFactory) 055 */ 056 @Override 057 public <T, R, E extends Exception> Invoker<Z, D, T, R, E> getInvoker(Invoker<Z, D, T, R, E> invoker, Phase phase, Object transactionId, ExceptionFactory<E> exceptionFactory) 058 { 059 return invoker; 060 } 061 062 /** 063 * {@inheritDoc} 064 * @see net.sf.hajdbc.durability.Durability#recover(java.util.Map) 065 */ 066 @Override 067 public void recover(Map<InvocationEvent, Map<String, InvokerEvent>> invokers) 068 { 069 this.logger.log(Level.WARN, invokers.toString()); 070 } 071}