32 import com.sun.xml.internal.ws.api.message.Message; |
32 import com.sun.xml.internal.ws.api.message.Message; |
33 import com.sun.xml.internal.ws.api.message.Packet; |
33 import com.sun.xml.internal.ws.api.message.Packet; |
34 import com.sun.xml.internal.ws.api.pipe.Codec; |
34 import com.sun.xml.internal.ws.api.pipe.Codec; |
35 import com.sun.xml.internal.ws.api.pipe.ContentType; |
35 import com.sun.xml.internal.ws.api.pipe.ContentType; |
36 import com.sun.xml.internal.ws.developer.StreamingAttachmentFeature; |
36 import com.sun.xml.internal.ws.developer.StreamingAttachmentFeature; |
37 import javax.activation.CommandMap; |
|
38 import javax.activation.MailcapCommandMap; |
|
39 |
37 |
40 import java.io.IOException; |
38 import java.io.IOException; |
41 import java.io.InputStream; |
39 import java.io.InputStream; |
42 import java.io.OutputStream; |
40 import java.io.OutputStream; |
43 import java.nio.channels.ReadableByteChannel; |
41 import java.nio.channels.ReadableByteChannel; |
60 * This improves the performance. |
58 * This improves the performance. |
61 * |
59 * |
62 * @author Kohsuke Kawaguchi |
60 * @author Kohsuke Kawaguchi |
63 */ |
61 */ |
64 abstract class MimeCodec implements Codec { |
62 abstract class MimeCodec implements Codec { |
65 |
|
66 static { |
|
67 // DataHandler.writeTo() may search for DCH. So adding some default ones. |
|
68 try { |
|
69 CommandMap map = CommandMap.getDefaultCommandMap(); |
|
70 if (map instanceof MailcapCommandMap) { |
|
71 MailcapCommandMap mailMap = (MailcapCommandMap) map; |
|
72 String hndlrStr = ";;x-java-content-handler="; |
|
73 // registering our DCH since javamail's DCH doesn't handle |
|
74 // Source |
|
75 mailMap.addMailcap( |
|
76 "text/xml" + hndlrStr + XmlDataContentHandler.class.getName()); |
|
77 mailMap.addMailcap( |
|
78 "application/xml" + hndlrStr + XmlDataContentHandler.class.getName()); |
|
79 if (map.createDataContentHandler("image/*") == null) { |
|
80 mailMap.addMailcap( |
|
81 "image/*" + hndlrStr + ImageDataContentHandler.class.getName()); |
|
82 } |
|
83 if (map.createDataContentHandler("text/plain") == null) { |
|
84 mailMap.addMailcap( |
|
85 "text/plain" + hndlrStr + StringDataContentHandler.class.getName()); |
|
86 } |
|
87 } |
|
88 } catch (Throwable t) { |
|
89 // ignore the exception. |
|
90 } |
|
91 } |
|
92 |
63 |
93 public static final String MULTIPART_RELATED_MIME_TYPE = "multipart/related"; |
64 public static final String MULTIPART_RELATED_MIME_TYPE = "multipart/related"; |
94 |
65 |
95 protected Codec mimeRootCodec; |
66 protected Codec mimeRootCodec; |
96 protected final SOAPVersion version; |
67 protected final SOAPVersion version; |