jdk/src/share/classes/com/sun/media/sound/JDK13Services.java
author amenkov
Wed, 13 May 2009 14:32:14 +0400
changeset 3452 e18ac2718a06
parent 2 90ce3da70b43
child 5506 202f599c92aa
permissions -rw-r--r--
6738524: JDK13Services allows read access to system properties from untrusted code Reviewed-by: hawtin
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
3452
e18ac2718a06 6738524: JDK13Services allows read access to system properties from untrusted code
amenkov
parents: 2
diff changeset
     2
 * Copyright 1999-2009 Sun Microsystems, Inc.  All Rights Reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
90ce3da70b43 Initial load
duke
parents:
diff changeset
     7
 * published by the Free Software Foundation.  Sun designates this
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
90ce3da70b43 Initial load
duke
parents:
diff changeset
     9
 * by Sun in the LICENSE file that accompanied this code.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    21
 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    22
 * CA 95054 USA or visit www.sun.com if you need additional information or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    23
 * have any questions.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
package com.sun.media.sound;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
import java.util.Collections;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
import java.util.HashMap;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
import java.util.List;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
import java.util.Map;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
import java.util.Properties;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
import javax.sound.sampled.spi.AudioFileReader;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
import javax.sound.sampled.spi.AudioFileWriter;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
import javax.sound.sampled.spi.FormatConversionProvider;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
import javax.sound.sampled.spi.MixerProvider;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
import javax.sound.midi.spi.MidiFileReader;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
import javax.sound.midi.spi.MidiFileWriter;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
import javax.sound.midi.spi.SoundbankReader;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
import javax.sound.midi.spi.MidiDeviceProvider;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
3452
e18ac2718a06 6738524: JDK13Services allows read access to system properties from untrusted code
amenkov
parents: 2
diff changeset
    44
import javax.sound.midi.Receiver;
e18ac2718a06 6738524: JDK13Services allows read access to system properties from untrusted code
amenkov
parents: 2
diff changeset
    45
import javax.sound.midi.Sequencer;
e18ac2718a06 6738524: JDK13Services allows read access to system properties from untrusted code
amenkov
parents: 2
diff changeset
    46
import javax.sound.midi.Synthesizer;
e18ac2718a06 6738524: JDK13Services allows read access to system properties from untrusted code
amenkov
parents: 2
diff changeset
    47
import javax.sound.midi.Transmitter;
e18ac2718a06 6738524: JDK13Services allows read access to system properties from untrusted code
amenkov
parents: 2
diff changeset
    48
import javax.sound.sampled.Clip;
e18ac2718a06 6738524: JDK13Services allows read access to system properties from untrusted code
amenkov
parents: 2
diff changeset
    49
import javax.sound.sampled.Port;
e18ac2718a06 6738524: JDK13Services allows read access to system properties from untrusted code
amenkov
parents: 2
diff changeset
    50
import javax.sound.sampled.SourceDataLine;
e18ac2718a06 6738524: JDK13Services allows read access to system properties from untrusted code
amenkov
parents: 2
diff changeset
    51
import javax.sound.sampled.TargetDataLine;
e18ac2718a06 6738524: JDK13Services allows read access to system properties from untrusted code
amenkov
parents: 2
diff changeset
    52
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
 * JDK13Services uses the Service class in JDK 1.3
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
 * to discover a list of service providers installed
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
 * in the system.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
 * This class is public because it is called from javax.sound.midi.MidiSystem
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
 * and javax.sound.sampled.AudioSystem. The alternative would be to make
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
 * JSSecurityManager public, which is considered worse.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
 * @author Matthias Pfisterer
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
public class JDK13Services {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
    /** The default for the length of the period to hold the cache.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
        This value is given in milliseconds. It is equivalent to
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
        1 minute.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
    */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
    private static final long DEFAULT_CACHING_PERIOD = 60000;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
    /** Filename of the properties file for default provider properties.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
        This file is searched in the subdirectory "lib" of the JRE directory
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
        (this behaviour is hardcoded).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
    */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
    private static final String PROPERTIES_FILENAME = "sound.properties";
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
    /** Cache for the providers.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
        Class objects of the provider type (MixerProvider, MidiDeviceProvider
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
        ...) are used as keys. The values are instances of ProviderCache.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
    */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
    private static Map providersCacheMap = new HashMap();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
    /** The length of the period to hold the cache.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
        This value is given in milliseconds.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
    */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
    private static long cachingPeriod = DEFAULT_CACHING_PERIOD;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
    /** Properties loaded from the properties file for default provider
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
        properties.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
    */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
    private static Properties properties;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
    /** Private, no-args constructor to ensure against instantiation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
    private JDK13Services() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
    /** Set the period provider lists are cached.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
        This method is only intended for testing.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
    public static void setCachingPeriod(int seconds) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
        cachingPeriod = seconds * 1000L;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
    /** Obtains a List containing installed instances of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
        providers for the requested service.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
        The List of providers is cached for the period of time given by
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
        {@link #cachingPeriod cachingPeriod}. During this period, the same
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
        List instance is returned for the same type of provider. After this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
        period, a new instance is constructed and returned. The returned
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
        List is immutable.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
        @param serviceClass The type of providers requested. This should be one
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
        of AudioFileReader.class, AudioFileWriter.class,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
        FormatConversionProvider.class, MixerProvider.class,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
        MidiDeviceProvider.class, MidiFileReader.class, MidiFileWriter.class or
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
        SoundbankReader.class.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
        @return A List of providers of the requested type. This List is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
        immutable.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
    public static synchronized List getProviders(Class serviceClass) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
        ProviderCache cache = (ProviderCache) providersCacheMap.get(serviceClass);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
        if (cache == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
            cache = new ProviderCache();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
            providersCacheMap.put(serviceClass, cache);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
        if (cache.providers == null ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
            System.currentTimeMillis() > cache.lastUpdate + cachingPeriod) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
            cache.providers = Collections.unmodifiableList(JSSecurityManager.getProviders(serviceClass));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
            cache.lastUpdate = System.currentTimeMillis();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
        return cache.providers;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
    /** Obtain the provider class name part of a default provider property.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
        @param typeClass The type of the default provider property. This
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
        should be one of Receiver.class, Transmitter.class, Sequencer.class,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
        Synthesizer.class, SourceDataLine.class, TargetDataLine.class,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
        Clip.class or Port.class.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
        @return The value of the provider class name part of the property
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
        (the part before the hash sign), if available. If the property is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
        not set or the value has no provider class name part, null is returned.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
    public static synchronized String getDefaultProviderClassName(Class typeClass) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
        String value = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
        String defaultProviderSpec = getDefaultProvider(typeClass);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
        if (defaultProviderSpec != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
            int hashpos = defaultProviderSpec.indexOf('#');
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
            if (hashpos == 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
                // instance name only; leave value as null
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
            } else if (hashpos > 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
                value = defaultProviderSpec.substring(0, hashpos);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
                value = defaultProviderSpec;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
        return value;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
    /** Obtain the instance name part of a default provider property.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
        @param typeClass The type of the default provider property. This
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
        should be one of Receiver.class, Transmitter.class, Sequencer.class,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
        Synthesizer.class, SourceDataLine.class, TargetDataLine.class,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
        Clip.class or Port.class.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
        @return The value of the instance name part of the property (the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
        part after the hash sign), if available. If the property is not set
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
        or the value has no instance name part, null is returned.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
    public static synchronized String getDefaultInstanceName(Class typeClass) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
        String value = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
        String defaultProviderSpec = getDefaultProvider(typeClass);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
        if (defaultProviderSpec != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
            int hashpos = defaultProviderSpec.indexOf('#');
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
            if (hashpos >= 0 && hashpos < defaultProviderSpec.length() - 1) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
                value = defaultProviderSpec.substring(hashpos + 1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
        return value;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
    /** Obtain the value of a default provider property.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
        @param typeClass The type of the default provider property. This
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
        should be one of Receiver.class, Transmitter.class, Sequencer.class,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
        Synthesizer.class, SourceDataLine.class, TargetDataLine.class,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
        Clip.class or Port.class.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
        @return The complete value of the property, if available.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
        If the property is not set, null is returned.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
    private static synchronized String getDefaultProvider(Class typeClass) {
3452
e18ac2718a06 6738524: JDK13Services allows read access to system properties from untrusted code
amenkov
parents: 2
diff changeset
   198
        if (!SourceDataLine.class.equals(typeClass)
e18ac2718a06 6738524: JDK13Services allows read access to system properties from untrusted code
amenkov
parents: 2
diff changeset
   199
                && !TargetDataLine.class.equals(typeClass)
e18ac2718a06 6738524: JDK13Services allows read access to system properties from untrusted code
amenkov
parents: 2
diff changeset
   200
                && !Clip.class.equals(typeClass)
e18ac2718a06 6738524: JDK13Services allows read access to system properties from untrusted code
amenkov
parents: 2
diff changeset
   201
                && !Port.class.equals(typeClass)
e18ac2718a06 6738524: JDK13Services allows read access to system properties from untrusted code
amenkov
parents: 2
diff changeset
   202
                && !Receiver.class.equals(typeClass)
e18ac2718a06 6738524: JDK13Services allows read access to system properties from untrusted code
amenkov
parents: 2
diff changeset
   203
                && !Transmitter.class.equals(typeClass)
e18ac2718a06 6738524: JDK13Services allows read access to system properties from untrusted code
amenkov
parents: 2
diff changeset
   204
                && !Synthesizer.class.equals(typeClass)
e18ac2718a06 6738524: JDK13Services allows read access to system properties from untrusted code
amenkov
parents: 2
diff changeset
   205
                && !Sequencer.class.equals(typeClass)) {
e18ac2718a06 6738524: JDK13Services allows read access to system properties from untrusted code
amenkov
parents: 2
diff changeset
   206
            return null;
e18ac2718a06 6738524: JDK13Services allows read access to system properties from untrusted code
amenkov
parents: 2
diff changeset
   207
        }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
        String value;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
        String propertyName = typeClass.getName();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
        value = JSSecurityManager.getProperty(propertyName);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
        if (value == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
            value = getProperties().getProperty(propertyName);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
        if ("".equals(value)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
            value = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
        return value;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
    /** Obtain a properties bundle containing property values from the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
        properties file. If the properties file could not be loaded,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
        the properties bundle is empty.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
    */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
    private static synchronized Properties getProperties() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
        if (properties == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
            properties = new Properties();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
            JSSecurityManager.loadProperties(properties, PROPERTIES_FILENAME);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
        return properties;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
    // INNER CLASSES
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
    private static class ProviderCache {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
        // System time of the last update in milliseconds.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
        public long lastUpdate;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
        // The providers.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
        public List providers;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
}