jaxws/src/java.xml.ws/share/classes/com/sun/xml/internal/ws/api/streaming/XMLStreamReaderFactory.java
author mkos
Fri, 30 Oct 2015 10:34:46 +0100
changeset 33547 e4c76ac38b12
parent 27837 86d4f46e622a
child 45678 65fdff10664d
permissions -rw-r--r--
8139743: Update JAX-WS RI integration to latest version (2.3.0-SNAPSHOT) Reviewed-by: lancea
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
12009
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
     1
/*
33547
e4c76ac38b12 8139743: Update JAX-WS RI integration to latest version (2.3.0-SNAPSHOT)
mkos
parents: 27837
diff changeset
     2
 * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
12009
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
     4
 *
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    10
 *
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    15
 * accompanied this code).
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    16
 *
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    20
 *
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    23
 * questions.
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    24
 */
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    25
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    26
package com.sun.xml.internal.ws.api.streaming;
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    27
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    28
import com.sun.istack.internal.NotNull;
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    29
import com.sun.istack.internal.Nullable;
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    30
import com.sun.xml.internal.ws.streaming.XMLReaderException;
16791
fe5141eabb0e 8010393: Update JAX-WS RI to 2.2.9-b12941
alanb
parents: 12009
diff changeset
    31
import com.sun.xml.internal.ws.util.xml.XmlUtil;
12009
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    32
import org.xml.sax.InputSource;
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    33
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    34
import javax.xml.stream.XMLInputFactory;
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    35
import javax.xml.stream.XMLStreamException;
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    36
import javax.xml.stream.XMLStreamReader;
19645
36f707905f2b 8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents: 16791
diff changeset
    37
import java.io.IOException;
36f707905f2b 8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents: 16791
diff changeset
    38
import java.io.InputStream;
36f707905f2b 8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents: 16791
diff changeset
    39
import java.io.InputStreamReader;
36f707905f2b 8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents: 16791
diff changeset
    40
import java.io.Reader;
36f707905f2b 8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents: 16791
diff changeset
    41
import java.io.StringReader;
36f707905f2b 8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents: 16791
diff changeset
    42
import java.io.UnsupportedEncodingException;
12009
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    43
import java.lang.reflect.InvocationTargetException;
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    44
import java.lang.reflect.Method;
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    45
import java.net.URL;
16791
fe5141eabb0e 8010393: Update JAX-WS RI to 2.2.9-b12941
alanb
parents: 12009
diff changeset
    46
import java.security.AccessController;
fe5141eabb0e 8010393: Update JAX-WS RI to 2.2.9-b12941
alanb
parents: 12009
diff changeset
    47
import java.util.logging.Level;
12009
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    48
import java.util.logging.Logger;
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    49
19645
36f707905f2b 8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents: 16791
diff changeset
    50
import com.sun.xml.internal.ws.resources.StreamingMessages;
36f707905f2b 8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents: 16791
diff changeset
    51
12009
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    52
/**
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    53
 * Factory for {@link XMLStreamReader}.
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    54
 *
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    55
 * <p>
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    56
 * This wraps {@link XMLInputFactory} and allows us to reuse {@link XMLStreamReader} instances
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    57
 * when appropriate.
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    58
 *
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    59
 * @author Kohsuke Kawaguchi
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    60
 */
16791
fe5141eabb0e 8010393: Update JAX-WS RI to 2.2.9-b12941
alanb
parents: 12009
diff changeset
    61
@SuppressWarnings("StaticNonFinalUsedInInitialization")
12009
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    62
public abstract class XMLStreamReaderFactory {
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    63
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    64
    private static final Logger LOGGER = Logger.getLogger(XMLStreamReaderFactory.class.getName());
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    65
23961
439846965790 8026188: Enhance envelope factory
mkos
parents: 19645
diff changeset
    66
    private static final String CLASS_NAME_OF_WSTXINPUTFACTORY = "com.ctc.wstx.stax.WstxInputFactory";
439846965790 8026188: Enhance envelope factory
mkos
parents: 19645
diff changeset
    67
12009
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    68
    /**
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    69
     * Singleton instance.
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    70
     */
23961
439846965790 8026188: Enhance envelope factory
mkos
parents: 19645
diff changeset
    71
    private static volatile ContextClassloaderLocal<XMLStreamReaderFactory> streamReader =
439846965790 8026188: Enhance envelope factory
mkos
parents: 19645
diff changeset
    72
            new ContextClassloaderLocal<XMLStreamReaderFactory>() {
12009
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    73
23961
439846965790 8026188: Enhance envelope factory
mkos
parents: 19645
diff changeset
    74
                @Override
439846965790 8026188: Enhance envelope factory
mkos
parents: 19645
diff changeset
    75
                protected XMLStreamReaderFactory initialValue() {
19645
36f707905f2b 8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents: 16791
diff changeset
    76
23961
439846965790 8026188: Enhance envelope factory
mkos
parents: 19645
diff changeset
    77
                    XMLInputFactory xif = getXMLInputFactory();
439846965790 8026188: Enhance envelope factory
mkos
parents: 19645
diff changeset
    78
                    XMLStreamReaderFactory f=null;
12009
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    79
23961
439846965790 8026188: Enhance envelope factory
mkos
parents: 19645
diff changeset
    80
                    // this system property can be used to disable the pooling altogether,
439846965790 8026188: Enhance envelope factory
mkos
parents: 19645
diff changeset
    81
                    // in case someone hits an issue with pooling in the production system.
439846965790 8026188: Enhance envelope factory
mkos
parents: 19645
diff changeset
    82
                    if(!getProperty(XMLStreamReaderFactory.class.getName()+".noPool")) {
439846965790 8026188: Enhance envelope factory
mkos
parents: 19645
diff changeset
    83
                        f = Zephyr.newInstance(xif);
439846965790 8026188: Enhance envelope factory
mkos
parents: 19645
diff changeset
    84
                    }
12009
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    85
23961
439846965790 8026188: Enhance envelope factory
mkos
parents: 19645
diff changeset
    86
                    if(f==null) {
439846965790 8026188: Enhance envelope factory
mkos
parents: 19645
diff changeset
    87
                        // is this Woodstox?
439846965790 8026188: Enhance envelope factory
mkos
parents: 19645
diff changeset
    88
                        if (xif.getClass().getName().equals(CLASS_NAME_OF_WSTXINPUTFACTORY)) {
439846965790 8026188: Enhance envelope factory
mkos
parents: 19645
diff changeset
    89
                            f = new Woodstox(xif);
439846965790 8026188: Enhance envelope factory
mkos
parents: 19645
diff changeset
    90
                        }
439846965790 8026188: Enhance envelope factory
mkos
parents: 19645
diff changeset
    91
                    }
12009
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    92
23961
439846965790 8026188: Enhance envelope factory
mkos
parents: 19645
diff changeset
    93
                    if (f==null) {
439846965790 8026188: Enhance envelope factory
mkos
parents: 19645
diff changeset
    94
                        f = new Default();
439846965790 8026188: Enhance envelope factory
mkos
parents: 19645
diff changeset
    95
                    }
12009
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    96
23961
439846965790 8026188: Enhance envelope factory
mkos
parents: 19645
diff changeset
    97
                    if (LOGGER.isLoggable(Level.FINE)) {
439846965790 8026188: Enhance envelope factory
mkos
parents: 19645
diff changeset
    98
                        LOGGER.log(Level.FINE, "XMLStreamReaderFactory instance is = {0}", f);
439846965790 8026188: Enhance envelope factory
mkos
parents: 19645
diff changeset
    99
                    }
439846965790 8026188: Enhance envelope factory
mkos
parents: 19645
diff changeset
   100
                    return f;
439846965790 8026188: Enhance envelope factory
mkos
parents: 19645
diff changeset
   101
                }
439846965790 8026188: Enhance envelope factory
mkos
parents: 19645
diff changeset
   102
            };
12009
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   103
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   104
    private static XMLInputFactory getXMLInputFactory() {
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   105
        XMLInputFactory xif = null;
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   106
        if (getProperty(XMLStreamReaderFactory.class.getName()+".woodstox")) {
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   107
            try {
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   108
                xif = (XMLInputFactory)Class.forName("com.ctc.wstx.stax.WstxInputFactory").newInstance();
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   109
            } catch (Exception e) {
19645
36f707905f2b 8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents: 16791
diff changeset
   110
                if (LOGGER.isLoggable(Level.WARNING)) {
36f707905f2b 8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents: 16791
diff changeset
   111
                    LOGGER.log(Level.WARNING, StreamingMessages.WOODSTOX_CANT_LOAD(CLASS_NAME_OF_WSTXINPUTFACTORY), e);
36f707905f2b 8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents: 16791
diff changeset
   112
                }
12009
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   113
            }
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   114
        }
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   115
        if (xif == null) {
16791
fe5141eabb0e 8010393: Update JAX-WS RI to 2.2.9-b12941
alanb
parents: 12009
diff changeset
   116
             xif = XmlUtil.newXMLInputFactory(true);
12009
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   117
        }
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   118
        xif.setProperty(XMLInputFactory.IS_NAMESPACE_AWARE, true);
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   119
        xif.setProperty(XMLInputFactory.SUPPORT_DTD, false);
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   120
        xif.setProperty(XMLInputFactory.IS_COALESCING, true);
19645
36f707905f2b 8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents: 16791
diff changeset
   121
12009
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   122
        return xif;
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   123
    }
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   124
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   125
    /**
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   126
     * Overrides the singleton {@link XMLStreamReaderFactory} instance that
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   127
     * the JAX-WS RI uses.
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   128
     */
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   129
    public static void set(XMLStreamReaderFactory f) {
16791
fe5141eabb0e 8010393: Update JAX-WS RI to 2.2.9-b12941
alanb
parents: 12009
diff changeset
   130
        if(f==null) {
fe5141eabb0e 8010393: Update JAX-WS RI to 2.2.9-b12941
alanb
parents: 12009
diff changeset
   131
            throw new IllegalArgumentException();
fe5141eabb0e 8010393: Update JAX-WS RI to 2.2.9-b12941
alanb
parents: 12009
diff changeset
   132
        }
23961
439846965790 8026188: Enhance envelope factory
mkos
parents: 19645
diff changeset
   133
        streamReader.set(f);
12009
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   134
    }
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   135
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   136
    public static XMLStreamReaderFactory get() {
23961
439846965790 8026188: Enhance envelope factory
mkos
parents: 19645
diff changeset
   137
        return streamReader.get();
12009
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   138
    }
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   139
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   140
    public static XMLStreamReader create(InputSource source, boolean rejectDTDs) {
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   141
        try {
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   142
            // Char stream available?
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   143
            if (source.getCharacterStream() != null) {
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   144
                return get().doCreate(source.getSystemId(), source.getCharacterStream(), rejectDTDs);
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   145
            }
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   146
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   147
            // Byte stream available?
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   148
            if (source.getByteStream() != null) {
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   149
                return get().doCreate(source.getSystemId(), source.getByteStream(), rejectDTDs);
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   150
            }
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   151
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   152
            // Otherwise, open URI
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   153
            return get().doCreate(source.getSystemId(), new URL(source.getSystemId()).openStream(),rejectDTDs);
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   154
        } catch (IOException e) {
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   155
            throw new XMLReaderException("stax.cantCreate",e);
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   156
        }
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   157
    }
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   158
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   159
    public static XMLStreamReader create(@Nullable String systemId, InputStream in, boolean rejectDTDs) {
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   160
        return get().doCreate(systemId,in,rejectDTDs);
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   161
    }
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   162
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   163
    public static XMLStreamReader create(@Nullable String systemId, InputStream in, @Nullable String encoding, boolean rejectDTDs) {
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   164
        return (encoding == null)
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   165
                ? create(systemId, in, rejectDTDs)
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   166
                : get().doCreate(systemId,in,encoding,rejectDTDs);
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   167
    }
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   168
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   169
    public static XMLStreamReader create(@Nullable String systemId, Reader reader, boolean rejectDTDs) {
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   170
        return get().doCreate(systemId,reader,rejectDTDs);
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   171
    }
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   172
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   173
    /**
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   174
     * Should be invoked when the code finished using an {@link XMLStreamReader}.
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   175
     *
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   176
     * <p>
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   177
     * If the recycled instance implements {@link RecycleAware},
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   178
     * {@link RecycleAware#onRecycled()} will be invoked to let the instance
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   179
     * know that it's being recycled.
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   180
     *
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   181
     * <p>
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   182
     * It is not a hard requirement to call this method on every {@link XMLStreamReader}
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   183
     * instance. Not doing so just reduces the performance by throwing away
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   184
     * possibly reusable instances. So the caller should always consider the effort
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   185
     * it takes to recycle vs the possible performance gain by doing so.
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   186
     *
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   187
     * <p>
19645
36f707905f2b 8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents: 16791
diff changeset
   188
     * This method may be invoked by multiple threads concurrently.
12009
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   189
     *
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   190
     * @param r
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   191
     *      The {@link XMLStreamReader} instance that the caller finished using.
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   192
     *      This could be any {@link XMLStreamReader} implementation, not just
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   193
     *      the ones that were created from this factory. So the implementation
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   194
     *      of this class needs to be aware of that.
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   195
     */
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   196
    public static void recycle(XMLStreamReader r) {
33547
e4c76ac38b12 8139743: Update JAX-WS RI integration to latest version (2.3.0-SNAPSHOT)
mkos
parents: 27837
diff changeset
   197
     /* the XMLStreamReaderFactory recycle becomes expenisve in the threadLocal get operation.
12009
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   198
        get().doRecycle(r);
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   199
        if (r instanceof RecycleAware) {
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   200
            ((RecycleAware)r).onRecycled();
33547
e4c76ac38b12 8139743: Update JAX-WS RI integration to latest version (2.3.0-SNAPSHOT)
mkos
parents: 27837
diff changeset
   201
        }*/
12009
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   202
    }
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   203
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   204
    // implementations
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   205
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   206
    public abstract XMLStreamReader doCreate(String systemId, InputStream in, boolean rejectDTDs);
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   207
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   208
    private XMLStreamReader doCreate(String systemId, InputStream in, @NotNull String encoding, boolean rejectDTDs) {
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   209
        Reader reader;
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   210
        try {
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   211
            reader = new InputStreamReader(in, encoding);
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   212
        } catch(UnsupportedEncodingException ue) {
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   213
            throw new XMLReaderException("stax.cantCreate", ue);
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   214
        }
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   215
        return doCreate(systemId, reader, rejectDTDs);
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   216
    }
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   217
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   218
    public abstract XMLStreamReader doCreate(String systemId, Reader reader, boolean rejectDTDs);
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   219
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   220
    public abstract void doRecycle(XMLStreamReader r);
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   221
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   222
    /**
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   223
     * Interface that can be implemented by {@link XMLStreamReader} to
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   224
     * be notified when it's recycled.
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   225
     *
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   226
     * <p>
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   227
     * This provides a filtering {@link XMLStreamReader} an opportunity to
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   228
     * recycle its inner {@link XMLStreamReader}.
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   229
     */
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   230
    public interface RecycleAware {
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   231
        void onRecycled();
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   232
    }
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   233
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   234
    /**
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   235
     * {@link XMLStreamReaderFactory} implementation for SJSXP/JAXP RI.
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   236
     */
16791
fe5141eabb0e 8010393: Update JAX-WS RI to 2.2.9-b12941
alanb
parents: 12009
diff changeset
   237
    private static final class Zephyr extends XMLStreamReaderFactory {
12009
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   238
        private final XMLInputFactory xif;
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   239
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   240
        private final ThreadLocal<XMLStreamReader> pool = new ThreadLocal<XMLStreamReader>();
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   241
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   242
        /**
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   243
         * Sun StAX impl <code>XMLReaderImpl.setInputSource()</code> method via reflection.
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   244
         */
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   245
        private final Method setInputSourceMethod;
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   246
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   247
        /**
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   248
         * Sun StAX impl <code>XMLReaderImpl.reset()</code> method via reflection.
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   249
         */
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   250
        private final Method resetMethod;
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   251
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   252
        /**
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   253
         * The Sun StAX impl's {@link XMLStreamReader} implementation clas.
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   254
         */
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   255
        private final Class zephyrClass;
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   256
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   257
        /**
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   258
         * Creates {@link Zephyr} instance if the given {@link XMLInputFactory} is the one
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   259
         * from Zephyr.
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   260
         */
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   261
        public static @Nullable
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   262
        XMLStreamReaderFactory newInstance(XMLInputFactory xif) {
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   263
            // check if this is from Zephyr
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   264
            try {
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   265
                Class<?> clazz = xif.createXMLStreamReader(new StringReader("<foo/>")).getClass();
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   266
                // JDK has different XMLStreamReader impl class. Even if we check for that,
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   267
                // it doesn't have setInputSource(InputSource). Let it use Default
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   268
                if(!(clazz.getName().startsWith("com.sun.xml.internal.stream.")) )
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   269
                    return null;    // nope
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   270
                return new Zephyr(xif,clazz);
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   271
            } catch (NoSuchMethodException e) {
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   272
                return null;    // this factory is not for zephyr
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   273
            } catch (XMLStreamException e) {
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   274
                return null;    // impossible to fail to parse <foo/>, but anyway
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   275
            }
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   276
        }
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   277
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   278
        public Zephyr(XMLInputFactory xif, Class clazz) throws NoSuchMethodException {
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   279
            zephyrClass = clazz;
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   280
            setInputSourceMethod = clazz.getMethod("setInputSource", InputSource.class);
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   281
            resetMethod = clazz.getMethod("reset");
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   282
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   283
            try {
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   284
                // Turn OFF internal factory caching in Zephyr.
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   285
                // Santiago told me that this makes it thread-safe.
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   286
                xif.setProperty("reuse-instance", false);
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   287
            } catch (IllegalArgumentException e) {
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   288
                // falls through
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   289
            }
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   290
            this.xif = xif;
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   291
        }
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   292
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   293
        /**
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   294
         * Fetchs an instance from the pool if available, otherwise null.
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   295
         */
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   296
        private @Nullable XMLStreamReader fetch() {
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   297
            XMLStreamReader sr = pool.get();
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   298
            if(sr==null)    return null;
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   299
            pool.set(null);
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   300
            return sr;
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   301
        }
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   302
19645
36f707905f2b 8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents: 16791
diff changeset
   303
        @Override
12009
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   304
        public void doRecycle(XMLStreamReader r) {
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   305
            if(zephyrClass.isInstance(r))
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   306
                pool.set(r);
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   307
        }
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   308
19645
36f707905f2b 8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents: 16791
diff changeset
   309
        @Override
12009
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   310
        public XMLStreamReader doCreate(String systemId, InputStream in, boolean rejectDTDs) {
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   311
            try {
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   312
                XMLStreamReader xsr = fetch();
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   313
                if(xsr==null)
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   314
                    return xif.createXMLStreamReader(systemId,in);
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   315
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   316
                // try re-using this instance.
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   317
                InputSource is = new InputSource(systemId);
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   318
                is.setByteStream(in);
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   319
                reuse(xsr,is);
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   320
                return xsr;
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   321
            } catch (IllegalAccessException e) {
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   322
                throw new XMLReaderException("stax.cantCreate",e);
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   323
            } catch (InvocationTargetException e) {
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   324
                throw new XMLReaderException("stax.cantCreate",e);
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   325
            } catch (XMLStreamException e) {
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   326
                throw new XMLReaderException("stax.cantCreate",e);
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   327
            }
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   328
        }
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   329
19645
36f707905f2b 8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents: 16791
diff changeset
   330
        @Override
12009
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   331
        public XMLStreamReader doCreate(String systemId, Reader in, boolean rejectDTDs) {
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   332
            try {
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   333
                XMLStreamReader xsr = fetch();
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   334
                if(xsr==null)
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   335
                    return xif.createXMLStreamReader(systemId,in);
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   336
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   337
                // try re-using this instance.
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   338
                InputSource is = new InputSource(systemId);
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   339
                is.setCharacterStream(in);
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   340
                reuse(xsr,is);
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   341
                return xsr;
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   342
            } catch (IllegalAccessException e) {
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   343
                throw new XMLReaderException("stax.cantCreate",e);
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   344
            } catch (InvocationTargetException e) {
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   345
                Throwable cause = e.getCause();
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   346
                if (cause == null) {
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   347
                    cause = e;
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   348
                }
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   349
                throw new XMLReaderException("stax.cantCreate", cause);
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   350
            } catch (XMLStreamException e) {
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   351
                throw new XMLReaderException("stax.cantCreate",e);
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   352
            }
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   353
        }
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   354
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   355
        private void reuse(XMLStreamReader xsr, InputSource in) throws IllegalAccessException, InvocationTargetException {
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   356
            resetMethod.invoke(xsr);
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   357
            setInputSourceMethod.invoke(xsr,in);
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   358
        }
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   359
    }
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   360
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   361
    /**
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   362
     * Default {@link XMLStreamReaderFactory} implementation
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   363
     * that can work with any {@link XMLInputFactory}.
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   364
     *
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   365
     * <p>
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   366
     * {@link XMLInputFactory} is not required to be thread-safe, but
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   367
     * if the create method on this implementation is synchronized,
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   368
     * it may run into (see <a href="https://jax-ws.dev.java.net/issues/show_bug.cgi?id=555">
19645
36f707905f2b 8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents: 16791
diff changeset
   369
     * race condition</a>). Hence, using a XMLInputFactory per thread.
12009
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   370
     */
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   371
    public static final class Default extends XMLStreamReaderFactory {
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   372
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   373
        private final ThreadLocal<XMLInputFactory> xif = new ThreadLocal<XMLInputFactory>() {
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   374
            @Override
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   375
            public XMLInputFactory initialValue() {
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   376
                return getXMLInputFactory();
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   377
            }
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   378
        };
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   379
19645
36f707905f2b 8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents: 16791
diff changeset
   380
        @Override
12009
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   381
        public XMLStreamReader doCreate(String systemId, InputStream in, boolean rejectDTDs) {
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   382
            try {
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   383
                return xif.get().createXMLStreamReader(systemId,in);
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   384
            } catch (XMLStreamException e) {
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   385
                throw new XMLReaderException("stax.cantCreate",e);
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   386
            }
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   387
        }
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   388
19645
36f707905f2b 8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents: 16791
diff changeset
   389
        @Override
12009
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   390
        public XMLStreamReader doCreate(String systemId, Reader in, boolean rejectDTDs) {
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   391
            try {
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   392
                return xif.get().createXMLStreamReader(systemId,in);
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   393
            } catch (XMLStreamException e) {
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   394
                throw new XMLReaderException("stax.cantCreate",e);
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   395
            }
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   396
        }
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   397
19645
36f707905f2b 8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents: 16791
diff changeset
   398
        @Override
12009
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   399
        public void doRecycle(XMLStreamReader r) {
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   400
            // there's no way to recycle with the default StAX API.
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   401
        }
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   402
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   403
    }
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   404
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   405
    /**
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   406
     * Similar to {@link Default} but doesn't do any synchronization.
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   407
     *
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   408
     * <p>
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   409
     * This is useful when you know your {@link XMLInputFactory} is thread-safe by itself.
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   410
     */
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   411
    public static class NoLock extends XMLStreamReaderFactory {
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   412
        private final XMLInputFactory xif;
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   413
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   414
        public NoLock(XMLInputFactory xif) {
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   415
            this.xif = xif;
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   416
        }
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   417
19645
36f707905f2b 8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents: 16791
diff changeset
   418
        @Override
12009
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   419
        public XMLStreamReader doCreate(String systemId, InputStream in, boolean rejectDTDs) {
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   420
            try {
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   421
                return xif.createXMLStreamReader(systemId,in);
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   422
            } catch (XMLStreamException e) {
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   423
                throw new XMLReaderException("stax.cantCreate",e);
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   424
            }
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   425
        }
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   426
19645
36f707905f2b 8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents: 16791
diff changeset
   427
        @Override
12009
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   428
        public XMLStreamReader doCreate(String systemId, Reader in, boolean rejectDTDs) {
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   429
            try {
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   430
                return xif.createXMLStreamReader(systemId,in);
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   431
            } catch (XMLStreamException e) {
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   432
                throw new XMLReaderException("stax.cantCreate",e);
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   433
            }
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   434
        }
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   435
19645
36f707905f2b 8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents: 16791
diff changeset
   436
        @Override
12009
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   437
        public void doRecycle(XMLStreamReader r) {
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   438
            // there's no way to recycle with the default StAX API.
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   439
        }
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   440
    }
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   441
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   442
    /**
19645
36f707905f2b 8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents: 16791
diff changeset
   443
     * Handles Woodstox's XIF, but sets properties to do the string interning, sets various limits, ...
12009
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   444
     * Woodstox {@link XMLInputFactory} is thread safe.
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   445
     */
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   446
    public static final class Woodstox extends NoLock {
19645
36f707905f2b 8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents: 16791
diff changeset
   447
36f707905f2b 8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents: 16791
diff changeset
   448
        public final static String PROPERTY_MAX_ATTRIBUTES_PER_ELEMENT = "xml.ws.maximum.AttributesPerElement";
36f707905f2b 8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents: 16791
diff changeset
   449
        public final static String PROPERTY_MAX_ATTRIBUTE_SIZE = "xml.ws.maximum.AttributeSize";
36f707905f2b 8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents: 16791
diff changeset
   450
        public final static String PROPERTY_MAX_CHILDREN_PER_ELEMENT = "xml.ws.maximum.ChildrenPerElement";
36f707905f2b 8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents: 16791
diff changeset
   451
        public final static String PROPERTY_MAX_ELEMENT_COUNT = "xml.ws.maximum.ElementCount";
36f707905f2b 8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents: 16791
diff changeset
   452
        public final static String PROPERTY_MAX_ELEMENT_DEPTH = "xml.ws.maximum.ElementDepth";
36f707905f2b 8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents: 16791
diff changeset
   453
        public final static String PROPERTY_MAX_CHARACTERS = "xml.ws.maximum.Characters";
36f707905f2b 8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents: 16791
diff changeset
   454
36f707905f2b 8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents: 16791
diff changeset
   455
        private static final int DEFAULT_MAX_ATTRIBUTES_PER_ELEMENT = 500;
36f707905f2b 8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents: 16791
diff changeset
   456
        private static final int DEFAULT_MAX_ATTRIBUTE_SIZE = 65536 * 8;
36f707905f2b 8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents: 16791
diff changeset
   457
        private static final int DEFAULT_MAX_CHILDREN_PER_ELEMENT = Integer.MAX_VALUE;
36f707905f2b 8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents: 16791
diff changeset
   458
        private static final int DEFAULT_MAX_ELEMENT_DEPTH = 500;
36f707905f2b 8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents: 16791
diff changeset
   459
        private static final long DEFAULT_MAX_ELEMENT_COUNT = Integer.MAX_VALUE;
36f707905f2b 8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents: 16791
diff changeset
   460
        private static final long DEFAULT_MAX_CHARACTERS = Long.MAX_VALUE;
36f707905f2b 8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents: 16791
diff changeset
   461
36f707905f2b 8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents: 16791
diff changeset
   462
        /* Woodstox default setting:
36f707905f2b 8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents: 16791
diff changeset
   463
         int mMaxAttributesPerElement = 1000;
36f707905f2b 8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents: 16791
diff changeset
   464
         int mMaxAttributeSize = 65536 * 8;
36f707905f2b 8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents: 16791
diff changeset
   465
         int mMaxChildrenPerElement = Integer.MAX_VALUE;
36f707905f2b 8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents: 16791
diff changeset
   466
         int mMaxElementDepth = 1000;
36f707905f2b 8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents: 16791
diff changeset
   467
         long mMaxElementCount = Long.MAX_VALUE;
36f707905f2b 8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents: 16791
diff changeset
   468
         long mMaxCharacters = Long.MAX_VALUE;
36f707905f2b 8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents: 16791
diff changeset
   469
         */
36f707905f2b 8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents: 16791
diff changeset
   470
36f707905f2b 8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents: 16791
diff changeset
   471
        private int maxAttributesPerElement = DEFAULT_MAX_ATTRIBUTES_PER_ELEMENT;
36f707905f2b 8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents: 16791
diff changeset
   472
        private int maxAttributeSize = DEFAULT_MAX_ATTRIBUTE_SIZE;
36f707905f2b 8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents: 16791
diff changeset
   473
        private int maxChildrenPerElement = DEFAULT_MAX_CHILDREN_PER_ELEMENT;
36f707905f2b 8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents: 16791
diff changeset
   474
        private int maxElementDepth = DEFAULT_MAX_ELEMENT_DEPTH;
36f707905f2b 8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents: 16791
diff changeset
   475
        private long maxElementCount = DEFAULT_MAX_ELEMENT_COUNT;
36f707905f2b 8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents: 16791
diff changeset
   476
        private long maxCharacters = DEFAULT_MAX_CHARACTERS;
36f707905f2b 8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents: 16791
diff changeset
   477
36f707905f2b 8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents: 16791
diff changeset
   478
        // Note: this is a copy from com.ctc.wstx.api.WstxInputProperties, to be removed in the future
36f707905f2b 8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents: 16791
diff changeset
   479
        private static final java.lang.String P_MAX_ATTRIBUTES_PER_ELEMENT = "com.ctc.wstx.maxAttributesPerElement";
36f707905f2b 8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents: 16791
diff changeset
   480
        private static final java.lang.String P_MAX_ATTRIBUTE_SIZE = "com.ctc.wstx.maxAttributeSize";
36f707905f2b 8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents: 16791
diff changeset
   481
        private static final java.lang.String P_MAX_CHILDREN_PER_ELEMENT = "com.ctc.wstx.maxChildrenPerElement";
36f707905f2b 8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents: 16791
diff changeset
   482
        private static final java.lang.String P_MAX_ELEMENT_COUNT = "com.ctc.wstx.maxElementCount";
36f707905f2b 8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents: 16791
diff changeset
   483
        private static final java.lang.String P_MAX_ELEMENT_DEPTH = "com.ctc.wstx.maxElementDepth";
36f707905f2b 8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents: 16791
diff changeset
   484
        private static final java.lang.String P_MAX_CHARACTERS = "com.ctc.wstx.maxCharacters";
36f707905f2b 8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents: 16791
diff changeset
   485
        private static final java.lang.String P_INTERN_NSURIS = "org.codehaus.stax2.internNsUris";
27837
86d4f46e622a 8065870: Update JAX-WS RI integration to latest version (2.2.11-b141124.1933)
mkos
parents: 25871
diff changeset
   486
        private static final java.lang.String P_RETURN_NULL_FOR_DEFAULT_NAMESPACE = "com.ctc.wstx.returnNullForDefaultNamespace";
19645
36f707905f2b 8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents: 16791
diff changeset
   487
12009
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   488
        public Woodstox(XMLInputFactory xif) {
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   489
            super(xif);
19645
36f707905f2b 8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents: 16791
diff changeset
   490
36f707905f2b 8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents: 16791
diff changeset
   491
            if (xif.isPropertySupported(P_INTERN_NSURIS)) {
36f707905f2b 8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents: 16791
diff changeset
   492
                xif.setProperty(P_INTERN_NSURIS, true);
36f707905f2b 8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents: 16791
diff changeset
   493
                if (LOGGER.isLoggable(Level.FINE)) {
36f707905f2b 8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents: 16791
diff changeset
   494
                    LOGGER.log(Level.FINE, P_INTERN_NSURIS + " is {0}", true);
36f707905f2b 8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents: 16791
diff changeset
   495
                }
36f707905f2b 8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents: 16791
diff changeset
   496
            }
36f707905f2b 8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents: 16791
diff changeset
   497
36f707905f2b 8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents: 16791
diff changeset
   498
            if (xif.isPropertySupported(P_MAX_ATTRIBUTES_PER_ELEMENT)) {
36f707905f2b 8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents: 16791
diff changeset
   499
                maxAttributesPerElement = Integer.valueOf(buildIntegerValue(
36f707905f2b 8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents: 16791
diff changeset
   500
                    PROPERTY_MAX_ATTRIBUTES_PER_ELEMENT, DEFAULT_MAX_ATTRIBUTES_PER_ELEMENT)
36f707905f2b 8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents: 16791
diff changeset
   501
                );
36f707905f2b 8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents: 16791
diff changeset
   502
                xif.setProperty(P_MAX_ATTRIBUTES_PER_ELEMENT, maxAttributesPerElement);
36f707905f2b 8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents: 16791
diff changeset
   503
                if (LOGGER.isLoggable(Level.FINE)) {
36f707905f2b 8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents: 16791
diff changeset
   504
                    LOGGER.log(Level.FINE, P_MAX_ATTRIBUTES_PER_ELEMENT + " is {0}", maxAttributesPerElement);
36f707905f2b 8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents: 16791
diff changeset
   505
                }
36f707905f2b 8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents: 16791
diff changeset
   506
            }
36f707905f2b 8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents: 16791
diff changeset
   507
36f707905f2b 8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents: 16791
diff changeset
   508
            if (xif.isPropertySupported(P_MAX_ATTRIBUTE_SIZE)) {
36f707905f2b 8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents: 16791
diff changeset
   509
                maxAttributeSize = Integer.valueOf(buildIntegerValue(
36f707905f2b 8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents: 16791
diff changeset
   510
                    PROPERTY_MAX_ATTRIBUTE_SIZE, DEFAULT_MAX_ATTRIBUTE_SIZE)
36f707905f2b 8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents: 16791
diff changeset
   511
                );
36f707905f2b 8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents: 16791
diff changeset
   512
                xif.setProperty(P_MAX_ATTRIBUTE_SIZE, maxAttributeSize);
36f707905f2b 8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents: 16791
diff changeset
   513
                if (LOGGER.isLoggable(Level.FINE)) {
36f707905f2b 8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents: 16791
diff changeset
   514
                    LOGGER.log(Level.FINE, P_MAX_ATTRIBUTE_SIZE + " is {0}", maxAttributeSize);
36f707905f2b 8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents: 16791
diff changeset
   515
                }
36f707905f2b 8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents: 16791
diff changeset
   516
            }
36f707905f2b 8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents: 16791
diff changeset
   517
36f707905f2b 8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents: 16791
diff changeset
   518
            if (xif.isPropertySupported(P_MAX_CHILDREN_PER_ELEMENT)) {
36f707905f2b 8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents: 16791
diff changeset
   519
                maxChildrenPerElement = Integer.valueOf(buildIntegerValue(
36f707905f2b 8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents: 16791
diff changeset
   520
                    PROPERTY_MAX_CHILDREN_PER_ELEMENT, DEFAULT_MAX_CHILDREN_PER_ELEMENT)
36f707905f2b 8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents: 16791
diff changeset
   521
                );
36f707905f2b 8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents: 16791
diff changeset
   522
                xif.setProperty(P_MAX_CHILDREN_PER_ELEMENT, maxChildrenPerElement);
36f707905f2b 8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents: 16791
diff changeset
   523
                if (LOGGER.isLoggable(Level.FINE)) {
36f707905f2b 8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents: 16791
diff changeset
   524
                    LOGGER.log(Level.FINE, P_MAX_CHILDREN_PER_ELEMENT + " is {0}", maxChildrenPerElement);
36f707905f2b 8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents: 16791
diff changeset
   525
                }
36f707905f2b 8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents: 16791
diff changeset
   526
            }
36f707905f2b 8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents: 16791
diff changeset
   527
36f707905f2b 8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents: 16791
diff changeset
   528
            if (xif.isPropertySupported(P_MAX_ELEMENT_DEPTH)) {
36f707905f2b 8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents: 16791
diff changeset
   529
                maxElementDepth = Integer.valueOf(buildIntegerValue(
36f707905f2b 8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents: 16791
diff changeset
   530
                    PROPERTY_MAX_ELEMENT_DEPTH, DEFAULT_MAX_ELEMENT_DEPTH)
36f707905f2b 8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents: 16791
diff changeset
   531
                );
36f707905f2b 8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents: 16791
diff changeset
   532
                xif.setProperty(P_MAX_ELEMENT_DEPTH, maxElementDepth);
36f707905f2b 8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents: 16791
diff changeset
   533
                if (LOGGER.isLoggable(Level.FINE)) {
36f707905f2b 8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents: 16791
diff changeset
   534
                    LOGGER.log(Level.FINE, P_MAX_ELEMENT_DEPTH + " is {0}", maxElementDepth);
36f707905f2b 8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents: 16791
diff changeset
   535
                }
36f707905f2b 8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents: 16791
diff changeset
   536
            }
36f707905f2b 8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents: 16791
diff changeset
   537
36f707905f2b 8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents: 16791
diff changeset
   538
            if (xif.isPropertySupported(P_MAX_ELEMENT_COUNT)) {
36f707905f2b 8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents: 16791
diff changeset
   539
                maxElementCount = Long.valueOf(buildLongValue(
36f707905f2b 8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents: 16791
diff changeset
   540
                    PROPERTY_MAX_ELEMENT_COUNT, DEFAULT_MAX_ELEMENT_COUNT)
36f707905f2b 8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents: 16791
diff changeset
   541
                );
36f707905f2b 8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents: 16791
diff changeset
   542
                xif.setProperty(P_MAX_ELEMENT_COUNT, maxElementCount);
36f707905f2b 8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents: 16791
diff changeset
   543
                if (LOGGER.isLoggable(Level.FINE)) {
36f707905f2b 8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents: 16791
diff changeset
   544
                    LOGGER.log(Level.FINE, P_MAX_ELEMENT_COUNT + " is {0}", maxElementCount);
36f707905f2b 8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents: 16791
diff changeset
   545
                }
36f707905f2b 8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents: 16791
diff changeset
   546
            }
36f707905f2b 8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents: 16791
diff changeset
   547
36f707905f2b 8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents: 16791
diff changeset
   548
            if (xif.isPropertySupported(P_MAX_CHARACTERS)) {
36f707905f2b 8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents: 16791
diff changeset
   549
                maxCharacters = Long.valueOf(buildLongValue(
36f707905f2b 8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents: 16791
diff changeset
   550
                    PROPERTY_MAX_CHARACTERS, DEFAULT_MAX_CHARACTERS)
36f707905f2b 8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents: 16791
diff changeset
   551
                );
36f707905f2b 8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents: 16791
diff changeset
   552
                xif.setProperty(P_MAX_CHARACTERS, maxCharacters);
36f707905f2b 8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents: 16791
diff changeset
   553
                if (LOGGER.isLoggable(Level.FINE)) {
36f707905f2b 8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents: 16791
diff changeset
   554
                    LOGGER.log(Level.FINE, P_MAX_CHARACTERS + " is {0}", maxCharacters);
36f707905f2b 8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents: 16791
diff changeset
   555
                }
36f707905f2b 8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents: 16791
diff changeset
   556
            }
27837
86d4f46e622a 8065870: Update JAX-WS RI integration to latest version (2.2.11-b141124.1933)
mkos
parents: 25871
diff changeset
   557
            //Using try/catch instead of isPropertySupported because Woodstox
86d4f46e622a 8065870: Update JAX-WS RI integration to latest version (2.2.11-b141124.1933)
mkos
parents: 25871
diff changeset
   558
            //isPropertySupported is not always reliable
86d4f46e622a 8065870: Update JAX-WS RI integration to latest version (2.2.11-b141124.1933)
mkos
parents: 25871
diff changeset
   559
            try {
86d4f46e622a 8065870: Update JAX-WS RI integration to latest version (2.2.11-b141124.1933)
mkos
parents: 25871
diff changeset
   560
                //this is needed to make sure Woodstox behavior is spec compliant for
86d4f46e622a 8065870: Update JAX-WS RI integration to latest version (2.2.11-b141124.1933)
mkos
parents: 25871
diff changeset
   561
                //calls to XMLStreamReader.getNamespacePrefix
86d4f46e622a 8065870: Update JAX-WS RI integration to latest version (2.2.11-b141124.1933)
mkos
parents: 25871
diff changeset
   562
                xif.setProperty(P_RETURN_NULL_FOR_DEFAULT_NAMESPACE, Boolean.TRUE);
86d4f46e622a 8065870: Update JAX-WS RI integration to latest version (2.2.11-b141124.1933)
mkos
parents: 25871
diff changeset
   563
                if (LOGGER.isLoggable(Level.FINE)) {
86d4f46e622a 8065870: Update JAX-WS RI integration to latest version (2.2.11-b141124.1933)
mkos
parents: 25871
diff changeset
   564
                    LOGGER.log(Level.FINE, P_RETURN_NULL_FOR_DEFAULT_NAMESPACE + " is {0}", xif.getProperty(P_RETURN_NULL_FOR_DEFAULT_NAMESPACE));
86d4f46e622a 8065870: Update JAX-WS RI integration to latest version (2.2.11-b141124.1933)
mkos
parents: 25871
diff changeset
   565
                }
86d4f46e622a 8065870: Update JAX-WS RI integration to latest version (2.2.11-b141124.1933)
mkos
parents: 25871
diff changeset
   566
            } catch (Throwable t) {
86d4f46e622a 8065870: Update JAX-WS RI integration to latest version (2.2.11-b141124.1933)
mkos
parents: 25871
diff changeset
   567
                //ignore - this should not happen Woodstox 4.1.2 or later (maybe older version of Woodstox).
86d4f46e622a 8065870: Update JAX-WS RI integration to latest version (2.2.11-b141124.1933)
mkos
parents: 25871
diff changeset
   568
                LOGGER.log(Level.WARNING, "Expected property not found in Woodstox input factory: '{0}'", P_RETURN_NULL_FOR_DEFAULT_NAMESPACE);
86d4f46e622a 8065870: Update JAX-WS RI integration to latest version (2.2.11-b141124.1933)
mkos
parents: 25871
diff changeset
   569
            }
12009
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   570
        }
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   571
19645
36f707905f2b 8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents: 16791
diff changeset
   572
        @Override
12009
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   573
        public XMLStreamReader doCreate(String systemId, InputStream in, boolean rejectDTDs) {
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   574
            return super.doCreate(systemId, in, rejectDTDs);
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   575
        }
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   576
19645
36f707905f2b 8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents: 16791
diff changeset
   577
        @Override
12009
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   578
        public XMLStreamReader doCreate(String systemId, Reader in, boolean rejectDTDs) {
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   579
            return super.doCreate(systemId, in, rejectDTDs);
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   580
        }
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   581
    }
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   582
19645
36f707905f2b 8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents: 16791
diff changeset
   583
    private static int buildIntegerValue(String propertyName, int defaultValue) {
36f707905f2b 8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents: 16791
diff changeset
   584
        String propVal = System.getProperty(propertyName);
36f707905f2b 8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents: 16791
diff changeset
   585
        if (propVal != null && propVal.length() > 0) {
36f707905f2b 8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents: 16791
diff changeset
   586
            try {
36f707905f2b 8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents: 16791
diff changeset
   587
                Integer value = Integer.parseInt(propVal);
36f707905f2b 8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents: 16791
diff changeset
   588
                if (value > 0) {
36f707905f2b 8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents: 16791
diff changeset
   589
                    // return with the value in System property
36f707905f2b 8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents: 16791
diff changeset
   590
                    return value;
36f707905f2b 8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents: 16791
diff changeset
   591
                }
36f707905f2b 8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents: 16791
diff changeset
   592
            } catch (NumberFormatException nfe) {
36f707905f2b 8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents: 16791
diff changeset
   593
                if (LOGGER.isLoggable(Level.WARNING)) {
36f707905f2b 8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents: 16791
diff changeset
   594
                    LOGGER.log(Level.WARNING, StreamingMessages.INVALID_PROPERTY_VALUE_INTEGER(propertyName, propVal, Integer.toString(defaultValue)), nfe);
36f707905f2b 8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents: 16791
diff changeset
   595
                }
36f707905f2b 8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents: 16791
diff changeset
   596
            }
36f707905f2b 8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents: 16791
diff changeset
   597
        }
36f707905f2b 8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents: 16791
diff changeset
   598
        // return with the default value
36f707905f2b 8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents: 16791
diff changeset
   599
        return defaultValue;
36f707905f2b 8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents: 16791
diff changeset
   600
    }
36f707905f2b 8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents: 16791
diff changeset
   601
36f707905f2b 8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents: 16791
diff changeset
   602
    private static long buildLongValue(String propertyName, long defaultValue) {
36f707905f2b 8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents: 16791
diff changeset
   603
        String propVal = System.getProperty(propertyName);
36f707905f2b 8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents: 16791
diff changeset
   604
        if (propVal != null && propVal.length() > 0) {
36f707905f2b 8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents: 16791
diff changeset
   605
            try {
36f707905f2b 8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents: 16791
diff changeset
   606
                long value = Long.parseLong(propVal);
36f707905f2b 8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents: 16791
diff changeset
   607
                if (value > 0L) {
36f707905f2b 8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents: 16791
diff changeset
   608
                    // return with the value in System property
36f707905f2b 8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents: 16791
diff changeset
   609
                    return value;
36f707905f2b 8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents: 16791
diff changeset
   610
                }
36f707905f2b 8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents: 16791
diff changeset
   611
            } catch (NumberFormatException nfe) {
36f707905f2b 8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents: 16791
diff changeset
   612
                // defult will be returned
36f707905f2b 8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents: 16791
diff changeset
   613
                if (LOGGER.isLoggable(Level.WARNING)) {
36f707905f2b 8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents: 16791
diff changeset
   614
                    LOGGER.log(Level.WARNING, StreamingMessages.INVALID_PROPERTY_VALUE_LONG(propertyName, propVal, Long.toString(defaultValue)), nfe);
36f707905f2b 8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents: 16791
diff changeset
   615
                }
36f707905f2b 8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents: 16791
diff changeset
   616
            }
36f707905f2b 8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents: 16791
diff changeset
   617
        }
36f707905f2b 8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents: 16791
diff changeset
   618
        // return with the default value
36f707905f2b 8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents: 16791
diff changeset
   619
        return defaultValue;
36f707905f2b 8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents: 16791
diff changeset
   620
    }
36f707905f2b 8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents: 16791
diff changeset
   621
12009
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   622
    private static Boolean getProperty(final String prop) {
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   623
        return AccessController.doPrivileged(
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   624
            new java.security.PrivilegedAction<Boolean>() {
19645
36f707905f2b 8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents: 16791
diff changeset
   625
                @Override
12009
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   626
                public Boolean run() {
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   627
                    String value = System.getProperty(prop);
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   628
                    return value != null ? Boolean.valueOf(value) : Boolean.FALSE;
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   629
                }
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   630
            }
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   631
        );
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   632
    }
19645
36f707905f2b 8022885: Update JAX-WS RI integration to 2.2.9-b14140
mkos
parents: 16791
diff changeset
   633
12009
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   634
}