KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > servicemix > soap > marshalers > SoapMessage


1 /*
2  * Licensed to the Apache Software Foundation (ASF) under one or more
3  * contributor license agreements. See the NOTICE file distributed with
4  * this work for additional information regarding copyright ownership.
5  * The ASF licenses this file to You under the Apache License, Version 2.0
6  * (the "License"); you may not use this file except in compliance with
7  * the License. You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */

17 package org.apache.servicemix.soap.marshalers;
18
19 import java.security.Principal JavaDoc;
20 import java.util.HashMap JavaDoc;
21 import java.util.Map JavaDoc;
22
23 import javax.activation.DataHandler JavaDoc;
24 import javax.security.auth.Subject JavaDoc;
25 import javax.xml.namespace.QName JavaDoc;
26 import javax.xml.transform.Source JavaDoc;
27
28 import org.apache.servicemix.soap.SoapFault;
29 import org.w3c.dom.Document JavaDoc;
30 import org.w3c.dom.DocumentFragment JavaDoc;
31
32 /**
33  * Simple DTO to hold attachments, soap headers and main xml source.
34  *
35  * @author Guillaume Nodet
36  * @version $Revision: 359186 $
37  * @since 3.0
38  */

39 public class SoapMessage {
40
41     private QName JavaDoc envelopeName;
42     private QName JavaDoc bodyName;
43     private Source JavaDoc source;
44     private Map JavaDoc attachments;
45     private Map JavaDoc headers;
46     private SoapFault fault;
47     private Subject JavaDoc subject;
48     private Document JavaDoc document;
49     
50     /**
51      * @return the document
52      */

53     public Document JavaDoc getDocument() {
54         return document;
55     }
56     /**
57      * @param document the document to set
58      */

59     public void setDocument(Document JavaDoc document) {
60         this.document = document;
61     }
62     /**
63      * @return the subject
64      */

65     public Subject JavaDoc getSubject() {
66         return subject;
67     }
68     /**
69      * @param subject the subject to set
70      */

71     public void setSubject(Subject JavaDoc subject) {
72         this.subject = subject;
73     }
74     public Map JavaDoc getAttachments() {
75         return attachments;
76     }
77     public void setAttachments(Map JavaDoc attachments) {
78         this.attachments = attachments;
79     }
80     public void addAttachment(String JavaDoc name, DataHandler JavaDoc handler) {
81         if (this.attachments == null) {
82             this.attachments = new HashMap JavaDoc();
83         }
84         this.attachments.put(name, handler);
85     }
86     public boolean hasAttachments() {
87         return attachments != null && attachments.size() > 0;
88     }
89     
90     public Map JavaDoc getHeaders() {
91         return headers;
92     }
93     public void setHeaders(Map JavaDoc headers) {
94         this.headers = headers;
95     }
96     public void addHeader(QName JavaDoc name, DocumentFragment JavaDoc header) {
97         if (this.headers == null) {
98             this.headers = new HashMap JavaDoc();
99         }
100         this.headers.put(name, header);
101     }
102     public boolean hasHeaders() {
103         return headers != null && headers.size() > 0;
104     }
105     
106     public Source JavaDoc getSource() {
107         return source;
108     }
109     public void setSource(Source JavaDoc source) {
110         this.source = source;
111     }
112     
113     public QName JavaDoc getEnvelopeName() {
114         return envelopeName;
115     }
116     public void setEnvelopeName(QName JavaDoc envelopeName) {
117         this.envelopeName = envelopeName;
118     }
119     public QName JavaDoc getBodyName() {
120         return bodyName;
121     }
122     public void setBodyName(QName JavaDoc bodyName) {
123         this.bodyName = bodyName;
124     }
125     
126     public SoapFault getFault() {
127         return fault;
128     }
129     public void setFault(SoapFault fault) {
130         this.fault = fault;
131     }
132     
133     public void addPrincipal(Principal JavaDoc principal) {
134         if (subject == null) {
135             subject = new Subject JavaDoc();
136         }
137         subject.getPrincipals().add(principal);
138     }
139     
140 }
141
Popular Tags