* @param defaultVersion the service version expected by this client library.
*/
protected static Version initServiceVersion(
Class<? extends Service> serviceClass, Version defaultVersion) {
VersionRegistry versionRegistry = VersionRegistry.ensureRegistry();
Version v = null;
try {
// Check to see if default has already been defined
v = versionRegistry.getVersion(serviceClass);
} catch (IllegalStateException ise) {
// If not, use system property override or provided default version
try {
v = VersionRegistry.getVersionFromProperty(serviceClass);
} catch (SecurityException e) {
// Ignore exception, and just take default.
}
if (v == null) {
v = defaultVersion;
}
// Do not include any implied versions, which are defaulted separately
// by their own service static initialization.
versionRegistry.addDefaultVersion(v, false);
}
return v;
}