1 16 17 package org.springframework.jdbc.support.lob; 18 19 import org.springframework.jdbc.datasource.DataSourceUtils; 20 import org.springframework.transaction.support.TransactionSynchronizationAdapter; 21 import org.springframework.util.Assert; 22 23 32 public class SpringLobCreatorSynchronization extends TransactionSynchronizationAdapter { 33 34 40 public static final int LOB_CREATOR_SYNCHRONIZATION_ORDER = 41 DataSourceUtils.CONNECTION_SYNCHRONIZATION_ORDER - 200; 42 43 44 private final LobCreator lobCreator; 45 46 private boolean beforeCompletionCalled = false; 47 48 49 53 public SpringLobCreatorSynchronization(LobCreator lobCreator) { 54 Assert.notNull(lobCreator, "LobCreator must not be null"); 55 this.lobCreator = lobCreator; 56 } 57 58 public int getOrder() { 59 return LOB_CREATOR_SYNCHRONIZATION_ORDER; 60 } 61 62 63 public void beforeCompletion() { 64 this.beforeCompletionCalled = true; 68 this.lobCreator.close(); 69 } 70 71 public void afterCompletion(int status) { 72 if (!this.beforeCompletionCalled) { 73 this.lobCreator.close(); 77 } 78 } 79 80 } 81 | Popular Tags |