本文整理汇总了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");
}
}