001: /*
002: * Copyright 2005 the original author or authors.
003: *
004: * Licensed under the Apache License, Version 2.0 (the "License");
005: * you may not use this file except in compliance with the License.
006: * You may obtain a copy of the License at
007: *
008: * http://www.apache.org/licenses/LICENSE-2.0
009: *
010: * Unless required by applicable law or agreed to in writing, software
011: * distributed under the License is distributed on an "AS IS" BASIS,
012: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013: * See the License for the specific language governing permissions and
014: * limitations under the License.
015: */
016:
017: package org.springframework.ws.context;
018:
019: import java.io.IOException;
020: import java.io.InputStream;
021:
022: import org.springframework.ws.WebServiceMessage;
023:
024: /**
025: * Context holder for message requests.
026: * <p/>
027: * <p>Contains both the message request as well as the response. Response message are usually lazily created (but do not
028: * have to be).
029: *
030: * @author Arjen Poutsma
031: * @since 1.0.0
032: */
033: public interface MessageContext {
034:
035: /**
036: * Returns the request message.
037: *
038: * @return the request message
039: */
040: WebServiceMessage getRequest();
041:
042: /**
043: * Returns the response message. Creates a new response if no response is present.
044: *
045: * @return the response message
046: * @see #hasResponse()
047: */
048: WebServiceMessage getResponse();
049:
050: /**
051: * Indicates whether this context has a response.
052: *
053: * @return <code>true</code> if this context has a response; <code>false</code> otherwise
054: */
055: boolean hasResponse();
056:
057: /**
058: * Reads a response message from the given input stream.
059: *
060: * @param inputStream the stream to read the response from
061: * @throws IOException in case of I/O errors
062: * @throws IllegalStateException if a response has already been created
063: */
064: void readResponse(InputStream inputStream) throws IOException;
065:
066: /**
067: * Sets the name and value of a property associated with the <code>MessageContext</code>. If the
068: * <code>MessageContext</code> contains a value of the same property, the old value is replaced.
069: *
070: * @param name name of the property associated with the value
071: * @param value value of the property
072: */
073: void setProperty(String name, Object value);
074:
075: /**
076: * Gets the value of a specific property from the <code>MessageContext</code>.
077: *
078: * @param name name of the property whose value is to be retrieved
079: * @return value of the property
080: */
081: Object getProperty(String name);
082:
083: /**
084: * Removes a property from the <code>MessageContext</code>.
085: *
086: * @param name name of the property to be removed
087: */
088: void removeProperty(String name);
089:
090: /**
091: * Check if this message context contains a property with the given name.
092: *
093: * @param name the name of the property to look for
094: * @return <code>true</code> if the <code>MessageContext</code> contains the property; <code>false</code> otherwise
095: */
096: boolean containsProperty(String name);
097:
098: /**
099: * 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: }
|