@@ -0,0 +1,1807 @@
+/*%0A * Copyright (C) 2004-2006  exedio GmbH (www.exedio.com)%0A *%0A * This library is free software; you can redistribute it and/or%0A * modify it under the terms of the GNU Lesser General Public%0A * License as published by the Free Software Foundation; either%0A * version 2.1 of the License, or (at your option) any later version.%0A *%0A * This library is distributed in the hope that it will be useful,%0A * but WITHOUT ANY WARRANTY; without even the implied warranty of%0A * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU%0A * Lesser General Public License for more details.%0A *%0A * You should have received a copy of the GNU Lesser General Public%0A * License along with this library; if not, write to the Free Software%0A * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA%0A */%0A%0Apackage com.exedio.cope.util;%0A%0Aimport java.io.IOException;%0A%0Aimport javax.servlet.Filter;%0Aimport javax.servlet.FilterChain;%0Aimport javax.servlet.FilterConfig;%0Aimport javax.servlet.ServletException;%0Aimport javax.servlet.ServletRequest;%0Aimport javax.servlet.ServletResponse;%0A%0Aimport com.exedio.cope.Model;%0Aimport com.exedio.cope.util.ServletUtil;%0A%0A/**%0A * @author Stephan Frisch, exedio GmbH%0A */%0Apublic class TransactionFilter implements Filter%0A%7B%0A%09private Model model;%0A%09%0A%09public void init(FilterConfig config) throws ServletException%0A%09%7B%0A%09%09model = ServletUtil.getModel(config);%0A%09%7D%0A%0A%09public void doFilter(%0A%09%09%09final ServletRequest request,%0A%09%09%09final ServletResponse response,%0A%09%09%09final FilterChain chain) throws IOException, ServletException%0A%09%7B%0A%09%09try%0A%09%09%7B%0A%09%09%09model.startTransaction();%0A%09%09%09chain.doFilter(request, response);%0A%09%09%09model.commit();%0A%09%09%7D%0A%09%09catch(Exception e)%0A%09%09%7B%0A%09%09%09model.rollback();%0A%09%09%7D%0A%09%09finally%0A%09%09%7B%0A%09%09%09model.rollbackIfNotCommitted();%0A%09%09%7D%0A%09%7D%0A%09%0A%09public void destroy()%0A%09%7B%0A%09%09// empty implementation%0A%09%7D%0A%09%0A%7D%0A

copy TransactionFilter from project