Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * JBoss, Home of Professional Open Source
   * Copyright 2007, 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) 2007,
  * @author JBoss Inc.
  */
 package com.arjuna.mw.wst11.service;
 
 
Common base class for classes used to perform WS-Transaction context manipulation on SOAP messages.
 
 {
    
Handle the request.

Parameters:
soapMessage The current message context.
 
     protected boolean handleInboundMessage(final SOAPMessage soapMessage)
     {
         return handleInboundMessage(soapMessagefalse);
     }

    
Handle the request.

Parameters:
soapMessage The current message context.
installSubordinateTx true if a subordinate transaction should be interposed and false if the handler should just resume the incoming transaction. currently only works for AT transactions but will eventually be extended to work for BA transactions too.
 
     protected boolean handleInboundMessage(final SOAPMessage soapMessageboolean installSubordinateTx)
     {
         if (soapMessage != null)
         {
             try
             {
                 final SOAPEnvelope soapEnvelope = soapMessage.getSOAPPart().getEnvelope() ;
                 final SOAPHeader soapHeader = soapEnvelope.getHeader() ;
                 final SOAPHeaderElement soapHeaderElement = getHeaderElement(soapHeader..) ;
 
                 if (soapHeaderElement != null)
                 {
                     final CoordinationContextType cc = CoordinationContextHelper.deserialise(soapHeaderElement) ;
                     final String coordinationType = cc.getCoordinationType();
                     if (..equals(coordinationType))
                     {
                         clearMustUnderstand(soapHeadersoapHeaderElement) ;
                         TxContext txContext = new TxContextImple(cc) ;
                         if (installSubordinateTx) {
                             txContext = SubordinateImporter.importContext(cc);
                         }
                         TransactionManagerFactory.transactionManager().resume(txContext);
                     }
                     else if (..equals(coordinationType))
                     {
                         // interposition is not yet implemented for business activities
                         clearMustUnderstand(soapHeadersoapHeaderElement) ;
                         TxContext txContext = new com.arjuna.mwlabs.wst11.ba.context.TxContextImple(cc);
                         if (installSubordinateTx) {
                             txContext = com.arjuna.mwlabs.wst11.ba.SubordinateImporter.importContext(cc);
                         }
                         BusinessActivityManagerFactory.businessActivityManager().resume(txContext) ;
                     }
                     else {
                         ..warn_mw_wst11_service_JaxHC11P_2("com.arjuna.mw.wst11.service.JaxBaseHeaderContextProcessor.handleRequest(MessageContext context)"coordinationType);
                     }
                 }
             }
             catch (final Throwable th) {
                ..warn_mw_wst11_service_JaxHC11P_1("com.arjuna.mw.wst11.service.JaxBaseHeaderContextProcessor.handleRequest(MessageContext context)"th);
            }
        }
        return true ;
    }

    
Suspend the current transaction.
    protected void suspendTransaction()
    {
        try
        {
            /*
             * 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) {
            ..warn_mw_wst11_service_JaxHC11P_1("com.arjuna.mw.wst11.service.JaxBaseHeaderContextProcessor.suspendTransaction()"th);
        }
    }

    
Clear the soap MustUnderstand.

Parameters:
soapHeader The SOAP header.
soapHeaderElement The SOAP header element.
    private void clearMustUnderstand(final SOAPHeader soapHeaderfinal SOAPHeaderElement soapHeaderElement)
            throws SOAPException
    {
        final Name headerName = soapHeader.getElementName() ;
        final SOAPFactory factory = SOAPFactory.newInstance() ;
        final Name attributeName = factory.createName("mustUnderstand"headerName.getPrefix(), headerName.getURI()) ;
        soapHeaderElement.removeAttribute(attributeName) ;
    }
    private SOAPHeaderElement getHeaderElement(final SOAPHeader soapHeaderfinal String urifinal String name)
            throws SOAPException
    {
        if (soapHeader != null)
        {
            final Iterator headerIter = SOAPUtil.getChildElements(soapHeader) ;
            while(headerIter.hasNext())
            {
                final SOAPHeaderElement current = (SOAPHeaderElement)headerIter.next() ;
                final Name currentName = current.getElementName() ;
                if ((currentName != null) &&
                        match(namecurrentName.getLocalName()) &&
                        match(uricurrentName.getURI()))
                {
                    return current ;
                }
            }
        }
        return null ;
    }

    
Do the two references match?

Parameters:
lhs The first reference.
rhs The second reference.
Returns:
true if the references are both null or if they are equal.
    private boolean match(final Object lhsfinal Object rhs)
    {
        if (lhs == null)
        {
            return (rhs == null) ;
        }
        else
        {
            return lhs.equals(rhs) ;
        }
    }
New to GrepCode? Check out our FAQ X