Package com.arjuna.mw.wst11

Examples of com.arjuna.mw.wst11.UserTransaction


            serviceURL1 = "http://localhost:8080/xtstest/xtsservicetest1";
        }

        addDefaultBinding("service1", serviceURL1);

        UserBusinessActivity ba = UserBusinessActivityFactory.userBusinessActivity();

        // start the transaction

        try {
            ba.begin();
        } catch (WrongStateException e) {
            exception = e;
        } catch (SystemException e) {
            exception = e;
        }

        if (exception != null) {
            error("txbegin failure " + exception);
            return;
        }

        List<String> resultsList;
        String participantId;

        List<String> commands = new ArrayList<String>();
        List<String> results = new ArrayList<String>();

        commands.add("block");
        commands.add("serve");
        commands.add("{service1}");
        commands.add("enlistCoordinatorCompletion");
        commands.add("bindings");
        commands.add("bind");
        commands.add("P1");
        commands.add("0");
        commands.add("next");
        commands.add("serve");
        commands.add("{service1}");
        commands.add("enlistCoordinatorCompletion");
        commands.add("complete");
        commands.add("close");
        commands.add("next");
        commands.add("serve");
        commands.add("{service1}");
        commands.add("enlistCoordinatorCompletion");
        commands.add("complete");
        commands.add("close");
        commands.add("next");
        commands.add("serve");
        commands.add("{service1}");
        commands.add("exit");
        commands.add("{P1}");
        commands.add("endblock");

        try {
            processCommands(commands, results);
        } catch (Exception e) {
            exception = e;
        }

        if (exception != null) {
            error("test failure " + exception);
            return;
        }

        // now close the activity

        try {
            ba.close();
        } catch (TransactionRolledBackException e) {
            exception = e;
        } catch (UnknownTransactionException e) {
            exception = e;
        } catch (SystemException e) {
View Full Code Here


public class Exit extends TestCase
{
    public static void testExit()
            throws Exception
    {
      UserBusinessActivity uba = UserBusinessActivity.getUserBusinessActivity();
        BusinessActivityManager bam = BusinessActivityManager.getBusinessActivityManager();
      com.arjuna.wst11.BAParticipantManager bpm = null;
      DemoBusinessParticipant p = new DemoBusinessParticipant(DemoBusinessParticipant.EXIT, "1238");
      try {
      uba.begin();

      bpm = bam.enlistForBusinessAgreementWithParticipantCompletion(p, "1238");

      bpm.exit();
        } catch (Exception eouter) {
            try {
                uba.cancel();
            } catch(Exception einner) {
            }
            throw eouter;
        }

      uba.close();

      assertTrue(p.passed());
    }
View Full Code Here

        PrintWriter out = resp.getWriter();

        out.write("<h1>Quickstart: This example demonstrates the deployment of a WS-AT (WS-AtomicTransaction) enabled JAX-WS Web service bundled in a war archive for deployment to *JBoss WildFly*.</h1>");

        System.out.println("[CLIENT] Creating a new WS-AT User Transaction");
        UserTransaction ut = UserTransactionFactory.userTransaction();
        try {
            System.out
                    .println("[CLIENT] Beginning Atomic Transaction (All calls to Web services that support WS-AT wil be included in this transaction)");
            ut.begin();
            System.out.println("[CLIENT] invoking makeBooking() on WS");
            client.makeBooking();
            System.out.println("[CLIENT] committing Atomic Transaction (This will cause the AT to complete successfully)");
            ut.commit();

            out.write("<p><i>Go to your WildFly console or Server log to see the result of the transaction</i></p>");

        } catch (Exception e) {
            e.printStackTrace();
View Full Code Here

    public void testCommit() throws Exception {

        System.out
                .println("\n\nStarting 'testCommit'. This test invokes a WS within an AT. The AT is later committed, which causes the back-end resource(s) to be committed.");
        System.out.println("[CLIENT] Creating a new WS-AT User Transaction");
        UserTransaction ut = UserTransactionFactory.userTransaction();
        try {
            System.out
                    .println("[CLIENT] Beginning Atomic Transaction (All calls to Web services that support WS-AT wil be included in this transaction)");
            ut.begin();
            System.out.println("[CLIENT] invoking makeBooking() on WS");
            client.makeBooking();
            System.out.println("[CLIENT] committing Atomic Transaction (This will cause the AT to complete successfully)");
            ut.commit();

            // Check the booking is visible after the transaction has committed.
            Assert.assertEquals(1, client.getBookingCount());

        } finally {
View Full Code Here

    public void testRollback() throws Exception {

        System.out
                .println("\n\nStarting 'testRollback'. This test invokes a WS within an AT. The AT is later rolled back, which causes the back-end resource(s) to be rolled back.");
        System.out.println("[CLIENT] Creating a new WS-AT User Transaction");
        UserTransaction ut = UserTransactionFactory.userTransaction();
        try {
            System.out
                    .println("[CLIENT] Beginning Atomic Transaction (All calls to Web services that support WS-AT wil be included in this transaction)");
            ut.begin();
            System.out.println("[CLIENT] invoking makeBooking() on WS");
            client.makeBooking();
            System.out
                    .println("[CLIENT] rolling back Atomic Transaction (This will cause the AT and thus the enlisted back-end resources to rollback)");
            ut.rollback();

            // Check the booking is visible after the transaction has committed.
            Assert.assertEquals(0, client.getBookingCount());

        } finally {
View Full Code Here

     * @throws Exception if something goes wrong.
     */
    @Test
    public void testCommit() throws Exception {
        log.info("[CLIENT] Creating a new WS-AT User Transaction");
        UserTransaction ut = UserTransactionFactory.userTransaction();
        try {
            log.info("[CLIENT] Beginning Atomic Transaction (All calls to Web services that support WS-AT wil be included in this transaction)");
            ut.begin();
            log.info("[CLIENT] invoking makeBooking() on WS");
            client.makeBooking();
            log.info("[CLIENT] committing Atomic Transaction (This will cause the AT to complete successfully)");
            ut.commit();

            // Check the booking is visible after the transaction has committed.
            Assert.assertEquals("Commit on the Durable2PC participant has not been invoked.", 1, client.getBookingCount());
            Assert.assertTrue("Commit on the Volatile2PC participant has not been invoked.", client.wasVolatileCommit());
            Assert.assertFalse("Rollback on the Volatile2PC participant has been invoked.", client.wasVolatileRollback());
View Full Code Here

     * @throws Exception if something goes wrong
     */
    @Test
    public void testRollback() throws Exception {
        log.info("[CLIENT] Creating a new WS-AT User Transaction");
        UserTransaction ut = UserTransactionFactory.userTransaction();
        try {
            log.info("[CLIENT] Beginning Atomic Transaction (All calls to Web services that support WS-AT wil be included in this transaction)");
            ut.begin();
            log.info("[CLIENT] invoking makeBooking() on WS");
            client.makeBooking();
            log.info("[CLIENT] rolling back Atomic Transaction (This will cause the AT and thus the enlisted back-end resources to rollback)");
            ut.rollback();

            // Check the booking is visible after the transaction has committed.
            Assert.assertEquals("Rollback on the Durable2PC participant has not been invoked.", 0, client.getBookingCount());
            Assert.assertFalse("Commit on the Volatile2PC participant has been invoked.", client.wasVolatileCommit());
            Assert.assertTrue("Rollback on the Volatile2PC participant has not been invoked.", client.wasVolatileRollback());
View Full Code Here

    @Test
    public void testActiveTransaction() throws Exception {
        final String deploymentUrl = getDeploymentUrl();
        final TransactionalService transactionalService = TransactionalClient.newInstance(deploymentUrl);
        final UserTransaction userTransaction = UserTransaction.getUserTransaction();

        userTransaction.begin();
        final boolean isTransactionActive = transactionalService.isTransactionActive();
        userTransaction.commit();

        Assert.assertEquals(true, isTransactionActive);
    }
View Full Code Here

     */
    public void invokeWithCallName(String callName, ServiceCommand[] serviceCommands) throws TestApplicationException {
       
        log.infof("[AT SERVICE] web method invoke(%s) with eventLog %s", callName, eventLog);
        eventLog.foundEventLogName(callName);
        UserTransaction userTransaction;
       
        try {
            userTransaction = UserTransactionFactory.userTransaction();
            String transactionId = userTransaction.transactionIdentifier();
            log.debug("RestaurantServiceAT transaction id =" + transactionId);
           
            // Enlist the Durable Participant for this service
            TransactionManager transactionManager = TransactionManagerFactory.transactionManager();
            ATDurableParticipant durableParticipant = new ATDurableParticipant(serviceCommands, callName, eventLog, transactionId);
            log.info("[SERVICE] Enlisting a Durable2PC participant into the AT");
            transactionManager.enlistForDurableTwoPhase(durableParticipant, "ATServiceDurable:" + new Uid().toString());
           
            // Enlist the Volatile Participant for this service
            ATVolatileParticipant volatileParticipant = new ATVolatileParticipant(serviceCommands, callName, eventLog, transactionId);
            log.info("[SERVICE] Enlisting a VolatilePC participant into the AT");
            transactionManager.enlistForVolatileTwoPhase(volatileParticipant, "ATServiceVolatile:" + new Uid().toString());
        } catch (Exception e) {
            throw new RuntimeException("Error when enlisting participants", e);
        }
       
        if (ServiceCommand.isPresent(APPLICATION_EXCEPTION, serviceCommands)) {
            throw new TestApplicationException("Intentionally thrown Application Exception - service command was set to: " + APPLICATION_EXCEPTION);
        }
       
        if (ServiceCommand.isPresent(ROLLBACK_ONLY, serviceCommands)) {
            log.info("Intentionally the service settings transaction to rollback only - service command was set to: " + ROLLBACK_ONLY);
            try {
                userTransaction.rollback();
            } catch (Exception e) {
                throw new RuntimeException("The rollback is not possible", e);
            }
        }

View Full Code Here

        PrintWriter out = resp.getWriter();

        out.write("<h1>Quickstart: This example demonstrates the deployment of a WS-AT (WS-AtomicTransaction) enabled JAX-WS Web service bundled in a war archive for deployment to *Red Hat JBoss Enterprise Application Platform 6*.</h1>");

        System.out.println("[CLIENT] Creating a new WS-AT User Transaction");
        UserTransaction ut = UserTransactionFactory.userTransaction();
        try {
            System.out
                    .println("[CLIENT] Beginning Atomic Transaction (All calls to Web services that support WS-AT wil be included in this transaction)");
            ut.begin();
            System.out.println("[CLIENT] invoking makeBooking() on WS");
            client.makeBooking();
            System.out.println("[CLIENT] committing Atomic Transaction (This will cause the AT to complete successfully)");
            ut.commit();

            out.write("<p><b>Transaction succeeded!</b></p>");

        } catch (Exception e) {
            e.printStackTrace();
View Full Code Here

TOP

Related Classes of com.arjuna.mw.wst11.UserTransaction

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.