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

Mon, 04 May 2009 21:10:41 -0700

author
tbell
date
Mon, 04 May 2009 21:10:41 -0700
changeset 50
42dfec6871f6
parent 45
31822b475baa
child 78
860b95cc8d1d
permissions
-rw-r--r--

6658158: Mutable statics in SAAJ (findbugs)
6658163: txw2.DatatypeWriter.BUILDIN is a mutable static (findbugs)
Reviewed-by: darcy

     1 /*
     2  * Copyright 2005-2006 Sun Microsystems, Inc.  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.  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  */
    25 /*
    26  *
    27  *
    28  *
    29  */
    32 package com.sun.xml.internal.messaging.saaj.soap;
    34 import java.io.*;
    35 import java.util.logging.Logger;
    37 import javax.xml.soap.*;
    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;
    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 {
    57     protected static final Logger log =
    58         Logger.getLogger(LogDomainConstants.SOAP_DOMAIN,
    59                          "com.sun.xml.internal.messaging.saaj.soap.LocalStrings");
    61     protected  OutputStream listener;
    63     protected boolean lazyAttachments = false;
    65     public  OutputStream listen(OutputStream newListener) {
    66         OutputStream oldListener = listener;
    67         listener = newListener;
    68         return oldListener;
    69     }
    71     public SOAPMessage createMessage() throws SOAPException {
    72         throw new UnsupportedOperationException();
    73     }
    75     public SOAPMessage createMessage(boolean isFastInfoset,
    76         boolean acceptFastInfoset) throws SOAPException
    77     {
    78         throw new UnsupportedOperationException();
    79     }
    81     public SOAPMessage createMessage(MimeHeaders headers, InputStream in)
    82         throws SOAPException, IOException {
    83         String contentTypeString = MessageImpl.getContentType(headers);
    85         if (listener != null) {
    86             in = new TeeInputStream(in, listener);
    87         }
    89         try {
    90             ContentType contentType = new ContentType(contentTypeString);
    91             int stat = MessageImpl.identifyContentType(contentType);
    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     }
   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     }
   116     public void setLazyAttachmentOptimization(boolean flag) {
   117         lazyAttachments = flag;
   118     }
   120 }

mercurial