Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  package com.arjuna.mwlabs.wst11.at;
  
 
 
 public class RegistrarImple implements Registrar
 {
 	public RegistrarImple()
     {
 		 = CoordinatorManagerFactory.coordinatorManager();
 
 		// register with mapper using tx id as protocol identifier.
         final com.arjuna.wsc11.RegistrarMapper mapper = RegistrarMapper.getFactory() ;
 
 	}

Called when a registrar is added to a register mapper. This method will be called multiple times if the registrar is added to multiple register mappers or to the same register mapper with different protocol identifiers.

Parameters:
protocolIdentifier the protocol identifier
 
 
 	public void install (final String protocolIdentifier)
 	{
 	}

Registers the interest of participant in a particular protocol.

Parameters:
participantProtocolService the address of the participant protocol service
protocolIdentifier the protocol identifier
Returns:
the PortReference of the coordinator protocol service
Throws:
com.arjuna.wsc.AlreadyRegisteredException if the participant is already registered for this coordination protocol under this activity identifier
com.arjuna.wsc.InvalidProtocolException if the coordination protocol is not supported
com.arjuna.wsc.InvalidStateException if the state of the coordinator no longer allows registration for this coordination protocol
com.arjuna.wsc.NoActivityException if the activity does not exist.
 
 
 	/*
 	 * TODO
 	 *
 	 * See comment at head of class definition. We shouldn't have to rely on
 	 * thread-to-activity association to register a participant. We currently do
 	 * because the code is based on old WS-CAF models that are no longer
 	 * applicable. This needs updating!
 	 */
 	public W3CEndpointReference register(final W3CEndpointReference participantProtocolService,
         final String protocolIdentifierfinal InstanceIdentifier instanceIdentifierfinal boolean isSecure)
             InvalidStateExceptionNoActivityException
 	{
 		Object tx = .get(instanceIdentifier.getInstanceIdentifier());
 
		if (tx instanceof SubordinateATCoordinator)
			return registerWithSubordinate((SubordinateATCoordinator)txparticipantProtocolServiceprotocolIdentifierisSecure);
		if (hier == null)
			throw new NoActivityException();
		try
		{
		}
		{
			throw new NoActivityException();
		}
		catch (SystemException ex)
		{
		}
		// TODO check for AlreadyRegisteredException
		{
			// enlist participant that wraps the requester URI.
			final String participantId = "D" + new Uid().stringForm();
			try
			{
                final Durable2PCStub participantStub = new Durable2PCStub(participantIdparticipantProtocolService) ;
				return getCoordinator(participantIdisSecure) ;
			}
			catch (Exception ex)
			{
				throw new InvalidStateException();
			}
		}
		{
			// enlist participant that wraps the requester URI.
			final String participantId = "V" + new Uid().stringForm();
			try
			{
                final Volatile2PCStub participantStub = new Volatile2PCStub(participantIdparticipantProtocolService) ;
				return getCoordinator(participantIdisSecure) ;
			}
			catch (Exception ex)
			{
				throw new InvalidStateException();
			}
		}
		{
			try
			{
                final CompletionCoordinatorParticipant participant = new CompletionCoordinatorImple(hiertrueparticipantProtocolService) ;
                CompletionCoordinatorProcessor.getProcessor().activateParticipant(participantinstanceIdentifier.getInstanceIdentifier()) ;
				return getCompletionCoordinator(instanceIdentifierisSecure) ;
			}
			catch (Exception ex)
			{
			}
		}
        else if (..equals(protocolIdentifier))
        {
            try
            {
                final CompletionCoordinatorParticipant participant = new CompletionCoordinatorRPCImple(hiertrueparticipantProtocolService) ;
                CompletionCoordinatorRPCProcessor.getProcessor().activateParticipant(participantinstanceIdentifier.getInstanceIdentifier()) ;
                .suspend();
                return getCompletionCoordinatorRPC(instanceIdentifierisSecure) ;
            }
            catch (Exception ex)
            {
                ex.printStackTrace();
                throw new InvalidStateException(ex.toString());
            }
        }
		else {
            throw new InvalidProtocolException();
        }
	}

    
Called when a registrar is removed from a register mapper. This method will be called multiple times if the registrar is removed from multiple register mappers or from the same register mapper with different protocol identifiers.

Parameters:
protocolIdentifier the protocol identifier
	public void uninstall(final String protocolIdentifier)
	{
	}
	public final void associate () throws Exception
	{
		// TODO colocation won't do suspend
		String txIdentifier = .identifier().toString();
		.put(txIdentifierhier);
	}
	public final void associate (ATCoordinator transactionthrows Exception
	{
		String txIdentifier = transaction.get_uid().stringForm();
		.put(txIdentifiertransaction);
	}
	public final void disassociate (String txIdentifierthrows Exception
	{
		.remove(txIdentifier);
	}
        final W3CEndpointReference participantProtocolServicefinal String protocolIdentifier,
        final boolean isSecure)
    {
		{
			// enlist participant that wraps the requester URI.
            final String participantId = "D" + new Uid().stringForm();
            try
            {
                final Durable2PCStub participantStub = new Durable2PCStub(participantIdparticipantProtocolService) ;
                theTx.enlistParticipant(new DurableTwoPhaseCommitParticipant(participantStubparticipantId));
                return getCoordinator(participantIdisSecure) ;
            }
            catch (Exception ex)
            {
                throw new InvalidStateException();
            }
		}
		{
			// enlist participant that wraps the requester URI.
            final String participantId = "V" + new Uid().stringForm();
            try
            {
                final Volatile2PCStub participantStub = new Volatile2PCStub(participantIdparticipantProtocolService) ;
                theTx.enlistSynchronization(new VolatileTwoPhaseCommitParticipant(participantStub)) ;
                return getCoordinator(participantIdisSecure) ;
            }
            catch (Exception ex)
            {
                throw new InvalidStateException();
            }
		}
		{
			// not allowed for subordinate transactions!
			throw new InvalidStateException();
		}
		else {
            throw new InvalidProtocolException();
        }
	}
    private W3CEndpointReference getCompletionCoordinator(final InstanceIdentifier instanceIdentifierfinal boolean isSecure)
    {
        W3CEndpointReferenceBuilder builder = new W3CEndpointReferenceBuilder();
        String address = ServiceRegistry.getRegistry().getServiceURI(.isSecure);
        builder.address(address);
        InstanceIdentifier.setEndpointInstanceIdentifier(builderinstanceIdentifier);
        return builder.build();
    }
    private W3CEndpointReference getCompletionCoordinatorRPC(final InstanceIdentifier instanceIdentifierfinal boolean isSecure)
    {
        W3CEndpointReferenceBuilder builder = new W3CEndpointReferenceBuilder();
        builder.address(address);
        InstanceIdentifier.setEndpointInstanceIdentifier(builderinstanceIdentifier);
        return builder.build();
    }
    private W3CEndpointReference getCoordinator(final String participantIdfinal boolean isSecure)
    {
        W3CEndpointReferenceBuilder builder = new W3CEndpointReferenceBuilder();
        String address = ServiceRegistry.getRegistry().getServiceURI(.isSecure);
        builder.address(address);
        InstanceIdentifier.setEndpointInstanceIdentifier(builderparticipantId);
        return builder.build();
    }
New to GrepCode? Check out our FAQ X