src/share/jaf_classes/javax/activation/MimetypesFileTypeMap.java

changeset 494
2fcd3ddb57a6
parent 286
f50545b5e2f1
child 637
9c07ef4934dd
equal deleted inserted replaced
493:b549c5ea34ab 494:2fcd3ddb57a6
1 /* 1 /*
2 * Copyright (c) 1997, 2005, Oracle and/or its affiliates. All rights reserved. 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. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 * 4 *
5 * This code is free software; you can redistribute it and/or modify it 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 6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this 7 * published by the Free Software Foundation. Oracle designates this
67 * @since 1.6 67 * @since 1.6
68 */ 68 */
69 public class MimetypesFileTypeMap extends FileTypeMap { 69 public class MimetypesFileTypeMap extends FileTypeMap {
70 /* 70 /*
71 * We manage a collection of databases, searched in order. 71 * We manage a collection of databases, searched in order.
72 * The default database is shared between all instances 72 */
73 * of this class.
74 * XXX - Can we safely share more databases between instances?
75 */
76 private static MimeTypeFile defDB = null;
77 private MimeTypeFile[] DB; 73 private MimeTypeFile[] DB;
78 private static final int PROG = 0; // programmatically added entries 74 private static final int PROG = 0; // programmatically added entries
79 75
80 private static String defaultType = "application/octet-stream"; 76 private static String defaultType = "application/octet-stream";
81 77
112 LogSupport.log("MimetypesFileTypeMap: load JAR"); 108 LogSupport.log("MimetypesFileTypeMap: load JAR");
113 // load from the app's jar file 109 // load from the app's jar file
114 loadAllResources(dbv, "META-INF/mime.types"); 110 loadAllResources(dbv, "META-INF/mime.types");
115 111
116 LogSupport.log("MimetypesFileTypeMap: load DEF"); 112 LogSupport.log("MimetypesFileTypeMap: load DEF");
117 synchronized (MimetypesFileTypeMap.class) { 113 mf = loadResource("/META-INF/mimetypes.default");
118 // see if another instance has created this yet. 114
119 if (defDB == null) 115 if (mf != null)
120 defDB = loadResource("/META-INF/mimetypes.default"); 116 dbv.addElement(mf);
121 }
122
123 if (defDB != null)
124 dbv.addElement(defDB);
125 117
126 DB = new MimeTypeFile[dbv.size()]; 118 DB = new MimeTypeFile[dbv.size()];
127 dbv.copyInto(DB); 119 dbv.copyInto(DB);
128 } 120 }
129 121

mercurial