Examples of AnnotationMetadata


Examples of org.springframework.core.type.AnnotationMetadata

   * Derive a bean name from one of the annotations on the class.
   * @param annotatedDef the annotation-aware bean definition
   * @return the bean name, or <code>null</code> if none is found
   */
  protected String determineBeanNameFromAnnotation(AnnotatedBeanDefinition annotatedDef) {
    AnnotationMetadata amd = annotatedDef.getMetadata();
    Set<String> types = amd.getAnnotationTypes();
    String beanName = null;
    for (String type : types) {
      AnnotationAttributes attributes = MetadataUtils.attributesFor(amd, type);
      if (isStereotypeWithNameValue(type, amd.getMetaAnnotationTypes(type), attributes)) {
        String value = (String) attributes.get("value");
        if (StringUtils.hasLength(value)) {
          if (beanName != null && !value.equals(beanName)) {
            throw new IllegalStateException("Stereotype annotations suggest inconsistent " +
                "component names: '" + beanName + "' versus '" + value + "'");
View Full Code Here

Examples of org.springframework.core.type.AnnotationMetadata

    registerBean(annotatedClass, null, qualifiers);
  }

  public void registerBean(Class<?> annotatedClass, String name, Class<? extends Annotation>... qualifiers) {
    AnnotatedGenericBeanDefinition abd = new AnnotatedGenericBeanDefinition(annotatedClass);
    AnnotationMetadata metadata = abd.getMetadata();
    if (metadata.isAnnotated(Profile.class.getName())) {
      AnnotationAttributes profile = MetadataUtils.attributesFor(metadata, Profile.class);
      if (!this.environment.acceptsProfiles(profile.getStringArray("value"))) {
        return;
      }
    }
View Full Code Here

Examples of org.springframework.core.type.AnnotationMetadata

        return false;
      }
    }
    for (TypeFilter tf : this.includeFilters) {
      if (tf.match(metadataReader, this.metadataReaderFactory)) {
        AnnotationMetadata metadata = metadataReader.getAnnotationMetadata();
        if (!metadata.isAnnotated(Profile.class.getName())) {
          return true;
        }
        AnnotationAttributes profile = MetadataUtils.attributesFor(metadata, Profile.class);
        return this.environment.acceptsProfiles(profile.getStringArray("value"));
      }
View Full Code Here

Examples of org.springframework.core.type.AnnotationMetadata

      if (bean instanceof ImportAware) {
        ImportRegistry importRegistry = this.beanFactory.getBean(IMPORT_REGISTRY_BEAN_NAME, ImportRegistry.class);
        String importingClass = importRegistry.getImportingClassFor(bean.getClass().getSuperclass().getName());
        if (importingClass != null) {
          try {
            AnnotationMetadata metadata =
                new SimpleMetadataReaderFactory().getMetadataReader(importingClass).getAnnotationMetadata();
            ((ImportAware) bean).setImportMetadata(metadata);
          }
          catch (IOException ex) {
            // should never occur -> at this point we know the class is present anyway
View Full Code Here

Examples of org.springframework.core.type.AnnotationMetadata

  public void parse(Class<?> clazz, String beanName) throws IOException {
    processConfigurationClass(new ConfigurationClass(clazz, beanName));
  }

  protected void processConfigurationClass(ConfigurationClass configClass) throws IOException {
    AnnotationMetadata metadata = configClass.getMetadata();
    if (this.environment != null && metadata.isAnnotated(Profile.class.getName())) {
      AnnotationAttributes profile = MetadataUtils.attributesFor(metadata, Profile.class);
      if (!this.environment.acceptsProfiles(profile.getStringArray("value"))) {
        return;
      }
    }
View Full Code Here

Examples of org.springframework.core.type.AnnotationMetadata

  /**
   * Register the {@link Configuration} class itself as a bean definition.
   */
  private void registerBeanDefinitionForImportedConfigurationClass(ConfigurationClass configClass) {
    AnnotationMetadata metadata = configClass.getMetadata();
    BeanDefinition configBeanDef = new AnnotatedGenericBeanDefinition(metadata);
    String className = metadata.getClassName();
    configBeanDef.setBeanClassName(className);
    if (ConfigurationClassUtils.checkConfigurationClassCandidate(configBeanDef, this.metadataReaderFactory)) {
      String configBeanName = this.importBeanNameGenerator.generateBeanName(configBeanDef, this.registry);
      this.registry.registerBeanDefinition(configBeanName, configBeanDef);
      configClass.setBeanName(configBeanName);
View Full Code Here

Examples of org.springframework.core.type.AnnotationMetadata

   * Derive a bean name from one of the annotations on the class.
   * @param annotatedDef the annotation-aware bean definition
   * @return the bean name, or <code>null</code> if none is found
   */
  protected String determineBeanNameFromAnnotation(AnnotatedBeanDefinition annotatedDef) {
    AnnotationMetadata amd = annotatedDef.getMetadata();
    Set<String> types = amd.getAnnotationTypes();
    String beanName = null;
    for (String type : types) {
      Map<String, Object> attributes = amd.getAnnotationAttributes(type);
      if (isStereotypeWithNameValue(type, amd.getMetaAnnotationTypes(type), attributes)) {
        if (attributes != null) {
          String value = (String) attributes.get("value");
          if (StringUtils.hasLength(value)) {
            if (beanName != null && !value.equals(beanName)) {
              throw new IllegalStateException("Stereotype annotations suggest inconsistent " +
View Full Code Here

Examples of org.springframework.core.type.AnnotationMetadata

   */
  protected void postProcessBeanDefinition(AbstractBeanDefinition beanDefinition, String beanName) {
    super.postProcessBeanDefinition(beanDefinition, beanName);
    if (beanDefinition instanceof AnnotatedBeanDefinition) {
      final AnnotatedBeanDefinition abd = (AnnotatedBeanDefinition) beanDefinition;
      final AnnotationMetadata amd = abd.getMetadata();
      if (amd.hasAnnotation("org.springframework.stereotype.Controller")) {
        //register @AppliedTo
        BeanDefinition forbd = null;
        String forBean = null;
        if (amd.hasAnnotation("org.zkoss.spring.context.annotation.AppliedTo")) {
          final Map<String, Object> attrs = amd.getAnnotationAttributes("org.zkoss.spring.context.annotation.AppliedTo");
          if (attrs.containsKey("value")) {
            forBean = (String) attrs.get("value");
            forbd = registerZkComponentFactoryBean(forBean, beanName, true, "idspace");
          } else {
            throw new UiException("ZK component id required in @AppliedTo annoation");
View Full Code Here

Examples of org.springframework.core.type.AnnotationMetadata

  }


  @Override
  protected boolean matchSelf(MetadataReader metadataReader) {
    AnnotationMetadata metadata = metadataReader.getAnnotationMetadata();
    return metadata.hasAnnotation(this.annotationType.getName()) ||
        (this.considerMetaAnnotations && metadata.hasMetaAnnotation(this.annotationType.getName()));
  }
View Full Code Here

Examples of org.springframework.core.type.AnnotationMetadata

            this.considerMetaAnnotations = considerMetaAnnotations;
        }

        @Override
        protected boolean matchSelf(MetadataReader metadataReader) {
            AnnotationMetadata metadata = metadataReader.getAnnotationMetadata();
            return metadata.hasAnnotation(this.annotationType.getName())
                    || (this.considerMetaAnnotations && metadata.hasMetaAnnotation(this.annotationType.getName()));
        }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.