1 16 package com.ibatis.dao.engine.transaction.toplink; 17 18 import java.util.Properties ; 19 20 import oracle.toplink.publicinterface.UnitOfWork; 21 import oracle.toplink.threetier.Server; 22 import oracle.toplink.tools.sessionmanagement.SessionManager; 23 24 import com.ibatis.dao.client.DaoException; 25 import com.ibatis.dao.client.DaoTransaction; 26 import com.ibatis.dao.engine.transaction.DaoTransactionManager; 27 28 35 public class ToplinkDaoTransactionManager implements DaoTransactionManager { 36 37 40 private Server server; 41 42 private UnitOfWork uow; 43 44 47 56 public void commitTransaction(DaoTransaction transaction) 57 throws DaoException { 58 59 ((ToplinkDaoTransaction) transaction).commit(); 60 61 } 62 63 77 public void configure(Properties properties) throws DaoException { 78 79 String sessionName = null; 81 82 try { 83 84 SessionManager manager = SessionManager.getManager(); 85 86 sessionName = properties.getProperty("session.name"); 88 server = (Server) manager.getSession(sessionName, 89 ToplinkDaoTransactionManager.class.getClassLoader()); 90 91 } catch (Exception e) { 92 93 throw new DaoException( 94 "Error configuring Toplink environment for session: " 95 + sessionName); 96 97 } 98 99 } 100 101 111 public void rollbackTransaction(DaoTransaction transaction) 112 throws DaoException { 113 114 ((ToplinkDaoTransaction) transaction).rollback(); 115 116 } 117 118 127 public DaoTransaction startTransaction() throws DaoException { 128 129 ToplinkDaoTransaction trans = new ToplinkDaoTransaction(uow, server); 130 131 return trans; 132 133 } 134 135 } | Popular Tags |