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

changeset 286
f50545b5e2f1
child 368
0989ad8c0860
equal deleted inserted replaced
284:88b85470e72c 286:f50545b5e2f1
1 /*
2 * Copyright (c) 1997, 2010, 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 */
25
26 package com.sun.xml.internal.ws.handler;
27
28 import com.sun.xml.internal.ws.api.message.AttachmentSet;
29 import com.sun.xml.internal.ws.api.message.HeaderList;
30 import com.sun.xml.internal.ws.api.message.Message;
31 import com.sun.xml.internal.ws.api.message.Packet;
32 import com.sun.xml.internal.ws.api.WSBinding;
33 import com.sun.xml.internal.ws.api.model.SEIModel;
34 import com.sun.xml.internal.ws.message.EmptyMessageImpl;
35 import com.sun.xml.internal.ws.message.source.PayloadSourceMessage;
36 import com.sun.xml.internal.ws.spi.db.BindingContext;
37
38 import javax.xml.transform.Source;
39
40 import javax.xml.ws.LogicalMessage;
41 import javax.xml.ws.handler.LogicalMessageContext;
42 import javax.xml.bind.JAXBContext;
43
44 /**
45 * Implementation of LogicalMessageContext. This class is used at runtime
46 * to pass to the handlers for processing logical messages.
47 *
48 * <p>This Class delegates most of the fuctionality to Packet
49 *
50 * @see Packet
51 *
52 * @author WS Development Team
53 */
54 class LogicalMessageContextImpl extends MessageUpdatableContext implements LogicalMessageContext {
55 private LogicalMessageImpl lm;
56 private WSBinding binding;
57 // private JAXBContext defaultJaxbContext;
58 private BindingContext defaultJaxbContext;
59 public LogicalMessageContextImpl(WSBinding binding, BindingContext defaultJAXBContext, Packet packet) {
60 super(packet);
61 this.binding = binding;
62 this.defaultJaxbContext = defaultJAXBContext;
63 }
64
65 public LogicalMessage getMessage() {
66 if(lm == null)
67 lm = new LogicalMessageImpl(defaultJaxbContext, packet);
68 return lm;
69 }
70
71 void setPacketMessage(Message newMessage){
72 if(newMessage != null) {
73 packet.setMessage(newMessage);
74 lm = null;
75 }
76 }
77
78
79 protected void updateMessage() {
80 //If LogicalMessage is not acccessed, its not modified.
81 if(lm != null) {
82 //Check if LogicalMessageImpl has changed, if so construct new one
83 // Packet are handled through MessageContext
84 if(lm.isPayloadModifed()){
85 Message msg = packet.getMessage();
86 Message updatedMsg = lm.getMessage(msg.getHeaders(),msg.getAttachments(),binding);
87 packet.setMessage(updatedMsg);
88 }
89 lm = null;
90 }
91
92 }
93
94 }

mercurial