コード例 #1
1
  protected void processConfigurationClass(ConfigurationClass configClass) throws IOException {
    AnnotationMetadata metadata = configClass.getMetadata();
    if (this.environment != null && ProfileHelper.isProfileAnnotationPresent(metadata)) {
      if (!this.environment.acceptsProfiles(ProfileHelper.getCandidateProfiles(metadata))) {
        return;
      }
    }

    while (metadata != null) {
      doProcessConfigurationClass(configClass, metadata);
      String superClassName = metadata.getSuperClassName();
      if (superClassName != null && !Object.class.getName().equals(superClassName)) {
        if (metadata instanceof StandardAnnotationMetadata) {
          Class<?> clazz = ((StandardAnnotationMetadata) metadata).getIntrospectedClass();
          metadata = new StandardAnnotationMetadata(clazz.getSuperclass());
        } else {
          MetadataReader reader = this.metadataReaderFactory.getMetadataReader(superClassName);
          metadata = reader.getAnnotationMetadata();
        }
      } else {
        metadata = null;
      }
    }
    if (this.configurationClasses.contains(configClass) && configClass.getBeanName() != null) {
      // Explicit bean definition found, probably replacing an import.
      // Let's remove the old one and go with the new one.
      this.configurationClasses.remove(configClass);
    }

    this.configurationClasses.add(configClass);
  }
コード例 #2
0
 @Test
 public void testNoConverterEnforcement() {
   ProfileHelper.setEnforceProfileDefinition(true);
   try {
     assertNull(definition.convert(NAME, VALUE));
   } finally {
     ProfileHelper.setEnforceProfileDefinition(false);
   }
 }
コード例 #3
0
 @Test
 public void testConverterEnforcement() {
   ProfileHelper.setEnforceProfileDefinition(true);
   try {
     definition.addAttribute(NAME, new FakeConverter());
     assertEquals(FAKE_VALUE, definition.convert(NAME, VALUE));
   } finally {
     ProfileHelper.setEnforceProfileDefinition(false);
   }
 }