src/share/jaxws_classes/com/sun/xml/internal/ws/handler/LogicalMessageContextImpl.java

Thu, 31 Aug 2017 15:18:52 +0800

author
aoqi
date
Thu, 31 Aug 2017 15:18:52 +0800
changeset 637
9c07ef4934dd
parent 368
0989ad8c0860
parent 0
373ffda63c9a
permissions
-rw-r--r--

merge

     1 /*
     2  * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.  Oracle designates this
     8  * particular file as subject to the "Classpath" exception as provided
     9  * by Oracle in the LICENSE file that accompanied this code.
    10  *
    11  * This code is distributed in the hope that it will be useful, but WITHOUT
    12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    14  * version 2 for more details (a copy is included in the LICENSE file that
    15  * accompanied this code).
    16  *
    17  * You should have received a copy of the GNU General Public License version
    18  * 2 along with this work; if not, write to the Free Software Foundation,
    19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    20  *
    21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    22  * or visit www.oracle.com if you need additional information or have any
    23  * questions.
    24  */
    26 package com.sun.xml.internal.ws.handler;
    28 import com.sun.xml.internal.ws.api.message.Message;
    29 import com.sun.xml.internal.ws.api.message.Packet;
    30 import com.sun.xml.internal.ws.api.WSBinding;
    31 import com.sun.xml.internal.ws.spi.db.BindingContext;
    33 import javax.xml.ws.LogicalMessage;
    34 import javax.xml.ws.handler.LogicalMessageContext;
    36 /**
    37  * Implementation of LogicalMessageContext. This class is used at runtime
    38  * to pass to the handlers for processing logical messages.
    39  *
    40  * <p>This Class delegates most of the fuctionality to Packet
    41  *
    42  * @see Packet
    43  *
    44  * @author WS Development Team
    45  */
    46 class LogicalMessageContextImpl extends MessageUpdatableContext implements LogicalMessageContext {
    47     private LogicalMessageImpl lm;
    48     private WSBinding binding;
    49 //  private JAXBContext defaultJaxbContext;
    50     private BindingContext defaultJaxbContext;
    51     public LogicalMessageContextImpl(WSBinding binding, BindingContext defaultJAXBContext, Packet packet) {
    52         super(packet);
    53         this.binding = binding;
    54         this.defaultJaxbContext = defaultJAXBContext;
    55     }
    57     public LogicalMessage getMessage() {
    58         if(lm == null)
    59             lm = new LogicalMessageImpl(defaultJaxbContext, packet);
    60         return lm;
    61     }
    63     void setPacketMessage(Message newMessage){
    64         if(newMessage != null) {
    65             packet.setMessage(newMessage);
    66             lm = null;
    67         }
    68     }
    71     protected void updateMessage() {
    72         //If LogicalMessage is not acccessed, its not modified.
    73         if(lm != null) {
    74             //Check if LogicalMessageImpl has changed, if so construct new one
    75             // Packet are handled through MessageContext
    76             if(lm.isPayloadModifed()){
    77                 Message msg = packet.getMessage();
    78                 Message updatedMsg = lm.getMessage(msg.getHeaders(),msg.getAttachments(),binding);
    79                 packet.setMessage(updatedMsg);
    80             }
    81             lm = null;
    82         }
    84     }
    86 }

mercurial