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.
  */
 package com.arjuna.webservices11.wsarj.handler;
 
 
 import java.util.Set;

Header handler for parsing the Arjuna WS instance identifier header.

Author(s):
adinn
 
 {
    
Gets the header blocks that can be processed by this Handler instance.

Returns:
Set of QNames of header blocks processed by this handler instance. QName is the qualified name of the outermost element of the Header block.
 
     public Set<QNamegetHeaders()
     {
         return ;
     }

    
Handle an outgoing message by inserting any current arjuna context attached to the context into the message headers and handle an incoming message by retrieving the context from the headers and attaching it to the context,

Parameters:
context the message context.
Returns:
Always return true
Throws:
java.lang.RuntimeException Causes the JAX-WS runtime to cease handler processing and generate a fault.
javax.xml.ws.ProtocolException Causes the JAX-WS runtime to switch to fault message processing.
 
     public boolean handleMessage(SOAPMessageContext contextthrows ProtocolException
     {
         final boolean outbound = (Boolean)context.get(.);
         if (outbound) {
             return handleMessageOutbound(context);
         } else {
             return handlemessageInbound(context);
         }
     }

    
check for an arjuna context attached to the message context and, if found, install its identifier as the value of a soap message header element

Parameters:
context
Returns:
Throws:
javax.xml.ws.ProtocolException
 
     protected boolean handleMessageOutbound(SOAPMessageContext contextthrows ProtocolException
     {
         try {
             ArjunaContext arjunaContext = ArjunaContext.getCurrentContext(context);
             if (arjunaContext != null) {
                 InstanceIdentifier instanceIdentifier = arjunaContext.getInstanceIdentifier();
                 // insert a header into the current message containing the instance identifier as a text element
                 final SOAPMessage soapMessage = context.getMessage();
                 final SOAPEnvelope soapEnvelope = soapMessage.getSOAPPart().getEnvelope();
                 SOAPHeader soapHeader = soapEnvelope.getHeader() ;
                 if (soapHeader == null)
                 {
                    soapHeader = soapEnvelope.addHeader() ;
                }
                final SOAPHeaderElement headerElement = soapHeader.addHeaderElement(.);
                headerElement.setValue(instanceIdentifier.getInstanceIdentifier());
                headerElement.setMustUnderstand(true);
            }
        } catch (Exception se) {
            throw new ProtocolException(se);
        }
        return true;
    }

    
check for an arjuna instance identifier element embedded in the soap message headesr and, if found, use it to label an arjuna context attached to the message context

Parameters:
context
Returns:
Throws:
javax.xml.ws.ProtocolException
    private boolean handlemessageInbound(SOAPMessageContext context)  throws ProtocolException
    {
        try {
            final SOAPMessage soapMessage = context.getMessage();
            final SOAPEnvelope soapEnvelope = soapMessage.getSOAPPart().getEnvelope();
            Iterator<SOAPHeaderElementiterator = soapEnvelope.getHeader().examineAllHeaderElements();
            while (iterator.hasNext()) {
                final SOAPHeaderElement headerElement = iterator.next();
                if (..equals(headerElement.getElementQName())) {
                    // found it - clear the must understand flag, retrieve the value and store an arjuna
                    // context in the message context
                    headerElement.setMustUnderstand(false);
                    String identifierString = headerElement.getValue();
                    if (identifierString != null) {
                        ArjunaContext arjunaContext = ArjunaContext.getContext(context);
                        arjunaContext.setInstanceIdentifier(new InstanceIdentifier(identifierString));
                        break;
                    }
                }
            }
        } catch (Exception se) {
            throw new ProtocolException(se);
        }
        return true;
    }

    
this handler ignores faults but allows other handlers to deal with them

Parameters:
context the message context
Returns:
true to allow fault handling to continue
    public boolean handleFault(SOAPMessageContext context)
    {
        return true;
    }

    
this hanlder ignores close messages

Parameters:
context the message context
    public void close(javax.xml.ws.handler.MessageContext context)
    {
    }

    
a singleton set containing the only header this handler is interested in
New to GrepCode? Check out our FAQ X