< prev index next >

src/java.xml.ws/share/classes/com/sun/xml/internal/messaging/saaj/soap/MessageFactoryImpl.java

Print this page


   1 /*
   2  * Copyright (c) 1997, 2014, 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


  46  * implementations.
  47  *
  48  * @author Phil Goodwin (phil.goodwin@sun.com)
  49  */
  50 public class MessageFactoryImpl extends MessageFactory {
  51 
  52     protected static final Logger log =
  53         Logger.getLogger(LogDomainConstants.SOAP_DOMAIN,
  54                          "com.sun.xml.internal.messaging.saaj.soap.LocalStrings");
  55 
  56     protected  OutputStream listener;
  57 
  58     protected boolean lazyAttachments = false;
  59 
  60     public  OutputStream listen(OutputStream newListener) {
  61         OutputStream oldListener = listener;
  62         listener = newListener;
  63         return oldListener;
  64     }
  65 

  66     public SOAPMessage createMessage() throws SOAPException {
  67         throw new UnsupportedOperationException();
  68     }
  69 
  70     public SOAPMessage createMessage(String protocol) throws SOAPException {
  71         if (SOAPConstants.SOAP_1_1_PROTOCOL.equals(protocol))
  72                 return new com.sun.xml.internal.messaging.saaj.soap.ver1_1.Message1_1Impl();
  73         else
  74                 return new com.sun.xml.internal.messaging.saaj.soap.ver1_2.Message1_2Impl();
  75     }
  76 
  77     public SOAPMessage createMessage(boolean isFastInfoset,
  78         boolean acceptFastInfoset) throws SOAPException
  79     {
  80         throw new UnsupportedOperationException();
  81     }
  82 
  83     public SOAPMessage createMessage(MimeHeaders headers, XMLStreamReader reader) throws SOAPException, IOException {
  84         String contentTypeString = MessageImpl.getContentType(headers);
  85 


  88         }
  89 
  90         try {
  91             ContentType contentType = new ContentType(contentTypeString);
  92             int stat = MessageImpl.identifyContentType(contentType);
  93 
  94             if (MessageImpl.isSoap1_1Content(stat)) {
  95                 return new Message1_1Impl(headers,contentType,stat,reader);
  96             } else if (MessageImpl.isSoap1_2Content(stat)) {
  97                 return new Message1_2Impl(headers,contentType,stat,reader);
  98             } else {
  99                 log.severe("SAAJ0530.soap.unknown.Content-Type");
 100                 throw new SOAPExceptionImpl("Unrecognized Content-Type");
 101             }
 102         } catch (ParseException e) {
 103             log.severe("SAAJ0531.soap.cannot.parse.Content-Type");
 104             throw new SOAPExceptionImpl(
 105                 "Unable to parse content type: " + e.getMessage());
 106         }
 107     }

 108     public SOAPMessage createMessage(MimeHeaders headers, InputStream in)
 109         throws SOAPException, IOException {
 110         String contentTypeString = MessageImpl.getContentType(headers);
 111 
 112         if (listener != null) {
 113             in = new TeeInputStream(in, listener);
 114         }
 115 
 116         try {
 117             ContentType contentType = new ContentType(contentTypeString);
 118             int stat = MessageImpl.identifyContentType(contentType);
 119 
 120             if (MessageImpl.isSoap1_1Content(stat)) {
 121                 return new Message1_1Impl(headers,contentType,stat,in);
 122             } else if (MessageImpl.isSoap1_2Content(stat)) {
 123                 return new Message1_2Impl(headers,contentType,stat,in);
 124             } else {
 125                 log.severe("SAAJ0530.soap.unknown.Content-Type");
 126                 throw new SOAPExceptionImpl("Unrecognized Content-Type");
 127             }
   1 /*
   2  * Copyright (c) 1997, 2017, 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


  46  * implementations.
  47  *
  48  * @author Phil Goodwin (phil.goodwin@sun.com)
  49  */
  50 public class MessageFactoryImpl extends MessageFactory {
  51 
  52     protected static final Logger log =
  53         Logger.getLogger(LogDomainConstants.SOAP_DOMAIN,
  54                          "com.sun.xml.internal.messaging.saaj.soap.LocalStrings");
  55 
  56     protected  OutputStream listener;
  57 
  58     protected boolean lazyAttachments = false;
  59 
  60     public  OutputStream listen(OutputStream newListener) {
  61         OutputStream oldListener = listener;
  62         listener = newListener;
  63         return oldListener;
  64     }
  65 
  66     @Override
  67     public SOAPMessage createMessage() throws SOAPException {
  68         throw new UnsupportedOperationException();
  69     }
  70 
  71     public SOAPMessage createMessage(String protocol) throws SOAPException {
  72         if (SOAPConstants.SOAP_1_1_PROTOCOL.equals(protocol))
  73                 return new com.sun.xml.internal.messaging.saaj.soap.ver1_1.Message1_1Impl();
  74         else
  75                 return new com.sun.xml.internal.messaging.saaj.soap.ver1_2.Message1_2Impl();
  76     }
  77 
  78     public SOAPMessage createMessage(boolean isFastInfoset,
  79         boolean acceptFastInfoset) throws SOAPException
  80     {
  81         throw new UnsupportedOperationException();
  82     }
  83 
  84     public SOAPMessage createMessage(MimeHeaders headers, XMLStreamReader reader) throws SOAPException, IOException {
  85         String contentTypeString = MessageImpl.getContentType(headers);
  86 


  89         }
  90 
  91         try {
  92             ContentType contentType = new ContentType(contentTypeString);
  93             int stat = MessageImpl.identifyContentType(contentType);
  94 
  95             if (MessageImpl.isSoap1_1Content(stat)) {
  96                 return new Message1_1Impl(headers,contentType,stat,reader);
  97             } else if (MessageImpl.isSoap1_2Content(stat)) {
  98                 return new Message1_2Impl(headers,contentType,stat,reader);
  99             } else {
 100                 log.severe("SAAJ0530.soap.unknown.Content-Type");
 101                 throw new SOAPExceptionImpl("Unrecognized Content-Type");
 102             }
 103         } catch (ParseException e) {
 104             log.severe("SAAJ0531.soap.cannot.parse.Content-Type");
 105             throw new SOAPExceptionImpl(
 106                 "Unable to parse content type: " + e.getMessage());
 107         }
 108     }
 109     @Override
 110     public SOAPMessage createMessage(MimeHeaders headers, InputStream in)
 111         throws SOAPException, IOException {
 112         String contentTypeString = MessageImpl.getContentType(headers);
 113 
 114         if (listener != null) {
 115             in = new TeeInputStream(in, listener);
 116         }
 117 
 118         try {
 119             ContentType contentType = new ContentType(contentTypeString);
 120             int stat = MessageImpl.identifyContentType(contentType);
 121 
 122             if (MessageImpl.isSoap1_1Content(stat)) {
 123                 return new Message1_1Impl(headers,contentType,stat,in);
 124             } else if (MessageImpl.isSoap1_2Content(stat)) {
 125                 return new Message1_2Impl(headers,contentType,stat,in);
 126             } else {
 127                 log.severe("SAAJ0530.soap.unknown.Content-Type");
 128                 throw new SOAPExceptionImpl("Unrecognized Content-Type");
 129             }
< prev index next >