gpt4 book ai didi

org.opendaylight.yangtools.yang.binding.YangModelBindingProvider.getModuleInfo()方法的使用及代码示例

转载 作者:知者 更新时间:2024-03-16 20:53:31 27 4
gpt4 key购买 nike

本文整理了Java中org.opendaylight.yangtools.yang.binding.YangModelBindingProvider.getModuleInfo()方法的一些代码示例,展示了YangModelBindingProvider.getModuleInfo()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。YangModelBindingProvider.getModuleInfo()方法的具体详情如下:
包路径:org.opendaylight.yangtools.yang.binding.YangModelBindingProvider
类名称:YangModelBindingProvider
方法名:getModuleInfo

YangModelBindingProvider.getModuleInfo介绍

[英]Returns YangModuleInfo associated with a package.
[中]返回与包关联的模块信息。

代码示例

代码示例来源: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);
  }
}

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com