1 /* 2 * Copyright 2005 the original author or authors. 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package org.springframework.ws.context; 18 19 import java.io.IOException; 20 import java.io.InputStream; 21 22 import org.springframework.ws.WebServiceMessage; 23 24 /** 25 * Context holder for message requests. 26 * <p/> 27 * <p>Contains both the message request as well as the response. Response message are usually lazily created (but do not 28 * have to be). 29 * 30 * @author Arjen Poutsma 31 * @since 1.0.0 32 */ 33 public interface MessageContext { 34 35 /** 36 * Returns the request message. 37 * 38 * @return the request message 39 */ 40 WebServiceMessage getRequest(); 41 42 /** 43 * Returns the response message. Creates a new response if no response is present. 44 * 45 * @return the response message 46 * @see #hasResponse() 47 */ 48 WebServiceMessage getResponse(); 49 50 /** 51 * Indicates whether this context has a response. 52 * 53 * @return <code>true</code> if this context has a response; <code>false</code> otherwise 54 */ 55 boolean hasResponse(); 56 57 /** 58 * Reads a response message from the given input stream. 59 * 60 * @param inputStream the stream to read the response from 61 * @throws IOException in case of I/O errors 62 * @throws IllegalStateException if a response has already been created 63 */ 64 void readResponse(InputStream inputStream) throws IOException; 65 66 /** 67 * Sets the name and value of a property associated with the <code>MessageContext</code>. If the 68 * <code>MessageContext</code> contains a value of the same property, the old value is replaced. 69 * 70 * @param name name of the property associated with the value 71 * @param value value of the property 72 */ 73 void setProperty(String name, Object value); 74 75 /** 76 * Gets the value of a specific property from the <code>MessageContext</code>. 77 * 78 * @param name name of the property whose value is to be retrieved 79 * @return value of the property 80 */ 81 Object getProperty(String name); 82 83 /** 84 * Removes a property from the <code>MessageContext</code>. 85 * 86 * @param name name of the property to be removed 87 */ 88 void removeProperty(String name); 89 90 /** 91 * Check if this message context contains a property with the given name. 92 * 93 * @param name the name of the property to look for 94 * @return <code>true</code> if the <code>MessageContext</code> contains the property; <code>false</code> otherwise 95 */ 96 boolean containsProperty(String name); 97 98 /** 99 * Return the names of all properties in this <code>MessageContext</code>. 100 * 101 * @return the names of all properties in this context, or an empty array if none defined 102 */ 103 String[] getPropertyNames(); 104 105 }