Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * JBoss, Home of Professional Open Source
   * Copyright 2006, Red Hat Middleware LLC, and individual contributors
   * as indicated by the @author tags. 
   * See the copyright.txt in the distribution for a full listing 
   * of individual contributors.
   * This copyrighted material is made available to anyone wishing to use,
   * modify, copy, or redistribute it subject to the terms and conditions
   * of the GNU Lesser General Public License, v. 2.1.
  * This program is distributed in the hope that it will be useful, but WITHOUT A
  * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
  * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
  * You should have received a copy of the GNU Lesser General Public License,
  * v.2.1 along with this distribution; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
  * MA  02110-1301, USA.
  * 
  * (C) 2005-2006,
  * @author JBoss Inc.
  */
 /*
  * Copyright (C) 2003,
  *
  * Arjuna Technologies Limited,
  * Newcastle upon Tyne,
  * Tyne and Wear,
  * UK.
  *
  * $Id: UserBusinessActivityImple.java,v 1.10.4.1 2005/11/22 10:36:07 kconner Exp $
  */
 
 package com.arjuna.mwlabs.wst11.ba.remote;
 
 
This is the interface that allows transactions to be started and terminated. The messaging layer converts the Commit, Rollback and Notify messages into calls on this.
 
 
 {
     public UserBusinessActivityImple()
     {
         try
         {
              = XTSPropertyManager.getWSCEnvironmentBean().getCoordinatorURL11();
 
             /*
              * If the coordinator URL hasn't been specified via the
              * configuration file then assume we are using a locally registered
              * implementation.
              */
 
             if ( == null)
             {
                 final ServiceRegistry serviceRegistry = ServiceRegistry.getRegistry() ;
                  = serviceRegistry.getServiceURI(.) ;
             }
         }
         catch (Exception ex)
         {
             // TODO
 
             ex.printStackTrace();
         }
     }
        return ;
    }
    public void begin () throws WrongStateExceptionSystemException
    {
    	begin(0);
    }
    public void begin (int timeoutthrows WrongStateExceptionSystemException
    {
    	try
    	{
    	    if (.currentTransaction() != null)
        		throw new WrongStateException();
    	    Context ctx = startTransaction(timeoutnull);
    	    .resume(new TxContextImple(ctx));
    	}
    	{
    	    tidyup();
    	    throw new SystemException(ex.toString());
    	}
    	catch (UnknownTransactionException ex)
    	{
    	    tidyup();
    	    throw new SystemException(ex.toString());
    	}
    	catch (SystemException ex)
    	{
    	    tidyup();
    	    throw ex;
    	}
    }
    {
    	TxContextImple ctx = null;
    	try
    	{
    	    ctx = (TxContextImple.suspend();
            if (ctx == null) {
                throw new WrongStateException();
            }
            final String id = ctx.identifier() ;
            final W3CEndpointReference terminatorCoordinator = getTerminationCoordinator(ctx) ;
    	    BusinessActivityTerminatorStub terminatorStub = new BusinessActivityTerminatorStub(idterminatorCoordinator);
    	    terminatorStub.close();
    	}
    	catch (SystemException ex)
    	{
    	    throw ex;
    	}
    	catch (TransactionRolledBackException ex)
    	{
    	    throw ex;
    	}
        catch (WrongStateException ex)
        {
            throw ex;
        }
    	catch (UnknownTransactionException ex)
    	{
    	    throw ex;
    	}
    	catch (Exception ex)
    	{
    	    ex.printStackTrace();
    	    throw new SystemException(ex.toString());
    	}
    	finally
    	{
    	    tidyup();
    	}
    }
    {
    	TxContextImple ctx = null;
    	try
    	{
            ctx = (TxContextImple.suspend();
            if (ctx == null) {
                throw new WrongStateException();
            }
            final String id = ctx.identifier() ;
            final W3CEndpointReference terminatorCoordinator = getTerminationCoordinator(ctx) ;
            BusinessActivityTerminatorStub terminatorStub = new BusinessActivityTerminatorStub(idterminatorCoordinator);
    	    terminatorStub.cancel();
    	}
    	catch (SystemException ex)
    	{
    	    throw ex;
    	}
        catch (WrongStateException ex)
        {
            throw ex;
        }
    	catch (UnknownTransactionException ex)
    	{
    	    throw ex;
    	}
    	catch (Exception ex)
    	{
    	    ex.printStackTrace();
    	    throw new SystemException(ex.toString());
    	}
    	finally
    	{
    	    tidyup();
    	}
    }
    {
    	try
    	{
            final TxContextImple ctx = ((TxContextImple.currentTransaction()) ;
            if (ctx == null) {
                throw new WrongStateException();
            }
            final String id = ctx.identifier() ;
            final W3CEndpointReference terminatorCoordinator = getTerminationCoordinator(ctx) ;
            BusinessActivityTerminatorStub terminatorStub = new BusinessActivityTerminatorStub(idterminatorCoordinator);
    	    terminatorStub.complete();
    	}
    	catch (SystemException ex)
    	{
    	    throw ex;
    	}
    	catch (UnknownTransactionException ex)
    	{
    	    throw ex;
    	}
        catch (WrongStateException ex)
        {
            throw ex;
        }
    	catch (Exception ex)
    	{
    	    throw new SystemException(ex.toString());
    	}
    }
    public String transactionIdentifier ()
    {
    	try
    	{
    	    return .currentTransaction().toString();
    	}
    	catch (SystemException ex)
    	{
    	    return "Unknown";
    	}
    	catch (NullPointerException ex)
    	{
    	    return "Unknown";
    	}
    }
    public String toString ()
    {
    	return transactionIdentifier();
    }
    public void beginSubordinate(int timeoutthrows WrongStateExceptionSystemException
    {
        try
        {
            TxContext current = .currentTransaction();
            if ((current == null) || !(current instanceof TxContextImple))
                throw new WrongStateException();
            TxContextImple currentImple = (TxContextImplecurrent;
            Context ctx = startTransaction(timeoutcurrentImple);
            .resume(new TxContextImple(ctx));
            // n.b. we don't enlist the subordinate transaction for completion
            // that ensures that any attempt to commit or rollback will fail
        }
        catch (com.arjuna.wsc.InvalidCreateParametersException ex)
        {
            tidyup();
            throw new SystemException(ex.toString());
        }
        catch (com.arjuna.wst.UnknownTransactionException ex)
        {
            tidyup();
            throw new SystemException(ex.toString());
        }
        catch (SystemException ex)
        {
            tidyup();
            throw ex;
        }
    }

    
fetch the coordination context type stashed in the current BA context implememtation and use it to construct an instance of the coordination context extension type we need to send down the wire to the activation coordinator

Parameters:
current the current AT context implememtation
Returns:
an instance of the coordination context extension type
    {
        CoordinationContextType contextType = getContextType(current);
        CoordinationContext context = new CoordinationContext();
        context.setCoordinationType(contextType.getCoordinationType());
        context.setExpires(contextType.getExpires());
        context.setIdentifier(contextType.getIdentifier());
        context.setRegistrationService(contextType.getRegistrationService());
        return context;
    }

    
fetch the coordination context type stashed in the current BA context implememtation

Parameters:
current the current AT context implememtation
Returns:
the coordination context type stashed in the current AT context implememtation
    {
        ContextImple contextImple = (ContextImple)current.context();
        return contextImple.getCoordinationContext();
    }
    private final Context startTransaction (int timeoutTxContextImple currentthrows InvalidCreateParametersExceptionSystemException
    {
        try
        {
            final Long expires = (timeout > 0 ? new Long(timeout) : null) ;
            final String messageId = MessageId.getMessageId() ;
            final CoordinationContext currentContext = (current != null ? getContext(current) : null);
            final CoordinationContextType coordinationContext = ActivationCoordinator.createCoordinationContext(
                    messageId.expirescurrentContext) ;
            if (coordinationContext == null)
            {
                throw new SystemException(
                        ..get_mwlabs_wst11_ba_remote_UserBusinessActivityImple_2());
            }
            return new ContextImple(coordinationContext) ;
        }
        catch (final InvalidCreateParametersException icpe)
        {
            throw icpe ;
        }
        catch (final SoapFault sf)
        {
            throw new SystemException(sf.getMessage()) ;
        }
        catch (final Exception ex)
        {
            throw new SystemException(ex.toString());
        }
	}
        throws SystemException
    {
        final CoordinationContextType coordinationContext = ctx.context().getCoordinationContext() ;
        final String messageId = MessageId.getMessageId() ;
        try
        {
            return RegistrationCoordinator.register(coordinationContextmessageId,
        }
        catch (final Throwable th)
        {
        }
    }
    private W3CEndpointReference getParticipantProtocolService(final String idboolean isSecure)
    {
        // final SoapRegistry soapRegistry = SoapRegistry.getRegistry() ;
        // final String serviceURI = soapRegistry.getServiceURI(ArjunaTX11Constants.SERVICE_TERMINATION_PARTICIPANT) ;
        final QName endpointId = .;
        final String address = ServiceRegistry.getRegistry().getServiceURI(.isSecure);
        W3CEndpointReferenceBuilder builder = new W3CEndpointReferenceBuilder();
        builder.serviceName(serviceId);
        builder.endpointName(endpointId);
        builder.address(address);
        InstanceIdentifier.setEndpointInstanceIdentifier(builderid) ;
        return builder.build();
    }
    private final void tidyup ()
    {
    	try
    	{
    	    .suspend();
    	}
    	catch (Exception ex)
    	{
    	    ex.printStackTrace();
    	}
    }
    private ContextManager _ctxManager = new ContextManager();
New to GrepCode? Check out our FAQ X