All Downloads are FREE. Search and download functionalities are using the official Maven repository.

net.stickycode.bootstrap.spring3.StickyScopeMetadataResolver Maven / Gradle / Ivy

Go to download

Bootstrap support for guice that will scan the given packages and contruct an injector for it

The newest version!
package net.stickycode.bootstrap.spring3;

import net.stickycode.stereotype.StickyDomain;

import org.springframework.beans.factory.annotation.AnnotatedBeanDefinition;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.context.annotation.ScopeMetadata;
import org.springframework.context.annotation.ScopeMetadataResolver;


public class StickyScopeMetadataResolver
    implements ScopeMetadataResolver {

  @Override
  public ScopeMetadata resolveScopeMetadata(BeanDefinition definition) {
    ScopeMetadata metadata = new ScopeMetadata();
    if (definition instanceof AnnotatedBeanDefinition) {
      AnnotatedBeanDefinition annDef = (AnnotatedBeanDefinition) definition;
      if (annDef.getMetadata().hasAnnotation(StickyDomain.class.getName())) {
        metadata.setScopeName("prototype");
      }
      else if (annDef.getMetadata().hasMetaAnnotation(StickyDomain.class.getName())) {
        metadata.setScopeName("prototype");
      }
      else {
        metadata.setScopeName("singleton");
      }
    }
    return metadata;
  }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy