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

Thu, 31 Aug 2017 15:18:52 +0800

author
aoqi
date
Thu, 31 Aug 2017 15:18:52 +0800
changeset 637
9c07ef4934dd
parent 374
72e03566f0a6
parent 0
373ffda63c9a
permissions
-rw-r--r--

merge

     1 /*
     2  * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.  Oracle designates this
     8  * particular file as subject to the "Classpath" exception as provided
     9  * by Oracle in the LICENSE file that accompanied this code.
    10  *
    11  * This code is distributed in the hope that it will be useful, but WITHOUT
    12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    14  * version 2 for more details (a copy is included in the LICENSE file that
    15  * accompanied this code).
    16  *
    17  * You should have received a copy of the GNU General Public License version
    18  * 2 along with this work; if not, write to the Free Software Foundation,
    19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    20  *
    21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    22  * or visit www.oracle.com if you need additional information or have any
    23  * questions.
    24  */
    26 package com.oracle.webservices.internal.api.message;
    28 import java.io.IOException;
    29 import java.io.InputStream;
    31 import com.oracle.webservices.internal.api.EnvelopeStyle;
    32 import com.sun.xml.internal.ws.api.SOAPVersion; // TODO leaking RI APIs
    33 import com.sun.xml.internal.ws.util.ServiceFinder;
    35 import javax.xml.soap.MimeHeaders;
    36 import javax.xml.soap.SOAPMessage;
    37 import javax.xml.transform.Source;
    38 import javax.xml.ws.WebServiceFeature;
    40 public abstract class MessageContextFactory
    41 {
    42     private static final MessageContextFactory DEFAULT = new com.sun.xml.internal.ws.api.message.MessageContextFactory(new WebServiceFeature[0]);
    44     protected abstract MessageContextFactory newFactory(WebServiceFeature ... f);
    46     public abstract MessageContext createContext();
    48     public abstract MessageContext createContext(SOAPMessage m);
    50     public abstract MessageContext createContext(Source m);
    52     public abstract MessageContext createContext(Source m, EnvelopeStyle.Style envelopeStyle);
    54     public abstract MessageContext createContext(InputStream in, String contentType) throws IOException;
    56     /**
    57      * @deprecated http://java.net/jira/browse/JAX_WS-1077
    58      */
    59     @Deprecated
    60     public abstract MessageContext createContext(InputStream in, MimeHeaders headers) throws IOException;
    62     static public MessageContextFactory createFactory(WebServiceFeature ... f) {
    63         return createFactory(null, f);
    64     }
    66     static public MessageContextFactory createFactory(ClassLoader cl, WebServiceFeature ...f) {
    67         for (MessageContextFactory factory : ServiceFinder.find(MessageContextFactory.class, cl)) {
    68             MessageContextFactory newfac = factory.newFactory(f);
    69             if (newfac != null) return newfac;
    70         }
    71         return new com.sun.xml.internal.ws.api.message.MessageContextFactory(f);
    72     }
    74     @Deprecated
    75     public abstract MessageContext doCreate();
    77     @Deprecated
    78     public abstract MessageContext doCreate(SOAPMessage m);
    80     //public abstract MessageContext doCreate(InputStream x);
    82     @Deprecated
    83     public abstract MessageContext doCreate(Source x, SOAPVersion soapVersion);
    85     @Deprecated
    86     public static MessageContext create(final ClassLoader... classLoader) {
    87         return serviceFinder(classLoader,
    88                              new Creator() {
    89                                  public MessageContext create(final MessageContextFactory f) {
    90                                      return f.doCreate();
    91                                  }
    92                              });
    93     }
    95     @Deprecated
    96     public static MessageContext create(final SOAPMessage m, final ClassLoader... classLoader) {
    97         return serviceFinder(classLoader,
    98                              new Creator() {
    99                                  public MessageContext create(final MessageContextFactory f) {
   100                                      return f.doCreate(m);
   101                                  }
   102                              });
   103     }
   105     @Deprecated
   106     public static MessageContext create(final Source m, final SOAPVersion v, final ClassLoader... classLoader) {
   107         return serviceFinder(classLoader,
   108                              new Creator() {
   109                                  public MessageContext create(final MessageContextFactory f) {
   110                                      return f.doCreate(m, v);
   111                                  }
   112                              });
   113     }
   115     @Deprecated
   116     private static MessageContext serviceFinder(final ClassLoader[] classLoader, final Creator creator) {
   117         final ClassLoader cl = classLoader.length == 0 ? null : classLoader[0];
   118         for (MessageContextFactory factory : ServiceFinder.find(MessageContextFactory.class, cl)) {
   119             final MessageContext messageContext = creator.create(factory);
   120             if (messageContext != null)
   121                 return messageContext;
   122         }
   123         return creator.create(DEFAULT);
   124     }
   126     @Deprecated
   127     private static interface Creator {
   128         public MessageContext create(MessageContextFactory f);
   129     }
   130 }

mercurial