1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/src/share/jaxws_classes/com/sun/xml/internal/ws/handler/MessageUpdatableContext.java Tue Mar 06 16:09:35 2012 -0800 1.3 @@ -0,0 +1,147 @@ 1.4 +/* 1.5 + * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved. 1.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 1.7 + * 1.8 + * This code is free software; you can redistribute it and/or modify it 1.9 + * under the terms of the GNU General Public License version 2 only, as 1.10 + * published by the Free Software Foundation. Oracle designates this 1.11 + * particular file as subject to the "Classpath" exception as provided 1.12 + * by Oracle in the LICENSE file that accompanied this code. 1.13 + * 1.14 + * This code is distributed in the hope that it will be useful, but WITHOUT 1.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 1.16 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 1.17 + * version 2 for more details (a copy is included in the LICENSE file that 1.18 + * accompanied this code). 1.19 + * 1.20 + * You should have received a copy of the GNU General Public License version 1.21 + * 2 along with this work; if not, write to the Free Software Foundation, 1.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 1.23 + * 1.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 1.25 + * or visit www.oracle.com if you need additional information or have any 1.26 + * questions. 1.27 + */ 1.28 + 1.29 +package com.sun.xml.internal.ws.handler; 1.30 + 1.31 +import com.sun.xml.internal.ws.api.message.Message; 1.32 +import com.sun.xml.internal.ws.api.message.Packet; 1.33 +import java.util.Collection; 1.34 +import java.util.Map; 1.35 +import java.util.Set; 1.36 +import javax.xml.ws.handler.MessageContext; 1.37 + 1.38 +/** 1.39 + * The class represents a MessageContext(Properties) and also allows the Message to be modified. 1.40 + * This is extended by SOAPMessageContextImpl and LogicalMessageContextImpl. 1.41 + * 1.42 + * @author WS Development Team 1.43 + */ 1.44 +public abstract class MessageUpdatableContext implements MessageContext { 1.45 + final Packet packet; 1.46 + private MessageContextImpl ctxt; 1.47 + /** Creates a new instance of MessageUpdatableContext */ 1.48 + public MessageUpdatableContext(Packet packet) { 1.49 + ctxt = new MessageContextImpl(packet); 1.50 + this.packet = packet; 1.51 + } 1.52 + 1.53 + /** 1.54 + * Fill a {@link Packet} with values of this {@link MessageContext}. 1.55 + */ 1.56 + private void fill(Packet packet) { 1.57 + ctxt.fill(packet); 1.58 + } 1.59 + /** 1.60 + * Updates Message in the packet with user modifications 1.61 + */ 1.62 + abstract void updateMessage(); 1.63 + 1.64 + /** 1.65 + * Updates Message in the packet with user modifications 1.66 + * returns the new packet's message 1.67 + */ 1.68 + Message getPacketMessage(){ 1.69 + updateMessage(); 1.70 + return packet.getMessage(); 1.71 + } 1.72 + 1.73 + /** 1.74 + * Sets Message in the packet 1.75 + * Any user modifications done on previous Message are lost. 1.76 + */ 1.77 + abstract void setPacketMessage(Message newMessage); 1.78 + 1.79 + /** 1.80 + * Updates the complete packet with user modfications to the message and 1.81 + * properties cahnges in MessageContext 1.82 + */ 1.83 + public final void updatePacket() { 1.84 + updateMessage(); 1.85 + fill(packet); 1.86 + } 1.87 + 1.88 + MessageContextImpl getMessageContext() { 1.89 + return ctxt; 1.90 + } 1.91 + 1.92 + public void setScope(String name, Scope scope) { 1.93 + ctxt.setScope(name, scope); 1.94 + } 1.95 + 1.96 + public Scope getScope(String name) { 1.97 + return ctxt.getScope(name); 1.98 + } 1.99 + 1.100 + /* java.util.Map methods below here */ 1.101 + 1.102 + public void clear() { 1.103 + ctxt.clear(); 1.104 + } 1.105 + 1.106 + public boolean containsKey(Object obj) { 1.107 + return ctxt.containsKey(obj); 1.108 + } 1.109 + 1.110 + public boolean containsValue(Object obj) { 1.111 + return ctxt.containsValue(obj); 1.112 + } 1.113 + 1.114 + public Set<Entry<String, Object>> entrySet() { 1.115 + return ctxt.entrySet(); 1.116 + } 1.117 + 1.118 + public Object get(Object obj) { 1.119 + return ctxt.get(obj); 1.120 + } 1.121 + 1.122 + public boolean isEmpty() { 1.123 + return ctxt.isEmpty(); 1.124 + } 1.125 + 1.126 + public Set<String> keySet() { 1.127 + return ctxt.keySet(); 1.128 + } 1.129 + 1.130 + public Object put(String str, Object obj) { 1.131 + return ctxt.put(str, obj); 1.132 + } 1.133 + 1.134 + public void putAll(Map<? extends String, ? extends Object> map) { 1.135 + ctxt.putAll(map); 1.136 + } 1.137 + 1.138 + public Object remove(Object obj) { 1.139 + return ctxt.remove(obj); 1.140 + } 1.141 + 1.142 + public int size() { 1.143 + return ctxt.size(); 1.144 + } 1.145 + 1.146 + public Collection<Object> values() { 1.147 + return ctxt.values(); 1.148 + } 1.149 + 1.150 +}