private void readObject(ObjectInputStream ois) throws IOException, ClassNotFoundException { // on the inverse, it makes sense that if a ThreadLocalSessionContext- // bound session then gets deserialized to go ahead and re-bind it to // the ThreadLocalSessionContext session map. ois.defaultReadObject(); realSession.getTransaction().registerSynchronization( buildCleanupSynch() ); doBind( wrappedSession, factory() ); } }
@Override public final Session currentSession() throws HibernateException { Session current = existingSession( factory() ); if ( current == null ) { current = buildOrObtainSession(); // register a cleanup sync current.getTransaction().registerSynchronization( buildCleanupSynch() ); // wrap the session in the transaction-protection proxy if ( needsWrapping( current ) ) { current = wrap( current ); } // then bind it doBind( current, factory() ); } else { validateExistingSession( current ); } return current; }
@Override public void addTransactionCallback(HibernateTransactionCallback callback) { transaction.registerSynchronization(callback); }
@Override public void registerSynchronization(final Synchronization synchronization) throws HibernateException { transaction.registerSynchronization(synchronization); }
private void readObject(ObjectInputStream ois) throws IOException, ClassNotFoundException { // on the inverse, it makes sense that if a ThreadLocalSessionContext- // bound session then gets deserialized to go ahead and re-bind it to // the ThreadLocalSessionContext session map. ois.defaultReadObject(); realSession.getTransaction().registerSynchronization( buildCleanupSynch() ); doBind( wrappedSession, factory ); } }
public static void registerRemovalHook(EventSource eventSource, Map<Object, Collection> pendingMap, Object entity) { eventSource.getTransaction().registerSynchronization(new RemoveFromPending(pendingMap, entity)); }
private void readObject(ObjectInputStream ois) throws IOException, ClassNotFoundException { // on the inverse, it makes sense that if a ThreadLocalSessionContext- // bound session then gets deserialized to go ahead and re-bind it to // the ThreadLocalSessionContext session map. ois.defaultReadObject(); realSession.getTransaction().registerSynchronization( buildCleanupSynch() ); doBind( wrappedSession, factory() ); } }
private void readObject(ObjectInputStream ois) throws IOException, ClassNotFoundException { // on the inverse, it makes sense that if a ThreadLocalSessionContext- // bound session then gets deserialized to go ahead and re-bind it to // the ThreadLocalSessionContext session map. ois.defaultReadObject(); realSession.getTransaction().registerSynchronization( buildCleanupSynch() ); doBind( wrappedSession, factory() ); } }
private void readObject(ObjectInputStream ois) throws IOException, ClassNotFoundException { // on the inverse, it makes sense that if a ThreadLocalSessionContext- // bound session then gets deserialized to go ahead and re-bind it to // the ThreadLocalSessionContext session map. ois.defaultReadObject(); realSession.getTransaction().registerSynchronization( buildCleanupSynch() ); doBind( wrappedSession, factory() ); } }
@Override public void registerSynchronization(Synchronization sync) { if (log.isDebugEnabled()) { log.debug("registering synchronization: " + sync); } getDelegate().registerSynchronization(sync); }
@Override public boolean registerSynchronization(Synchronization sync, EntityManager entityManager) { try { //TODO: just make sure that a Hibernate JPA EntityTransaction // delegates to the Hibernate Session transaction getSession(entityManager).getTransaction().registerSynchronization(sync); return true; } catch (NotHibernateException nhe) { return super.registerSynchronization(sync, entityManager); } }
private static void registerNotification(final String event) { Synchronization notification = new Synchronization() { public void beforeCompletion() { } public void afterCompletion(int status) { if (status == Status.STATUS_COMMITTED) { if (log.isDebugEnabled()) log.debug("sending '" + event + "' notification"); Semaphore eventSemaphore = getEventSemaphore(event); eventSemaphore.release(); } } }; JbpmContext.getCurrentJbpmContext() .getSession() .getTransaction() .registerSynchronization(notification); }
private static void registerNotification(final String event) { Synchronization notification = new Synchronization() { public void beforeCompletion() { } public void afterCompletion(int status) { if (status == Status.STATUS_COMMITTED) { if (log.isDebugEnabled()) log.debug("sending '" + event + "' notification"); Semaphore eventSemaphore = getEventSemaphore(event); eventSemaphore.release(); } } }; JbpmContext.getCurrentJbpmContext() .getSession() .getTransaction() .registerSynchronization(notification); }
@Override public void registerSynchronization(Synchronization sync) { if ( log.isDebugEnabled() ) { log.debug("registering synchronization: " + sync); } assertActive(); getDelegate().registerSynchronization(sync); }
@Override public void doAfterCommit(Runnable runnable) { if (getSession().getTransaction().isActive()) { getSession().getTransaction().registerSynchronization(new Synchronization() { @Override public void beforeCompletion() { } @Override public void afterCompletion(int status) { if (status == Status.STATUS_COMMITTED) runnable.run(); } }); } else { runnable.run(); } }
private void joinTransaction() throws SystemException { UserTransaction transaction = Transaction.instance(); if ( transaction.isActive() ) { session.isOpen(); try { transaction.registerSynchronization(this); } catch (Exception e) { session.getTransaction().registerSynchronization(this); } synchronizationRegistered = true; } }
public void begin() throws NotSupportedException, SystemException { log.debug("beginning JPA resource-local transaction"); // TODO: translate exceptions that occur into the correct JTA exception try { getDelegate().begin(); getSynchronizations().afterTransactionBegin(); // use hibernate to manage the synchronizations // that way even if the user commits the transaction // themselves they will still be handled getDelegate().registerSynchronization(this); synchronizationRegistered = true; } catch (RuntimeException re) { throw re; } }
public final Session currentSession() throws HibernateException { Session current = existingSession( factory ); if (current == null) { current = buildOrObtainSession(); // register a cleanup synch current.getTransaction().registerSynchronization( buildCleanupSynch() ); // wrap the session in the transaction-protection proxy if ( needsWrapping( current ) ) { current = wrap( current ); } // then bind it doBind( current, factory ); } return current; }
private void joinTransaction() throws SystemException { UserTransaction transaction = Transaction.instance(); if ( !transaction.isActiveOrMarkedRollback() ) { throw new IllegalStateException("JbpmContext may only be used inside a transaction"); } if ( !synchronizationRegistered && !Lifecycle.isDestroying() && transaction.isActive() ) { jbpmContext.getSession().isOpen(); try //TODO: what we really want here is if (!cmt) { transaction.registerSynchronization(this); } catch (UnsupportedOperationException uoe) { jbpmContext.getSession().getTransaction().registerSynchronization(this); } synchronizationRegistered = true; } }
@Override public final Session currentSession() throws HibernateException { Session current = existingSession( factory() ); if ( current == null ) { current = buildOrObtainSession(); // register a cleanup sync current.getTransaction().registerSynchronization( buildCleanupSynch() ); // wrap the session in the transaction-protection proxy if ( needsWrapping( current ) ) { current = wrap( current ); } // then bind it doBind( current, factory() ); } else { validateExistingSession( current ); } return current; }