Search in sources :

Example 6 with ITransaction

use of org.eclipse.scout.rt.platform.transaction.ITransaction in project scout.rt by eclipse.

the class StatementProcessor method registerActiveStatement.

protected void registerActiveStatement(Statement s) throws SQLException {
    ITransaction tx = ITransaction.CURRENT.get();
    if (tx == null) {
        return;
    }
    ITransactionMember member = tx.getMember(getCallerService().getTransactionMemberId());
    if (member instanceof AbstractSqlTransactionMember) {
        ((AbstractSqlTransactionMember) member).registerActiveStatement(s);
    }
}
Also used : AbstractSqlTransactionMember(org.eclipse.scout.rt.server.jdbc.AbstractSqlTransactionMember) ITransaction(org.eclipse.scout.rt.platform.transaction.ITransaction) ITransactionMember(org.eclipse.scout.rt.platform.transaction.ITransactionMember)

Example 7 with ITransaction

use of org.eclipse.scout.rt.platform.transaction.ITransaction in project scout.rt by eclipse.

the class StatementProcessor method unregisterActiveStatement.

protected void unregisterActiveStatement(Statement s) {
    ITransaction tx = ITransaction.CURRENT.get();
    if (tx == null) {
        return;
    }
    ITransactionMember member = tx.getMember(getCallerService().getTransactionMemberId());
    if (member instanceof AbstractSqlTransactionMember) {
        ((AbstractSqlTransactionMember) member).unregisterActiveStatement(s);
    }
}
Also used : AbstractSqlTransactionMember(org.eclipse.scout.rt.server.jdbc.AbstractSqlTransactionMember) ITransaction(org.eclipse.scout.rt.platform.transaction.ITransaction) ITransactionMember(org.eclipse.scout.rt.platform.transaction.ITransactionMember)

Example 8 with ITransaction

use of org.eclipse.scout.rt.platform.transaction.ITransaction in project scout.rt by eclipse.

the class JmsMomImplementor method publishTransactional.

protected <DTO> void publishTransactional(final IDestination<DTO> destination, final DTO transferObject, final PublishInput input) throws JMSException {
    final ITransaction currentTransaction = assertNotNull(ITransaction.CURRENT.get(), "Transaction required for transactional messaging");
    // Register transaction member for transacted publishing.
    final JmsTransactionMember txMember = currentTransaction.registerMemberIfAbsent(m_momUid, new IFunction<String, JmsTransactionMember>() {

        @Override
        public JmsTransactionMember apply(final String memberId) {
            try {
                return BEANS.get(JmsTransactionMember.class).withMemberId(memberId).withSessionProvider(createSessionProvider(destination, true)).withAutoClose(// close upon transaction end
                true);
            } catch (final JMSException e) {
                throw BEANS.get(DefaultRuntimeExceptionTranslator.class).translate(e);
            }
        }
    });
    // Publish the message
    send(txMember.getSessionProvider(), destination, transferObject, input);
}
Also used : ITransaction(org.eclipse.scout.rt.platform.transaction.ITransaction) JMSException(javax.jms.JMSException) DefaultRuntimeExceptionTranslator(org.eclipse.scout.rt.platform.exception.DefaultRuntimeExceptionTranslator)

Example 9 with ITransaction

use of org.eclipse.scout.rt.platform.transaction.ITransaction in project scout.rt by eclipse.

the class ServerTestRunnerDifferentSessionTest method test2.

@Test
public void test2() {
    ISession serverSession = IServerSession.CURRENT.get();
    assertTrue(serverSession instanceof JUnitServerSession1);
    assertEquals("anna", serverSession.getUserId());
    m_serverSessions.add(serverSession);
    ITransaction transaction = ITransaction.CURRENT.get();
    assertNotNull(transaction);
    m_transactions.add(transaction);
}
Also used : ISession(org.eclipse.scout.rt.shared.ISession) JUnitServerSession1(org.eclipse.scout.rt.testing.server.runner.ServerTestRunnerDifferentSessionTest.JUnitServerSession1) ITransaction(org.eclipse.scout.rt.platform.transaction.ITransaction) Test(org.junit.Test)

Example 10 with ITransaction

use of org.eclipse.scout.rt.platform.transaction.ITransaction in project scout.rt by eclipse.

the class ServerTestRunnerDifferentSessionTest method test1.

@Test
public void test1() {
    ISession serverSession = IServerSession.CURRENT.get();
    assertTrue(serverSession instanceof JUnitServerSession1);
    assertEquals("anna", serverSession.getUserId());
    m_serverSessions.add(serverSession);
    ITransaction transaction = ITransaction.CURRENT.get();
    assertNotNull(transaction);
    m_transactions.add(transaction);
}
Also used : ISession(org.eclipse.scout.rt.shared.ISession) JUnitServerSession1(org.eclipse.scout.rt.testing.server.runner.ServerTestRunnerDifferentSessionTest.JUnitServerSession1) ITransaction(org.eclipse.scout.rt.platform.transaction.ITransaction) Test(org.junit.Test)

Aggregations

ITransaction (org.eclipse.scout.rt.platform.transaction.ITransaction)37 Test (org.junit.Test)20 ISession (org.eclipse.scout.rt.shared.ISession)13 HashMap (java.util.HashMap)7 ITransactionMember (org.eclipse.scout.rt.platform.transaction.ITransactionMember)5 IRunnable (org.eclipse.scout.rt.platform.util.concurrent.IRunnable)5 JUnitServerSession1 (org.eclipse.scout.rt.testing.server.runner.ServerTestRunnerDifferentSessionTest.JUnitServerSession1)4 JUnitServerSession (org.eclipse.scout.rt.testing.server.runner.ServerTestRunnerDifferentSubjectTest.JUnitServerSession)4 JUnitServerSession (org.eclipse.scout.rt.testing.server.runner.ServerTestRunnerSameSessionTest.JUnitServerSession)4 AssertionException (org.eclipse.scout.rt.platform.util.Assertions.AssertionException)3 AfterClass (org.junit.AfterClass)3 BeforeClass (org.junit.BeforeClass)3 InvocationHandler (java.lang.reflect.InvocationHandler)2 Method (java.lang.reflect.Method)2 WebMethod (javax.jws.WebMethod)2 BooleanHolder (org.eclipse.scout.rt.platform.holders.BooleanHolder)2 Holder (org.eclipse.scout.rt.platform.holders.Holder)2 IServerSession (org.eclipse.scout.rt.server.IServerSession)2 AbstractSqlTransactionMember (org.eclipse.scout.rt.server.jdbc.AbstractSqlTransactionMember)2 Connection (java.sql.Connection)1