Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  package com.arjuna.mwlabs.wst11.at.remote;
  
 
 
 public class UserTransactionImple extends UserTransaction
 {
 
 	{
 		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.
 			 */
 
 			{
                 final ServiceRegistry serviceRegistry = ServiceRegistry.getRegistry() ;
                  = serviceRegistry.getServiceURI(.) ;
 			}
 		}
 		catch (Exception ex)
 		{
 			// TODO
 
 		}
 	}
 
         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);
 
 
 		}
 		{
 			tidyup();
 
 			throw new SystemException(ex.toString());
 		}
 		{
 			tidyup();
 
 			throw new SystemException(ex.toString());
 		}
 		catch (SystemException ex)
 		{
			throw ex;
		}
	}
	public void commit () throws TransactionRolledBackException,
	{
		try
		{
		}
		catch (SystemException ex)
		{
			throw ex;
		}
		finally
		{
		}
	}
	{
		try
		{
		}
		catch (SystemException ex)
		{
			throw ex;
		}
		finally
		{
		}
	}
	{
		try
		{
		}
		catch (SystemException ex)
		{
			return "Unknown";
		}
		{
			return "Unknown";
		}
	}
	public String toString ()
	{
	}

    
method provided for the benefit of UserSubordinateTransactionImple to allow it to begin a subordinate transaction which requires an existing context to be installed on the thread before it will start and instal la new transaction

    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;
        }
    }
	/*
	 * Not sure if this is right as it doesn't map to registering a participant
	 * with the coordinator.
	 */
	private final void enlistCompletionParticipants ()
	{
        TransactionManagerImple tm = (TransactionManagerImple) TransactionManager.getTransactionManager();
        final TxContextImple currentTx = (TxContextImpletm.currentTransaction();
        if (currentTx == null)
            throw new UnknownTransactionException();
        final String id = currentTx.identifier();
        final W3CEndpointReference completionParticipant = getCompletionParticipant(idcurrentTx.isSecure());
        W3CEndpointReference completionCoordinator = null;
        try
        {
            completionCoordinator = tm.registerParticipant(completionParticipant.);
        }
        catch (com.arjuna.wsc.InvalidProtocolException ex)
        {
            ex.printStackTrace();
            throw new SystemException(ex.toString());
        }
        catch (com.arjuna.wsc.InvalidStateException ex)
        {
            throw new WrongStateException();
        }
        catch (com.arjuna.wsc.CannotRegisterException ex)
        {
            // cause could actually be no activity or already registered
            throw new UnknownTransactionException();
        }
        .put(idcompletionCoordinator);
	}

    
fetch the coordination context type stashed in the current AT 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 AT 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();
    }
    protected final Context startTransaction(int timeoutTxContextImple current)
	{
		try
		{
            // TODO: tricks for per app _activationCoordinatorService config, perhaps:
            //InputStream inputStream = Thread.currentThread().getContextClassLoader().getResourceAsStream("/foo.properties");
            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_wst_at_remote_UserTransaction11Imple__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());
		}
	}
	private final void commitWithoutAck ()
	{
		TxContextImple ctx = null;
		String id = null;
		try
		{
            if (ctx == null) {
                throw new WrongStateException();
            }
			id = ctx.identifier();
			/*
			 * By default the completionParticipantURL won't be set for an interposed (imported)
			 * bridged transaction. This is fine, because you shouldn't be able to commit that
			 * transaction from a node in the tree, only from the root. So, we can prevent commit
			 * or rollback at this stage. The alternative would be to setup the completionParticipantURL
			 * and throw the exception from the remote coordinator side (see enlistCompletionParticipants
			 * for how to do this).
			 *
			 * The same applies for an interposed subordinate transaction created via beginSubordinate.
			 */
			final W3CEndpointReference completionCoordinator = (W3CEndpointReference.get(id);
			if (completionCoordinator == null)
				throw new WrongStateException();
			CompletionStub completionStub = new CompletionStub(idcompletionCoordinator);
			completionStub.commit();
		}
		catch (SystemException ex)
		{
			throw ex;
		}
		{
			throw ex;
		}
		{
			throw ex;
		}
		catch (SecurityException ex)
		{
			throw ex;
		}
        catch (WrongStateException ex)
        {
            throw ex;
        }
		catch (Exception ex)
		{
			throw new SystemException(ex.toString());
		}
		finally
		{
			try
			{
				if (ctx != null)
			}
			catch (Exception ex)
			{
			}
			if (id != null)
		}
	}
	{
		TxContextImple ctx = null;
		String id = null;
		try
		{
            if (ctx == null) {
                throw new WrongStateException();
            }
			id = ctx.identifier();
			/*
			 * By default the completionParticipantURL won't be set for an interposed (imported)
			 * bridged transaction. This is fine, because you shouldn't be able to commit that
			 * transaction from a node in the tree, only from the root. So, we can prevent commit
			 * or rollback at this stage. The alternative would be to setup the completionParticipantURL
			 * and throw the exception from the remote coordinator side (see enlistCompletionParticipants
			 * for how to do this).
			 *
			 * The same applies for an interposed subordinate transaction created via beginSubordinate.
			 */
			if (completionCoordinator == null)
				throw new WrongStateException();
			CompletionStub completionStub = new CompletionStub(idcompletionCoordinator);
			completionStub.rollback();
		}
		catch (SystemException ex)
		{
			throw ex;
		}
		{
			throw ex;
		}
		catch (SecurityException ex)
		{
			throw ex;
		}
        catch (WrongStateException ex)
        {
            throw ex;
        }
		catch (Exception ex)
		{
			throw new SystemException(ex.toString());
		}
		finally
		{
			try
			{
				if (ctx != null)
			}
			catch (Exception ex)
			{
			}
			if (id != null)
		}
	}

    
Create an endpoint for the local participant service labelled with the current context id which can be passed to the registration service and handed on to the registered coordinator to call back to this transaction

Parameters:
id the current transaction context identifier
Returns:
    private W3CEndpointReference getCompletionParticipant(final String idfinal boolean isSecure)
    {
        final QName endpointName = .;
        final String address = ServiceRegistry.getRegistry().getServiceURI(.isSecure);
        W3CEndpointReferenceBuilder builder = new W3CEndpointReferenceBuilder();
        builder.serviceName(serviceName);
        builder.endpointName(endpointName);
        builder.address(address);
        InstanceIdentifier.setEndpointInstanceIdentifier(builderid);
        return builder.build();
    }
	protected final void tidyup ()
	{
		try
		{
		}
		catch (Exception ex)
		{
		}
	}
New to GrepCode? Check out our FAQ X