001: /*
002: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003: *
004: * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
005: *
006: * The contents of this file are subject to the terms of either the GNU
007: * General Public License Version 2 only ("GPL") or the Common Development
008: * and Distribution License("CDDL") (collectively, the "License"). You
009: * may not use this file except in compliance with the License. You can obtain
010: * a copy of the License at https://glassfish.dev.java.net/public/CDDL+GPL.html
011: * or glassfish/bootstrap/legal/LICENSE.txt. See the License for the specific
012: * language governing permissions and limitations under the License.
013: *
014: * When distributing the software, include this License Header Notice in each
015: * file and include the License file at glassfish/bootstrap/legal/LICENSE.txt.
016: * Sun designates this particular file as subject to the "Classpath" exception
017: * as provided by Sun in the GPL Version 2 section of the License file that
018: * accompanied this code. If applicable, add the following below the License
019: * Header, with the fields enclosed by brackets [] replaced by your own
020: * identifying information: "Portions Copyrighted [year]
021: * [name of copyright owner]"
022: *
023: * Contributor(s):
024: *
025: * If you wish your version of this file to be governed by only the CDDL or
026: * only the GPL Version 2, indicate your decision by adding "[Contributor]
027: * elects to include this software in this distribution under the [CDDL or GPL
028: * Version 2] license." If you don't indicate a single choice of license, a
029: * recipient has the option to distribute your version of this file under
030: * either the CDDL, the GPL Version 2 or to extend the choice of license to
031: * its licensees as provided above. However, if you add GPL Version 2 code
032: * and therefore, elected the GPL Version 2 license, then the option applies
033: * only if the new code is made subject to such option by the copyright
034: * holder.
035: */
036: package com.sun.xml.ws.handler;
037:
038: import com.sun.xml.ws.api.message.Message;
039: import com.sun.xml.ws.api.message.Packet;
040: import java.util.Collection;
041: import java.util.Map;
042: import java.util.Set;
043: import javax.xml.ws.handler.MessageContext;
044:
045: /**
046: * The class represents a MessageContext(Properties) and also allows the Message to be modified.
047: * This is extended by SOAPMessageContextImpl and LogicalMessageContextImpl.
048: *
049: * @author WS Development Team
050: */
051: public abstract class MessageUpdatableContext implements MessageContext {
052: final Packet packet;
053: private MessageContextImpl ctxt;
054:
055: /** Creates a new instance of MessageUpdatableContext */
056: public MessageUpdatableContext(Packet packet) {
057: ctxt = new MessageContextImpl(packet);
058: this .packet = packet;
059: }
060:
061: /**
062: * Fill a {@link Packet} with values of this {@link MessageContext}.
063: */
064: private void fill(Packet packet) {
065: ctxt.fill(packet);
066: }
067:
068: /**
069: * Updates Message in the packet with user modifications
070: */
071: abstract void updateMessage();
072:
073: /**
074: * Updates Message in the packet with user modifications
075: * returns the new packet's message
076: */
077: Message getPacketMessage() {
078: updateMessage();
079: return packet.getMessage();
080: }
081:
082: /**
083: * Sets Message in the packet
084: * Any user modifications done on previous Message are lost.
085: */
086: abstract void setPacketMessage(Message newMessage);
087:
088: /**
089: * Updates the complete packet with user modfications to the message and
090: * properties cahnges in MessageContext
091: */
092: final void updatePacket() {
093: updateMessage();
094: fill(packet);
095: }
096:
097: MessageContextImpl getMessageContext() {
098: return ctxt;
099: }
100:
101: public void setScope(String name, Scope scope) {
102: ctxt.setScope(name, scope);
103: }
104:
105: public Scope getScope(String name) {
106: return ctxt.getScope(name);
107: }
108:
109: /* java.util.Map methods below here */
110:
111: public void clear() {
112: ctxt.clear();
113: }
114:
115: public boolean containsKey(Object obj) {
116: return ctxt.containsKey(obj);
117: }
118:
119: public boolean containsValue(Object obj) {
120: return ctxt.containsValue(obj);
121: }
122:
123: public Set<Entry<String, Object>> entrySet() {
124: return ctxt.entrySet();
125: }
126:
127: public Object get(Object obj) {
128: return ctxt.get(obj);
129: }
130:
131: public boolean isEmpty() {
132: return ctxt.isEmpty();
133: }
134:
135: public Set<String> keySet() {
136: return ctxt.keySet();
137: }
138:
139: public Object put(String str, Object obj) {
140: return ctxt.put(str, obj);
141: }
142:
143: public void putAll(Map<? extends String, ? extends Object> map) {
144: ctxt.putAll(map);
145: }
146:
147: public Object remove(Object obj) {
148: return ctxt.remove(obj);
149: }
150:
151: public int size() {
152: return ctxt.size();
153: }
154:
155: public Collection<Object> values() {
156: return ctxt.values();
157: }
158:
159: }
|