author | tbell |
Mon, 04 May 2009 21:10:41 -0700 | |
changeset 2719 | 99d59312294b |
parent 2678 | 57cf2a1c1a05 |
child 3530 | 18fb7507984b |
permissions | -rw-r--r-- |
8 | 1 |
/* |
2678
57cf2a1c1a05
6831313: update jaxws in OpenJDK7 to 2.1 plus bug fixes from OpenJDK 6
tbell
parents:
8
diff
changeset
|
2 |
* Copyright 2005-2006 Sun Microsystems, Inc. All Rights Reserved. |
8 | 3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 |
* |
|
5 |
* This code is free software; you can redistribute it and/or modify it |
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
|
7 |
* published by the Free Software Foundation. Sun designates this |
|
8 |
* particular file as subject to the "Classpath" exception as provided |
|
9 |
* by Sun in the LICENSE file that accompanied this code. |
|
10 |
* |
|
11 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
13 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
14 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
15 |
* accompanied this code). |
|
16 |
* |
|
17 |
* You should have received a copy of the GNU General Public License version |
|
18 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
19 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
20 |
* |
|
21 |
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, |
|
22 |
* CA 95054 USA or visit www.sun.com if you need additional information or |
|
23 |
* have any questions. |
|
24 |
*/ |
|
2678
57cf2a1c1a05
6831313: update jaxws in OpenJDK7 to 2.1 plus bug fixes from OpenJDK 6
tbell
parents:
8
diff
changeset
|
25 |
/* |
2719 | 26 |
* |
27 |
* |
|
28 |
* |
|
2678
57cf2a1c1a05
6831313: update jaxws in OpenJDK7 to 2.1 plus bug fixes from OpenJDK 6
tbell
parents:
8
diff
changeset
|
29 |
*/ |
57cf2a1c1a05
6831313: update jaxws in OpenJDK7 to 2.1 plus bug fixes from OpenJDK 6
tbell
parents:
8
diff
changeset
|
30 |
|
57cf2a1c1a05
6831313: update jaxws in OpenJDK7 to 2.1 plus bug fixes from OpenJDK 6
tbell
parents:
8
diff
changeset
|
31 |
|
8 | 32 |
package com.sun.xml.internal.messaging.saaj.soap; |
33 |
||
34 |
import java.io.*; |
|
35 |
import java.util.logging.Logger; |
|
36 |
||
37 |
import javax.xml.soap.*; |
|
38 |
||
39 |
import com.sun.xml.internal.messaging.saaj.packaging.mime.internet.ContentType; |
|
40 |
import com.sun.xml.internal.messaging.saaj.packaging.mime.internet.ParseException; |
|
41 |
import com.sun.xml.internal.messaging.saaj.SOAPExceptionImpl; |
|
42 |
import com.sun.xml.internal.messaging.saaj.soap.ver1_1.Message1_1Impl; |
|
43 |
import com.sun.xml.internal.messaging.saaj.soap.ver1_2.Message1_2Impl; |
|
44 |
import com.sun.xml.internal.messaging.saaj.util.LogDomainConstants; |
|
45 |
import com.sun.xml.internal.messaging.saaj.util.TeeInputStream; |
|
46 |
||
47 |
/** |
|
48 |
* A factory for creating SOAP messages. |
|
49 |
* |
|
50 |
* Converted to a placeholder for common functionality between SOAP |
|
51 |
* implementations. |
|
52 |
* |
|
53 |
* @author Phil Goodwin (phil.goodwin@sun.com) |
|
54 |
*/ |
|
55 |
public class MessageFactoryImpl extends MessageFactory { |
|
56 |
||
2719 | 57 |
protected static final Logger log = |
8 | 58 |
Logger.getLogger(LogDomainConstants.SOAP_DOMAIN, |
59 |
"com.sun.xml.internal.messaging.saaj.soap.LocalStrings"); |
|
60 |
||
2719 | 61 |
protected OutputStream listener; |
8 | 62 |
|
63 |
protected boolean lazyAttachments = false; |
|
64 |
||
2719 | 65 |
public OutputStream listen(OutputStream newListener) { |
8 | 66 |
OutputStream oldListener = listener; |
67 |
listener = newListener; |
|
68 |
return oldListener; |
|
69 |
} |
|
70 |
||
71 |
public SOAPMessage createMessage() throws SOAPException { |
|
72 |
throw new UnsupportedOperationException(); |
|
73 |
} |
|
74 |
||
75 |
public SOAPMessage createMessage(boolean isFastInfoset, |
|
76 |
boolean acceptFastInfoset) throws SOAPException |
|
77 |
{ |
|
78 |
throw new UnsupportedOperationException(); |
|
79 |
} |
|
80 |
||
81 |
public SOAPMessage createMessage(MimeHeaders headers, InputStream in) |
|
82 |
throws SOAPException, IOException { |
|
83 |
String contentTypeString = MessageImpl.getContentType(headers); |
|
84 |
||
85 |
if (listener != null) { |
|
86 |
in = new TeeInputStream(in, listener); |
|
87 |
} |
|
88 |
||
89 |
try { |
|
90 |
ContentType contentType = new ContentType(contentTypeString); |
|
91 |
int stat = MessageImpl.identifyContentType(contentType); |
|
92 |
||
93 |
if (MessageImpl.isSoap1_1Content(stat)) { |
|
94 |
return new Message1_1Impl(headers,contentType,stat,in); |
|
95 |
} else if (MessageImpl.isSoap1_2Content(stat)) { |
|
96 |
return new Message1_2Impl(headers,contentType,stat,in); |
|
97 |
} else { |
|
98 |
log.severe("SAAJ0530.soap.unknown.Content-Type"); |
|
99 |
throw new SOAPExceptionImpl("Unrecognized Content-Type"); |
|
100 |
} |
|
101 |
} catch (ParseException e) { |
|
102 |
log.severe("SAAJ0531.soap.cannot.parse.Content-Type"); |
|
103 |
throw new SOAPExceptionImpl( |
|
104 |
"Unable to parse content type: " + e.getMessage()); |
|
105 |
} |
|
106 |
} |
|
107 |
||
108 |
protected static final String getContentType(MimeHeaders headers) { |
|
109 |
String[] values = headers.getHeader("Content-Type"); |
|
110 |
if (values == null) |
|
111 |
return null; |
|
112 |
else |
|
113 |
return values[0]; |
|
114 |
} |
|
115 |
||
116 |
public void setLazyAttachmentOptimization(boolean flag) { |
|
117 |
lazyAttachments = flag; |
|
118 |
} |
|
119 |
||
120 |
} |