use of org.springframework.beans.factory.config.ConfigurableListableBeanFactory in project wicket by apache.
the class SpringBeanLocator method getBeanDefinition.
/**
* Gets the root bean definition for the given name.
*
* @param ctx
* spring application context.
* @param name
* bean name
* @return bean definition for the current name, null if such a definition is not found.
*/
public RootBeanDefinition getBeanDefinition(final ApplicationContext ctx, final String name) {
ConfigurableListableBeanFactory beanFactory = ((AbstractApplicationContext) ctx).getBeanFactory();
BeanDefinition beanDef = beanFactory.containsBean(name) ? beanFactory.getMergedBeanDefinition(name) : null;
if (beanDef instanceof RootBeanDefinition) {
return (RootBeanDefinition) beanDef;
}
return null;
}
use of org.springframework.beans.factory.config.ConfigurableListableBeanFactory in project spring-cloud-gcp by spring-cloud.
the class AbstractSpannerIntegrationTest method createDatabaseWithSchema.
protected void createDatabaseWithSchema() {
this.tableNameSuffix = String.valueOf(System.currentTimeMillis());
ConfigurableListableBeanFactory beanFactory = ((ConfigurableApplicationContext) this.applicationContext).getBeanFactory();
beanFactory.registerSingleton("tableNameSuffix", this.tableNameSuffix);
String instanceId = this.databaseId.getInstanceId().getInstance();
String database = this.databaseId.getDatabase();
if (!hasDatabaseDefined(instanceId, database)) {
this.databaseAdminClient.createDatabase(instanceId, database, createSchemaStatements()).waitFor();
System.out.println(this.getClass() + " - Integration database created with schema: " + createSchemaStatements());
} else {
this.databaseAdminClient.updateDatabaseDdl(instanceId, database, createSchemaStatements(), null).waitFor();
System.out.println(this.getClass() + " - schema created: " + createSchemaStatements());
}
}
use of org.springframework.beans.factory.config.ConfigurableListableBeanFactory in project OpenOLAT by OpenOLAT.
the class SpringInitDestroyVerficationTest method testDestroyMethodCalls.
@Test
public void testDestroyMethodCalls() {
XmlWebApplicationContext context = (XmlWebApplicationContext) applicationContext;
ConfigurableListableBeanFactory beanFactory = context.getBeanFactory();
Map<String, Destroyable> beans = applicationContext.getBeansOfType(Destroyable.class);
for (Iterator<String> iterator = beans.keySet().iterator(); iterator.hasNext(); ) {
String beanName = iterator.next();
try {
GenericBeanDefinition beanDef = (GenericBeanDefinition) beanFactory.getBeanDefinition(beanName);
assertNotNull("Spring Bean (" + beanName + ") of type Destroyable does not have the required destroy-method attribute or the method name is not destroy!", beanDef.getDestroyMethodName());
if (beanDef.getDestroyMethodName() != null) {
assertTrue("Spring Bean (" + beanName + ") of type Destroyable does not have the required destroy-method attribute or the method name is not destroy!", beanDef.getDestroyMethodName().equals("destroy"));
}
} catch (NoSuchBeanDefinitionException e) {
log.error("testDestroyMethodCalls: Error while trying to analyze bean with name: " + beanName + " :" + e);
} catch (Exception e) {
log.error("testDestroyMethodCalls: Error while trying to analyze bean with name: " + beanName + " :" + e);
}
}
}
use of org.springframework.beans.factory.config.ConfigurableListableBeanFactory in project openolat by klemens.
the class SpringInitDestroyVerficationTest method testDestroyMethodCalls.
@Test
public void testDestroyMethodCalls() {
XmlWebApplicationContext context = (XmlWebApplicationContext) applicationContext;
ConfigurableListableBeanFactory beanFactory = context.getBeanFactory();
Map<String, Destroyable> beans = applicationContext.getBeansOfType(Destroyable.class);
for (Iterator<String> iterator = beans.keySet().iterator(); iterator.hasNext(); ) {
String beanName = iterator.next();
try {
GenericBeanDefinition beanDef = (GenericBeanDefinition) beanFactory.getBeanDefinition(beanName);
assertNotNull("Spring Bean (" + beanName + ") of type Destroyable does not have the required destroy-method attribute or the method name is not destroy!", beanDef.getDestroyMethodName());
if (beanDef.getDestroyMethodName() != null) {
assertTrue("Spring Bean (" + beanName + ") of type Destroyable does not have the required destroy-method attribute or the method name is not destroy!", beanDef.getDestroyMethodName().equals("destroy"));
}
} catch (NoSuchBeanDefinitionException e) {
log.error("testDestroyMethodCalls: Error while trying to analyze bean with name: " + beanName + " :" + e);
} catch (Exception e) {
log.error("testDestroyMethodCalls: Error while trying to analyze bean with name: " + beanName + " :" + e);
}
}
}
use of org.springframework.beans.factory.config.ConfigurableListableBeanFactory in project spring-framework by spring-projects.
the class DefaultLifecycleProcessor method getLifecycleBeans.
// overridable hooks
/**
* Retrieve all applicable Lifecycle beans: all singletons that have already been created,
* as well as all SmartLifecycle beans (even if they are marked as lazy-init).
* @return the Map of applicable beans, with bean names as keys and bean instances as values
*/
protected Map<String, Lifecycle> getLifecycleBeans() {
ConfigurableListableBeanFactory beanFactory = getBeanFactory();
Map<String, Lifecycle> beans = new LinkedHashMap<>();
String[] beanNames = beanFactory.getBeanNamesForType(Lifecycle.class, false, false);
for (String beanName : beanNames) {
String beanNameToRegister = BeanFactoryUtils.transformedBeanName(beanName);
boolean isFactoryBean = beanFactory.isFactoryBean(beanNameToRegister);
String beanNameToCheck = (isFactoryBean ? BeanFactory.FACTORY_BEAN_PREFIX + beanName : beanName);
if ((beanFactory.containsSingleton(beanNameToRegister) && (!isFactoryBean || matchesBeanType(Lifecycle.class, beanNameToCheck, beanFactory))) || matchesBeanType(SmartLifecycle.class, beanNameToCheck, beanFactory)) {
Object bean = beanFactory.getBean(beanNameToCheck);
if (bean != this && bean instanceof Lifecycle) {
beans.put(beanNameToRegister, (Lifecycle) bean);
}
}
}
return beans;
}
Aggregations