当前位置: 首页>>代码示例>>Java>>正文


Java DatastoreCommodityRegistrar类代码示例

本文整理汇总了Java中com.holonplatform.core.datastore.DatastoreCommodityRegistrar的典型用法代码示例。如果您正苦于以下问题:Java DatastoreCommodityRegistrar类的具体用法?Java DatastoreCommodityRegistrar怎么用?Java DatastoreCommodityRegistrar使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


DatastoreCommodityRegistrar类属于com.holonplatform.core.datastore包,在下文中一共展示了DatastoreCommodityRegistrar类的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: configureDatastoreCommodityFactories

import com.holonplatform.core.datastore.DatastoreCommodityRegistrar; //导入依赖的package包/类
/**
 * Register {@link com.holonplatform.spring.DatastoreCommodityFactory} annotated beans as <code>datastore</code>
 * {@link DatastoreCommodityFactory}s.
 * @param datastore Datastore to configure
 * @param datastoreBeanName Datastore bean name to configure
 * @param beanFactory Bean factory
 */
@SuppressWarnings({ "unchecked", "rawtypes" })
private static void configureDatastoreCommodityFactories(Datastore datastore, String datastoreBeanName,
		ListableBeanFactory beanFactory) {
	if (datastore instanceof DatastoreCommodityRegistrar) {
		final Class<? extends DatastoreCommodityFactory> baseType = ((DatastoreCommodityRegistrar<?>) datastore)
				.getCommodityFactoryType();
		if (baseType != null) {
			final String[] beanNames = beanFactory
					.getBeanNamesForAnnotation(com.holonplatform.spring.DatastoreCommodityFactory.class);
			if (beanNames != null && beanNames.length > 0) {
				for (String beanName : beanNames) {
					com.holonplatform.spring.DatastoreCommodityFactory dr = beanFactory.findAnnotationOnBean(
							beanName, com.holonplatform.spring.DatastoreCommodityFactory.class);
					String datastoreRef = AnnotationUtils.getStringValue(dr.datastoreBeanName());
					if (datastoreRef == null || datastoreRef.equals(datastoreBeanName)) {
						if (!baseType.isAssignableFrom(beanFactory.getType(beanName))) {
							throw new BeanNotOfRequiredTypeException(beanName, baseType,
									beanFactory.getType(beanName));
						}
						// register resolver
						DatastoreCommodityFactory datastoreCommodityFactory = (DatastoreCommodityFactory) beanFactory
								.getBean(beanName);
						((DatastoreCommodityRegistrar) datastore).registerCommodity(datastoreCommodityFactory);
						LOGGER.debug(() -> "Registered factory [" + datastoreCommodityFactory.getClass().getName()
								+ "] into Datastore with bean name [" + datastoreBeanName + "]");
					}
				}
			}
		} else {
			LOGGER.debug(
					() -> "Datastore [" + datastore + "] does not declares a DatastoreCommodityFactory base type: "
							+ "skipping DatastoreCommodityFactory beans configuration");
		}
	} else {
		LOGGER.debug(() -> "Datastore [" + datastore
				+ "] is not a DatastoreCommodityRegistrar: skipping DatastoreCommodityFactory beans configuration");
	}
}
 
开发者ID:holon-platform,项目名称:holon-core,代码行数:46,代码来源:DatastoreInitializer.java


注:本文中的com.holonplatform.core.datastore.DatastoreCommodityRegistrar类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。