Wed, 27 Apr 2016 01:27:09 +0800
Initial load
http://hg.openjdk.java.net/jdk8u/jdk8u/jaxws/
changeset: 657:d47a47f961ee
tag: jdk8u25-b17
1 /*
2 * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
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. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
23 * questions.
24 */
26 package com.sun.xml.internal.messaging.saaj.soap;
28 import java.io.*;
29 import java.util.logging.Logger;
31 import javax.xml.soap.*;
33 import com.sun.xml.internal.messaging.saaj.packaging.mime.internet.ContentType;
34 import com.sun.xml.internal.messaging.saaj.packaging.mime.internet.ParseException;
35 import com.sun.xml.internal.messaging.saaj.SOAPExceptionImpl;
36 import com.sun.xml.internal.messaging.saaj.soap.ver1_1.Message1_1Impl;
37 import com.sun.xml.internal.messaging.saaj.soap.ver1_2.Message1_2Impl;
38 import com.sun.xml.internal.messaging.saaj.util.LogDomainConstants;
39 import com.sun.xml.internal.messaging.saaj.util.TeeInputStream;
41 /**
42 * A factory for creating SOAP messages.
43 *
44 * Converted to a placeholder for common functionality between SOAP
45 * implementations.
46 *
47 * @author Phil Goodwin (phil.goodwin@sun.com)
48 */
49 public class MessageFactoryImpl extends MessageFactory {
51 protected static final Logger log =
52 Logger.getLogger(LogDomainConstants.SOAP_DOMAIN,
53 "com.sun.xml.internal.messaging.saaj.soap.LocalStrings");
55 protected OutputStream listener;
57 protected boolean lazyAttachments = false;
59 public OutputStream listen(OutputStream newListener) {
60 OutputStream oldListener = listener;
61 listener = newListener;
62 return oldListener;
63 }
65 public SOAPMessage createMessage() throws SOAPException {
66 throw new UnsupportedOperationException();
67 }
69 public SOAPMessage createMessage(boolean isFastInfoset,
70 boolean acceptFastInfoset) throws SOAPException
71 {
72 throw new UnsupportedOperationException();
73 }
75 public SOAPMessage createMessage(MimeHeaders headers, InputStream in)
76 throws SOAPException, IOException {
77 String contentTypeString = MessageImpl.getContentType(headers);
79 if (listener != null) {
80 in = new TeeInputStream(in, listener);
81 }
83 try {
84 ContentType contentType = new ContentType(contentTypeString);
85 int stat = MessageImpl.identifyContentType(contentType);
87 if (MessageImpl.isSoap1_1Content(stat)) {
88 return new Message1_1Impl(headers,contentType,stat,in);
89 } else if (MessageImpl.isSoap1_2Content(stat)) {
90 return new Message1_2Impl(headers,contentType,stat,in);
91 } else {
92 log.severe("SAAJ0530.soap.unknown.Content-Type");
93 throw new SOAPExceptionImpl("Unrecognized Content-Type");
94 }
95 } catch (ParseException e) {
96 log.severe("SAAJ0531.soap.cannot.parse.Content-Type");
97 throw new SOAPExceptionImpl(
98 "Unable to parse content type: " + e.getMessage());
99 }
100 }
102 protected static final String getContentType(MimeHeaders headers) {
103 String[] values = headers.getHeader("Content-Type");
104 if (values == null)
105 return null;
106 else
107 return values[0];
108 }
110 public void setLazyAttachmentOptimization(boolean flag) {
111 lazyAttachments = flag;
112 }
114 }