8025152: Enhance activation set up jdk8u5-b01

Sun, 15 Dec 2013 23:35:45 +0100

author
mkos
date
Sun, 15 Dec 2013 23:35:45 +0100
changeset 494
2fcd3ddb57a6
parent 493
b549c5ea34ab
child 495
634ea49f0422

8025152: Enhance activation set up
8028388: 9 jaxws tests failed in nightly build with java.lang.ClassCastException
Summary: fix also reviewed by Bill Shannon, Alexander Fomin
Reviewed-by: dfuchs, hawtin, mgrebac
Contributed-by: bill.shannon@oracle.com

src/share/jaf_classes/javax/activation/CommandMap.java file | annotate | diff | comparison | revisions
src/share/jaf_classes/javax/activation/DataHandler.java file | annotate | diff | comparison | revisions
src/share/jaf_classes/javax/activation/FileTypeMap.java file | annotate | diff | comparison | revisions
src/share/jaf_classes/javax/activation/MailcapCommandMap.java file | annotate | diff | comparison | revisions
src/share/jaf_classes/javax/activation/MimetypesFileTypeMap.java file | annotate | diff | comparison | revisions
src/share/jaxws_classes/com/sun/xml/internal/messaging/saaj/soap/AttachmentPartImpl.java file | annotate | diff | comparison | revisions
src/share/jaxws_classes/com/sun/xml/internal/ws/binding/BindingImpl.java file | annotate | diff | comparison | revisions
src/share/jaxws_classes/com/sun/xml/internal/ws/encoding/MimeCodec.java file | annotate | diff | comparison | revisions
src/share/jaxws_classes/com/sun/xml/internal/ws/util/version.properties file | annotate | diff | comparison | revisions
     1.1 --- a/src/share/jaf_classes/javax/activation/CommandMap.java	Fri Dec 13 17:20:01 2013 -0800
     1.2 +++ b/src/share/jaf_classes/javax/activation/CommandMap.java	Sun Dec 15 23:35:45 2013 +0100
     1.3 @@ -1,5 +1,5 @@
     1.4  /*
     1.5 - * Copyright (c) 1997, 2005, Oracle and/or its affiliates. All rights reserved.
     1.6 + * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
     1.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     1.8   *
     1.9   * This code is free software; you can redistribute it and/or modify it
    1.10 @@ -25,6 +25,9 @@
    1.11  
    1.12  package javax.activation;
    1.13  
    1.14 +import java.util.Map;
    1.15 +import java.util.WeakHashMap;
    1.16 +
    1.17  
    1.18  /**
    1.19   * The CommandMap class provides an interface to a registry of
    1.20 @@ -38,6 +41,8 @@
    1.21   */
    1.22  public abstract class CommandMap {
    1.23      private static CommandMap defaultCommandMap = null;
    1.24 +    private static Map<ClassLoader,CommandMap> map =
    1.25 +                                new WeakHashMap<ClassLoader,CommandMap>();
    1.26  
    1.27      /**
    1.28       * Get the default CommandMap.
    1.29 @@ -56,11 +61,18 @@
    1.30       *
    1.31       * @return the CommandMap
    1.32       */
    1.33 -    public static CommandMap getDefaultCommandMap() {
    1.34 -        if (defaultCommandMap == null)
    1.35 -            defaultCommandMap = new MailcapCommandMap();
    1.36 +    public static synchronized CommandMap getDefaultCommandMap() {
    1.37 +        if (defaultCommandMap != null)
    1.38 +            return defaultCommandMap;
    1.39  
    1.40 -        return defaultCommandMap;
    1.41 +        // fetch per-thread-context-class-loader default
    1.42 +        ClassLoader tccl = SecuritySupport.getContextClassLoader();
    1.43 +        CommandMap def = map.get(tccl);
    1.44 +        if (def == null) {
    1.45 +            def = new MailcapCommandMap();
    1.46 +            map.put(tccl, def);
    1.47 +        }
    1.48 +        return def;
    1.49      }
    1.50  
    1.51      /**
    1.52 @@ -71,7 +83,7 @@
    1.53       * @exception SecurityException if the caller doesn't have permission
    1.54       *                                  to change the default
    1.55       */
    1.56 -    public static void setDefaultCommandMap(CommandMap commandMap) {
    1.57 +    public static synchronized void setDefaultCommandMap(CommandMap commandMap) {
    1.58          SecurityManager security = System.getSecurityManager();
    1.59          if (security != null) {
    1.60              try {
    1.61 @@ -79,13 +91,16 @@
    1.62                  security.checkSetFactory();
    1.63              } catch (SecurityException ex) {
    1.64                  // otherwise, we also allow it if this code and the
    1.65 -                // factory come from the same class loader (e.g.,
    1.66 +                // factory come from the same (non-system) class loader (e.g.,
    1.67                  // the JAF classes were loaded with the applet classes).
    1.68 -                if (CommandMap.class.getClassLoader() !=
    1.69 +                if (CommandMap.class.getClassLoader() == null ||
    1.70 +                    CommandMap.class.getClassLoader() !=
    1.71                              commandMap.getClass().getClassLoader())
    1.72                      throw ex;
    1.73              }
    1.74          }
    1.75 +        // remove any per-thread-context-class-loader CommandMap
    1.76 +        map.remove(SecuritySupport.getContextClassLoader());
    1.77          defaultCommandMap = commandMap;
    1.78      }
    1.79  
     2.1 --- a/src/share/jaf_classes/javax/activation/DataHandler.java	Fri Dec 13 17:20:01 2013 -0800
     2.2 +++ b/src/share/jaf_classes/javax/activation/DataHandler.java	Sun Dec 15 23:35:45 2013 +0100
     2.3 @@ -1,5 +1,5 @@
     2.4  /*
     2.5 - * Copyright (c) 1997, 2006, Oracle and/or its affiliates. All rights reserved.
     2.6 + * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
     2.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     2.8   *
     2.9   * This code is free software; you can redistribute it and/or modify it
    2.10 @@ -368,7 +368,12 @@
    2.11          // if it's not set, set it...
    2.12          if (transferFlavors == emptyFlavors)
    2.13              transferFlavors = getDataContentHandler().getTransferDataFlavors();
    2.14 -        return transferFlavors;
    2.15 +
    2.16 +        if (transferFlavors == emptyFlavors)
    2.17 +            return transferFlavors;
    2.18 +        else
    2.19 +            return transferFlavors.clone();
    2.20 +
    2.21      }
    2.22  
    2.23      /**
     3.1 --- a/src/share/jaf_classes/javax/activation/FileTypeMap.java	Fri Dec 13 17:20:01 2013 -0800
     3.2 +++ b/src/share/jaf_classes/javax/activation/FileTypeMap.java	Sun Dec 15 23:35:45 2013 +0100
     3.3 @@ -1,5 +1,5 @@
     3.4  /*
     3.5 - * Copyright (c) 1997, 2005, Oracle and/or its affiliates. All rights reserved.
     3.6 + * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
     3.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3.8   *
     3.9   * This code is free software; you can redistribute it and/or modify it
    3.10 @@ -26,6 +26,8 @@
    3.11  package javax.activation;
    3.12  
    3.13  import java.io.File;
    3.14 +import java.util.Map;
    3.15 +import java.util.WeakHashMap;
    3.16  
    3.17  /**
    3.18   * The FileTypeMap is an abstract class that provides a data typing
    3.19 @@ -48,6 +50,8 @@
    3.20  public abstract class FileTypeMap {
    3.21  
    3.22      private static FileTypeMap defaultMap = null;
    3.23 +    private static Map<ClassLoader,FileTypeMap> map =
    3.24 +                                new WeakHashMap<ClassLoader,FileTypeMap>();
    3.25  
    3.26      /**
    3.27       * The default constructor.
    3.28 @@ -78,11 +82,11 @@
    3.29       * Sets the default FileTypeMap for the system. This instance
    3.30       * will be returned to callers of getDefaultFileTypeMap.
    3.31       *
    3.32 -     * @param map The FileTypeMap.
    3.33 +     * @param fileTypeMap The FileTypeMap.
    3.34       * @exception SecurityException if the caller doesn't have permission
    3.35       *                                  to change the default
    3.36       */
    3.37 -    public static void setDefaultFileTypeMap(FileTypeMap map) {
    3.38 +    public static synchronized void setDefaultFileTypeMap(FileTypeMap fileTypeMap) {
    3.39          SecurityManager security = System.getSecurityManager();
    3.40          if (security != null) {
    3.41              try {
    3.42 @@ -90,14 +94,17 @@
    3.43                  security.checkSetFactory();
    3.44              } catch (SecurityException ex) {
    3.45                  // otherwise, we also allow it if this code and the
    3.46 -                // factory come from the same class loader (e.g.,
    3.47 +                // factory come from the same (non-system) class loader (e.g.,
    3.48                  // the JAF classes were loaded with the applet classes).
    3.49 -                if (FileTypeMap.class.getClassLoader() !=
    3.50 -                        map.getClass().getClassLoader())
    3.51 +                if (FileTypeMap.class.getClassLoader() == null ||
    3.52 +                    FileTypeMap.class.getClassLoader() !=
    3.53 +                        fileTypeMap.getClass().getClassLoader())
    3.54                      throw ex;
    3.55              }
    3.56          }
    3.57 -        defaultMap = map;
    3.58 +        // remove any per-thread-context-class-loader FileTypeMap
    3.59 +        map.remove(SecuritySupport.getContextClassLoader());
    3.60 +        defaultMap = fileTypeMap;
    3.61      }
    3.62  
    3.63      /**
    3.64 @@ -109,10 +116,17 @@
    3.65       * @return The default FileTypeMap
    3.66       * @see javax.activation.FileTypeMap#setDefaultFileTypeMap
    3.67       */
    3.68 -    public static FileTypeMap getDefaultFileTypeMap() {
    3.69 -        // XXX - probably should be synchronized
    3.70 -        if (defaultMap == null)
    3.71 -            defaultMap = new MimetypesFileTypeMap();
    3.72 -        return defaultMap;
    3.73 +    public static synchronized FileTypeMap getDefaultFileTypeMap() {
    3.74 +        if (defaultMap != null)
    3.75 +            return defaultMap;
    3.76 +
    3.77 +        // fetch per-thread-context-class-loader default
    3.78 +        ClassLoader tccl = SecuritySupport.getContextClassLoader();
    3.79 +        FileTypeMap def = map.get(tccl);
    3.80 +        if (def == null) {
    3.81 +            def = new MimetypesFileTypeMap();
    3.82 +            map.put(tccl, def);
    3.83 +        }
    3.84 +        return def;
    3.85      }
    3.86  }
     4.1 --- a/src/share/jaf_classes/javax/activation/MailcapCommandMap.java	Fri Dec 13 17:20:01 2013 -0800
     4.2 +++ b/src/share/jaf_classes/javax/activation/MailcapCommandMap.java	Sun Dec 15 23:35:45 2013 +0100
     4.3 @@ -1,5 +1,5 @@
     4.4  /*
     4.5 - * Copyright (c) 1997, 2005, Oracle and/or its affiliates. All rights reserved.
     4.6 + * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
     4.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4.8   *
     4.9   * This code is free software; you can redistribute it and/or modify it
    4.10 @@ -120,11 +120,7 @@
    4.11  public class MailcapCommandMap extends CommandMap {
    4.12      /*
    4.13       * We manage a collection of databases, searched in order.
    4.14 -     * The default database is shared between all instances
    4.15 -     * of this class.
    4.16 -     * XXX - Can we safely share more databases between instances?
    4.17       */
    4.18 -    private static MailcapFile defDB = null;
    4.19      private MailcapFile[] DB;
    4.20      private static final int PROG = 0;  // programmatically added entries
    4.21  
    4.22 @@ -164,14 +160,10 @@
    4.23          loadAllResources(dbv, "META-INF/mailcap");
    4.24  
    4.25          LogSupport.log("MailcapCommandMap: load DEF");
    4.26 -        synchronized (MailcapCommandMap.class) {
    4.27 -            // see if another instance has created this yet.
    4.28 -            if (defDB == null)
    4.29 -                defDB = loadResource("/META-INF/mailcap.default");
    4.30 -        }
    4.31 +        mf = loadResource("/META-INF/mailcap.default");
    4.32  
    4.33 -        if (defDB != null)
    4.34 -            dbv.add(defDB);
    4.35 +        if (mf != null)
    4.36 +            dbv.add(mf);
    4.37  
    4.38          DB = new MailcapFile[dbv.size()];
    4.39          DB = (MailcapFile[])dbv.toArray(DB);
     5.1 --- a/src/share/jaf_classes/javax/activation/MimetypesFileTypeMap.java	Fri Dec 13 17:20:01 2013 -0800
     5.2 +++ b/src/share/jaf_classes/javax/activation/MimetypesFileTypeMap.java	Sun Dec 15 23:35:45 2013 +0100
     5.3 @@ -1,5 +1,5 @@
     5.4  /*
     5.5 - * Copyright (c) 1997, 2005, Oracle and/or its affiliates. All rights reserved.
     5.6 + * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
     5.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     5.8   *
     5.9   * This code is free software; you can redistribute it and/or modify it
    5.10 @@ -69,11 +69,7 @@
    5.11  public class MimetypesFileTypeMap extends FileTypeMap {
    5.12      /*
    5.13       * We manage a collection of databases, searched in order.
    5.14 -     * The default database is shared between all instances
    5.15 -     * of this class.
    5.16 -     * XXX - Can we safely share more databases between instances?
    5.17       */
    5.18 -    private static MimeTypeFile defDB = null;
    5.19      private MimeTypeFile[] DB;
    5.20      private static final int PROG = 0;  // programmatically added entries
    5.21  
    5.22 @@ -114,14 +110,10 @@
    5.23          loadAllResources(dbv, "META-INF/mime.types");
    5.24  
    5.25          LogSupport.log("MimetypesFileTypeMap: load DEF");
    5.26 -        synchronized (MimetypesFileTypeMap.class) {
    5.27 -            // see if another instance has created this yet.
    5.28 -            if (defDB == null)
    5.29 -                defDB = loadResource("/META-INF/mimetypes.default");
    5.30 -        }
    5.31 +        mf = loadResource("/META-INF/mimetypes.default");
    5.32  
    5.33 -        if (defDB != null)
    5.34 -            dbv.addElement(defDB);
    5.35 +        if (mf != null)
    5.36 +            dbv.addElement(mf);
    5.37  
    5.38          DB = new MimeTypeFile[dbv.size()];
    5.39          dbv.copyInto(DB);
     6.1 --- a/src/share/jaxws_classes/com/sun/xml/internal/messaging/saaj/soap/AttachmentPartImpl.java	Fri Dec 13 17:20:01 2013 -0800
     6.2 +++ b/src/share/jaxws_classes/com/sun/xml/internal/messaging/saaj/soap/AttachmentPartImpl.java	Sun Dec 15 23:35:45 2013 +0100
     6.3 @@ -62,61 +62,6 @@
     6.4          Logger.getLogger(LogDomainConstants.SOAP_DOMAIN,
     6.5                           "com.sun.xml.internal.messaging.saaj.soap.LocalStrings");
     6.6  
     6.7 -    static {
     6.8 -        try {
     6.9 -            CommandMap map = CommandMap.getDefaultCommandMap();
    6.10 -            if (map instanceof MailcapCommandMap) {
    6.11 -                MailcapCommandMap mailMap = (MailcapCommandMap) map;
    6.12 -                String hndlrStr = ";;x-java-content-handler=";
    6.13 -                mailMap.addMailcap(
    6.14 -                    "text/xml"
    6.15 -                        + hndlrStr
    6.16 -                        + "com.sun.xml.internal.messaging.saaj.soap.XmlDataContentHandler");
    6.17 -                mailMap.addMailcap(
    6.18 -                    "application/xml"
    6.19 -                        + hndlrStr
    6.20 -                        + "com.sun.xml.internal.messaging.saaj.soap.XmlDataContentHandler");
    6.21 -                mailMap.addMailcap(
    6.22 -                    "application/fastinfoset"
    6.23 -                        + hndlrStr
    6.24 -                        + "com.sun.xml.internal.messaging.saaj.soap.FastInfosetDataContentHandler");
    6.25 -                /* Image DataContentHandler handles all image types
    6.26 -                mailMap.addMailcap(
    6.27 -                    "image/jpeg"
    6.28 -                        + hndlrStr
    6.29 -                        + "com.sun.xml.internal.messaging.saaj.soap.JpegDataContentHandler");
    6.30 -                mailMap.addMailcap(
    6.31 -                    "image/gif"
    6.32 -                        + hndlrStr
    6.33 -                        + "com.sun.xml.internal.messaging.saaj.soap.GifDataContentHandler"); */
    6.34 -                /*mailMap.addMailcap(
    6.35 -                    "multipart/*"
    6.36 -                        + hndlrStr
    6.37 -                        + "com.sun.xml.internal.messaging.saaj.soap.MultipartDataContentHandler");*/
    6.38 -                mailMap.addMailcap(
    6.39 -                    "image/*"
    6.40 -                        + hndlrStr
    6.41 -                        + "com.sun.xml.internal.messaging.saaj.soap.ImageDataContentHandler");
    6.42 -                mailMap.addMailcap(
    6.43 -                    "text/plain"
    6.44 -                        + hndlrStr
    6.45 -                        + "com.sun.xml.internal.messaging.saaj.soap.StringDataContentHandler");
    6.46 -            } else {
    6.47 -                throw new SOAPExceptionImpl("Default CommandMap is not a MailcapCommandMap");
    6.48 -            }
    6.49 -        } catch (Throwable t) {
    6.50 -            log.log(
    6.51 -                Level.SEVERE,
    6.52 -                "SAAJ0508.soap.cannot.register.handlers",
    6.53 -                t);
    6.54 -            if (t instanceof RuntimeException) {
    6.55 -                throw (RuntimeException) t;
    6.56 -            } else {
    6.57 -                throw new RuntimeException(t.getLocalizedMessage());
    6.58 -            }
    6.59 -        }
    6.60 -    };
    6.61 -
    6.62      private final MimeHeaders headers;
    6.63      private MimeBodyPart rawContent = null;
    6.64      private DataHandler dataHandler = null;
    6.65 @@ -126,6 +71,12 @@
    6.66  
    6.67      public AttachmentPartImpl() {
    6.68          headers = new MimeHeaders();
    6.69 +
    6.70 +        // initialization from here should cover most of cases;
    6.71 +        // if not, it would be necessary to call
    6.72 +        //   AttachmentPartImpl.initializeJavaActivationHandlers()
    6.73 +        // explicitly by programmer
    6.74 +        initializeJavaActivationHandlers();
    6.75      }
    6.76  
    6.77      public AttachmentPartImpl(MIMEPart part) {
    6.78 @@ -404,7 +355,7 @@
    6.79              throw new SOAPExceptionImpl(e.getLocalizedMessage());
    6.80          } finally {
    6.81              try {
    6.82 -                decoded.close();
    6.83 +                    decoded.close();
    6.84              } catch (IOException ex) {
    6.85                  throw new SOAPException(ex);
    6.86              }
    6.87 @@ -613,4 +564,43 @@
    6.88          return headers;
    6.89      }
    6.90  
    6.91 +    public static void initializeJavaActivationHandlers() {
    6.92 +        // DataHandler.writeTo() may search for DCH. So adding some default ones.
    6.93 +        try {
    6.94 +            CommandMap map = CommandMap.getDefaultCommandMap();
    6.95 +            if (map instanceof MailcapCommandMap) {
    6.96 +                MailcapCommandMap mailMap = (MailcapCommandMap) map;
    6.97 +
    6.98 +                // registering our DCH since javamail's DCH doesn't handle
    6.99 +                if (!cmdMapInitialized(mailMap)) {
   6.100 +                    mailMap.addMailcap("text/xml;;x-java-content-handler=com.sun.xml.internal.messaging.saaj.soap.XmlDataContentHandler");
   6.101 +                    mailMap.addMailcap("application/xml;;x-java-content-handler=com.sun.xml.internal.messaging.saaj.soap.XmlDataContentHandler");
   6.102 +                    mailMap.addMailcap("application/fastinfoset;;x-java-content-handler=com.sun.xml.internal.messaging.saaj.soap.FastInfosetDataContentHandler");
   6.103 +                    mailMap.addMailcap("multipart/*;;x-java-content-handler=com.sun.xml.internal.messaging.saaj.soap.MultipartDataContentHandler");
   6.104 +                    mailMap.addMailcap("image/*;;x-java-content-handler=com.sun.xml.internal.messaging.saaj.soap.ImageDataContentHandler");
   6.105 +                    mailMap.addMailcap("text/plain;;x-java-content-handler=com.sun.xml.internal.messaging.saaj.soap.StringDataContentHandler");
   6.106 +                }
   6.107 +            }
   6.108 +        } catch (Throwable t) {
   6.109 +            // ignore the exception.
   6.110 +        }
   6.111 +    }
   6.112 +
   6.113 +    private static boolean cmdMapInitialized(MailcapCommandMap mailMap) {
   6.114 +
   6.115 +        // checking fastinfoset handler, since this one is specific to SAAJ
   6.116 +        CommandInfo[] commands = mailMap.getAllCommands("application/fastinfoset");
   6.117 +        if (commands == null || commands.length == 0) {
   6.118 +            return false;
   6.119 +        }
   6.120 +
   6.121 +        String saajClassName = "com.sun.xml.internal.ws.binding.FastInfosetDataContentHandler";
   6.122 +        for (CommandInfo command : commands) {
   6.123 +            String commandClass = command.getCommandClass();
   6.124 +            if (saajClassName.equals(commandClass)) {
   6.125 +                return true;
   6.126 +            }
   6.127 +        }
   6.128 +        return false;
   6.129 +    }
   6.130  }
     7.1 --- a/src/share/jaxws_classes/com/sun/xml/internal/ws/binding/BindingImpl.java	Fri Dec 13 17:20:01 2013 -0800
     7.2 +++ b/src/share/jaxws_classes/com/sun/xml/internal/ws/binding/BindingImpl.java	Sun Dec 15 23:35:45 2013 +0100
     7.3 @@ -37,6 +37,9 @@
     7.4  import com.sun.xml.internal.ws.developer.MemberSubmissionAddressingFeature;
     7.5  import com.sun.xml.internal.ws.developer.BindingTypeFeature;
     7.6  
     7.7 +import javax.activation.CommandInfo;
     7.8 +import javax.activation.CommandMap;
     7.9 +import javax.activation.MailcapCommandMap;
    7.10  import javax.xml.namespace.QName;
    7.11  import javax.xml.ws.Service;
    7.12  import javax.xml.ws.WebServiceFeature;
    7.13 @@ -151,12 +154,61 @@
    7.14          return addressingVersion;
    7.15      }
    7.16  
    7.17 -    public final
    7.18      @NotNull
    7.19 -    Codec createCodec() {
    7.20 +    public final Codec createCodec() {
    7.21 +
    7.22 +        // initialization from here should cover most of cases;
    7.23 +        // if not, it would be necessary to call
    7.24 +        //   BindingImpl.initializeJavaActivationHandlers()
    7.25 +        // explicitly by programmer
    7.26 +        initializeJavaActivationHandlers();
    7.27 +
    7.28          return bindingId.createEncoder(this);
    7.29      }
    7.30  
    7.31 +    public static void initializeJavaActivationHandlers() {
    7.32 +        // DataHandler.writeTo() may search for DCH. So adding some default ones.
    7.33 +        try {
    7.34 +            CommandMap map = CommandMap.getDefaultCommandMap();
    7.35 +            if (map instanceof MailcapCommandMap) {
    7.36 +                MailcapCommandMap mailMap = (MailcapCommandMap) map;
    7.37 +
    7.38 +                // registering our DCH since javamail's DCH doesn't handle
    7.39 +                if (!cmdMapInitialized(mailMap)) {
    7.40 +                    mailMap.addMailcap("text/xml;;x-java-content-handler=com.sun.xml.internal.ws.encoding.XmlDataContentHandler");
    7.41 +                    mailMap.addMailcap("application/xml;;x-java-content-handler=com.sun.xml.internal.ws.encoding.XmlDataContentHandler");
    7.42 +                    mailMap.addMailcap("image/*;;x-java-content-handler=com.sun.xml.internal.ws.encoding.ImageDataContentHandler");
    7.43 +                    mailMap.addMailcap("text/plain;;x-java-content-handler=com.sun.xml.internal.ws.encoding.StringDataContentHandler");
    7.44 +                }
    7.45 +            }
    7.46 +        } catch (Throwable t) {
    7.47 +            // ignore the exception.
    7.48 +        }
    7.49 +    }
    7.50 +
    7.51 +    private static boolean cmdMapInitialized(MailcapCommandMap mailMap) {
    7.52 +        CommandInfo[] commands = mailMap.getAllCommands("text/xml");
    7.53 +        if (commands == null || commands.length == 0) {
    7.54 +            return false;
    7.55 +        }
    7.56 +
    7.57 +        // SAAJ RI implements it's own DataHandlers which can be used for JAX-WS too;
    7.58 +        // see com.sun.xml.internal.messaging.saaj.soap.AttachmentPartImpl#initializeJavaActivationHandlers
    7.59 +        // so if found any of SAAJ or our own handler registered, we are ok; anyway using SAAJ directly here
    7.60 +        // is not good idea since we don't want standalone JAX-WS to depend on specific SAAJ impl.
    7.61 +        // This is also reason for duplication of Handler's code by JAX-WS
    7.62 +        String saajClassName = "com.sun.xml.internal.messaging.saaj.soap.XmlDataContentHandler";
    7.63 +        String jaxwsClassName = "com.sun.xml.internal.ws.encoding.XmlDataContentHandler";
    7.64 +        for (CommandInfo command : commands) {
    7.65 +            String commandClass = command.getCommandClass();
    7.66 +            if (saajClassName.equals(commandClass) ||
    7.67 +                    jaxwsClassName.equals(commandClass)) {
    7.68 +                return true;
    7.69 +            }
    7.70 +        }
    7.71 +        return false;
    7.72 +    }
    7.73 +
    7.74      public static BindingImpl create(@NotNull BindingID bindingId) {
    7.75          if (bindingId.equals(BindingID.XML_HTTP))
    7.76              return new HTTPBindingImpl();
     8.1 --- a/src/share/jaxws_classes/com/sun/xml/internal/ws/encoding/MimeCodec.java	Fri Dec 13 17:20:01 2013 -0800
     8.2 +++ b/src/share/jaxws_classes/com/sun/xml/internal/ws/encoding/MimeCodec.java	Sun Dec 15 23:35:45 2013 +0100
     8.3 @@ -34,8 +34,6 @@
     8.4  import com.sun.xml.internal.ws.api.pipe.Codec;
     8.5  import com.sun.xml.internal.ws.api.pipe.ContentType;
     8.6  import com.sun.xml.internal.ws.developer.StreamingAttachmentFeature;
     8.7 -import javax.activation.CommandMap;
     8.8 -import javax.activation.MailcapCommandMap;
     8.9  
    8.10  import java.io.IOException;
    8.11  import java.io.InputStream;
    8.12 @@ -63,33 +61,6 @@
    8.13   */
    8.14  abstract class MimeCodec implements Codec {
    8.15  
    8.16 -    static {
    8.17 -        // DataHandler.writeTo() may search for DCH. So adding some default ones.
    8.18 -        try {
    8.19 -            CommandMap map = CommandMap.getDefaultCommandMap();
    8.20 -            if (map instanceof MailcapCommandMap) {
    8.21 -                MailcapCommandMap mailMap = (MailcapCommandMap) map;
    8.22 -                String hndlrStr = ";;x-java-content-handler=";
    8.23 -                // registering our DCH since javamail's DCH doesn't handle
    8.24 -                // Source
    8.25 -                mailMap.addMailcap(
    8.26 -                    "text/xml" + hndlrStr + XmlDataContentHandler.class.getName());
    8.27 -                mailMap.addMailcap(
    8.28 -                    "application/xml" + hndlrStr + XmlDataContentHandler.class.getName());
    8.29 -                if (map.createDataContentHandler("image/*") == null) {
    8.30 -                    mailMap.addMailcap(
    8.31 -                        "image/*" + hndlrStr + ImageDataContentHandler.class.getName());
    8.32 -                }
    8.33 -                if (map.createDataContentHandler("text/plain") == null) {
    8.34 -                    mailMap.addMailcap(
    8.35 -                        "text/plain" + hndlrStr + StringDataContentHandler.class.getName());
    8.36 -                }
    8.37 -            }
    8.38 -        } catch (Throwable t) {
    8.39 -            // ignore the exception.
    8.40 -        }
    8.41 -    }
    8.42 -
    8.43      public static final String MULTIPART_RELATED_MIME_TYPE = "multipart/related";
    8.44  
    8.45      protected Codec mimeRootCodec;
     9.1 --- a/src/share/jaxws_classes/com/sun/xml/internal/ws/util/version.properties	Fri Dec 13 17:20:01 2013 -0800
     9.2 +++ b/src/share/jaxws_classes/com/sun/xml/internal/ws/util/version.properties	Sun Dec 15 23:35:45 2013 +0100
     9.3 @@ -26,4 +26,4 @@
     9.4  build-id=2.2.9-b130926.1035
     9.5  build-version=JAX-WS RI 2.2.9-b130926.1035
     9.6  major-version=2.2.9
     9.7 -svn-revision=8c29a9a53251ff741fca1664a8221dc876b2eac8
     9.8 +svn-revision=5f6196f2b90e9460065a4c2f4e30e065b245e51e

mercurial