congrats Icon
New! Tabnine Pro 14-day free trial
Start a free trial
Tabnine Logo
AbstractImportSelector
Code IndexAdd Tabnine to your IDE (free)

How to use
AbstractImportSelector
in
com.nepxion.matrix.selector

Best Java code snippets using com.nepxion.matrix.selector.AbstractImportSelector (Showing top 2 results out of 315)

origin: Nepxion/Matrix

@Override
public String[] selectImports(AnnotationMetadata metadata) {
  if (!isEnabled()) {
    return new String[0];
  }
  AnnotationAttributes attributes = AnnotationAttributes.fromMap(metadata.getAnnotationAttributes(this.annotationClass.getName(), true));
  Assert.notNull(attributes, "No " + getSimpleName() + " attributes found. Is " + metadata.getClassName() + " annotated with @" + getSimpleName() + "?");
  // Find all possible auto configuration classes, filtering duplicates
  List<String> factories = new ArrayList<>(new LinkedHashSet<>(SpringFactoriesLoader.loadFactoryNames(this.annotationClass, this.beanClassLoader)));
  if (factories.isEmpty() && !hasDefaultFactory()) {
    throw new IllegalStateException("Annotation @" + getSimpleName() + " found, but there are no implementations. Did you forget to include a starter?");
  }
  if (factories.size() > 1) {
    // there should only ever be one DiscoveryClient, but there might be more than one factory
    LOG.warn("More than one implementation " + "of @" + getSimpleName() + " (now relying on @Conditionals to pick one): " + factories);
  }
  return factories.toArray(new String[factories.size()]);
}
origin: Nepxion/Matrix

@Override
public String[] selectImports(AnnotationMetadata metadata) {
  // 获取父类的Configuration列表
  String[] imports = super.selectImports(metadata);
  // 从注解上获取参数
  AnnotationAttributes attributes = AnnotationAttributes.fromMap(metadata.getAnnotationAttributes(getAnnotationClass().getName(), true));
  boolean extension = attributes.getBoolean("extension");
  if (extension) {
    // 如果EnableMyAnnotation注解上的extension为true,那么去装载MyConfigurationExtension,即初始化里面的MyBeanExtension
    List<String> importsList = new ArrayList<>(Arrays.asList(imports));
    importsList.add(MyConfigurationExtension.class.getCanonicalName());
    imports = importsList.toArray(new String[0]);
  } else {
    // 如果EnableMyAnnotation注解上的extension为false,那么你可以把该参数动态放到属性列表里
    Environment environment = getEnvironment();
    if (ConfigurableEnvironment.class.isInstance(environment)) {
      ConfigurableEnvironment configurableEnvironment = (ConfigurableEnvironment) environment;
      LinkedHashMap<String, Object> map = new LinkedHashMap<>();
      map.put("extension.enabled", false);
      MapPropertySource propertySource = new MapPropertySource("nepxion", map);
      configurableEnvironment.getPropertySources().addLast(propertySource);
    }
  }
  return imports;
}
com.nepxion.matrix.selectorAbstractImportSelector

Most used methods

  • getSimpleName
  • hasDefaultFactory
  • isEnabled
  • selectImports

Popular in Java

  • Reading from database using SQL prepared statement
  • getSharedPreferences (Context)
  • getExternalFilesDir (Context)
  • notifyDataSetChanged (ArrayAdapter)
  • Rectangle (java.awt)
    A Rectangle specifies an area in a coordinate space that is enclosed by the Rectangle object's top-
  • Path (java.nio.file)
  • Vector (java.util)
    Vector is an implementation of List, backed by an array and synchronized. All optional operations in
  • BlockingQueue (java.util.concurrent)
    A java.util.Queue that additionally supports operations that wait for the queue to become non-empty
  • JLabel (javax.swing)
  • Base64 (org.apache.commons.codec.binary)
    Provides Base64 encoding and decoding as defined by RFC 2045.This class implements section 6.8. Base
  • Top 15 Vim Plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyStudentsTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now