src/share/jaxws_classes/com/oracle/webservices/internal/api/message/MessageContextFactory.java

changeset 368
0989ad8c0860
child 374
72e03566f0a6
     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	Tue Apr 09 14:51:13 2013 +0100
     1.3 @@ -0,0 +1,145 @@
     1.4 +/*
     1.5 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
     1.6 + *
     1.7 + * Copyright (c) 1997-2013 Oracle and/or its affiliates. All rights reserved.
     1.8 + *
     1.9 + * The contents of this file are subject to the terms of either the GNU
    1.10 + * General Public License Version 2 only ("GPL") or the Common Development
    1.11 + * and Distribution License("CDDL") (collectively, the "License").  You
    1.12 + * may not use this file except in compliance with the License.  You can
    1.13 + * obtain a copy of the License at
    1.14 + * http://glassfish.java.net/public/CDDL+GPL_1_1.html
    1.15 + * or packager/legal/LICENSE.txt.  See the License for the specific
    1.16 + * language governing permissions and limitations under the License.
    1.17 + *
    1.18 + * When distributing the software, include this License Header Notice in each
    1.19 + * file and include the License file at packager/legal/LICENSE.txt.
    1.20 + *
    1.21 + * GPL Classpath Exception:
    1.22 + * Oracle designates this particular file as subject to the "Classpath"
    1.23 + * exception as provided by Oracle in the GPL Version 2 section of the License
    1.24 + * file that accompanied this code.
    1.25 + *
    1.26 + * Modifications:
    1.27 + * If applicable, add the following below the License Header, with the fields
    1.28 + * enclosed by brackets [] replaced by your own identifying information:
    1.29 + * "Portions Copyright [year] [name of copyright owner]"
    1.30 + *
    1.31 + * Contributor(s):
    1.32 + * If you wish your version of this file to be governed by only the CDDL or
    1.33 + * only the GPL Version 2, indicate your decision by adding "[Contributor]
    1.34 + * elects to include this software in this distribution under the [CDDL or GPL
    1.35 + * Version 2] license."  If you don't indicate a single choice of license, a
    1.36 + * recipient has the option to distribute your version of this file under
    1.37 + * either the CDDL, the GPL Version 2 or to extend the choice of license to
    1.38 + * its licensees as provided above.  However, if you add GPL Version 2 code
    1.39 + * and therefore, elected the GPL Version 2 license, then the option applies
    1.40 + * only if the new code is made subject to such option by the copyright
    1.41 + * holder.
    1.42 + */
    1.43 +
    1.44 +package com.oracle.webservices.internal.api.message;
    1.45 +
    1.46 +import java.io.IOException;
    1.47 +import java.io.InputStream;
    1.48 +
    1.49 +import com.oracle.webservices.internal.api.EnvelopeStyle;
    1.50 +import com.sun.xml.internal.ws.api.SOAPVersion; // TODO leaking RI APIs
    1.51 +import com.sun.xml.internal.ws.util.ServiceFinder;
    1.52 +
    1.53 +import javax.xml.soap.MimeHeaders;
    1.54 +import javax.xml.soap.SOAPMessage;
    1.55 +import javax.xml.transform.Source;
    1.56 +import javax.xml.ws.WebServiceFeature;
    1.57 +
    1.58 +public abstract class MessageContextFactory
    1.59 +{
    1.60 +    private static final MessageContextFactory DEFAULT = new com.sun.xml.internal.ws.api.message.MessageContextFactory(new WebServiceFeature[0]);
    1.61 +
    1.62 +    protected abstract MessageContextFactory newFactory(WebServiceFeature ... f);
    1.63 +
    1.64 +    public abstract MessageContext createContext();
    1.65 +
    1.66 +    public abstract MessageContext createContext(SOAPMessage m);
    1.67 +
    1.68 +    public abstract MessageContext createContext(Source m);
    1.69 +
    1.70 +    public abstract MessageContext createContext(Source m, EnvelopeStyle.Style envelopeStyle);
    1.71 +
    1.72 +    public abstract MessageContext createContext(InputStream in, String contentType) throws IOException;
    1.73 +
    1.74 +    /**
    1.75 +     * @deprecated http://java.net/jira/browse/JAX_WS-1077
    1.76 +     */
    1.77 +    @Deprecated
    1.78 +    public abstract MessageContext createContext(InputStream in, MimeHeaders headers) throws IOException;
    1.79 +
    1.80 +    static public MessageContextFactory createFactory(WebServiceFeature ... f) {
    1.81 +        return createFactory(null, f);
    1.82 +    }
    1.83 +
    1.84 +    static public MessageContextFactory createFactory(ClassLoader cl, WebServiceFeature ...f) {
    1.85 +        for (MessageContextFactory factory : ServiceFinder.find(MessageContextFactory.class, cl)) {
    1.86 +            MessageContextFactory newfac = factory.newFactory(f);
    1.87 +            if (newfac != null) return newfac;
    1.88 +        }
    1.89 +        return new com.sun.xml.internal.ws.api.message.MessageContextFactory(f);
    1.90 +    }
    1.91 +
    1.92 +    @Deprecated
    1.93 +    public abstract MessageContext doCreate();
    1.94 +
    1.95 +    @Deprecated
    1.96 +    public abstract MessageContext doCreate(SOAPMessage m);
    1.97 +
    1.98 +    //public abstract MessageContext doCreate(InputStream x);
    1.99 +
   1.100 +    @Deprecated
   1.101 +    public abstract MessageContext doCreate(Source x, SOAPVersion soapVersion);
   1.102 +
   1.103 +    @Deprecated
   1.104 +    public static MessageContext create(final ClassLoader... classLoader) {
   1.105 +        return serviceFinder(classLoader,
   1.106 +                             new Creator() {
   1.107 +                                 public MessageContext create(final MessageContextFactory f) {
   1.108 +                                     return f.doCreate();
   1.109 +                                 }
   1.110 +                             });
   1.111 +    }
   1.112 +
   1.113 +    @Deprecated
   1.114 +    public static MessageContext create(final SOAPMessage m, final ClassLoader... classLoader) {
   1.115 +        return serviceFinder(classLoader,
   1.116 +                             new Creator() {
   1.117 +                                 public MessageContext create(final MessageContextFactory f) {
   1.118 +                                     return f.doCreate(m);
   1.119 +                                 }
   1.120 +                             });
   1.121 +    }
   1.122 +
   1.123 +    @Deprecated
   1.124 +    public static MessageContext create(final Source m, final SOAPVersion v, final ClassLoader... classLoader) {
   1.125 +        return serviceFinder(classLoader,
   1.126 +                             new Creator() {
   1.127 +                                 public MessageContext create(final MessageContextFactory f) {
   1.128 +                                     return f.doCreate(m, v);
   1.129 +                                 }
   1.130 +                             });
   1.131 +    }
   1.132 +
   1.133 +    @Deprecated
   1.134 +    private static MessageContext serviceFinder(final ClassLoader[] classLoader, final Creator creator) {
   1.135 +        final ClassLoader cl = classLoader.length == 0 ? null : classLoader[0];
   1.136 +        for (MessageContextFactory factory : ServiceFinder.find(MessageContextFactory.class, cl)) {
   1.137 +            final MessageContext messageContext = creator.create(factory);
   1.138 +            if (messageContext != null)
   1.139 +                return messageContext;
   1.140 +        }
   1.141 +        return creator.create(DEFAULT);
   1.142 +    }
   1.143 +
   1.144 +    @Deprecated
   1.145 +    private static interface Creator {
   1.146 +        public MessageContext create(MessageContextFactory f);
   1.147 +    }
   1.148 +}

mercurial