This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

View | Details | Raw Unified | Return to bug 250865
Collapse All | Expand All

(-)a/editor.mimelookup.impl/manifest.mf (-1 / +1 lines)
Lines 2-5 Link Here
2
OpenIDE-Module: org.netbeans.modules.editor.mimelookup.impl/1
2
OpenIDE-Module: org.netbeans.modules.editor.mimelookup.impl/1
3
OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/editor/mimelookup/impl/Bundle.properties
3
OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/editor/mimelookup/impl/Bundle.properties
4
OpenIDE-Module-Provides: org.netbeans.spi.editor.mimelookup.MimeDataProvider
4
OpenIDE-Module-Provides: org.netbeans.spi.editor.mimelookup.MimeDataProvider
5
OpenIDE-Module-Specification-Version: 1.29
5
OpenIDE-Module-Specification-Version: 1.30
(-)a/editor.mimelookup.impl/nbproject/project.xml (-9 / +1 lines)
Lines 67-80 Link Here
67
                    </run-dependency>
67
                    </run-dependency>
68
                </dependency>
68
                </dependency>
69
                <dependency>
69
                <dependency>
70
                    <code-name-base>org.openide.util.ui</code-name-base>
71
                    <build-prerequisite/>
72
                    <compile-dependency/>
73
                    <run-dependency>
74
                        <specification-version>9.3</specification-version>
75
                    </run-dependency>
76
                </dependency>
77
                <dependency>
78
                    <code-name-base>org.openide.util</code-name-base>
70
                    <code-name-base>org.openide.util</code-name-base>
79
                    <build-prerequisite/>
71
                    <build-prerequisite/>
80
                    <compile-dependency/>
72
                    <compile-dependency/>
Lines 87-93 Link Here
87
                    <build-prerequisite/>
79
                    <build-prerequisite/>
88
                    <compile-dependency/>
80
                    <compile-dependency/>
89
                    <run-dependency>
81
                    <run-dependency>
90
                        <specification-version>8.0</specification-version>
82
                        <specification-version>8.31</specification-version>
91
                    </run-dependency>
83
                    </run-dependency>
92
                </dependency>
84
                </dependency>
93
            </module-dependencies>
85
            </module-dependencies>
(-)a/editor.mimelookup.impl/src/org/netbeans/modules/editor/mimelookup/impl/CompoundFolderChildren.java (-1 / +2 lines)
Lines 116-122 Link Here
116
            List<FileObject> folders = new ArrayList<FileObject>(prefixes.size());
116
            List<FileObject> folders = new ArrayList<FileObject>(prefixes.size());
117
            List<FileSystem> layers = new ArrayList<FileSystem>(prefixes.size());
117
            List<FileSystem> layers = new ArrayList<FileSystem>(prefixes.size());
118
            for (final String prefix : prefixes) {
118
            for (final String prefix : prefixes) {
119
                FileObject layer = FileUtil.getConfigFile(prefix);
119
                // use system-wide configuration, ignore execution-local specifics
120
                FileObject layer = FileUtil.getSystemConfigFile(prefix);
120
                if (layer != null && layer.isFolder()) {
121
                if (layer != null && layer.isFolder()) {
121
                    folders.add(layer);
122
                    folders.add(layer);
122
                    try {
123
                    try {
(-)a/editor.mimelookup.impl/src/org/netbeans/modules/editor/mimelookup/impl/FolderPathLookup.java (-13 / +44 lines)
Lines 48-54 Link Here
48
import java.beans.PropertyChangeListener;
48
import java.beans.PropertyChangeListener;
49
import java.lang.ref.Reference;
49
import java.lang.ref.Reference;
50
import java.lang.ref.WeakReference;
50
import java.lang.ref.WeakReference;
51
import java.lang.reflect.Constructor;
52
import java.lang.reflect.InvocationTargetException;
51
import java.util.ArrayList;
53
import java.util.ArrayList;
54
import java.util.Collection;
52
import java.util.Collections;
55
import java.util.Collections;
53
import java.util.Enumeration;
56
import java.util.Enumeration;
54
import java.util.HashMap;
57
import java.util.HashMap;
Lines 58-69 Link Here
58
import java.util.logging.Logger;
61
import java.util.logging.Logger;
59
import org.openide.filesystems.FileObject;
62
import org.openide.filesystems.FileObject;
60
import org.openide.filesystems.FileStateInvalidException;
63
import org.openide.filesystems.FileStateInvalidException;
64
import org.openide.filesystems.spi.CustomInstanceFactory;
65
import org.openide.util.BaseUtilities;
61
import org.openide.util.Exceptions;
66
import org.openide.util.Exceptions;
62
import org.openide.util.Lookup;
67
import org.openide.util.Lookup;
63
import org.openide.util.SharedClassObject;
64
import org.openide.util.Utilities;
65
import org.openide.util.lookup.AbstractLookup;
68
import org.openide.util.lookup.AbstractLookup;
66
import org.openide.util.lookup.InstanceContent;
69
import org.openide.util.lookup.InstanceContent;
70
import org.openide.util.lookup.Lookups;
67
71
68
/**
72
/**
69
 *
73
 *
Lines 205-210 Link Here
205
209
206
    }
210
    }
207
    
211
    
212
    private static volatile Lookup.Result<CustomInstanceFactory> factories;
213
    
214
    private static Collection<? extends CustomInstanceFactory> getInstanceFactories() {
215
        Lookup.Result<CustomInstanceFactory> v = factories;
216
        if (v != null) {
217
            return v.allInstances();
218
        }
219
        final Lookup.Result<CustomInstanceFactory> fr[] = new Lookup.Result[1];
220
        // ensure the system - global Lookup is used
221
        Lookups.executeWith(null, new Runnable() {
222
            public void run() {
223
                fr[0] = factories = Lookup.getDefault().lookupResult(CustomInstanceFactory.class);
224
            }
225
        });
226
        return fr[0].allInstances();
227
    }
228
            
229
    public static final <T> T createInstance(Class<T> type) throws InstantiationException, 
230
            IllegalAccessException, InvocationTargetException, NoSuchMethodException {
231
        T r = null;
232
        for (CustomInstanceFactory fif : getInstanceFactories()) {
233
            r = (T)fif.createInstance(type);
234
            if (r != null) {
235
                break;
236
            }
237
        }
238
        if (r == null) {
239
            Constructor<T> init = type.getDeclaredConstructor();
240
            init.setAccessible(true);
241
            r = init.newInstance();
242
        }
243
        return r;
244
    }
208
245
209
    /**
246
    /**
210
     * Item referencing a file object and object instance that was created from it.
247
     * Item referencing a file object and object instance that was created from it.
Lines 342-355 Link Here
342
                    if (type == null) {
379
                    if (type == null) {
343
                        return null;
380
                        return null;
344
                    }
381
                    }
345
                    if (SharedClassObject.class.isAssignableFrom(type)) {
382
                    inst = createInstance(type);
346
                        inst = SharedClassObject.findObject(type.asSubclass(SharedClassObject.class), true);
383
                } catch (InstantiationException | IllegalAccessException | InvocationTargetException | NoSuchMethodException ex) {
347
                    } else {
348
                        inst = type.newInstance();
349
                    }
350
                } catch (InstantiationException ex) {
351
                    Exceptions.printStackTrace(ex);
352
                } catch (IllegalAccessException ex) {
353
                    Exceptions.printStackTrace(ex);
384
                    Exceptions.printStackTrace(ex);
354
                }
385
                }
355
            }
386
            }
Lines 373-379 Link Here
373
            // first of all try "instanceClass" property of the primary file
404
            // first of all try "instanceClass" property of the primary file
374
            Object attr = fo.getAttribute ("instanceClass");
405
            Object attr = fo.getAttribute ("instanceClass");
375
            if (attr instanceof String) {
406
            if (attr instanceof String) {
376
                return Utilities.translate((String) attr);
407
                return BaseUtilities.translate((String) attr);
377
            } else if (attr != null) {
408
            } else if (attr != null) {
378
                LOG.warning(
409
                LOG.warning(
379
                    "instanceClass was a " + attr.getClass().getName()); // NOI18N
410
                    "instanceClass was a " + attr.getClass().getName()); // NOI18N
Lines 411-417 Link Here
411
            }
442
            }
412
443
413
            name = name.replace ('-', '.');
444
            name = name.replace ('-', '.');
414
            name = Utilities.translate(name);
445
            name = BaseUtilities.translate(name);
415
446
416
            return name;
447
            return name;
417
        }
448
        }
Lines 423-429 Link Here
423
        private final class Ref extends WeakReference<Object> implements Runnable {
454
        private final class Ref extends WeakReference<Object> implements Runnable {
424
            
455
            
425
            Ref(Object inst) {
456
            Ref(Object inst) {
426
                super(inst, Utilities.activeReferenceQueue());
457
                super(inst, BaseUtilities.activeReferenceQueue());
427
            }
458
            }
428
459
429
            @Override
460
            @Override
(-)a/editor.mimelookup.impl/src/org/netbeans/modules/editor/mimelookup/impl/SwitchLookup.java (-25 / +3 lines)
Lines 57-63 Link Here
57
import org.netbeans.spi.editor.mimelookup.MimeLocation;
57
import org.netbeans.spi.editor.mimelookup.MimeLocation;
58
import org.openide.util.Exceptions;
58
import org.openide.util.Exceptions;
59
import org.openide.util.Lookup;
59
import org.openide.util.Lookup;
60
import org.openide.util.lookup.ProxyLookup;
61
60
62
/**
61
/**
63
 *
62
 *
Lines 73-79 Link Here
73
72
74
    private final String LOCK = new String("SwitchLookup.LOCK"); //NOI18N
73
    private final String LOCK = new String("SwitchLookup.LOCK"); //NOI18N
75
    
74
    
76
    private Map<Class<?>,UpdatableProxyLookup> classLookups = new HashMap<Class<?>, UpdatableProxyLookup>();
75
    private Map<Class<?>,Lookup> classLookups = new HashMap<Class<?>, Lookup>();
77
    private Map<List<String>,Lookup> pathsLookups = new HashMap<List<String>,Lookup>();
76
    private Map<List<String>,Lookup> pathsLookups = new HashMap<List<String>,Lookup>();
78
77
79
    public SwitchLookup(MimePath mimePath) {
78
    public SwitchLookup(MimePath mimePath) {
Lines 92-106 Link Here
92
91
93
    private Lookup findLookup(Class<?> clazz) {
92
    private Lookup findLookup(Class<?> clazz) {
94
        synchronized (LOCK) {
93
        synchronized (LOCK) {
95
            UpdatableProxyLookup lookup = classLookups.get(clazz);
94
            Lookup lookup = classLookups.get(clazz);
96
            if (lookup == null) {
95
            if (lookup == null) {
97
                // Create lookup
96
                // Create lookup
98
                Lookup innerLookup = createLookup(clazz);
97
                lookup = createLookup(clazz);
99
                lookup = new UpdatableProxyLookup(innerLookup);
100
                
101
                classLookups.put(clazz, lookup);
98
                classLookups.put(clazz, lookup);
102
            }
99
            }
103
104
            return lookup;
100
            return lookup;
105
        }
101
        }
106
    }
102
    }
Lines 192-213 Link Here
192
        return Collections.singletonList(sb.toString());
188
        return Collections.singletonList(sb.toString());
193
    }
189
    }
194
    
190
    
195
    /**
196
     * An ordinary <code>ProxyLookup</code> except that it exposes the
197
     * <code>setLookupEx</code> method.
198
     */
199
    private static final class UpdatableProxyLookup extends ProxyLookup {
200
        public UpdatableProxyLookup() {
201
            super();
202
        }
203
        
204
        public UpdatableProxyLookup(Lookup... lookups) {
205
            super(lookups);
206
        }
207
        
208
        public void setLookupsEx(Lookup... lookups) {
209
            setLookups(lookups);
210
        }
211
    } // End of UpdatableProxyLookup class
212
    
213
}
191
}
(-)a/editor.mimelookup/nbproject/project.xml (-8 lines)
Lines 58-71 Link Here
58
                    </run-dependency>
58
                    </run-dependency>
59
                </dependency>
59
                </dependency>
60
                <dependency>
60
                <dependency>
61
                    <code-name-base>org.openide.util.ui</code-name-base>
62
                    <build-prerequisite/>
63
                    <compile-dependency/>
64
                    <run-dependency>
65
                        <specification-version>9.3</specification-version>
66
                    </run-dependency>
67
                </dependency>
68
                <dependency>
69
                    <code-name-base>org.openide.util</code-name-base>
61
                    <code-name-base>org.openide.util</code-name-base>
70
                    <build-prerequisite/>
62
                    <build-prerequisite/>
71
                    <compile-dependency/>
63
                    <compile-dependency/>
(-)a/editor.mimelookup/src/org/netbeans/api/editor/mimelookup/MimeLookup.java (-6 / +9 lines)
Lines 96-102 Link Here
96
 */
96
 */
97
public final class MimeLookup extends Lookup {
97
public final class MimeLookup extends Lookup {
98
    
98
    
99
    private MimePathLookup mimePathLookup;
99
    private Lookup mimePathLookup;
100
    
101
    private final MimePath mimePath;
100
    
102
    
101
    /**
103
    /**
102
     * Gets a <code>Lookup</code> implementation that exposes objects specific
104
     * Gets a <code>Lookup</code> implementation that exposes objects specific
Lines 145-152 Link Here
145
        if (mimeType == null) {
147
        if (mimeType == null) {
146
            throw new NullPointerException("The mimeType parameter must not be null."); //NOI18N
148
            throw new NullPointerException("The mimeType parameter must not be null."); //NOI18N
147
        }
149
        }
148
        
150
        MimePath path = MimePath.get(mimeType);
149
        return new MimeLookup(MimePath.get(mimeType).getLookup());
151
        return new MimeLookup(path, MimePath.get(mimeType).getLookup());
150
    }
152
    }
151
153
152
    /**
154
    /**
Lines 156-163 Link Here
156
     *                 the root MimeLookup
158
     *                 the root MimeLookup
157
     * @param mimeType non-null mime-type string representation, e.g. "text/x-java"
159
     * @param mimeType non-null mime-type string representation, e.g. "text/x-java"
158
     */
160
     */
159
    private MimeLookup(MimePathLookup lookup) {
161
    private MimeLookup(MimePath path, Lookup lookup) {
160
        this.mimePathLookup = lookup;
162
        this.mimePathLookup = lookup;
163
        this.mimePath = path;
161
    }
164
    }
162
    
165
    
163
    /** 
166
    /** 
Lines 177-184 Link Here
177
            throw new NullPointerException("The mimeType parameter must not be null."); //NOI18N
180
            throw new NullPointerException("The mimeType parameter must not be null."); //NOI18N
178
        }
181
        }
179
        
182
        
180
        MimePath mimePath = MimePath.get(mimePathLookup.getMimePath(), mimeType);
183
        MimePath newPath = MimePath.get(mimePath, mimeType);
181
        return new MimeLookup(mimePath.getLookup());
184
        return new MimeLookup(newPath, newPath.getLookup());
182
    }
185
    }
183
186
184
    /**
187
    /**
(-)a/editor.mimelookup/src/org/netbeans/api/editor/mimelookup/MimePath.java (-3 / +33 lines)
Lines 55-61 Link Here
55
import java.util.Map;
55
import java.util.Map;
56
import java.util.Set;
56
import java.util.Set;
57
import java.util.regex.Pattern;
57
import java.util.regex.Pattern;
58
import org.netbeans.modules.editor.mimelookup.APIAccessor;
59
import org.netbeans.modules.editor.mimelookup.MimeLookupCacheSPI;
58
import org.netbeans.modules.editor.mimelookup.MimePathLookup;
60
import org.netbeans.modules.editor.mimelookup.MimePathLookup;
61
import org.openide.util.Lookup;
62
import org.openide.util.lookup.Lookups;
59
63
60
/**
64
/**
61
 * The mime path is a concatenation of one or more mime types. The purpose of
65
 * The mime path is a concatenation of one or more mime types. The purpose of
Lines 328-334 Link Here
328
    /**
332
    /**
329
     * The lookup with objects registered for this mime path.
333
     * The lookup with objects registered for this mime path.
330
     */
334
     */
331
    private MimePathLookup lookup;
335
    private Lookup lookup;
332
    
336
    
333
    /**
337
    /**
334
     * Synchronization lock for creation of the mime path lookup.
338
     * Synchronization lock for creation of the mime path lookup.
Lines 505-518 Link Here
505
     *
509
     *
506
     * @return The mime path specific lookup.
510
     * @return The mime path specific lookup.
507
     */
511
     */
508
    /* package */ MimePathLookup getLookup() {
512
    /* package */ Lookup getLookup() {
513
        return Lookup.getDefault().lookup(MimeLookupCacheSPI.class).getLookup(this);
514
    }
515
    
516
    private Lookup getLookupImpl() {
509
        synchronized (LOOKUP_LOCK) {
517
        synchronized (LOOKUP_LOCK) {
510
            if (lookup == null) {
518
            if (lookup == null) {
511
                lookup = new MimePathLookup(this);
519
                lookup = new MimePathLookup(this);  
512
            }
520
            }
513
            return lookup;
521
            return lookup;
514
        }
522
        }
515
    }
523
    }
524
    
525
    private static final Lookup systemLookup;
526
    
527
    static {
528
        final Lookup[] lkp = new Lookup[1];
529
        Lookups.executeWith(null, new Runnable() {
530
            public void run() {
531
                lkp[0] = Lookup.getDefault();
532
            }
533
        });
534
        systemLookup = lkp[0];
535
    }
516
536
517
    public @Override String toString() {
537
    public @Override String toString() {
518
        return "MimePath[" + path + "]"; // NOI18N
538
        return "MimePath[" + path + "]"; // NOI18N
Lines 704-707 Link Here
704
        return array;
724
        return array;
705
    }
725
    }
706
726
727
    private static class AccessorImpl extends APIAccessor {
728
        @Override
729
        public Lookup cacheMimeLookup(MimePath path) {
730
            return path.getLookupImpl();
731
        }
732
    }
733
    
734
    static {
735
        new AccessorImpl();
736
    }
707
}
737
}
(-)a/editor.mimelookup/src/org/netbeans/modules/editor/mimelookup/APIAccessor.java (+67 lines)
Line 0 Link Here
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
4
 * Copyright 2015 Oracle and/or its affiliates. All rights reserved.
5
 *
6
 * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
7
 * Other names may be trademarks of their respective owners.
8
 *
9
 * The contents of this file are subject to the terms of either the GNU
10
 * General Public License Version 2 only ("GPL") or the Common
11
 * Development and Distribution License("CDDL") (collectively, the
12
 * "License"). You may not use this file except in compliance with the
13
 * License. You can obtain a copy of the License at
14
 * http://www.netbeans.org/cddl-gplv2.html
15
 * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
16
 * specific language governing permissions and limitations under the
17
 * License.  When distributing the software, include this License Header
18
 * Notice in each file and include the License file at
19
 * nbbuild/licenses/CDDL-GPL-2-CP.  Oracle designates this
20
 * particular file as subject to the "Classpath" exception as provided
21
 * by Oracle in the GPL Version 2 section of the License file that
22
 * accompanied this code. If applicable, add the following below the
23
 * License Header, with the fields enclosed by brackets [] replaced by
24
 * your own identifying information:
25
 * "Portions Copyrighted [year] [name of copyright owner]"
26
 *
27
 * If you wish your version of this file to be governed by only the CDDL
28
 * or only the GPL Version 2, indicate your decision by adding
29
 * "[Contributor] elects to include this software in this distribution
30
 * under the [CDDL or GPL Version 2] license." If you do not indicate a
31
 * single choice of license, a recipient has the option to distribute
32
 * your version of this file under either the CDDL, the GPL Version 2 or
33
 * to extend the choice of license to its licensees as provided above.
34
 * However, if you add GPL Version 2 code and therefore, elected the GPL
35
 * Version 2 license, then the option applies only if the new code is
36
 * made subject to such option by the copyright holder.
37
 *
38
 * Contributor(s):
39
 *
40
 * Portions Copyrighted 2015 Sun Microsystems, Inc.
41
 */
42
package org.netbeans.modules.editor.mimelookup;
43
44
import org.netbeans.api.editor.mimelookup.MimePath;
45
import org.openide.util.Lookup;
46
47
/**
48
 *
49
 * @author sdedic
50
 */
51
public abstract class APIAccessor {
52
    private static APIAccessor INSTANCE;
53
    
54
    @SuppressWarnings("LeakingThisInConstructor")
55
    protected APIAccessor() {
56
        if (INSTANCE != null) {
57
            throw new IllegalStateException();
58
        }
59
        INSTANCE = this;
60
    }
61
    
62
    public static APIAccessor get() {
63
        return INSTANCE;
64
    }
65
    
66
    public abstract Lookup cacheMimeLookup(MimePath path);
67
}
(-)a/editor.mimelookup/src/org/netbeans/modules/editor/mimelookup/MimeLookupCacheSPI.java (+67 lines)
Line 0 Link Here
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
4
 * Copyright 2015 Oracle and/or its affiliates. All rights reserved.
5
 *
6
 * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
7
 * Other names may be trademarks of their respective owners.
8
 *
9
 * The contents of this file are subject to the terms of either the GNU
10
 * General Public License Version 2 only ("GPL") or the Common
11
 * Development and Distribution License("CDDL") (collectively, the
12
 * "License"). You may not use this file except in compliance with the
13
 * License. You can obtain a copy of the License at
14
 * http://www.netbeans.org/cddl-gplv2.html
15
 * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
16
 * specific language governing permissions and limitations under the
17
 * License.  When distributing the software, include this License Header
18
 * Notice in each file and include the License file at
19
 * nbbuild/licenses/CDDL-GPL-2-CP.  Oracle designates this
20
 * particular file as subject to the "Classpath" exception as provided
21
 * by Oracle in the GPL Version 2 section of the License file that
22
 * accompanied this code. If applicable, add the following below the
23
 * License Header, with the fields enclosed by brackets [] replaced by
24
 * your own identifying information:
25
 * "Portions Copyrighted [year] [name of copyright owner]"
26
 *
27
 * If you wish your version of this file to be governed by only the CDDL
28
 * or only the GPL Version 2, indicate your decision by adding
29
 * "[Contributor] elects to include this software in this distribution
30
 * under the [CDDL or GPL Version 2] license." If you do not indicate a
31
 * single choice of license, a recipient has the option to distribute
32
 * your version of this file under either the CDDL, the GPL Version 2 or
33
 * to extend the choice of license to its licensees as provided above.
34
 * However, if you add GPL Version 2 code and therefore, elected the GPL
35
 * Version 2 license, then the option applies only if the new code is
36
 * made subject to such option by the copyright holder.
37
 *
38
 * Contributor(s):
39
 *
40
 * Portions Copyrighted 2015 Sun Microsystems, Inc.
41
 */
42
package org.netbeans.modules.editor.mimelookup;
43
44
import org.netbeans.api.editor.mimelookup.MimePath;
45
import org.openide.util.Lookup;
46
47
/**
48
 * Caching of MimeLookups. Since MimePath is a global object, it cannot cache potentially
49
 * execution-specific data, such as the concrete MimeLookup. Instead, the MimePath looks up
50
 * the intrinsic data in the cache, which can be potentially execution-specific.
51
 * <p/>
52
 * MimePath obtains the MimeLookupCacheSPI from the default Lookup supposing that if some
53
 * local execution context is active, the infrastructure placed a separate MimeLookupCacheSPI
54
 * implementation into it.
55
 * <p/>
56
 * @author sdedic
57
 */
58
public abstract class MimeLookupCacheSPI {
59
    /**
60
     * Obtains a MIME-specific Lookup from the cache. If the Lookup does not exist,
61
     * it is created. The cache implementor is responsible for synchronization, only one
62
     * Lookup instance can be returned from the cache for the given execution context and MimePath.
63
     * @param mp MimePath to select the Lookup contents
64
     * @return Lookup instance
65
     */
66
    public abstract Lookup   getLookup(MimePath mp);
67
}
(-)a/editor.mimelookup/src/org/netbeans/modules/editor/mimelookup/SharedMimeLookupCache.java (+64 lines)
Line 0 Link Here
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
4
 * Copyright 2015 Oracle and/or its affiliates. All rights reserved.
5
 *
6
 * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
7
 * Other names may be trademarks of their respective owners.
8
 *
9
 * The contents of this file are subject to the terms of either the GNU
10
 * General Public License Version 2 only ("GPL") or the Common
11
 * Development and Distribution License("CDDL") (collectively, the
12
 * "License"). You may not use this file except in compliance with the
13
 * License. You can obtain a copy of the License at
14
 * http://www.netbeans.org/cddl-gplv2.html
15
 * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
16
 * specific language governing permissions and limitations under the
17
 * License.  When distributing the software, include this License Header
18
 * Notice in each file and include the License file at
19
 * nbbuild/licenses/CDDL-GPL-2-CP.  Oracle designates this
20
 * particular file as subject to the "Classpath" exception as provided
21
 * by Oracle in the GPL Version 2 section of the License file that
22
 * accompanied this code. If applicable, add the following below the
23
 * License Header, with the fields enclosed by brackets [] replaced by
24
 * your own identifying information:
25
 * "Portions Copyrighted [year] [name of copyright owner]"
26
 *
27
 * If you wish your version of this file to be governed by only the CDDL
28
 * or only the GPL Version 2, indicate your decision by adding
29
 * "[Contributor] elects to include this software in this distribution
30
 * under the [CDDL or GPL Version 2] license." If you do not indicate a
31
 * single choice of license, a recipient has the option to distribute
32
 * your version of this file under either the CDDL, the GPL Version 2 or
33
 * to extend the choice of license to its licensees as provided above.
34
 * However, if you add GPL Version 2 code and therefore, elected the GPL
35
 * Version 2 license, then the option applies only if the new code is
36
 * made subject to such option by the copyright holder.
37
 *
38
 * Contributor(s):
39
 *
40
 * Portions Copyrighted 2015 Sun Microsystems, Inc.
41
 */
42
package org.netbeans.modules.editor.mimelookup;
43
44
import org.netbeans.api.editor.mimelookup.MimePath;
45
import org.openide.util.Lookup;
46
import org.openide.util.lookup.ServiceProvider;
47
48
/**
49
 * The default cache for MIME Lookups for single-context environment.
50
 * This defaut implementation caches MimeLookup directly in MimePath field
51
 * so Lookup contents live at least as long as the reference to the MimePath,
52
 * but are not prevented from GC after the MimePath is released.
53
 * 
54
 * @author sdedic
55
 */
56
@ServiceProvider(service = MimeLookupCacheSPI.class)
57
public final class SharedMimeLookupCache extends MimeLookupCacheSPI {
58
59
    @Override
60
    public synchronized Lookup getLookup(MimePath mp) {
61
        return APIAccessor.get().cacheMimeLookup(mp);
62
    }
63
    
64
}

Return to bug 250865