001    /*
002     * Licensed to the Apache Software Foundation (ASF) under one or more
003     * contributor license agreements.  See the NOTICE file distributed with
004     * this work for additional information regarding copyright ownership.
005     * The ASF licenses this file to You under the Apache License, Version 2.0
006     * (the "License"); you may not use this file except in compliance with
007     * the License.  You may obtain a copy of the License at
008     *
009     *      http://www.apache.org/licenses/LICENSE-2.0
010     *
011     * Unless required by applicable law or agreed to in writing, software
012     * distributed under the License is distributed on an "AS IS" BASIS,
013     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014     * See the License for the specific language governing permissions and
015     * limitations under the License.
016     */
017    package org.apache.servicemix.soap.api;
018    
019    import java.util.Map;
020    
021    import javax.activation.DataHandler;
022    import javax.xml.namespace.QName;
023    
024    import org.w3c.dom.DocumentFragment;
025    
026    
027    public interface Message extends Map<String, Object> {
028    
029        public static final String CONTENT_TYPE = "Content-Type";
030        
031        /**
032         * Acces to attachments
033         * @return
034         */
035        Map<String, DataHandler> getAttachments();
036    
037        /**
038         * Retreive the encapsulated content as a particular type (a result type
039         * if message is outbound, a source type if message is inbound)
040         * 
041         * @param format the expected content format 
042         * @return the encapsulated content
043         */    
044        <T> T getContent(Class<T> format);
045    
046        /**
047         * Provide the encapsulated content as a particular type (a result type
048         * if message is outbound, a source type if message is inbound)
049         * 
050         * @param format the provided content format 
051         * @param content the content to be encapsulated
052         */    
053        <T> void setContent(Class<T> format, Object content);
054        
055        /**
056         * Convenience method for storing/retrieving typed objects from the map.
057         * equivilent to:  (T)get(key.getName());
058         * @param <T> key
059         * @return
060         */
061        <T> T get(Class<T> key);
062        
063        /**
064         * Convenience method for storing/retrieving typed objects from the map.
065         * equivilent to:  put(key.getName(), value);
066         * @param <T> key
067         * @return
068         */
069        <T> void put(Class<T> key, T value);
070        
071        /**
072         * Access to the transport level headers
073         * @return
074         */
075        Map<String, String> getTransportHeaders();
076        
077        /**
078         * Access to soap headers
079         * @return
080         */
081        Map<QName, DocumentFragment> getSoapHeaders();
082    
083    }