本文整理了Java中org.opendaylight.yangtools.yang.binding.YangModelBindingProvider
类的一些代码示例,展示了YangModelBindingProvider
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。YangModelBindingProvider
类的具体详情如下:
包路径:org.opendaylight.yangtools.yang.binding.YangModelBindingProvider
类名称:YangModelBindingProvider
[英]Provider of YangModuleInfo for specified package / model. Implementations of this interface should be discoverable via ServiceLoader.
[中]指定包/型号的YangModuleInfo提供程序。该接口的实现应该可以通过ServiceLoader发现。
代码示例来源:origin: io.lighty.core/lighty-common
/**
* Get all Yang modules from classpath using ServiceLoader scanning.
* @return
* Complete list of models found on classpath.
*/
public static Set<YangModuleInfo> getAllModelsFromClasspath() {
Set<YangModuleInfo> moduleInfos = new HashSet<>();
ServiceLoader<YangModelBindingProvider> yangProviderLoader = ServiceLoader.load(YangModelBindingProvider.class);
for (YangModelBindingProvider yangModelBindingProvider : yangProviderLoader) {
moduleInfos.add(yangModelBindingProvider.getModuleInfo());
LOG.info("Adding [{}] module into known modules", yangModelBindingProvider.getModuleInfo());
}
return Collections.unmodifiableSet(moduleInfos);
}
代码示例来源:origin: io.lighty.core/lighty-common
private static Set<YangModuleInfo> filterYangModelBindingProviders(final ModuleId moduleId,
final ServiceLoader<YangModelBindingProvider> yangProviderLoader) {
Set<YangModuleInfo> filteredSet = new HashSet<>();
for (YangModelBindingProvider yangModelBindingProvider : yangProviderLoader) {
if (moduleId.getQName().equals(yangModelBindingProvider.getModuleInfo().getName())) {
filteredSet.add(yangModelBindingProvider.getModuleInfo());
}
}
return filteredSet;
}
代码示例来源:origin: org.opendaylight.yangtools/yang-binding
/**
*
* Loads {@link YangModuleInfo} infos available on supplied classloader.
*
* {@link YangModuleInfo} are discovered using {@link ServiceLoader} for
* {@link YangModelBindingProvider}. {@link YangModelBindingProvider} are
* simple classes which holds only pointers to actual instance
* {@link YangModuleInfo}.
*
* When {@link YangModuleInfo} is available, all dependencies are
* recursivelly collected into returning set by collecting results of
* {@link YangModuleInfo#getImportedModules()}.
*
*
* @param loader
* Classloader for which {@link YangModuleInfo} should be
* retrieved.
* @return Set of {@link YangModuleInfo} available for supplied classloader.
*/
public static ImmutableSet<YangModuleInfo> loadModuleInfos(final ClassLoader loader) {
Builder<YangModuleInfo> moduleInfoSet = ImmutableSet.<YangModuleInfo> builder();
ServiceLoader<YangModelBindingProvider> serviceLoader = ServiceLoader.load(YangModelBindingProvider.class,
loader);
for (YangModelBindingProvider bindingProvider : serviceLoader) {
YangModuleInfo moduleInfo = bindingProvider.getModuleInfo();
checkState(moduleInfo != null, "Module Info for %s is not available.", bindingProvider.getClass());
collectYangModuleInfo(bindingProvider.getModuleInfo(), moduleInfoSet);
}
return moduleInfoSet.build();
}
代码示例来源:origin: org.opendaylight.mdsal/mdsal-binding-dom-codec-osgi
private static YangModuleInfo retrieveModuleInfo(final String moduleInfoClass, final Bundle bundle) {
final Class<?> clazz = loadClass(moduleInfoClass, bundle);
if (!YangModelBindingProvider.class.isAssignableFrom(clazz)) {
String errorMessage = logMessage("Class {} does not implement {} in bundle {}", clazz,
YangModelBindingProvider.class, bundle);
throw new IllegalStateException(errorMessage);
}
final YangModelBindingProvider instance;
try {
Object instanceObj = clazz.newInstance();
instance = YangModelBindingProvider.class.cast(instanceObj);
} catch (InstantiationException e) {
String errorMessage = logMessage("Could not instantiate {} in bundle {}, reason {}", moduleInfoClass,
bundle, e);
throw new IllegalStateException(errorMessage, e);
} catch (IllegalAccessException e) {
String errorMessage = logMessage("Illegal access during instantiation of class {} in bundle {}, reason {}",
moduleInfoClass, bundle, e);
throw new IllegalStateException(errorMessage, e);
}
try {
return instance.getModuleInfo();
} catch (NoClassDefFoundError | ExceptionInInitializerError e) {
throw new IllegalStateException("Error while executing getModuleInfo on " + instance, e);
}
}
内容来源于网络,如有侵权,请联系作者删除!