/** * Gets the data source bean from the application context statically. This is needed for static @Bean creation methods that won't have access to an * auto-wired data source. * * @return the data source. */ public static DataSource getHerdDataSource() { return (DataSource) ApplicationContextHolder.getApplicationContext().getBean(HERD_DATA_SOURCE_BEAN_NAME); }
/** * Determines whether Quartz tables need to be created which should return true for JUnits only. * * @return whether Quartz tables need to be created. */ private Boolean shouldCreateQuartzTables() { return (Boolean) ApplicationContextHolder.getApplicationContext().getBean(CREATE_QUARTZ_TABLES_BEAN_NAME); }
/** * Gets the data source bean from the application context statically. This is needed for static @Bean creation methods that won't have access to an * auto-wired data source. * * @return the data source. */ public static DataSource getHerdDataSource() { return (DataSource) ApplicationContextHolder.getApplicationContext().getBean(HERD_DATA_SOURCE_BEAN_NAME); }
/** * Gets the Activiti database schema update param from the application context statically. * * @return the Activiti database schema update param. */ private String getActivitiDbSchemaUpdateParamBeanName() { return (String) ApplicationContextHolder.getApplicationContext().getBean(ACTIVITI_DB_SCHEMA_UPDATE_PARAM_BEAN_NAME); }
/** * Gets the Hibernate HBM2DDL bean from the application context statically. * * @return the Hibernate HBM2DDL auto param. */ public String getHibernateHbm2DdlAutoParam() { return (String) ApplicationContextHolder.getApplicationContext().getBean(HIBERNATE_HBM2DDL_AUTO_PARAM_BEAN_NAME); }
/** * Gets the Activiti database schema update param from the application context statically. * * @return the Activiti database schema update param. */ private String getActivitiDbSchemaUpdateParamBeanName() { return (String) ApplicationContextHolder.getApplicationContext().getBean(ACTIVITI_DB_SCHEMA_UPDATE_PARAM_BEAN_NAME); }
/** * Gets the Hibernate HBM2DDL bean from the application context statically. * * @return the Hibernate HBM2DDL auto param. */ public String getHibernateHbm2DdlAutoParam() { return (String) ApplicationContextHolder.getApplicationContext().getBean(HIBERNATE_HBM2DDL_AUTO_PARAM_BEAN_NAME); }
/** * Determines whether Quartz tables need to be created which should return true for JUnits only. * * @return whether Quartz tables need to be created. */ private Boolean shouldCreateQuartzTables() { return (Boolean) ApplicationContextHolder.getApplicationContext().getBean(CREATE_QUARTZ_TABLES_BEAN_NAME); }
/** * Retrieves functional points that have no roles mapped to them. * * @return set of {@link GrantedAuthority} representing functional points */ public Set<GrantedAuthority> getUnrestrictedFunctions() { // TODO Getting HerdDao from applicationContext statically because if we try to wire HerdDao here it does not get constructed with proxy class that is // needed for @Cacheable methods to work. SecurityFunctionDao securityFunctionDao = ApplicationContextHolder.getApplicationContext().getBean(SecurityFunctionDao.class); Set<GrantedAuthority> authorities = new HashSet<>(); // Add all unrestricted functional points. for (String function : securityFunctionDao.getUnrestrictedSecurityFunctions()) { authorities.add(new SimpleGrantedAuthority(function)); } return authorities; }
SecurityFunctionDao securityFunctionDao = ApplicationContextHolder.getApplicationContext().getBean(SecurityFunctionDao.class);
/** * The data source for the application. * * @return the data source. */ @Bean public static DataSource herdDataSource() { // Access the environment using the application context holder since we're in a static method that doesn't have access to the environment in any // other way. Environment environment = ApplicationContextHolder.getApplicationContext().getEnvironment(); // Get the configuration property for the data source JNDI name. String dataSourceJndiName = ConfigurationHelper.getProperty(ConfigurationValue.HERD_DATA_SOURCE_JNDI_NAME, environment); // Return a new JNDI data source. return new JndiDataSourceLookup().getDataSource(dataSourceJndiName); }
/** * The data source for the application. * * @return the data source. */ @Bean public static DataSource herdDataSource() { // Access the environment using the application context holder since we're in a static method that doesn't have access to the environment in any // other way. Environment environment = ApplicationContextHolder.getApplicationContext().getEnvironment(); // Get the configuration property for the data source JNDI name. String dataSourceJndiName = ConfigurationHelper.getProperty(ConfigurationValue.HERD_DATA_SOURCE_JNDI_NAME, environment); // Return a new JNDI data source. return new JndiDataSourceLookup().getDataSource(dataSourceJndiName); }
JmsListenerEndpointRegistry registry = ApplicationContextHolder.getApplicationContext() .getBean("org.springframework.jms.config.internalJmsListenerEndpointRegistry", JmsListenerEndpointRegistry.class);
JmsListenerEndpointRegistry registry = ApplicationContextHolder.getApplicationContext() .getBean("org.springframework.jms.config.internalJmsListenerEndpointRegistry", JmsListenerEndpointRegistry.class);
/** * The database supplied property sources placeholder configurer that allows access to externalized properties from a database. This method also adds a new * property source that contains the database properties to the environment. * * @return the property sources placeholder configurer. */ @Bean public static PropertySourcesPlaceholderConfigurer databasePropertySourcesPlaceholderConfigurer() { // Get the configurable environment and add a new property source to it that contains the database properties. // That way, the properties can be accessed via the environment or via an injected @Value annotation. // We are adding this property source last so other property sources (e.g. system properties, environment variables) can be used // to override the database properties. Environment environment = ApplicationContextHolder.getApplicationContext().getEnvironment(); if (environment instanceof ConfigurableEnvironment) { ConfigurableEnvironment configurableEnvironment = (ConfigurableEnvironment) environment; ReloadablePropertySource reloadablePropertySource = new ReloadablePropertySource(ReloadablePropertySource.class.getName(), ConfigurationConverter.getProperties(getPropertyDatabaseConfiguration()), getPropertyDatabaseConfiguration()); configurableEnvironment.getPropertySources().addLast(reloadablePropertySource); } return new PropertySourcesPlaceholderConfigurer(); }
/** * The database supplied property sources placeholder configurer that allows access to externalized properties from a database. This method also adds a new * property source that contains the database properties to the environment. * * @return the property sources placeholder configurer. */ @Bean public static PropertySourcesPlaceholderConfigurer databasePropertySourcesPlaceholderConfigurer() { // Get the configurable environment and add a new property source to it that contains the database properties. // That way, the properties can be accessed via the environment or via an injected @Value annotation. // We are adding this property source last so other property sources (e.g. system properties, environment variables) can be used // to override the database properties. Environment environment = ApplicationContextHolder.getApplicationContext().getEnvironment(); if (environment instanceof ConfigurableEnvironment) { ConfigurableEnvironment configurableEnvironment = (ConfigurableEnvironment) environment; ReloadablePropertySource reloadablePropertySource = new ReloadablePropertySource(ReloadablePropertySource.class.getName(), ConfigurationConverter.getProperties(getPropertyDatabaseConfiguration()), getPropertyDatabaseConfiguration()); configurableEnvironment.getPropertySources().addLast(reloadablePropertySource); } return new PropertySourcesPlaceholderConfigurer(); }
JmsListenerEndpointRegistry registry = ApplicationContextHolder.getApplicationContext() .getBean("org.springframework.jms.config.internalJmsListenerEndpointRegistry", JmsListenerEndpointRegistry.class); when(registry.getListenerContainer(HerdJmsDestinationResolver.SQS_DESTINATION_STORAGE_POLICY_SELECTOR_JOB_SQS_QUEUE))
JmsListenerEndpointRegistry registry = ApplicationContextHolder.getApplicationContext() .getBean("org.springframework.jms.config.internalJmsListenerEndpointRegistry", JmsListenerEndpointRegistry.class); when(registry.getListenerContainer(HerdJmsDestinationResolver.SQS_DESTINATION_SEARCH_INDEX_UPDATE_QUEUE)).thenReturn(mockMessageListenerContainer);
JmsListenerEndpointRegistry registry = ApplicationContextHolder.getApplicationContext() .getBean("org.springframework.jms.config.internalJmsListenerEndpointRegistry", JmsListenerEndpointRegistry.class); when(registry.getListenerContainer(HerdJmsDestinationResolver.SQS_DESTINATION_HERD_INCOMING)).thenReturn(mockMessageListenerContainer);
JmsListenerEndpointRegistry registry = ApplicationContextHolder.getApplicationContext() .getBean("org.springframework.jms.config.internalJmsListenerEndpointRegistry", JmsListenerEndpointRegistry.class); when(registry.getListenerContainer(HerdJmsDestinationResolver.SQS_DESTINATION_SAMPLE_DATA_QUEUE)).thenReturn(mockMessageListenerContainer);