Package com.arjuna.mw.wst

Examples of com.arjuna.mw.wst.BusinessActivityManager


    public static void testConfirmWithComplete()
            throws Exception
    {
      UserBusinessActivity uba = UserBusinessActivity.getUserBusinessActivity();
        BusinessActivityManager bam = BusinessActivityManager.getBusinessActivityManager();
      DemoBusinessParticipantWithComplete p = new DemoBusinessParticipantWithComplete(DemoBusinessParticipantWithComplete.COMPLETE, "1234");
      try {
      uba.begin();
     
      bam.enlistForBusinessAgreementWithCoordinatorCompletion(p, "1237");

      uba.complete();
        } catch (Exception eouter) {
            try {
                uba.cancel();
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, new Uid().toString());
            }
            catch (Exception e)
            {
                restaurantView.addMessage("id:" + transactionId + ". Participant enrolement failed");
                System.err.println("bookSeats: Participant enlistment failed");
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, new Uid().toString());
            }
            catch (Exception e)
            {
                taxiView.addMessage("id:" + transactionId + ". Participant enrolement failed");
                System.err.println("bookTaxi: Participant enrolment failed");
View Full Code Here

  boolean passed = false;
 
  try
  {
      UserBusinessActivity uba = UserBusinessActivity.getUserBusinessActivity();
      BusinessActivityManager bam = BusinessActivityManager.getBusinessActivityManager();
      com.arjuna.wst.BAParticipantManager bpm = null;
      DemoBusinessParticipant p = new DemoBusinessParticipant(DemoBusinessParticipant.EXIT, "1234");
     
      uba.begin();
     
      bpm = bam.enlistForBusinessAgreementWithParticipantCompletion(p, "1234");

      bpm.exit();
     
      uba.close();
View Full Code Here

  boolean passed = false;
 
  try
  {
      UserBusinessActivity uba = UserBusinessActivity.getUserBusinessActivity();
      BusinessActivityManager bam = BusinessActivityManager.getBusinessActivityManager();
      DemoBusinessParticipant p = new DemoBusinessParticipant(DemoBusinessParticipant.CANCEL, "1234");
      FailureBusinessParticipant fp = new FailureBusinessParticipant(FailureBusinessParticipant.FAIL_IN_CANCEL, "5678");
     
      uba.begin();
     
      bam.enlistForBusinessAgreementWithParticipantCompletion(p, "1234");
      bam.enlistForBusinessAgreementWithParticipantCompletion(fp, "5678");
     
      uba.close();

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

        if (soapMessage != null)
        {
            try
            {
                final TransactionManager transactionManager = TransactionManagerFactory.transactionManager() ;
                final BusinessActivityManager businessActivityManager = BusinessActivityManagerFactory.businessActivityManager() ;

                if (transactionManager != null)
                {
                    final com.arjuna.mwlabs.wst.at.context.TxContextImple txContext =
                        (com.arjuna.mwlabs.wst.at.context.TxContextImple)transactionManager.suspend() ;

                    if (txContext != null)
                    {
                        messageContext.setProperty(AtomicTransactionConstants.WSAT_PROTOCOL, txContext) ;
                    }
                }

                if (businessActivityManager != null)
                {
                    final com.arjuna.mwlabs.wst.ba.context.TxContextImple txContext =
                        (com.arjuna.mwlabs.wst.ba.context.TxContextImple)businessActivityManager.suspend() ;

                    if (txContext != null)
                    {
                        messageContext.setProperty(BusinessActivityConstants.WSBA_PROTOCOL_ATOMIC_OUTCOME, txContext) ;
                    }
                }

                final Element soapHeaderElement = soapMessage.getHeaderElement(CoordinationConstants.WSCOOR_NAMESPACE, CoordinationConstants.WSCOOR_ELEMENT_COORDINATION_CONTEXT) ;

                if (soapHeaderElement != null)
                {
                    final CoordinationContextType cc = CoordinationContextHelper.deserialise(soapHeaderElement) ;

                    final String coordinationType = cc.getCoordinationType().getValue() ;

                    if (AtomicTransactionConstants.WSAT_PROTOCOL.equals(coordinationType))
                    {
                        final TxContext txContext = new com.arjuna.mwlabs.wst.at.context.TxContextImple(cc) ;
                        transactionManager.resume(txContext) ;
                    }
                    else if (BusinessActivityConstants.WSBA_PROTOCOL_ATOMIC_OUTCOME.equals(coordinationType))
                    {
                        final TxContext txContext = new com.arjuna.mwlabs.wst.ba.context.TxContextImple(cc);
                        businessActivityManager.resume(txContext) ;
                    }
                    else
                    {
                    wstxLogger.arjLoggerI18N.warn("com.arjuna.mw.wst.service.GlueICI_1",
                            new Object[]{"com.arjuna.mw.wst.service.GlueOutgoingContextInterceptor.intercept()"});
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() ;

            if (transactionManager != null)
            {
                transactionManager.suspend() ;
            }

            if (businessActivityManager != null)
            {
                businessActivityManager.suspend() ;
            }
        }
        catch (final Throwable th)
        {
      wstxLogger.arjLoggerI18N.warn("com.arjuna.mw.wst.service.JaxRPCHCP_1",
View Full Code Here

            else
            {
                transactionManager.suspend() ;
            }

            final BusinessActivityManager businessActivityManager = BusinessActivityManagerFactory.businessActivityManager() ;
            final com.arjuna.mwlabs.wst.ba.context.TxContextImple baTXContext =
                (com.arjuna.mwlabs.wst.ba.context.TxContextImple)messageContext.getProperty(BusinessActivityConstants.WSBA_PROTOCOL_ATOMIC_OUTCOME) ;

            if (baTXContext != null)
            {
                businessActivityManager.resume(baTXContext) ;
            }
            else
            {
                businessActivityManager.suspend() ;
            }
        }
        catch (final Throwable th)
        {
          wstxLogger.arjLoggerI18N.warn("com.arjuna.mw.wst.service.GlueOCI_1",
View Full Code Here

  boolean passed = false;
 
  try
  {
      UserBusinessActivity uba = UserBusinessActivity.getUserBusinessActivity();
      BusinessActivityManager bam = BusinessActivityManager.getBusinessActivityManager();
      DemoBusinessParticipant p = new DemoBusinessParticipant(DemoBusinessParticipant.CLOSE, "1234");
     
      uba.begin();
     
      bam.enlistForBusinessAgreementWithParticipantCompletion(p, null);
     
      uba.close();

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

  boolean passed = false;
 
  try
  {
      UserBusinessActivity uba = UserBusinessActivity.getUserBusinessActivity();
      BusinessActivityManager bam = BusinessActivityManager.getBusinessActivityManager();
      String participantId = "1234";
      DemoBusinessParticipant p = new DemoBusinessParticipant(DemoBusinessParticipant.CANCEL, participantId);
     
      uba.begin();
     
      bam.enlistForBusinessAgreementWithParticipantCompletion(p, participantId);

      uba.cancel();

      passed = p.passed();
  }
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.