use of org.springframework.beans.factory.support.AbstractBeanDefinition in project grails-core by grails.
the class DefaultBeanConfiguration method createBeanDefinition.
protected AbstractBeanDefinition createBeanDefinition() {
AbstractBeanDefinition bd = new GenericBeanDefinition();
if (!constructorArgs.isEmpty()) {
ConstructorArgumentValues cav = new ConstructorArgumentValues();
for (Object constructorArg : constructorArgs) {
cav.addGenericArgumentValue(constructorArg);
}
bd.setConstructorArgumentValues(cav);
}
if (clazz != null) {
bd.setLazyInit(clazz.getAnnotation(Lazy.class) != null);
bd.setBeanClass(clazz);
}
bd.setScope(singleton ? AbstractBeanDefinition.SCOPE_SINGLETON : AbstractBeanDefinition.SCOPE_PROTOTYPE);
if (parentName != null) {
bd.setParentName(parentName);
}
wrapper = new BeanWrapperImpl(bd);
return bd;
}
use of org.springframework.beans.factory.support.AbstractBeanDefinition in project qi4j-sdk by Qi4j.
the class Qi4jBootstrapBeanDefinitionParser method parse.
@Override
public final BeanDefinition parse(Element anElement, ParserContext aParserContext) {
Qi4jApplicationBootstrap bootstrap = createQi4jApplicationBootstrap(anElement, aParserContext);
AbstractBeanDefinition factoryBeanDefinition = createQi4jApplicationFactoryBeanDefinition(bootstrap);
registerBean(aParserContext, factoryBeanDefinition);
return factoryBeanDefinition;
}
use of org.springframework.beans.factory.support.AbstractBeanDefinition in project qi4j-sdk by Qi4j.
the class Qi4jServiceBeanDefinitionParser method parse.
@Override
public final BeanDefinition parse(Element anElement, ParserContext aParserContext) {
String serviceId = anElement.getAttribute(SERVICE_ID);
// Service factory bean
BeanDefinitionBuilder builder = rootBeanDefinition(ServiceFactoryBean.class);
builder.addConstructorArgReference(BEAN_ID_QI4J_APPLICATION);
builder.addConstructorArgValue(serviceId);
AbstractBeanDefinition definition = builder.getBeanDefinition();
// Register service factory bean
BeanDefinitionRegistry definitionRegistry = aParserContext.getRegistry();
definitionRegistry.registerBeanDefinition(serviceId, definition);
return definition;
}
use of org.springframework.beans.factory.support.AbstractBeanDefinition in project spring-security by spring-projects.
the class AbstractUserDetailsServiceBeanDefinitionParser method resolveId.
private String resolveId(Element element, AbstractBeanDefinition definition, ParserContext pc) throws BeanDefinitionStoreException {
String id = element.getAttribute("id");
if (pc.isNested()) {
// We're inside an <authentication-provider> element
if (!StringUtils.hasText(id)) {
id = pc.getReaderContext().generateBeanName(definition);
}
BeanDefinition container = pc.getContainingBeanDefinition();
container.getPropertyValues().add("userDetailsService", new RuntimeBeanReference(id));
}
if (StringUtils.hasText(id)) {
return id;
}
// If top level, use the default name or throw an exception if already used
if (pc.getRegistry().containsBeanDefinition(BeanIds.USER_DETAILS_SERVICE)) {
throw new BeanDefinitionStoreException("No id supplied and another " + "bean is already registered as " + BeanIds.USER_DETAILS_SERVICE);
}
return BeanIds.USER_DETAILS_SERVICE;
}
use of org.springframework.beans.factory.support.AbstractBeanDefinition in project spring-framework by spring-projects.
the class PropertyPlaceholderConfigurerTests method twoPlacholderConfigurers_withConflictingSettings.
/**
* Creates a scenario in which two PPCs are configured, each with different
* settings regarding resolving properties from the environment.
*/
@Test
public void twoPlacholderConfigurers_withConflictingSettings() {
String P2 = "p2";
String P2_LOCAL_PROPS_VAL = "p2LocalPropsVal";
String P2_SYSTEM_PROPS_VAL = "p2SystemPropsVal";
String P2_SYSTEM_ENV_VAL = "p2SystemEnvVal";
AbstractBeanDefinition p2BeanDef = rootBeanDefinition(TestBean.class).addPropertyValue("name", "${" + P1 + "}").addPropertyValue("country", "${" + P2 + "}").getBeanDefinition();
bf.registerBeanDefinition("p1Bean", p1BeanDef);
bf.registerBeanDefinition("p2Bean", p2BeanDef);
ppc.setIgnoreUnresolvablePlaceholders(true);
ppc.postProcessBeanFactory(bf);
System.setProperty(P2, P2_SYSTEM_PROPS_VAL);
getModifiableSystemEnvironment().put(P2, P2_SYSTEM_ENV_VAL);
Properties ppc2Properties = new Properties();
ppc2Properties.put(P2, P2_LOCAL_PROPS_VAL);
PropertyPlaceholderConfigurer ppc2 = new PropertyPlaceholderConfigurer();
ppc2.setSystemPropertiesMode(PropertyPlaceholderConfigurer.SYSTEM_PROPERTIES_MODE_OVERRIDE);
ppc2.setProperties(ppc2Properties);
ppc2Properties = new Properties();
ppc2Properties.setProperty(P2, P2_LOCAL_PROPS_VAL);
ppc2.postProcessBeanFactory(bf);
TestBean p1Bean = bf.getBean("p1Bean", TestBean.class);
assertThat(p1Bean.getName(), equalTo(P1_LOCAL_PROPS_VAL));
TestBean p2Bean = bf.getBean("p2Bean", TestBean.class);
assertThat(p2Bean.getName(), equalTo(P1_LOCAL_PROPS_VAL));
assertThat(p2Bean.getCountry(), equalTo(P2_SYSTEM_PROPS_VAL));
System.clearProperty(P2);
getModifiableSystemEnvironment().remove(P2);
}
Aggregations