/** * Get the {@link Cluster} object associated with the only Cassandra service bound to * the app. * * @return the Cassandra {@link Cluster} * @throws org.springframework.cloud.CloudException if there are either 0 or more than * 1 Cassandra database services. */ @Override public Cluster cluster() { return cluster((CassandraClusterConfig) null); }
/** * Get the {@link DataSource} object associated with the only relational database service bound to the app. * * This is equivalent to the {@code <cloud:data-source/>} element. * * @return data source * @throws CloudException * if there are either 0 or more than 1 relational database services. */ @Override public DataSource dataSource() { return dataSource((DataSourceConfig) null); }
/** * Get the {@link MongoDbFactory} object associated with the only MongoDB service bound to the app. * * This is equivalent to the {@code <cloud:mongo-db-factory/>} element. * * @return mongo db factory * @throws CloudException * if there are either 0 or more than 1 mongodb services. */ @Override public MongoDbFactory mongoDbFactory() { return mongoDbFactory((MongoDbFactoryConfig) null); }
/** * Get the service connector object associated with the only service bound to the app. * * This is equivalent to the {@code <cloud:service/>} element. * * @return service connector object * @throws CloudException * if there are either 0 or more than 1 services. */ @Override public Object service() { return service(Object.class); }
/** * Get the {@link ConnectionFactory} object associated with the only RabbitMQ service bound to the app. * * This is equivalent to the {@code <cloud:rabbit-connection-factory>} element. * * @return rabbit connection factory * @throws CloudException * if there are either 0 or more than 1 RabbitMQ services. */ @Override public ConnectionFactory rabbitConnectionFactory() { return rabbitConnectionFactory((RabbitConnectionFactoryConfig) null); }
/** * Get the {@link RedisConnectionFactory} object associated with the only Redis service bound to the app. * * This is equivalent to the {@code <cloud:redis-connection-factory/>} element * * @return redis connection factory * @throws CloudException * if there are either 0 or more than 1 redis services. */ @Override public RedisConnectionFactory redisConnectionFactory() { return redisConnectionFactory((PooledServiceConnectorConfig) null); }
/** * Implementation note: This roundabout way of implementation is required to ensure that * a {@link CloudFactory} bean if created in some other configuration is available, we should use * that. */ @Override public void setBeanFactory(BeanFactory beanFactory) throws BeansException { if (cloudFactory == null) { try { cloudFactory = beanFactory.getBean(CloudFactory.class); } catch (NoSuchBeanDefinitionException ex) { cloudFactory = new CloudFactory(); ((SingletonBeanRegistry) beanFactory).registerSingleton(CLOUD_FACTORY_BEAN_NAME, cloudFactory); } } this.cloud = cloudFactory.getCloud(); this.connectionFactory = new CloudServiceConnectionFactory(cloud); }
/** * Get the service connector object associated with the only service bound to the app. * * This is equivalent to the {@code <cloud:service/>} element. * * @return service connector object * @throws CloudException * if there are either 0 or more than 1 services. */ @Override public Object service() { return service(Object.class); }
/** * Get the {@link ConnectionFactory} object associated with the only RabbitMQ service bound to the app. * * This is equivalent to the {@code <cloud:rabbit-connection-factory>} element. * * @return rabbit connection factory * @throws CloudException * if there are either 0 or more than 1 RabbitMQ services. */ @Override public ConnectionFactory rabbitConnectionFactory() { return rabbitConnectionFactory((RabbitConnectionFactoryConfig) null); }
/** * Get the {@link RedisConnectionFactory} object associated with the only Redis service bound to the app. * * This is equivalent to the {@code <cloud:redis-connection-factory/>} element * * @return redis connection factory * @throws CloudException * if there are either 0 or more than 1 redis services. */ @Override public RedisConnectionFactory redisConnectionFactory() { return redisConnectionFactory((PooledServiceConnectorConfig) null); }
/** * Implementation note: This roundabout way of implementation is required to ensure that * a {@link CloudFactory} bean if created in some other configuration is available, we should use * that. */ @Override public void setBeanFactory(BeanFactory beanFactory) throws BeansException { if (cloudFactory == null) { try { cloudFactory = beanFactory.getBean(CloudFactory.class); } catch (NoSuchBeanDefinitionException ex) { cloudFactory = new CloudFactory(); ((SingletonBeanRegistry) beanFactory).registerSingleton(CLOUD_FACTORY_BEAN_NAME, cloudFactory); } } this.cloud = cloudFactory.getCloud(); this.connectionFactory = new CloudServiceConnectionFactory(cloud); }
/** * Get the {@link Cluster} object associated with the only Cassandra service bound to * the app. * * @return the Cassandra {@link Cluster} * @throws org.springframework.cloud.CloudException if there are either 0 or more than * 1 Cassandra database services. */ @Override public Cluster cluster() { return cluster((CassandraClusterConfig) null); }
/** * Get the {@link DataSource} object associated with the only relational database service bound to the app. * * This is equivalent to the {@code <cloud:data-source/>} element. * * @return data source * @throws CloudException * if there are either 0 or more than 1 relational database services. */ @Override public DataSource dataSource() { return dataSource((DataSourceConfig) null); }
/** * Get the {@link MongoDbFactory} object associated with the only MongoDB service bound to the app. * * This is equivalent to the {@code <cloud:mongo-db-factory/>} element. * * @return mongo db factory * @throws CloudException * if there are either 0 or more than 1 mongodb services. */ @Override public MongoDbFactory mongoDbFactory() { return mongoDbFactory((MongoDbFactoryConfig) null); }
/** * Get the service connector object for the specified service. * * This is equivalent to the {@code <cloud:service service-id="serviceId"/>} element. * * @param serviceId * the service ID of the service to be returned * @return service connector object * @throws CloudException * if the specified service doesn't exist */ @Override public Object service(String serviceId) { return service(serviceId, Object.class); }
/** * Get the {@link ConnectionFactory} object for the specified RabbitMQ service. * * This is equivalent to the {@code <cloud:rabbit-connection-factory service-id="serviceId">} element. * * @param serviceId * the name of the service * @return rabbit connection factory * @throws CloudException * if the specified service doesn't exist */ @Override public ConnectionFactory rabbitConnectionFactory(String serviceId) { return rabbitConnectionFactory(serviceId, null); }
/** * Get the {@link RedisConnectionFactory} object for the specified Redis service. * * This is equivalent to the {@code <cloud:redis-connection-factory service-id="serviceId">} element. * * @param serviceId * the name of the service * @return redis connection factory * @throws CloudException * if the specified service doesn't exist */ @Override public RedisConnectionFactory redisConnectionFactory(String serviceId) { return redisConnectionFactory(serviceId, null); }
/** * Get the {@link Cluster} object associated with the Cassandra {@code serviceId} * bound to the app. * * @param serviceId the Cassandra serviceId * @return the Cassandra {@link Cluster} * @throws org.springframework.cloud.CloudException if there is no service bound with * the {@code serviceId} */ @Override public Cluster cluster(String serviceId) { return cluster(serviceId, null); }
/** * Get the {@link DataSource} object for the specified relational database service. * * This is equivalent to the {@code <cloud:data-source service-id="serviceId"/>} * * @param serviceId * the name of the service * @return data source * @throws CloudException * if the specified service doesn't exist */ @Override public DataSource dataSource(String serviceId) { return dataSource(serviceId, null); }
/** * Get the {@link MongoDbFactory} object for the specified MongoDB service. * * This is equivalent to the {@code <cloud:mongo-db-factory service-id="serviceId">} element. * * @param serviceId * the name of the service * @return mongo db factory * @throws CloudException * if the specified service doesn't exist */ @Override public MongoDbFactory mongoDbFactory(String serviceId) { return mongoDbFactory(serviceId, null); }