本文整理汇总了Java中org.springframework.beans.factory.support.ChildBeanDefinition类的典型用法代码示例。如果您正苦于以下问题:Java ChildBeanDefinition类的具体用法?Java ChildBeanDefinition怎么用?Java ChildBeanDefinition使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ChildBeanDefinition类属于org.springframework.beans.factory.support包,在下文中一共展示了ChildBeanDefinition类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: testCanReferenceParentBeanFromChildViaAlias
import org.springframework.beans.factory.support.ChildBeanDefinition; //导入依赖的package包/类
@Test
public void testCanReferenceParentBeanFromChildViaAlias() {
final String EXPECTED_NAME = "Juergen";
final int EXPECTED_AGE = 41;
RootBeanDefinition parentDefinition = new RootBeanDefinition(TestBean.class);
parentDefinition.setAbstract(true);
parentDefinition.getPropertyValues().add("name", EXPECTED_NAME);
parentDefinition.getPropertyValues().add("age", EXPECTED_AGE);
ChildBeanDefinition childDefinition = new ChildBeanDefinition("alias");
DefaultListableBeanFactory factory = new DefaultListableBeanFactory();
factory.registerBeanDefinition("parent", parentDefinition);
factory.registerBeanDefinition("child", childDefinition);
factory.registerAlias("parent", "alias");
TestBean child = (TestBean) factory.getBean("child");
assertEquals(EXPECTED_NAME, child.getName());
assertEquals(EXPECTED_AGE, child.getAge());
assertEquals("Use cached merged bean definition",
factory.getMergedBeanDefinition("child"), factory.getMergedBeanDefinition("child"));
}
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:25,代码来源:DefaultListableBeanFactoryTests.java
示例2: testCanReferenceParentBeanFromChildViaAlias
import org.springframework.beans.factory.support.ChildBeanDefinition; //导入依赖的package包/类
@Test
public void testCanReferenceParentBeanFromChildViaAlias() {
final String EXPECTED_NAME = "Juergen";
final int EXPECTED_AGE = 41;
RootBeanDefinition parentDefinition = new RootBeanDefinition(TestBean.class);
parentDefinition.setAbstract(true);
parentDefinition.getPropertyValues().add("name", EXPECTED_NAME);
parentDefinition.getPropertyValues().add("age", new Integer(EXPECTED_AGE));
ChildBeanDefinition childDefinition = new ChildBeanDefinition("alias");
DefaultListableBeanFactory factory = new DefaultListableBeanFactory();
factory.registerBeanDefinition("parent", parentDefinition);
factory.registerBeanDefinition("child", childDefinition);
factory.registerAlias("parent", "alias");
TestBean child = (TestBean) factory.getBean("child");
assertEquals(EXPECTED_NAME, child.getName());
assertEquals(EXPECTED_AGE, child.getAge());
assertEquals("Use cached merged bean definition",
factory.getMergedBeanDefinition("child"), factory.getMergedBeanDefinition("child"));
}
开发者ID:deathspeeder,项目名称:class-guard,代码行数:25,代码来源:DefaultListableBeanFactoryTests.java
示例3: resolveBeanClassname
import org.springframework.beans.factory.support.ChildBeanDefinition; //导入依赖的package包/类
/**
* Try getting the beanClassName from the definition and if that fails try to get it from
* the parent (and even parent BeanFactory if we have to).
*
* @param definition
* @param registry
* @return class name or null if not found
*/
private String resolveBeanClassname(BeanDefinition definition, BeanDefinitionRegistry registry)
{
String beanClassName = definition.getBeanClassName();
if (!StringUtils.hasText(beanClassName))
{
while (definition instanceof ChildBeanDefinition )
{
String parentName = ((ChildBeanDefinition)definition).getParentName();
BeanDefinition parentDefinition = findParentDefinition(parentName, registry);
if (parentDefinition == null)
{
if (log.isDebugEnabled())
{
log.debug("No parent bean named '" + parentName + "' could be found in the " +
"hierarchy of BeanFactorys. Check you've defined a bean called '" + parentName + "'");
}
break;
}
beanClassName = parentDefinition.getBeanClassName();
if (StringUtils.hasText(beanClassName ))
{
// found the class name we were looking for
break;
}
definition = parentDefinition;
}
}
return beanClassName;
}
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:39,代码来源:DwrNamespaceHandler.java
示例4: postProcessorIntrospectsInheritedDefinitionsCorrectly
import org.springframework.beans.factory.support.ChildBeanDefinition; //导入依赖的package包/类
/**
* Tests whether a bean definition without a specified bean class is handled
* correctly.
*/
@Test
public void postProcessorIntrospectsInheritedDefinitionsCorrectly() {
beanFactory.registerBeanDefinition("config", new RootBeanDefinition(SingletonBeanConfig.class));
beanFactory.registerBeanDefinition("parent", new RootBeanDefinition(TestBean.class));
beanFactory.registerBeanDefinition("child", new ChildBeanDefinition("parent"));
ConfigurationClassPostProcessor pp = new ConfigurationClassPostProcessor();
pp.postProcessBeanFactory(beanFactory);
Foo foo = beanFactory.getBean("foo", Foo.class);
Bar bar = beanFactory.getBean("bar", Bar.class);
assertSame(foo, bar.foo);
}
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:16,代码来源:ConfigurationClassPostProcessorTests.java
示例5: testGetTypeWorksAfterParentChildMerging
import org.springframework.beans.factory.support.ChildBeanDefinition; //导入依赖的package包/类
@Test
public void testGetTypeWorksAfterParentChildMerging() {
RootBeanDefinition parentDefinition = new RootBeanDefinition(TestBean.class);
ChildBeanDefinition childDefinition = new ChildBeanDefinition("parent", DerivedTestBean.class, null, null);
DefaultListableBeanFactory factory = new DefaultListableBeanFactory();
factory.registerBeanDefinition("parent", parentDefinition);
factory.registerBeanDefinition("child", childDefinition);
factory.freezeConfiguration();
assertEquals(TestBean.class, factory.getType("parent"));
assertEquals(DerivedTestBean.class, factory.getType("child"));
}
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:14,代码来源:DefaultListableBeanFactoryTests.java
示例6: testScopeInheritanceForChildBeanDefinitions
import org.springframework.beans.factory.support.ChildBeanDefinition; //导入依赖的package包/类
@Test
public void testScopeInheritanceForChildBeanDefinitions() throws Exception {
RootBeanDefinition parent = new RootBeanDefinition();
parent.setScope("bonanza!");
AbstractBeanDefinition child = new ChildBeanDefinition("parent");
child.setBeanClass(TestBean.class);
DefaultListableBeanFactory factory = new DefaultListableBeanFactory();
factory.registerBeanDefinition("parent", parent);
factory.registerBeanDefinition("child", child);
BeanDefinition def = factory.getMergedBeanDefinition("child");
assertEquals("Child 'scope' not inherited", "bonanza!", def.getScope());
}
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:16,代码来源:DefaultListableBeanFactoryTests.java
示例7: emitCustomStoreBeanDefinition
import org.springframework.beans.factory.support.ChildBeanDefinition; //导入依赖的package包/类
protected void emitCustomStoreBeanDefinition(final BeanDefinitionRegistry registry, final String storeName)
{
if (registry.containsBeanDefinition(storeName))
{
throw new AlfrescoRuntimeException(
storeName + " (custom content store) cannot be defined - a bean with same name already exists");
}
final MessageFormat mf = new MessageFormat("{0}.{1}.", Locale.ENGLISH);
final String prefix = mf.format(new Object[] { PROP_CUSTOM_STORE_PREFIX, storeName });
final String typeProperty = prefix + "type";
final String typeValue = this.propertiesSource.getProperty(typeProperty);
if (typeValue != null && !typeValue.isEmpty())
{
LOGGER.debug("Emitting bean definition for custom store {} based on template {}", storeName, typeValue);
final BeanDefinition storeBeanDefinition = new ChildBeanDefinition(STORE_TEMPLATE_PREFIX + typeValue);
storeBeanDefinition.setScope(BeanDefinition.SCOPE_SINGLETON);
final Set<String> propertyNames = this.propertiesSource.stringPropertyNames();
for (final String propertyName : propertyNames)
{
if (propertyName.startsWith(prefix) && !typeProperty.equals(propertyName))
{
this.handleBeanProperty(storeBeanDefinition, propertyName, this.propertiesSource.getProperty(propertyName));
}
}
registry.registerBeanDefinition(storeName, storeBeanDefinition);
}
else
{
LOGGER.warn("Custom store {} does not define a type", storeName);
throw new AlfrescoRuntimeException(storeName + " (custom content store) has not been given a type");
}
}
开发者ID:Acosix,项目名称:alfresco-simple-content-stores,代码行数:37,代码来源:SimpleContentStoresBeanDefinitionEmitter.java
示例8: generateMissingLookupDefinitions
import org.springframework.beans.factory.support.ChildBeanDefinition; //导入依赖的package包/类
protected void generateMissingLookupDefinitions() {
Collection<LookupView> lookupViewBeans = ddBeans.getBeansOfType(LookupView.class).values();
// Index all the inquiry views by the data object class so we can find them easily below
Map<Class<?>,LookupView> defaultViewsByDataObjectClass = new HashMap<>();
for ( LookupView view : lookupViewBeans ) {
if ( view.getViewName().equals(UifConstants.DEFAULT_VIEW_NAME) ) {
defaultViewsByDataObjectClass.put(view.getDataObjectClass(), view);
}
}
for (DataObjectEntry entry : ddBeans.getBeansOfType(DataObjectEntry.class).values()) {
// if an inquiry already exists, just ignore - we only default if none exist
if ( defaultViewsByDataObjectClass.containsKey(entry.getDataObjectClass())) {
continue;
}
// We only generate the inquiry if the metadata says to
if ( entry.getDataObjectMetadata() == null ) {
continue;
}
if ( !entry.getDataObjectMetadata().shouldAutoCreateUifViewOfType(UifAutoCreateViewType.LOOKUP)) {
continue;
}
// no inquiry exists and we want one to, create one
if ( LOG.isInfoEnabled() ) {
LOG.info( "Generating Lookup View for : " + entry.getDataObjectClass() );
}
String lookupBeanName = entry.getDataObjectClass().getSimpleName()+"-LookupView-default";
LookupView lookupView = KRADServiceLocatorWeb.getUifDefaultingService().deriveLookupViewFromMetadata(entry);
lookupView.setId(lookupBeanName);
lookupView.setViewName(UifConstants.DEFAULT_VIEW_NAME);
ChildBeanDefinition lookupBean = new ChildBeanDefinition(ComponentFactory.LOOKUP_VIEW);
lookupBean.setScope(BeanDefinition.SCOPE_SINGLETON);
lookupBean.setAttribute("dataObjectClassName", lookupView.getDataObjectClass());
lookupBean.getPropertyValues().add("dataObjectClassName", lookupView.getDataObjectClass().getName());
lookupBean.setResourceDescription("Autogenerated From Metadata");
ddBeans.registerBeanDefinition(lookupBeanName, lookupBean);
ddBeans.registerSingleton(lookupBeanName, lookupView);
}
}
开发者ID:kuali,项目名称:kc-rice,代码行数:41,代码来源:DataDictionary.java
示例9: testPostProcessorIntrospectsInheritedDefinitionsCorrectly
import org.springframework.beans.factory.support.ChildBeanDefinition; //导入依赖的package包/类
/**
* Tests whether a bean definition without a specified bean class is handled
* correctly.
*/
@Test
public void testPostProcessorIntrospectsInheritedDefinitionsCorrectly() {
DefaultListableBeanFactory beanFactory = new DefaultListableBeanFactory();
beanFactory.registerBeanDefinition("config", new RootBeanDefinition(SingletonBeanConfig.class));
beanFactory.registerBeanDefinition("parent", new RootBeanDefinition(TestBean.class));
beanFactory.registerBeanDefinition("child", new ChildBeanDefinition("parent"));
ConfigurationClassPostProcessor pp = new ConfigurationClassPostProcessor();
pp.postProcessBeanFactory(beanFactory);
Foo foo = beanFactory.getBean("foo", Foo.class);
Bar bar = beanFactory.getBean("bar", Bar.class);
assertSame(foo, bar.foo);
}
开发者ID:deathspeeder,项目名称:class-guard,代码行数:17,代码来源:ConfigurationClassPostProcessorTests.java
示例10: parseInternal
import org.springframework.beans.factory.support.ChildBeanDefinition; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
protected AbstractBeanDefinition parseInternal(@Nullable Element element,
@Nullable ParserContext parserContext) {
// Here we parse the Spring elements such as < property>
if (parserContext==null || element == null ) throw GlobalUtils.createNotInitializedException("element and parserContext");
// Here we parse the Spring elements such as < property>
BeanDefinitionHolder holder = parserContext.getDelegate().parseBeanDefinitionElement(element);
BeanDefinition bDef = holder.getBeanDefinition();
bDef.setBeanClassName(PagePropertyCorrectnessAsserter.class.getName());
String resultPage = element
.getAttribute(XsdElementConstants.ATTR_ABSTRACTEXPECTEDRESULTASSERTER_RESULTPAGE);
if (StringUtils.hasText(resultPage)) {
bDef.getConstructorArgumentValues().addGenericArgumentValue(
new RuntimeBeanReference(resultPage));
}
String stepERValue = element
.getAttribute(XsdElementConstants.ATTR_ABSTRACTEXPECTEDRESULTASSERTER_STEPERVALUE);
if (StringUtils.hasText(stepERValue)) {
ConstructorArgumentValues erValueDefConstrs = new ConstructorArgumentValues();
erValueDefConstrs.addGenericArgumentValue(stepERValue);
BeanDefinition erValueDef = new ChildBeanDefinition(
XsdElementConstants.ELEMENT_ID_BASEERVALUE,
StepErPagePropertyValue.class, erValueDefConstrs, null);
parserContext.getRegistry().registerBeanDefinition(element.getAttribute("id") + "_ASSERTER_STEPERVALUE_ID", erValueDef);
bDef.getConstructorArgumentValues().addGenericArgumentValue(
new RuntimeBeanReference(element.getAttribute("id") + "_ASSERTER_STEPERVALUE_ID"));
}
parserContext.getRegistry().registerBeanDefinition(element.getAttribute("id"), bDef);
return (AbstractBeanDefinition) bDef;
}
开发者ID:bigtester,项目名称:automation-test-engine,代码行数:40,代码来源:PagePropertyCorrectBeanDefinitionParser.java
示例11: generateMissingLookupDefinitions
import org.springframework.beans.factory.support.ChildBeanDefinition; //导入依赖的package包/类
protected void generateMissingLookupDefinitions() {
Collection<LookupView> lookupViewBeans = ddBeans.getBeansOfType(LookupView.class).values();
// Index all the inquiry views by the data object class so we can find them easily below
Map<Class<?>,LookupView> defaultViewsByDataObjectClass = new HashMap<Class<?>, LookupView>();
for ( LookupView view : lookupViewBeans ) {
if ( view.getViewName().equals(UifConstants.DEFAULT_VIEW_NAME) ) {
defaultViewsByDataObjectClass.put(view.getDataObjectClass(), view);
}
}
for (DataObjectEntry entry : ddBeans.getBeansOfType(DataObjectEntry.class).values()) {
// if an inquiry already exists, just ignore - we only default if none exist
if ( defaultViewsByDataObjectClass.containsKey(entry.getDataObjectClass())) {
continue;
}
// We only generate the inquiry if the metadata says to
if ( entry.getDataObjectMetadata() == null ) {
continue;
}
if ( !entry.getDataObjectMetadata().shouldAutoCreateUifViewOfType(UifAutoCreateViewType.LOOKUP)) {
continue;
}
// no inquiry exists and we want one to, create one
if ( LOG.isInfoEnabled() ) {
LOG.info( "Generating Lookup View for : " + entry.getDataObjectClass() );
}
String lookupBeanName = entry.getDataObjectClass().getSimpleName()+"-LookupView-default";
LookupView lookupView = KRADServiceLocatorWeb.getUifDefaultingService().deriveLookupViewFromMetadata(entry);
lookupView.setId(lookupBeanName);
lookupView.setViewName(UifConstants.DEFAULT_VIEW_NAME);
ChildBeanDefinition lookupBean = new ChildBeanDefinition(ComponentFactory.LOOKUP_VIEW);
lookupBean.setScope(BeanDefinition.SCOPE_SINGLETON);
lookupBean.setAttribute("dataObjectClassName", lookupView.getDataObjectClass());
lookupBean.getPropertyValues().add("dataObjectClassName", lookupView.getDataObjectClass().getName());
lookupBean.setResourceDescription("Autogenerated From Metadata");
ddBeans.registerBeanDefinition(lookupBeanName, lookupBean);
ddBeans.registerSingleton(lookupBeanName, lookupView);
}
}
开发者ID:kuali,项目名称:rice,代码行数:41,代码来源:DataDictionary.java
示例12: generateMissingInquiryDefinitions
import org.springframework.beans.factory.support.ChildBeanDefinition; //导入依赖的package包/类
protected void generateMissingInquiryDefinitions() {
Collection<InquiryView> inquiryViewBeans = ddBeans.getBeansOfType(InquiryView.class).values();
// Index all the inquiry views by the data object class so we can find them easily below
Map<Class<?>,InquiryView> defaultViewsByDataObjectClass = new HashMap<>();
for ( InquiryView view : inquiryViewBeans ) {
if ( view.getViewName().equals(UifConstants.DEFAULT_VIEW_NAME) ) {
defaultViewsByDataObjectClass.put(view.getDataObjectClassName(), view);
}
}
for (DataObjectEntry entry : ddBeans.getBeansOfType(DataObjectEntry.class).values()) {
// if an inquiry already exists, just ignore - we only default if none exist
if ( defaultViewsByDataObjectClass.containsKey(entry.getDataObjectClass())) {
continue;
}
// We only generate the inquiry if the metadata says to
if ( entry.getDataObjectMetadata() == null ) {
continue;
}
if ( !entry.getDataObjectMetadata().shouldAutoCreateUifViewOfType(UifAutoCreateViewType.INQUIRY)) {
continue;
}
// no inquiry exists and we want one to, create one
if ( LOG.isInfoEnabled() ) {
LOG.info( "Generating Inquiry View for : " + entry.getDataObjectClass() );
}
String inquiryBeanName = entry.getDataObjectClass().getSimpleName()+"-InquiryView-default";
InquiryView inquiryView = KRADServiceLocatorWeb.getUifDefaultingService().deriveInquiryViewFromMetadata(entry);
inquiryView.setId(inquiryBeanName);
inquiryView.setViewName(UifConstants.DEFAULT_VIEW_NAME);
ChildBeanDefinition inquiryBean = new ChildBeanDefinition("Uif-InquiryView");
inquiryBean.setScope(BeanDefinition.SCOPE_SINGLETON);
inquiryBean.setAttribute("dataObjectClassName", inquiryView.getDataObjectClassName());
inquiryBean.getPropertyValues().add("dataObjectClassName", inquiryView.getDataObjectClassName().getName());
inquiryBean.setResourceDescription("Autogenerated From Metadata");
ddBeans.registerBeanDefinition(inquiryBeanName, inquiryBean);
ddBeans.registerSingleton(inquiryBeanName, inquiryView);
}
}
开发者ID:kuali,项目名称:kc-rice,代码行数:48,代码来源:DataDictionary.java
示例13: testServletContextPropertyPlaceholderConfigurerWithAttributes
import org.springframework.beans.factory.support.ChildBeanDefinition; //导入依赖的package包/类
@Test
@Deprecated
public void testServletContextPropertyPlaceholderConfigurerWithAttributes() {
MockServletContext sc = new MockServletContext();
sc.addInitParameter("key4", "mykey4");
StaticWebApplicationContext wac = new StaticWebApplicationContext();
wac.setServletContext(sc);
MutablePropertyValues pvs = new MutablePropertyValues();
pvs.add("age", "${age}");
pvs.add("name", "name${var}${var}${");
pvs.add("spouse", new RuntimeBeanReference("${ref}"));
wac.registerSingleton("tb1", TestBean.class, pvs);
ConstructorArgumentValues cas = new ConstructorArgumentValues();
cas.addIndexedArgumentValue(1, "${age}");
cas.addGenericArgumentValue("${var}name${age}");
pvs = new MutablePropertyValues();
List<Object> friends = new ManagedList<Object>();
friends.add("na${age}me");
friends.add(new RuntimeBeanReference("${ref}"));
pvs.add("friends", friends);
Set<Object> someSet = new ManagedSet<Object>();
someSet.add("na${age}me");
someSet.add(new RuntimeBeanReference("${ref}"));
pvs.add("someSet", someSet);
Map<String, Object> someMap = new ManagedMap<String, Object>();
someMap.put("key1", new RuntimeBeanReference("${ref}"));
someMap.put("key2", "${age}name");
MutablePropertyValues innerPvs = new MutablePropertyValues();
innerPvs.add("touchy", "${os.name}");
RootBeanDefinition innerBd = new RootBeanDefinition(TestBean.class);
innerBd.setPropertyValues(innerPvs);
someMap.put("key3", innerBd);
MutablePropertyValues innerPvs2 = new MutablePropertyValues(innerPvs);
someMap.put("${key4}", new BeanDefinitionHolder(new ChildBeanDefinition("tb1", innerPvs2), "child"));
pvs.add("someMap", someMap);
RootBeanDefinition bd = new RootBeanDefinition(TestBean.class, cas, pvs);
wac.getDefaultListableBeanFactory().registerBeanDefinition("tb2", bd);
pvs = new MutablePropertyValues();
pvs.add("properties", "var=${m}var\nref=tb2\nm=my");
pvs.add("searchContextAttributes", Boolean.TRUE);
wac.registerSingleton("configurer", ServletContextPropertyPlaceholderConfigurer.class, pvs);
sc.setAttribute("age", new Integer(98));
wac.refresh();
TestBean tb1 = (TestBean) wac.getBean("tb1");
TestBean tb2 = (TestBean) wac.getBean("tb2");
assertEquals(98, tb1.getAge());
assertEquals(98, tb2.getAge());
assertEquals("namemyvarmyvar${", tb1.getName());
assertEquals("myvarname98", tb2.getName());
assertEquals(tb2, tb1.getSpouse());
assertEquals(2, tb2.getFriends().size());
assertEquals("na98me", tb2.getFriends().iterator().next());
assertEquals(tb2, tb2.getFriends().toArray()[1]);
assertEquals(2, tb2.getSomeSet().size());
assertTrue(tb2.getSomeSet().contains("na98me"));
assertTrue(tb2.getSomeSet().contains(tb2));
assertEquals(4, tb2.getSomeMap().size());
assertEquals(tb2, tb2.getSomeMap().get("key1"));
assertEquals("98name", tb2.getSomeMap().get("key2"));
TestBean inner1 = (TestBean) tb2.getSomeMap().get("key3");
TestBean inner2 = (TestBean) tb2.getSomeMap().get("mykey4");
assertEquals(0, inner1.getAge());
assertEquals(null, inner1.getName());
assertEquals(System.getProperty("os.name"), inner1.getTouchy());
assertEquals(98, inner2.getAge());
assertEquals("namemyvarmyvar${", inner2.getName());
assertEquals(System.getProperty("os.name"), inner2.getTouchy());
}
开发者ID:deathspeeder,项目名称:class-guard,代码行数:79,代码来源:ServletContextSupportTests.java
示例14: parseInternal
import org.springframework.beans.factory.support.ChildBeanDefinition; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
protected AbstractBeanDefinition parseInternal(@Nullable Element element,
@Nullable ParserContext parserContext) {
// Here we parse the Spring elements such as < property>
if (parserContext == null || element == null)
throw GlobalUtils
.createNotInitializedException("element and parserContext");
// Here we parse the Spring elements such as < property>
BeanDefinitionHolder holder = parserContext.getDelegate()
.parseBeanDefinitionElement(element);
BeanDefinition bDef = holder.getBeanDefinition();
bDef.setBeanClassName(PageElementExistenceAsserter.class.getName());
String resultPage = element
.getAttribute(XsdElementConstants.ATTR_ABSTRACTEXPECTEDRESULTASSERTER_RESULTPAGE);
if (StringUtils.hasText(resultPage)) {
bDef.getConstructorArgumentValues().addGenericArgumentValue(
new RuntimeBeanReference(resultPage));
}
String stepERValue = element
.getAttribute(XsdElementConstants.ATTR_ABSTRACTEXPECTEDRESULTASSERTER_STEPERVALUE);
if (StringUtils.hasText(stepERValue)) {
ConstructorArgumentValues erValueDefConstrs = new ConstructorArgumentValues();
erValueDefConstrs.addGenericArgumentValue(stepERValue);
BeanDefinition erValueDef = new ChildBeanDefinition(
XsdElementConstants.ELEMENT_ID_BASEERVALUE,
StepErElementExistenceValue.class, erValueDefConstrs, null);
parserContext.getRegistry().registerBeanDefinition(element.getAttribute("id") + "_ASSERTER_STEPERVALUE_ID", erValueDef);
bDef.getConstructorArgumentValues().addGenericArgumentValue(
new RuntimeBeanReference(element.getAttribute("id") + "_ASSERTER_STEPERVALUE_ID"));
}
parserContext.getRegistry().registerBeanDefinition(
element.getAttribute("id"), bDef);
return (AbstractBeanDefinition) bDef;
}
开发者ID:bigtester,项目名称:automation-test-engine,代码行数:44,代码来源:PageElementExistBeanDefinitionParser.java
示例15: generateMissingInquiryDefinitions
import org.springframework.beans.factory.support.ChildBeanDefinition; //导入依赖的package包/类
protected void generateMissingInquiryDefinitions() {
Collection<InquiryView> inquiryViewBeans = ddBeans.getBeansOfType(InquiryView.class).values();
// Index all the inquiry views by the data object class so we can find them easily below
Map<Class<?>,InquiryView> defaultViewsByDataObjectClass = new HashMap<Class<?>, InquiryView>();
for ( InquiryView view : inquiryViewBeans ) {
if ( view.getViewName().equals(UifConstants.DEFAULT_VIEW_NAME) ) {
defaultViewsByDataObjectClass.put(view.getDataObjectClassName(), view);
}
}
for (DataObjectEntry entry : ddBeans.getBeansOfType(DataObjectEntry.class).values()) {
// if an inquiry already exists, just ignore - we only default if none exist
if ( defaultViewsByDataObjectClass.containsKey(entry.getDataObjectClass())) {
continue;
}
// We only generate the inquiry if the metadata says to
if ( entry.getDataObjectMetadata() == null ) {
continue;
}
if ( !entry.getDataObjectMetadata().shouldAutoCreateUifViewOfType(UifAutoCreateViewType.INQUIRY)) {
continue;
}
// no inquiry exists and we want one to, create one
if ( LOG.isInfoEnabled() ) {
LOG.info( "Generating Inquiry View for : " + entry.getDataObjectClass() );
}
String inquiryBeanName = entry.getDataObjectClass().getSimpleName()+"-InquiryView-default";
InquiryView inquiryView = KRADServiceLocatorWeb.getUifDefaultingService().deriveInquiryViewFromMetadata(entry);
inquiryView.setId(inquiryBeanName);
inquiryView.setViewName(UifConstants.DEFAULT_VIEW_NAME);
ChildBeanDefinition inquiryBean = new ChildBeanDefinition("Uif-InquiryView");
inquiryBean.setScope(BeanDefinition.SCOPE_SINGLETON);
inquiryBean.setAttribute("dataObjectClassName", inquiryView.getDataObjectClassName());
inquiryBean.getPropertyValues().add("dataObjectClassName", inquiryView.getDataObjectClassName().getName());
inquiryBean.setResourceDescription("Autogenerated From Metadata");
ddBeans.registerBeanDefinition(inquiryBeanName, inquiryBean);
ddBeans.registerSingleton(inquiryBeanName, inquiryView);
}
}
开发者ID:kuali,项目名称:rice,代码行数:48,代码来源:DataDictionary.java
注:本文中的org.springframework.beans.factory.support.ChildBeanDefinition类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论