FileDocCategorySizeDatePackage
ConsumerInOut.javaAPI DocGlassfish v2 API6584Fri May 04 22:30:26 BST 2007com.sun.enterprise.jbi.serviceengine.comm

ConsumerInOut

public class ConsumerInOut extends MessageExchangeTransportImpl
This class handles sending message to & receiving message from NMR when 1) Role of the component is Consumer. 2) Message exchange pattern is In-Out.
author
bhavanishankar@dev.java.net

Fields Summary
private javax.jbi.messaging.InOut
me
Constructors Summary
public ConsumerInOut(javax.jbi.messaging.InOut me)

        super(me);
        this.me = me;
    
Methods Summary
public UnWrappedMessagereceive(com.sun.enterprise.jbi.serviceengine.util.soap.EndpointMetaData emd)

        NormalizedMessage normalizedMessage = receiveNormalized();
        UnWrappedMessage unwrappedMessage = null;
        if(normalizedMessage != null) {
            try {
                String operationName = me.getOperation().getLocalPart();
                
                unwrappedMessage = new UnWrappedMessage();
                unwrappedMessage.setNormalizedMessage(normalizedMessage);
                
                if(normalizedMessage instanceof Fault) {
                    unwrappedMessage.unwrapFault();
                } else {
                    unwrappedMessage.setWSDLMessageType(
                            new QName(
                            emd.getOutputMessage(operationName).getQName().getNamespaceURI(),
                            operationName + "Response"));
                    
                    unwrappedMessage.setWSDLBindingStyle(
                            emd.getBindingStyle(operationName));
                    
                    unwrappedMessage.setWSDLOrderedParts(
                            emd.getOutputMessage(operationName).getOrderedParts(null));
                    
                    unwrappedMessage.setWSDLPartBindings(
                            emd.getOutputPartBindings(operationName));
                    
                    unwrappedMessage.unwrap();
                }
            } catch(Exception ex) {
                logger.log(Level.WARNING, ex.getMessage() +
                        StringTranslator.getDefaultInstance().getString(
                        "serviceengine.unwrapping_failed_hint1"));
            }
        }
        return unwrappedMessage;
    
public javax.jbi.messaging.NormalizedMessagereceiveNormalized()

        msg = (me.getFault() != null)? me.getFault() : me.getOutMessage();
        preReceive();
        return msg;
    
public voidsend(javax.jbi.messaging.NormalizedMessage message)

        this.msg = message;
        me.setInMessage(message);
        send();
    
public voidsend(com.sun.xml.ws.api.message.Message message, com.sun.enterprise.jbi.serviceengine.util.soap.EndpointMetaData emd)

        String operationName = me.getOperation().getLocalPart();
        WrappedMessage wrappedMessage = new WrappedMessage();
        wrappedMessage.setAbstractMessage(message);
        
        if(message.isFault()) {
            wrappedMessage.wrapFault(operationName, emd);
        } else {
            wrappedMessage.setWSDLBindingStyle(emd.getBindingStyle(operationName));
            wrappedMessage.setWSDLMessageType(emd.getInputMessage(operationName).getQName());
            wrappedMessage.setWSDLMessageName(emd.getOperationInputName(operationName));
            wrappedMessage.setWSDLOrderedParts(emd.getInputMessage(operationName).getOrderedParts(null));
            wrappedMessage.setWSDLPartBindings(emd.getInputPartBindings(operationName));
            wrappedMessage.wrap();
        }
        NormalizedMessage normalizedMessage = me.createMessage();
        normalizedMessage.setContent(wrappedMessage.readPayloadAsSource());
        
        /**
         * Process the attachments.
         */
        for(Attachment attachment : (Iterable<Attachment>)message.getAttachments()) {
            logger.log(Level.FINE, "Adding attachment to Normalized Message, attachmentID = "
                    + attachment.getContentId());
            normalizedMessage.addAttachment(attachment.getContentId(), attachment.asDataHandler());
        }
        send(normalizedMessage);