@Test public void runtime_exception_will_abort_transaction() throws Exception { Performer delegate = newMock(Performer.class); HibernateSessionManager manager = newMock(HibernateSessionManager.class); HibernateTransactionDecorator decorator = newHibernateSessionManagerDecorator(manager); RuntimeException re = new RuntimeException("Unexpected."); delegate.perform(); TestBase.setThrowable(re); manager.abort(); replay(); Performer interceptor = decorator.build(Performer.class, delegate, "foo.Bar"); try { interceptor.perform(); TestBase.unreachable(); } catch (RuntimeException ex) { Assert.assertSame(ex, re); } verify(); }
@Override public <T> T build(Class<T> serviceInterface, T delegate, String serviceId) { assert serviceInterface != null; assert delegate != null; assert InternalUtils.isNonBlank(serviceId); String description = String.format("<Hibernate Transaction interceptor for %s(%s)>", serviceId, serviceInterface.getName()); AspectInterceptorBuilder<T> builder = aspectDecorator.createBuilder(serviceInterface, delegate, description); advisor.addTransactionCommitAdvice(builder); return builder.build(); }
HibernateTransactionDecoratorImpl implements HibernateTransactionDecorator { @Override public <T> T build(Class<T> serviceInterface, T delegate, String serviceId) { assert serviceInterface != null; assert delegate != null; assert InternalUtils.isNonBlank(serviceId); String description = String.format("<Hibernate Transaction interceptor for %s(%s)>", serviceId, serviceInterface.getName()); AspectInterceptorBuilder<T> builder = aspectDecorator.createBuilder(serviceInterface, delegate, description); advisor.addTransactionCommitAdvice(builder); return builder.build(); } }
HibernateTransactionDecoratorImpl implements HibernateTransactionDecorator { @Override public <T> T build(Class<T> serviceInterface, T delegate, String serviceId) { assert serviceInterface != null; assert delegate != null; assert InternalUtils.isNonBlank(serviceId); String description = String.format("<Hibernate Transaction interceptor for %s(%s)>", serviceId, serviceInterface.getName()); AspectInterceptorBuilder<T> builder = aspectDecorator.createBuilder(serviceInterface, delegate, description); advisor.addTransactionCommitAdvice(builder); return builder.build(); } HibernateTransactionDecoratorImpl(AspectDecorator aspectDecorator, HibernateTransactionAdvisor advisor); }
HibernateTransactionDecoratorImpl implements HibernateTransactionDecorator { @Override public <T> T build(Class<T> serviceInterface, T delegate, String serviceId) { assert serviceInterface != null; assert delegate != null; assert InternalUtils.isNonBlank(serviceId); String description = String.format("<Hibernate Transaction interceptor for %s(%s)>", serviceId, serviceInterface.getName()); AspectInterceptorBuilder<T> builder = aspectDecorator.createBuilder(serviceInterface, delegate, description); advisor.addTransactionCommitAdvice(builder); return builder.build(); } HibernateTransactionDecoratorImpl(AspectDecorator aspectDecorator, HibernateTransactionAdvisor advisor); @Override T build(Class<T> serviceInterface, T delegate, String serviceId); }
HibernateTransactionDecoratorImpl implements HibernateTransactionDecorator { @Override public <T> T build(Class<T> serviceInterface, T delegate, String serviceId) { assert serviceInterface != null; assert delegate != null; assert InternalUtils.isNonBlank(serviceId); String description = String.format("<Hibernate Transaction interceptor for %s(%s)>", serviceId, serviceInterface.getName()); AspectInterceptorBuilder<T> builder = aspectDecorator.createBuilder(serviceInterface, delegate, description); advisor.addTransactionCommitAdvice(builder); return builder.build(); } HibernateTransactionDecoratorImpl(AspectDecorator aspectDecorator, HibernateTransactionAdvisor advisor); @Override T build(Class<T> serviceInterface, T delegate, String serviceId);  }