本文整理汇总了Java中org.springframework.beans.factory.config.ListFactoryBean类的典型用法代码示例。如果您正苦于以下问题:Java ListFactoryBean类的具体用法?Java ListFactoryBean怎么用?Java ListFactoryBean使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ListFactoryBean类属于org.springframework.beans.factory.config包,在下文中一共展示了ListFactoryBean类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: configWithFactoryBeanReturnType
import org.springframework.beans.factory.config.ListFactoryBean; //导入依赖的package包/类
@Test
public void configWithFactoryBeanReturnType() {
ListableBeanFactory factory = initBeanFactory(ConfigWithNonSpecificReturnTypes.class);
assertEquals(List.class, factory.getType("factoryBean"));
assertTrue(factory.isTypeMatch("factoryBean", List.class));
assertEquals(FactoryBean.class, factory.getType("&factoryBean"));
assertTrue(factory.isTypeMatch("&factoryBean", FactoryBean.class));
assertFalse(factory.isTypeMatch("&factoryBean", BeanClassLoaderAware.class));
assertFalse(factory.isTypeMatch("&factoryBean", ListFactoryBean.class));
assertTrue(factory.getBean("factoryBean") instanceof List);
String[] beanNames = factory.getBeanNamesForType(FactoryBean.class);
assertEquals(1, beanNames.length);
assertEquals("&factoryBean", beanNames[0]);
beanNames = factory.getBeanNamesForType(BeanClassLoaderAware.class);
assertEquals(1, beanNames.length);
assertEquals("&factoryBean", beanNames[0]);
beanNames = factory.getBeanNamesForType(ListFactoryBean.class);
assertEquals(1, beanNames.length);
assertEquals("&factoryBean", beanNames[0]);
beanNames = factory.getBeanNamesForType(List.class);
assertEquals("factoryBean", beanNames[0]);
}
示例2: testCollectionFactoryDefaults
import org.springframework.beans.factory.config.ListFactoryBean; //导入依赖的package包/类
@Test
public void testCollectionFactoryDefaults() throws Exception {
ListFactoryBean listFactory = new ListFactoryBean();
listFactory.setSourceList(new LinkedList());
listFactory.afterPropertiesSet();
assertTrue(listFactory.getObject() instanceof ArrayList);
SetFactoryBean setFactory = new SetFactoryBean();
setFactory.setSourceSet(new TreeSet());
setFactory.afterPropertiesSet();
assertTrue(setFactory.getObject() instanceof LinkedHashSet);
MapFactoryBean mapFactory = new MapFactoryBean();
mapFactory.setSourceMap(new TreeMap());
mapFactory.afterPropertiesSet();
assertTrue(mapFactory.getObject() instanceof LinkedHashMap);
}
示例3: registerDefaultTableActions
import org.springframework.beans.factory.config.ListFactoryBean; //导入依赖的package包/类
/**
* Register default TablePanel Actions
* @param element current element
* @param parserContext parserContext
* @return a new ComponentDefinition with default table action list.
*/
private ComponentDefinition registerDefaultTableActions(Element element, ParserContext parserContext) {
ManagedList<Object> actions = new ManagedList<Object>(7);
actions.add(createBeanDefinition(AddAction.class, parserContext));
actions.add(createBeanDefinition(RefreshAction.class, parserContext));
actions.add(createBeanDefinition(RemoveAction.class, parserContext));
actions.add(createBeanDefinition(FindAction.class, parserContext));
actions.add(createBeanDefinition(ClearFilterAction.class, parserContext));
BeanDefinitionBuilder bdb = BeanDefinitionBuilder.genericBeanDefinition(ListFactoryBean.class);
bdb.getRawBeanDefinition().setSource(parserContext.extractSource(element));
bdb.addPropertyValue("sourceList", actions);
bdb.setScope(BeanDefinition.SCOPE_PROTOTYPE);
BeanComponentDefinition bcd = new BeanComponentDefinition(bdb.getBeanDefinition(),
DEFAULT_TABLE_ACTIONS);
registerBeanComponentDefinition(element, parserContext, bcd);
return bcd;
}
示例4: registerDefaultTableActions
import org.springframework.beans.factory.config.ListFactoryBean; //导入依赖的package包/类
/**
* Register default TablePanel Actions
* @param element current element
* @param parserContext parserContext
* @return a new ComponentDefinition with default table action list.
*/
private ComponentDefinition registerDefaultTableActions(Element element, ParserContext parserContext) {
ManagedList<Object> actions = new ManagedList<Object>(7);
actions.add(createBeanDefinition(AddAction.class, parserContext));
actions.add(createBeanDefinition(SelectAllAction.class, parserContext));
actions.add(createBeanDefinition(DeselectAllAction.class, parserContext));
actions.add(createBeanDefinition(RemoveAllAction.class, parserContext));
actions.add(createBeanDefinition(HideShowFilterAction.class, parserContext));
actions.add(createBeanDefinition(ApplyFilterAction.class, parserContext));
actions.add(createBeanDefinition(ClearFilterAction.class, parserContext));
BeanDefinitionBuilder bdb = BeanDefinitionBuilder.genericBeanDefinition(ListFactoryBean.class);
bdb.getRawBeanDefinition().setSource(parserContext.extractSource(element));
bdb.addPropertyValue("sourceList", actions);
bdb.setScope(BeanDefinition.SCOPE_PROTOTYPE);
BeanComponentDefinition bcd = new BeanComponentDefinition(bdb.getBeanDefinition(),
DEFAULT_TABLE_ACTIONS);
registerBeanComponentDefinition(element, parserContext, bcd);
return bcd;
}
示例5: processBeanMessages
import org.springframework.beans.factory.config.ListFactoryBean; //导入依赖的package包/类
/**
* Retrieves external messages whose namespace and component matches the bean definition and applies
* the message text to the bean property values
*
* @param beanName name of the bean to process
* @param beanDefinition bean definition to process
* @param nestedBeanStack stack of beans that contain the given bean, used for finding a namespace
*/
protected void processBeanMessages(String beanName, BeanDefinition beanDefinition,
Stack<BeanDefinitionHolder> nestedBeanStack) {
Class<?> beanClass = getBeanClass(beanDefinition, beanFactory);
if ((beanClass == null) || !(DictionaryBean.class.isAssignableFrom(beanClass) || ListFactoryBean.class
.isAssignableFrom(beanClass))) {
return;
}
String namespace = getNamespaceForBean(beanName, beanDefinition);
if (StringUtils.isBlank(namespace)) {
namespace = getNamespaceForBeanInStack(nestedBeanStack);
}
String componentCode = getComponentForBean(beanName, beanDefinition);
if (StringUtils.equals(componentCode, beanName)) {
// check if there is a parent bean in the factory using the standard suffix, if so we will skip this
// bean as messages will be picked up by that parent bean definition. Note this is not for all parents,
// just where the convention has been setup for extension (ex. 'bean' and 'bean-parentName')
String extensionParentBeanName = beanName + KRADConstants.DICTIONARY_BEAN_PARENT_SUFFIX;
if (beanFactory.containsBean(extensionParentBeanName)) {
return;
}
}
// if a namespace and component was found retrieve all messages associated with them
if (StringUtils.isNotBlank(namespace) && StringUtils.isNotBlank(componentCode)) {
Collection<Message> beanMessages = getMessageService().getAllMessagesForComponent(namespace, componentCode);
for (Message beanMessage : beanMessages) {
applyMessageToBean(beanMessage, beanDefinition, beanClass);
}
}
}
示例6: applyMessageToBean
import org.springframework.beans.factory.config.ListFactoryBean; //导入依赖的package包/类
/**
* Applies the text for a given message to the associated bean definition property
*
* @param message message instance to apply
* @param beanDefinition bean definition the message should be applied to
* @param beanClass class for the bean definition
*/
protected void applyMessageToBean(Message message, BeanDefinition beanDefinition, Class<?> beanClass) {
String key = message.getKey().trim();
// if message doesn't start with path indicator, it will be an explicit key that is matched when
// iterating over the property values, so we will just return in that case
if (!key.startsWith(KRADConstants.MESSAGE_KEY_PATH_INDICATOR)) {
return;
}
// if here dealing with a path key, strip off indicator and then process as a property path
key = StringUtils.stripStart(key, KRADConstants.MESSAGE_KEY_PATH_INDICATOR);
// list factory beans just have the one list property (with no name)
if (ListFactoryBean.class.isAssignableFrom(beanClass)) {
MutablePropertyValues pvs = beanDefinition.getPropertyValues();
PropertyValue propertyValue = pvs.getPropertyValueList().get(0);
List<?> listValue = (List<?>) propertyValue.getValue();
applyMessageToNestedListBean(message, listValue, key);
} else if (StringUtils.contains(key, ".")) {
applyMessageToNestedBean(message, beanDefinition, key);
} else {
applyMessageTextToPropertyValue(key, message.getText(), beanDefinition);
}
}
示例7: getBeanClass
import org.springframework.beans.factory.config.ListFactoryBean; //导入依赖的package包/类
@Override
protected Class<?> getBeanClass(Element element) {
return ListFactoryBean.class;
}
示例8: factoryBean
import org.springframework.beans.factory.config.ListFactoryBean; //导入依赖的package包/类
public @Bean FactoryBean<?> factoryBean() {
ListFactoryBean fb = new ListFactoryBean();
fb.setSourceList(Arrays.asList("element1", "element2"));
return fb;
}
示例9: getBeanClass
import org.springframework.beans.factory.config.ListFactoryBean; //导入依赖的package包/类
@Override
protected Class<ListFactoryBean> getBeanClass(final Element element) {
return ListFactoryBean.class;
}
示例10: getBeanClass
import org.springframework.beans.factory.config.ListFactoryBean; //导入依赖的package包/类
@Override
protected Class getBeanClass(Element element) {
return ListFactoryBean.class;
}
示例11: getBeanClass
import org.springframework.beans.factory.config.ListFactoryBean; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
protected Class<?> getBeanClass(Element element) {
return ListFactoryBean.class;
}