src/share/jaxws_classes/com/sun/xml/internal/ws/message/XMLReaderImpl.java

Fri, 14 Feb 2014 11:13:45 +0100

author
mkos
date
Fri, 14 Feb 2014 11:13:45 +0100
changeset 515
6cd506508147
parent 368
0989ad8c0860
child 637
9c07ef4934dd
permissions
-rw-r--r--

8026188: Enhance envelope factory
Summary: Avoiding caching data initialized via TCCL in static context; fix also reviewed by Alexander Fomin
Reviewed-by: ahgross, mgrebac, skoivu

     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.ws.message;
    28 import com.sun.xml.internal.ws.api.message.Message;
    29 import org.xml.sax.ContentHandler;
    30 import org.xml.sax.InputSource;
    31 import org.xml.sax.SAXException;
    32 import org.xml.sax.helpers.DefaultHandler;
    33 import org.xml.sax.helpers.XMLFilterImpl;
    35 import javax.xml.transform.sax.SAXSource;
    37 /**
    38  * @author Kohsuke Kawaguchi
    39  */
    40 final class XMLReaderImpl extends XMLFilterImpl {
    42     private final Message msg;
    44     XMLReaderImpl(Message msg) {
    45         this.msg = msg;
    46     }
    48     public void parse(String systemId) {
    49         reportError();
    50     }
    52     private void reportError() {
    53         // TODO: i18n
    54         throw new IllegalStateException(
    55             "This is a special XMLReader implementation that only works with the InputSource given in SAXSource.");
    56     }
    58     public void parse(InputSource input) throws SAXException {
    59         if(input!=THE_SOURCE)
    60             reportError();
    61         msg.writeTo(this,this);
    62     }
    64     @Override
    65     public ContentHandler getContentHandler() {
    66         if(super.getContentHandler()==DUMMY)   return null;
    67         return super.getContentHandler();
    68     }
    70     @Override
    71     public void setContentHandler(ContentHandler contentHandler) {
    72         if(contentHandler==null)    contentHandler = DUMMY;
    73         super.setContentHandler(contentHandler);
    74     }
    76     private static final ContentHandler DUMMY = new DefaultHandler();
    78     /**
    79      * Special {@link InputSource} instance that we use to pass to {@link SAXSource}.
    80      */
    81     protected static final InputSource THE_SOURCE = new InputSource();
    82 }

mercurial