1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/src/share/jaxws_classes/com/oracle/webservices/internal/api/message/MessageContextFactory.java Wed Apr 27 01:27:09 2016 +0800 1.3 @@ -0,0 +1,130 @@ 1.4 +/* 1.5 + * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. 1.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 1.7 + * 1.8 + * This code is free software; you can redistribute it and/or modify it 1.9 + * under the terms of the GNU General Public License version 2 only, as 1.10 + * published by the Free Software Foundation. Oracle designates this 1.11 + * particular file as subject to the "Classpath" exception as provided 1.12 + * by Oracle in the LICENSE file that accompanied this code. 1.13 + * 1.14 + * This code is distributed in the hope that it will be useful, but WITHOUT 1.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 1.16 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 1.17 + * version 2 for more details (a copy is included in the LICENSE file that 1.18 + * accompanied this code). 1.19 + * 1.20 + * You should have received a copy of the GNU General Public License version 1.21 + * 2 along with this work; if not, write to the Free Software Foundation, 1.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 1.23 + * 1.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 1.25 + * or visit www.oracle.com if you need additional information or have any 1.26 + * questions. 1.27 + */ 1.28 + 1.29 +package com.oracle.webservices.internal.api.message; 1.30 + 1.31 +import java.io.IOException; 1.32 +import java.io.InputStream; 1.33 + 1.34 +import com.oracle.webservices.internal.api.EnvelopeStyle; 1.35 +import com.sun.xml.internal.ws.api.SOAPVersion; // TODO leaking RI APIs 1.36 +import com.sun.xml.internal.ws.util.ServiceFinder; 1.37 + 1.38 +import javax.xml.soap.MimeHeaders; 1.39 +import javax.xml.soap.SOAPMessage; 1.40 +import javax.xml.transform.Source; 1.41 +import javax.xml.ws.WebServiceFeature; 1.42 + 1.43 +public abstract class MessageContextFactory 1.44 +{ 1.45 + private static final MessageContextFactory DEFAULT = new com.sun.xml.internal.ws.api.message.MessageContextFactory(new WebServiceFeature[0]); 1.46 + 1.47 + protected abstract MessageContextFactory newFactory(WebServiceFeature ... f); 1.48 + 1.49 + public abstract MessageContext createContext(); 1.50 + 1.51 + public abstract MessageContext createContext(SOAPMessage m); 1.52 + 1.53 + public abstract MessageContext createContext(Source m); 1.54 + 1.55 + public abstract MessageContext createContext(Source m, EnvelopeStyle.Style envelopeStyle); 1.56 + 1.57 + public abstract MessageContext createContext(InputStream in, String contentType) throws IOException; 1.58 + 1.59 + /** 1.60 + * @deprecated http://java.net/jira/browse/JAX_WS-1077 1.61 + */ 1.62 + @Deprecated 1.63 + public abstract MessageContext createContext(InputStream in, MimeHeaders headers) throws IOException; 1.64 + 1.65 + static public MessageContextFactory createFactory(WebServiceFeature ... f) { 1.66 + return createFactory(null, f); 1.67 + } 1.68 + 1.69 + static public MessageContextFactory createFactory(ClassLoader cl, WebServiceFeature ...f) { 1.70 + for (MessageContextFactory factory : ServiceFinder.find(MessageContextFactory.class, cl)) { 1.71 + MessageContextFactory newfac = factory.newFactory(f); 1.72 + if (newfac != null) return newfac; 1.73 + } 1.74 + return new com.sun.xml.internal.ws.api.message.MessageContextFactory(f); 1.75 + } 1.76 + 1.77 + @Deprecated 1.78 + public abstract MessageContext doCreate(); 1.79 + 1.80 + @Deprecated 1.81 + public abstract MessageContext doCreate(SOAPMessage m); 1.82 + 1.83 + //public abstract MessageContext doCreate(InputStream x); 1.84 + 1.85 + @Deprecated 1.86 + public abstract MessageContext doCreate(Source x, SOAPVersion soapVersion); 1.87 + 1.88 + @Deprecated 1.89 + public static MessageContext create(final ClassLoader... classLoader) { 1.90 + return serviceFinder(classLoader, 1.91 + new Creator() { 1.92 + public MessageContext create(final MessageContextFactory f) { 1.93 + return f.doCreate(); 1.94 + } 1.95 + }); 1.96 + } 1.97 + 1.98 + @Deprecated 1.99 + public static MessageContext create(final SOAPMessage m, final ClassLoader... classLoader) { 1.100 + return serviceFinder(classLoader, 1.101 + new Creator() { 1.102 + public MessageContext create(final MessageContextFactory f) { 1.103 + return f.doCreate(m); 1.104 + } 1.105 + }); 1.106 + } 1.107 + 1.108 + @Deprecated 1.109 + public static MessageContext create(final Source m, final SOAPVersion v, final ClassLoader... classLoader) { 1.110 + return serviceFinder(classLoader, 1.111 + new Creator() { 1.112 + public MessageContext create(final MessageContextFactory f) { 1.113 + return f.doCreate(m, v); 1.114 + } 1.115 + }); 1.116 + } 1.117 + 1.118 + @Deprecated 1.119 + private static MessageContext serviceFinder(final ClassLoader[] classLoader, final Creator creator) { 1.120 + final ClassLoader cl = classLoader.length == 0 ? null : classLoader[0]; 1.121 + for (MessageContextFactory factory : ServiceFinder.find(MessageContextFactory.class, cl)) { 1.122 + final MessageContext messageContext = creator.create(factory); 1.123 + if (messageContext != null) 1.124 + return messageContext; 1.125 + } 1.126 + return creator.create(DEFAULT); 1.127 + } 1.128 + 1.129 + @Deprecated 1.130 + private static interface Creator { 1.131 + public MessageContext create(MessageContextFactory f); 1.132 + } 1.133 +}