/** * 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); }
/** * 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); }