本文整理汇总了Java中com.microsoft.windowsazure.core.DefaultBuilder类的典型用法代码示例。如果您正苦于以下问题:Java DefaultBuilder类的具体用法?Java DefaultBuilder怎么用?Java DefaultBuilder使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
DefaultBuilder类属于com.microsoft.windowsazure.core包,在下文中一共展示了DefaultBuilder类的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: AzureComputeServiceImpl
import com.microsoft.windowsazure.core.DefaultBuilder; //导入依赖的package包/类
public AzureComputeServiceImpl(Settings settings) {
super(settings);
String subscriptionId = getRequiredSetting(settings, Management.SUBSCRIPTION_ID_SETTING);
serviceName = getRequiredSetting(settings, Management.SERVICE_NAME_SETTING);
String keystorePath = getRequiredSetting(settings, Management.KEYSTORE_PATH_SETTING);
String keystorePassword = getRequiredSetting(settings, Management.KEYSTORE_PASSWORD_SETTING);
KeyStoreType keystoreType = Management.KEYSTORE_TYPE_SETTING.get(settings);
logger.trace("creating new Azure client for [{}], [{}]", subscriptionId, serviceName);
try {
// Azure SDK configuration uses DefaultBuilder which uses java.util.ServiceLoader to load the
// various Azure services. By default, this will use the current thread's context classloader
// to load services. Since the current thread refers to the main application classloader it
// won't find any Azure service implementation.
// Here we basically create a new DefaultBuilder that uses the current class classloader to load services.
DefaultBuilder builder = new DefaultBuilder();
for (Builder.Exports exports : ServiceLoader.load(Builder.Exports.class, getClass().getClassLoader())) {
exports.register(builder);
}
// And create a new blank configuration based on the previous DefaultBuilder
Configuration configuration = new Configuration(builder);
configuration.setProperty(Configuration.PROPERTY_LOG_HTTP_REQUESTS, logger.isTraceEnabled());
Configuration managementConfig = ManagementConfiguration.configure(null, configuration,
Management.ENDPOINT_SETTING.get(settings), subscriptionId, keystorePath, keystorePassword, keystoreType);
logger.debug("creating new Azure client for [{}], [{}]", subscriptionId, serviceName);
client = ComputeManagementService.create(managementConfig);
} catch (IOException e) {
throw new ElasticsearchException("Unable to configure Azure compute service", e);
}
}