Package com.arjuna.mw.wst

Examples of com.arjuna.mw.wst.BusinessActivityManager


{
    public static void testExit()
            throws Exception
    {
      UserBusinessActivity uba = UserBusinessActivity.getUserBusinessActivity();
        BusinessActivityManager bam = BusinessActivityManager.getBusinessActivityManager();
      com.arjuna.wst.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();
View Full Code Here


{
    public static void testMultiCancel()
            throws Exception
    {
      UserBusinessActivity uba = UserBusinessActivity.getUserBusinessActivity();
        BusinessActivityManager bam = BusinessActivityManager.getBusinessActivityManager();
      DemoBusinessParticipant p = new DemoBusinessParticipant(DemoBusinessParticipant.CANCEL, "1239");
      FailureBusinessParticipant fp = new FailureBusinessParticipant(FailureBusinessParticipant.FAIL_IN_CANCEL, "5678");
      try {
      uba.begin();
     
      bam.enlistForBusinessAgreementWithParticipantCompletion(p, "1239");
      bam.enlistForBusinessAgreementWithParticipantCompletion(fp, "5678");
        } catch (Exception eouter) {
            try {
                uba.cancel();
            } catch(Exception einner) {
            }
View Full Code Here

{
    public static void testClose()
            throws Exception
    {
      UserBusinessActivity uba = UserBusinessActivity.getUserBusinessActivity();
        BusinessActivityManager bam = BusinessActivityManager.getBusinessActivityManager();
      com.arjuna.wst.BAParticipantManager bpm = null;
        DemoBusinessParticipant p = new DemoBusinessParticipant(DemoBusinessParticipant.CLOSE, "1235");
      try {
      uba.begin();
     
      bpm = bam.enlistForBusinessAgreementWithParticipantCompletion(p, p.identifier());
        bpm.completed();
        } catch (Exception eouter) {
            try {
                uba.cancel();
            } catch(Exception einner) {
View Full Code Here

{
    public static void testCancel()
            throws Exception
    {
        UserBusinessActivity uba = UserBusinessActivity.getUserBusinessActivity();
        BusinessActivityManager bam = BusinessActivityManager.getBusinessActivityManager();
      String participantId = "1234";
      DemoBusinessParticipant p = new DemoBusinessParticipant(DemoBusinessParticipant.CANCEL, participantId);
        try {

      uba.begin();
     
      bam.enlistForBusinessAgreementWithParticipantCompletion(p, participantId);
        } catch (Exception eouter) {
            try {
                uba.cancel();
            } catch(Exception einner) {
            }
View Full Code Here

            /*
             * There should either be an Atomic Transaction *or* a Business Activity
             * associated with the thread.
             */
            final TransactionManager transactionManager = TransactionManagerFactory.transactionManager() ;
            final BusinessActivityManager businessActivityManager = BusinessActivityManagerFactory.businessActivityManager() ;

            final Context atContext ;
            if (transactionManager != null)
            {
                final com.arjuna.mwlabs.wst.at.context.TxContextImple txContext =
                    (com.arjuna.mwlabs.wst.at.context.TxContextImple)transactionManager.currentTransaction() ;
                atContext = (txContext == null ? null : txContext.context()) ;
            }
            else
            {
                atContext = null ;
            }

            final Context baContext ;
            if (businessActivityManager != null)
            {
                final com.arjuna.mwlabs.wst.ba.context.TxContextImple txContext =
                    (com.arjuna.mwlabs.wst.ba.context.TxContextImple)businessActivityManager.currentTransaction() ;
                baContext = (txContext == null ? null : txContext.context()) ;
            }
            else
            {
                baContext = null ;
View Full Code Here

    public boolean bookTaxi()
    {
        TaxiView taxiView = TaxiView.getSingletonInstance();
        TaxiManager taxiManager = TaxiManager.getSingletonInstance();

        BusinessActivityManager activityManager = BusinessActivityManagerFactory.businessActivityManager();

        // get the transaction context of this thread:
        String transactionId = null;
        try
        {
            transactionId = activityManager.currentTransaction().toString();
        }
        catch (SystemException e)
        {
            System.err.println("bookTaxi: unable to obtain a transaction context!");
            e.printStackTrace(System.err);
            return false;
        }

        // log the event:
        System.out.println("TaxiServiceBA transaction id =" + transactionId);

        taxiView.addMessage("******************************");

        taxiView.addPrepareMessage("id:" + transactionId.toString() + ". Received a taxi booking request");
        taxiView.updateFields();

        // invoke the backend business logic:
        taxiManager.bookTaxi(transactionId);

        // attempt to finalise the booking
        if (taxiManager.prepareTaxi(transactionId))
        {
            taxiView.addMessage("id:" + transactionId + ". Seats prepared, trying to commit and enlist compensation Participant");
            taxiView.updateFields();

            // it worked, so now we need a participant enlisted in case of compensation:
            TaxiParticipantBA taxiParticipant = new TaxiParticipantBA(transactionId);
            // enlist the Participant for this service:
            BAParticipantManager participantManager = null;
            try
            {
                participantManager = activityManager.enlistForBusinessAgreementWithParticipantCompletion(taxiParticipant, "com.arjuna.xts-demorpc:taxiBA:" + new Uid().toString());
            }
            catch (Exception e)
            {
                taxiView.addMessage("id:" + transactionId + ". Participant enrolement failed");
                taxiManager.cancelTaxi(transactionId);
View Full Code Here

    public boolean bookSeats(int how_many)
    {
        RestaurantView restaurantView = RestaurantView.getSingletonInstance();
        RestaurantManager restaurantManager = RestaurantManager.getSingletonInstance();

        BusinessActivityManager activityManager = BusinessActivityManagerFactory.businessActivityManager();

        // get the transaction context of this thread:
        String transactionId = null;
        try
        {
            transactionId = activityManager.currentTransaction().toString();
        }
        catch (SystemException e)
        {
            System.err.println("bookSeats: unable to obtain a transaction context!");
            e.printStackTrace(System.err);
            return false;
        }

        // log the event:
        System.out.println("RestaurantServiceBA transaction id =" + transactionId);

        restaurantView.addMessage("******************************");

        restaurantView.addPrepareMessage("id:" + transactionId + ". Received a booking request for one table of " + how_many + " people");
        restaurantView.updateFields();

        // invoke the backend business logic:
        restaurantManager.bookSeats(transactionId, how_many);

        // attempt to finalise the booking
        // (it will be compensated later if necessary)
        if (restaurantManager.prepareSeats(transactionId))
        {
            restaurantView.addMessage("id:" + transactionId + ". Seats prepared, trying to commit and enlist compensation Participant");
            restaurantView.updateFields();

            // it worked, so now we need a participant enlisted in case of compensation:

            RestaurantParticipantBA restaurantParticipant = new RestaurantParticipantBA(transactionId, how_many);
            // enlist the Participant for this service:
            BAParticipantManager participantManager = null;
            try
            {
                participantManager = activityManager.enlistForBusinessAgreementWithParticipantCompletion(restaurantParticipant, "com.arjuna.xts-demorpc:restaurantBA:" + new Uid().toString());
            }
            catch (Exception e)
            {
                restaurantView.addMessage("id:" + transactionId + ". Participant enrolement failed");
                restaurantManager.cancelSeats(transactionId);
View Full Code Here

{
    public static void testMultiCompensate()
            throws Exception
    {
      UserBusinessActivity uba = UserBusinessActivity.getUserBusinessActivity();
        BusinessActivityManager bam = BusinessActivityManager.getBusinessActivityManager();
      com.arjuna.wst.BAParticipantManager bpm1 = null;
      com.arjuna.wst.BAParticipantManager bpm2 = null;
      DemoBusinessParticipant p = new DemoBusinessParticipant(DemoBusinessParticipant.COMPENSATE, "1241");
      FailureBusinessParticipant fp = new FailureBusinessParticipant(FailureBusinessParticipant.FAIL_IN_COMPENSATE, "5680");
      try {
      uba.begin();
     
      bpm1 = bam.enlistForBusinessAgreementWithParticipantCompletion(p, "1241");
      bpm2 = bam.enlistForBusinessAgreementWithParticipantCompletion(fp, "5680");

      bpm1.completed();
      bpm2.completed();
        } catch (Exception eouter) {
            try {
View Full Code Here

{
    public static void testCompensate()
            throws Exception
    {
      UserBusinessActivity uba = UserBusinessActivity.getUserBusinessActivity();
        BusinessActivityManager bam = BusinessActivityManager.getBusinessActivityManager();
      com.arjuna.wst.BAParticipantManager bpm = null;
      String participantId = "1236";
      DemoBusinessParticipant p = new DemoBusinessParticipant(DemoBusinessParticipant.COMPENSATE, participantId);
      try {
      uba.begin();
     
      bpm = bam.enlistForBusinessAgreementWithParticipantCompletion(p, participantId);

      bpm.completed();
        } catch (Exception eouter) {
            try {
                uba.cancel();
View Full Code Here

    public static void testMultiClose()
            throws Exception
    {
      UserBusinessActivity uba = UserBusinessActivity.getUserBusinessActivity();

        BusinessActivityManager bam = BusinessActivityManager.getBusinessActivityManager();
        com.arjuna.wst.BAParticipantManager bpm1 = null;
        com.arjuna.wst.BAParticipantManager bpm2 = null;
        DemoBusinessParticipant p = new DemoBusinessParticipant(DemoBusinessParticipant.CLOSE, "1240");
      FailureBusinessParticipant fp = new FailureBusinessParticipant(FailureBusinessParticipant.FAIL_IN_CLOSE, "5679");
     
        try {
      uba.begin();
     
      bpm1 = bam.enlistForBusinessAgreementWithParticipantCompletion(p, "1240");
      bpm2 = bam.enlistForBusinessAgreementWithParticipantCompletion(fp, "5679");
        bpm1.completed();
        bpm2.completed();
        } catch (Exception eouter) {
            try {
                uba.cancel();
View Full Code Here

TOP

Related Classes of com.arjuna.mw.wst.BusinessActivityManager

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.