本文整理汇总了Java中org.springframework.cloud.CloudFactory.getCloud方法的典型用法代码示例。如果您正苦于以下问题:Java CloudFactory.getCloud方法的具体用法?Java CloudFactory.getCloud怎么用?Java CloudFactory.getCloud使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.springframework.cloud.CloudFactory
的用法示例。
在下文中一共展示了CloudFactory.getCloud方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getMatchOutcome
import org.springframework.cloud.CloudFactory; //导入方法依赖的package包/类
@Override
public ConditionOutcome getMatchOutcome(ConditionContext context,
AnnotatedTypeMetadata metadata) {
CloudFactory cloudFactory = new CloudFactory();
try {
Cloud cloud = cloudFactory.getCloud();
List<ServiceInfo> serviceInfos = cloud.getServiceInfos();
for (ServiceInfo serviceInfo : serviceInfos) {
if (serviceInfo instanceof VaultServiceInfo) {
return ConditionOutcome.match(String.format(
"Found Vault service %s", serviceInfo.getId()));
}
}
return ConditionOutcome.noMatch("No Vault service found");
}
catch (CloudException e) {
return ConditionOutcome.noMatch("Not running in a Cloud");
}
}
开发者ID:pivotal-cf,项目名称:spring-cloud-vault-connector,代码行数:23,代码来源:VaultConnectorBootstrapConfiguration.java
示例2: main
import org.springframework.cloud.CloudFactory; //导入方法依赖的package包/类
public static void main(String[] args) {
CloudFactory cloudFactory = new CloudFactory();
Cloud cloud = cloudFactory.getCloud();
GemfireServiceInfo myService = (GemfireServiceInfo) cloud.getServiceInfo("service0");
Properties props = new Properties();
props.setProperty("security-client-auth-init", "io.pivotal.ClientAuthInitialize.create");
ClientCacheFactory ccf = new ClientCacheFactory(props);
URI[] locators = myService.getLocators();
for (URI locator : locators) {
ccf.addPoolLocator(locator.getHost(), locator.getPort());
}
ClientCache client = ccf.create();
Region r = client.createClientRegionFactory(ClientRegionShortcut.PROXY).create("test");
r.put("1", "one");
if (!r.get("1").equals("one")) {
throw new RuntimeException("Expected value to be \"one\", but was:"+r.get("1"));
}
try {
Thread.sleep(Long.MAX_VALUE);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
示例3: getGemfireClientCache
import org.springframework.cloud.CloudFactory; //导入方法依赖的package包/类
@Bean(name = "my-client-cache")
public ClientCache getGemfireClientCache() {
CloudFactory cloudFactory = new CloudFactory();
// Obtain the Cloud object for the environment in which the application is running.
// Note that you must have a CloudConnector suitable for your deployment environment on your classpath.
// For example, if you are deploying the application to Cloud Foundry, you must add the Cloud Foundry
// Connector to your classpath. If no suitable CloudConnector is found, the getCloud() method will throw
// a CloudException. Use the Cloud instance to access application and service information and to create
// service connectors.
Cloud cloud = cloudFactory.getCloud();
// Let Spring Cloud create a service connector for you.
ClientCache cache = cloud.getServiceConnector("service0", ClientCache.class,
createGemfireConnectorConfig());
return cache;
}
示例4: rabbitConnectionFactory
import org.springframework.cloud.CloudFactory; //导入方法依赖的package包/类
@Bean(name="rabbitMQConnectionFactory")
public ConnectionFactory rabbitConnectionFactory() {
CloudFactory cloudFactory = new CloudFactory();
Cloud cloud = cloudFactory.getCloud();
AmqpServiceInfo amqpServiceInfo = (AmqpServiceInfo) cloud.getServiceInfo("activationAmqpBroker");
String serviceID = amqpServiceInfo.getId();
ConnectionFactory connectionFactory = cloud.getServiceConnector(serviceID, ConnectionFactory.class, null);
try{
LOGGER.info("Setting CachingConnectionFactory specific properties");
((CachingConnectionFactory)connectionFactory).setChannelCacheSize(channelCacheSize);
((CachingConnectionFactory)connectionFactory).setRequestedHeartBeat(requestedHeartbeat);
((CachingConnectionFactory)connectionFactory).setConnectionTimeout(connectionTimeout);
} catch (ClassCastException cce){
throw new TechnicalException("Cannot customize CachingConnectionFactory for rabbitConnectionFactory");
}
return connectionFactory;
}
示例5: afterPropertiesSet
import org.springframework.cloud.CloudFactory; //导入方法依赖的package包/类
@Override
public void afterPropertiesSet() throws Exception {
ConfigurableListableBeanFactory beanFactory = (ConfigurableListableBeanFactory) getBeanFactory();
if (cloud == null) {
if (beanFactory.getBeansOfType(CloudFactory.class).isEmpty()) {
beanFactory.registerSingleton(CLOUD_FACTORY_BEAN_NAME, new CloudFactory());
}
CloudFactory cloudFactory = beanFactory.getBeansOfType(CloudFactory.class).values().iterator().next();
cloud = cloudFactory.getCloud();
}
if (!StringUtils.hasText(serviceId)) {
List<? extends ServiceInfo> infos = cloud.getServiceInfos(serviceConnectorType);
if (infos.size() != 1) {
throw new CloudException("Expected 1 service matching " + serviceConnectorType.getName() + " type, but found "
+ infos.size());
}
serviceId = infos.get(0).getId();
}
super.afterPropertiesSet();
}
开发者ID:spring-cloud,项目名称:spring-cloud-connectors,代码行数:23,代码来源:AbstractCloudServiceConnectorFactory.java
示例6: VaultConnectorBootstrapConfiguration
import org.springframework.cloud.CloudFactory; //导入方法依赖的package包/类
public VaultConnectorBootstrapConfiguration(
VaultConnectorGenericBackendProperties connectorVaultProperties,
VaultGenericBackendProperties genericBackendProperties,
Environment environment) {
this.connectorVaultProperties = connectorVaultProperties;
this.genericBackendProperties = genericBackendProperties;
this.environment = environment;
Cloud cloud;
VaultServiceInfo vaultServiceInfo = null;
try {
CloudFactory cloudFactory = new CloudFactory();
cloud = cloudFactory.getCloud();
List<ServiceInfo> serviceInfos = cloud.getServiceInfos(VaultOperations.class);
if (serviceInfos.size() == 1) {
vaultServiceInfo = (VaultServiceInfo) serviceInfos.get(0);
}
}
catch (CloudException e) {
// not running in a Cloud environment
}
this.vaultServiceInfo = vaultServiceInfo;
}
开发者ID:pivotal-cf,项目名称:spring-cloud-vault-connector,代码行数:28,代码来源:VaultConnectorBootstrapConfiguration.java
示例7: getFileServiceStorageLocation
import org.springframework.cloud.CloudFactory; //导入方法依赖的package包/类
private String getFileServiceStorageLocation(String serviceName) {
try {
if (serviceName != null && !serviceName.isEmpty()) {
CloudFactory cloudFactory = new CloudFactory();
Cloud cloud = cloudFactory.getCloud();
FileSystemServiceInfo serviceInfo = (FileSystemServiceInfo) cloud.getServiceInfo(serviceName);
return serviceInfo.getStoragePath();
}
} catch (CloudException e) {
LOGGER.debug("Persistent Shared File System Service detection failed", e);
}
return null;
}
示例8: cloudRedisConnectionFactory
import org.springframework.cloud.CloudFactory; //导入方法依赖的package包/类
@Profile(GitHubClaProfiles.CLOUDFOUNDRY)
@Bean
public RedisConnectionFactory cloudRedisConnectionFactory() {
CloudFactory cloudFactory = new CloudFactory();
Cloud cloud = cloudFactory.getCloud();
RedisConnectionFactory connectionFactory = cloud.getSingletonServiceConnector(RedisConnectionFactory.class, null);
if(connectionFactory instanceof LettuceConnectionFactory){
((LettuceConnectionFactory) connectionFactory).setShutdownTimeout(0);
}
return connectionFactory;
}
示例9: getCloud
import org.springframework.cloud.CloudFactory; //导入方法依赖的package包/类
private Cloud getCloud() {
try {
CloudFactory cloudFactory = new CloudFactory();
return cloudFactory.getCloud();
} catch (CloudException e) {
return null;
}
}
示例10: getCloud
import org.springframework.cloud.CloudFactory; //导入方法依赖的package包/类
private Cloud getCloud() {
try {
CloudFactory cloudFactory = new CloudFactory();
return cloudFactory.getCloud();
} catch (CloudException ce) {
return null;
}
}
开发者ID:pivotalservices,项目名称:concourse-spring-music,代码行数:9,代码来源:SpringApplicationContextInitializer.java
示例11: cloud
import org.springframework.cloud.CloudFactory; //导入方法依赖的package包/类
@Bean
public Cloud cloud() {
try {
CloudFactory factory = new CloudFactory();
return factory.getCloud();
} catch (CloudException e) {
throw new CloudConnectorNotDefinedException("CloudConnector for cloud environment not found in classpath.", e);
}
}
示例12: getCloud
import org.springframework.cloud.CloudFactory; //导入方法依赖的package包/类
protected Cloud getCloud() {
try {
CloudFactory cloudFactory = new CloudFactory();
return cloudFactory.getCloud();
} catch (CloudException ce) {
return null;
}
}
示例13: afterPropertiesSet
import org.springframework.cloud.CloudFactory; //导入方法依赖的package包/类
@Override
public void afterPropertiesSet() throws Exception {
ConfigurableListableBeanFactory listableBeanFactory = (ConfigurableListableBeanFactory) beanFactory;
if (cloud == null) {
if(listableBeanFactory.getBeansOfType(CloudFactory.class).isEmpty()) {
listableBeanFactory.registerSingleton(CLOUD_FACTORY_BEAN_NAME , new CloudFactory());
}
CloudFactory cloudFactory = listableBeanFactory.getBeansOfType(CloudFactory.class).values().iterator().next();
cloud = cloudFactory.getCloud();
}
}
示例14: initializeCloud
import org.springframework.cloud.CloudFactory; //导入方法依赖的package包/类
private void initializeCloud(BeanDefinitionRegistry registry) {
if (cloud != null) {
return;
}
ConfigurableListableBeanFactory beanFactory = (ConfigurableListableBeanFactory) registry;
if(beanFactory.getBeansOfType(CloudFactory.class).isEmpty()) {
beanFactory.registerSingleton(CLOUD_FACTORY_BEAN_NAME, new CloudFactory());
}
CloudFactory cloudFactory = beanFactory.getBeansOfType(CloudFactory.class).values().iterator().next();
cloud = cloudFactory.getCloud();
}
示例15: init
import org.springframework.cloud.CloudFactory; //导入方法依赖的package包/类
@PostConstruct
public void init() {
// Connect to Solace
trace.info("************* Init Called ************");
trace.info(System.getenv("VCAP_SERVICES"));
CloudFactory cloudFactory = new CloudFactory();
Cloud cloud = cloudFactory.getCloud();
SolaceMessagingInfo solaceMessagingServiceInfo =
(SolaceMessagingInfo) cloud.getServiceInfo("solace-messaging-demo-instance");
if (solaceMessagingServiceInfo == null) {
trace.error("Did not find instance of 'solace-messaging' service");
trace.error("************* Aborting Solace initialization!! ************");
return;
}
trace.info("Solace client initializing and using SolaceMessagingInfo: " + solaceMessagingServiceInfo);
final JCSMPProperties properties = new JCSMPProperties();
properties.setProperty(JCSMPProperties.HOST, solaceMessagingServiceInfo.getSmfHost());
properties.setProperty(JCSMPProperties.VPN_NAME, solaceMessagingServiceInfo.getMsgVpnName());
properties.setProperty(JCSMPProperties.USERNAME, solaceMessagingServiceInfo.getClientUsername());
properties.setProperty(JCSMPProperties.PASSWORD, solaceMessagingServiceInfo.getClientPassword());
try {
session = JCSMPFactory.onlyInstance().createSession(properties);
session.connect();
clientName = (String)session.getProperty(JCSMPProperties.CLIENT_NAME);
final Queue queue = JCSMPFactory.onlyInstance().createQueue("Q/demo/requests");
// set queue permissions to "consume" and access-type to "exclusive"
final EndpointProperties endpointProps = new EndpointProperties();
endpointProps.setPermission(EndpointProperties.PERMISSION_CONSUME);
endpointProps.setAccessType(EndpointProperties.ACCESSTYPE_NONEXCLUSIVE);
// Actually provision it, and do not fail if it already exists
session.provision(queue, endpointProps, JCSMPSession.FLAG_IGNORE_ALREADY_EXISTS);
producer = session.getMessageProducer(new PublisherEventHandler());
final ConsumerFlowProperties flowProp = new ConsumerFlowProperties();
flowProp.setEndpoint(queue);
flowProp.setAckMode(JCSMPProperties.SUPPORTED_MESSAGE_ACK_CLIENT);
final FlowReceiver cons = session.createFlow(new DemoMessageListener(), flowProp, endpointProps);
cons.start();
System.out.println("************* Solace initialized correctly!! ************");
} catch (Exception e) {
Trace.error("Error connecting and setting up session.", e);
}
}