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) 2002, 2003, 2004,
  *
  * Arjuna Technologies Limited,
  * Newcastle upon Tyne,
  * Tyne and Wear,
  * UK.
  *
  * $Id: RegistrarImple.java,v 1.7.4.1 2005/11/22 10:36:14 kconner Exp $
  */
 
 package com.arjuna.mwlabs.wst11.ba;
 
 
 
 public class RegistrarImple implements com.arjuna.wsc11.Registrar
 {
 
 	{
 		 = CoordinatorManagerFactory.coordinatorManager();
 
 		// register with mapper using tx id as protocol identifier.
 		final RegistrarMapper mapper = RegistrarMapper.getFactory();
 
 		mapper.addRegistrar(
 		mapper.addRegistrar(
 	}

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 (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.
			final W3CEndpointReference participantProtocolService,
			final String protocolIdentifier,
			final InstanceIdentifier instanceIdentifier,
            final boolean isSecure)
	{
        Object tx = .get(instanceIdentifier.getInstanceIdentifier());
        if (tx instanceof SubordinateBACoordinator)
            return registerWithSubordinate((SubordinateBACoordinator)txparticipantProtocolServiceprotocolIdentifierisSecure);
        ActivityHierarchy hier = (ActivityHierarchytx;
		if (hier == nullthrow new NoActivityException();
		try
		{
		}
		{
			throw new NoActivityException();
		}
		catch (SystemException ex)
		{
		}
		// TODO check for AlreadyRegisteredException
				.equals(protocolIdentifier))
		{
			// enlist participant that wraps the requester URI.
			final String id = new Uid().stringForm();
			try
			{
                final ParticipantCompletionCoordinatorEngine engine = new ParticipantCompletionCoordinatorEngine(idparticipantProtocolService) ;
                engine.setCoordinator(participant.participantManager()) ;
                        .,
                        ServiceRegistry.getRegistry().getServiceURI(.isSecure),
						id);
			}
			catch (Exception ex)
			{
				throw new InvalidStateException();
			}
		}
		else
					.equals(protocolIdentifier))
			{
				final String id = new Uid().stringForm();
				try
				{
                    final CoordinatorCompletionCoordinatorEngine engine = new CoordinatorCompletionCoordinatorEngine(idparticipantProtocolService) ;
                    engine.setCoordinator(participant.participantManager()) ;
                            .,
                            ServiceRegistry.getRegistry().getServiceURI(.isSecure),
							id);
				}
				catch (Exception ex)
				{
					throw new InvalidStateException();
				}
			}
			else
				{
                    /*
                     * update the server side terminator with the participant end point
                     */
                    BusinessActivityTerminatorImple terminator;
                    terminator = (BusinessActivityTerminatorImple) TerminationCoordinatorProcessor.getProcessor().getParticipant(instanceIdentifier);
                    terminator.setEndpoint(participantProtocolService);
                    
                    try
					{
                        return getParticipantManager(
                                .,
                                ServiceRegistry.getRegistry().getServiceURI(.isSecure),
                                instanceIdentifier.getInstanceIdentifier());
					}
					catch (Exception ex)
					{
						throw new InvalidStateException();
					}
				}
                else
                    if (......equals(protocolIdentifier))
                    {
                        /*
                         * there is no end point ot update here so there is no need to look up the terminator
                         *
                         * this is a hack because the terminator has already been created at context create. this allows the
                         * enlist to be delayed until close/cancel and just return the end point with the requisite instance
                         * identifier. unfortunately this also means that you have to register in order to complete but not
                         * remove the terminator.
                         * 
                         * TODO sort this out
                         */
                        /*
                        BusinessActivityTerminatorImple terminator;
                        terminator = (BusinessActivityTerminatorImple) TerminationCoordinatorProcessor.getProcessor().getParticipant(instanceIdentifier);
                        */
                        try
                        {
                            return getParticipantManager(
                                    .,
                                    .,
                                    ServiceRegistry.getRegistry().getServiceURI(.isSecure),
                                    instanceIdentifier.getInstanceIdentifier());
                        }
                        catch (Exception ex)
                        {
                            throw new InvalidStateException();
                        }
                    }
				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 (String protocolIdentifier)
	{
	}
	public final void associate () throws Exception
	{
		// TODO colocation won't do suspend
		String txIdentifier = .identifier().toString();
		.put(txIdentifierhier);
	}
    public final void associate (BACoordinator 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)
            throws AlreadyRegisteredExceptionInvalidProtocolException,
    {
            // enlist participant that wraps the requester URI.
            final String id = "PCP" + new Uid().stringForm();
            try {
                // we use a manager which goes direct to the tx rather than via the activity service
                BAParticipantManager manager = new SubordinateBAParticipantManagerImple(theTxid);
                final ParticipantCompletionCoordinatorEngine engine = new ParticipantCompletionCoordinatorEngine(idparticipantProtocolService) ;
                BusinessAgreementWithParticipantCompletionImple participant =
                        new BusinessAgreementWithParticipantCompletionImple(
                                manager,
                                new BusinessAgreementWithParticipantCompletionStub(engine),
                                id);
                engine.setCoordinator(participant.participantManager()) ;
                theTx.enlistParticipant(participant);
                return getParticipantManager(
                        .,
                        ServiceRegistry.getRegistry().getServiceURI(.isSecure),
                        id);
            } catch (DuplicateParticipantException dpe ) {
                throw new AlreadyRegisteredException();
            } catch (Exception ex) {
                throw new InvalidStateException();
            }
        } else if (..equals(protocolIdentifier)) {
            // enlist participant that wraps the requester URI.
            final String id = "CCP" + new Uid().stringForm();
            try
            {
                BAParticipantManager manager = new SubordinateBAParticipantManagerImple(theTxid);
                final CoordinatorCompletionCoordinatorEngine engine = new CoordinatorCompletionCoordinatorEngine(idparticipantProtocolService) ;
                BusinessAgreementWithCoordinatorCompletionImple participant =
                        new BusinessAgreementWithCoordinatorCompletionImple(
                                manager,
                                new BusinessAgreementWithCoordinatorCompletionStub(engine),
                                id);
                engine.setCoordinator(participant.participantManager()) ;
                theTx.enlistParticipant(participant);
                return getParticipantManager(
                        .,
                        ServiceRegistry.getRegistry().getServiceURI(.isSecure),
                        id);
            }
            catch (Exception ex)
            {
                throw new InvalidStateException();
            }
        } else if (......equals(protocolIdentifier)) {
            // not allowed for subordinate transactions!
            throw new InvalidStateException();
        } else {
            throw new InvalidProtocolException();
        }
    }
	private W3CEndpointReference getParticipantManager (final QName serviceNamefinal QName endpointNamefinal String addressfinal String id)
	{
        W3CEndpointReferenceBuilder builder = new W3CEndpointReferenceBuilder();
        builder.serviceName(serviceName);
        builder.endpointName(endpointName);
        builder.address(address);
        InstanceIdentifier.setEndpointInstanceIdentifier(builderid);
        return builder.build();
	}
New to GrepCode? Check out our FAQ X