com.sun.media.sound
public class: JDK13Services [javadoc |
source]
java.lang.Object
com.sun.media.sound.JDK13Services
JDK13Services uses the Service class in JDK 1.3
to discover a list of service providers installed
in the system.
This class is public because it is called from javax.sound.midi.MidiSystem
and javax.sound.sampled.AudioSystem. The alternative would be to make
JSSecurityManager public, which is considered worse.
- author:
Matthias
- Pfisterer
Methods from java.lang.Object: |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method from com.sun.media.sound.JDK13Services Detail: |
public static synchronized String getDefaultInstanceName(Class typeClass) {
String value = null;
String defaultProviderSpec = getDefaultProvider(typeClass);
if (defaultProviderSpec != null) {
int hashpos = defaultProviderSpec.indexOf('#');
if (hashpos >= 0 && hashpos < defaultProviderSpec.length() - 1) {
value = defaultProviderSpec.substring(hashpos + 1);
}
}
return value;
}
Obtain the instance name part of a default provider property. |
public static synchronized String getDefaultProviderClassName(Class typeClass) {
String value = null;
String defaultProviderSpec = getDefaultProvider(typeClass);
if (defaultProviderSpec != null) {
int hashpos = defaultProviderSpec.indexOf('#');
if (hashpos == 0) {
// instance name only; leave value as null
} else if (hashpos > 0) {
value = defaultProviderSpec.substring(0, hashpos);
} else {
value = defaultProviderSpec;
}
}
return value;
}
Obtain the provider class name part of a default provider property. |
public static synchronized List getProviders(Class serviceClass) {
ProviderCache cache = (ProviderCache) providersCacheMap.get(serviceClass);
if (cache == null) {
cache = new ProviderCache();
providersCacheMap.put(serviceClass, cache);
}
if (cache.providers == null ||
System.currentTimeMillis() > cache.lastUpdate + cachingPeriod) {
cache.providers = Collections.unmodifiableList(JSSecurityManager.getProviders(serviceClass));
cache.lastUpdate = System.currentTimeMillis();
}
return cache.providers;
}
Obtains a List containing installed instances of the
providers for the requested service.
The List of providers is cached for the period of time given by
cachingPeriod . During this period, the same
List instance is returned for the same type of provider. After this
period, a new instance is constructed and returned. The returned
List is immutable. |
public static void setCachingPeriod(int seconds) {
cachingPeriod = seconds * 1000L;
}
Set the period provider lists are cached.
This method is only intended for testing. |