Package org.springframework.context.annotation

Examples of org.springframework.context.annotation.ScopeMetadata


        }
        return requestScopeAsDefault();
    }

    private ScopeMetadata requestScopeAsDefault() {
        ScopeMetadata singleton = new ScopeMetadata();
        singleton.setScopeName(WebApplicationContext.SCOPE_REQUEST);
        return singleton;
    }
View Full Code Here


    String name = beanNameGenerator.generateBeanName(definition, registry);
    BeanDefinitionHolder definitionHolder = new BeanDefinitionHolder(definition, name);

    VRaptorScopeResolver scopeResolver = new VRaptorScopeResolver();
    ScopeMetadata scopeMetadata = scopeResolver.resolveScopeMetadata(definition);
    definitionHolder = applyScopeOn(registry, definitionHolder, scopeMetadata);

    BeanDefinitionReaderUtils.registerBeanDefinition(definitionHolder, registry);
  }
View Full Code Here

     *
     * @param beanDef the component bean definition to resolve
     * @return the scope meta data for the given bean definition.
     */
    public ScopeMetadata resolveScopeMetadata(BeanDefinition beanDef) {
        ScopeMetadata sm = new ScopeMetadata();

        try {
            Class<?> beanClass = ClickUtils.classForName(beanDef.getBeanClassName());

            if (Page.class.isAssignableFrom(beanClass)) {
                sm.setScopeName(ConfigurableBeanFactory.SCOPE_PROTOTYPE);

            } else {
                // TODO: see whether we can determine the default scope definition
                // from the beanDef and return this instead.
                sm.setScopeName(ConfigurableBeanFactory.SCOPE_SINGLETON);
            }

            return sm;

        } catch (Exception e) {
View Full Code Here

    String name = beanNameGenerator.generateBeanName(definition, registry);
    BeanDefinitionHolder definitionHolder = new BeanDefinitionHolder(definition, name);

    VRaptorScopeResolver scopeResolver = new VRaptorScopeResolver();
    ScopeMetadata scopeMetadata = scopeResolver.resolveScopeMetadata(definition);
    definitionHolder = applyScopeOn(registry, definitionHolder, scopeMetadata);

    BeanDefinitionReaderUtils.registerBeanDefinition(definitionHolder, registry);
  }
View Full Code Here

     *
     * @param candidate the candidate to reload
     */
    public void defineBean(BeanDefinition candidate) {
        synchronized (getClass()) { // TODO sychronize on DefaultListableFactory.beanDefinitionMap?
            ScopeMetadata scopeMetadata = this.scopeMetadataResolver.resolveScopeMetadata(candidate);
            candidate.setScope(scopeMetadata.getScopeName());
            String beanName = this.beanNameGenerator.generateBeanName(candidate, registry);
            if (candidate instanceof AbstractBeanDefinition) {
                postProcessBeanDefinition((AbstractBeanDefinition) candidate, beanName);
            }
            if (candidate instanceof AnnotatedBeanDefinition) {
View Full Code Here

    definition.setRole(customComponent ? BeanDefinition.ROLE_APPLICATION : BeanDefinition.ROLE_INFRASTRUCTURE);

    String name = beanNameGenerator.generateBeanName(definition, (BeanDefinitionRegistry) beanFactory);
    BeanDefinitionHolder definitionHolder = new BeanDefinitionHolder(definition, name);

    ScopeMetadata scopeMetadata = scopeResolver.resolveScopeMetadata(definition);
    definitionHolder = applyScopeOn(definitionHolder, scopeMetadata);

    BeanDefinitionReaderUtils.registerBeanDefinition(definitionHolder, (BeanDefinitionRegistry) beanFactory);
  }
View Full Code Here

    definition.setRole(customComponent ? BeanDefinition.ROLE_APPLICATION : BeanDefinition.ROLE_INFRASTRUCTURE);

    String name = beanNameGenerator.generateBeanName(definition, (BeanDefinitionRegistry) beanFactory);
    BeanDefinitionHolder definitionHolder = new BeanDefinitionHolder(definition, name);

    ScopeMetadata scopeMetadata = scopeResolver.resolveScopeMetadata(definition);
    definitionHolder = applyScopeOn(definitionHolder, scopeMetadata);

    BeanDefinitionReaderUtils.registerBeanDefinition(definitionHolder, (BeanDefinitionRegistry) beanFactory);
  }
View Full Code Here

    //
    if (scope != null) {
      definition.setScope(scope.name().toLowerCase());
    }
    else {
      ScopeMetadata scopeMD = builder.scopeResolver.resolveScopeMetadata(definition);
      if (scopeMD != null) {
        definition.setScope(scopeMD.getScopeName());
      }
    }

    //
    if (qualifiers != null) {
View Full Code Here

    this.scopes = scopes;
  }

  @Override
  public ScopeMetadata resolveScopeMetadata(BeanDefinition definition) {
    ScopeMetadata metadata = new ScopeMetadata();
    if (definition instanceof AnnotatedBeanDefinition) {
      AnnotatedBeanDefinition annDef = (AnnotatedBeanDefinition)definition;
      Set<String> annotationTypes = annDef.getMetadata().getAnnotationTypes();

      //
      String scopeName;
      if (annotationTypes.contains(Singleton.class.getName())) {
        scopeName = "singleton";
      }
      else {
        scopeName = "prototype";
        for (Scope scope : scopes) {
          if (annotationTypes.contains(scope.getAnnotationType().getName())) {
            scopeName = scope.name().toLowerCase();
            break;
          }
        }
      }
      metadata.setScopeName(scopeName);
      return metadata;
    }
    else {
      return super.resolveScopeMetadata(definition);
    }
View Full Code Here

    //
    if (scope != null) {
      definition.setScope(scope.name().toLowerCase());
    }
    else {
      ScopeMetadata scopeMD = builder.scopeResolver.resolveScopeMetadata(definition);
      if (scopeMD != null) {
        definition.setScope(scopeMD.getScopeName());
      }
    }

    //
    if (qualifiers != null) {
View Full Code Here

TOP

Related Classes of org.springframework.context.annotation.ScopeMetadata

Copyright © 2018 www.massapicom. 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.