List of usage examples for org.springframework.core.type StandardAnnotationMetadata StandardAnnotationMetadata
@Deprecated
public StandardAnnotationMetadata(Class<?> introspectedClass)
From source file:com.github.persapiens.jsfboot.annotations.JsfCdiToSpringScopeMetadadaResolverIT.java
public void testNoScope() { AnnotationMetadata annotationMetadata = new StandardAnnotationMetadata(NoScopedClass.class); AnnotatedBeanDefinition beanDefinition = new AnnotatedGenericBeanDefinition(annotationMetadata); AnnotationScopeMetadataResolver annotationScopeMetadataResolver = new JsfCdiToSpringScopeMetadataResolver(); ScopeMetadata scopeMetadata = annotationScopeMetadataResolver.resolveScopeMetadata(beanDefinition); assertThat(scopeMetadata.getScopeName()).isEqualTo(JsfCdiToSpring.SINGLETON); }
From source file:com.github.persapiens.jsfboot.annotations.JsfCdiToSpringBeanNameGeneratorIT.java
public void testNoScope() { AnnotationMetadata annotationMetadata = new StandardAnnotationMetadata(NoScopedClass.class); AnnotatedBeanDefinition beanDefinition = new AnnotatedGenericBeanDefinition(annotationMetadata); BeanDefinitionRegistry registry = new SimpleBeanDefinitionRegistry(); AnnotationBeanNameGenerator annotationBeanNameGeneratorannotationScopeMetadataResolver = new JsfCdiToSpringBeanNameGenerator(); annotationBeanNameGeneratorannotationScopeMetadataResolver.generateBeanName(beanDefinition, registry); assertThat(beanDefinition.getScope()).isEmpty(); }
From source file:me.yanaga.winter.data.jpa.spring.config.metadata.EnableRepositoriesMetadataTest.java
@Test public void testMetadataValueAndBasePackagesAndClasses() { StandardAnnotationMetadata annotationMetadata = new StandardAnnotationMetadata( ValueAndBasePackagesAndClassesConfiguration.class); EnableRepositoriesMetadata metadata = EnableRepositoriesMetadata.of(annotationMetadata); assertThat(metadata.getPackagesToScan()).contains("me", "me.yanaga", "me.yanaga.winter.data.jpa"); }
From source file:org.joinfaces.annotations.JsfCdiToSpringApplicationBeanFactoryPostProcessorIT.java
@Test public void testSessionScopedClass() { GenericApplicationContext acx = new GenericApplicationContext(); AnnotationConfigUtils.registerAnnotationConfigProcessors(acx); acx.registerBeanDefinition("sessionScopedClass", new AnnotatedGenericBeanDefinition(new StandardAnnotationMetadata(SessionScopedClass.class))); acx.registerBeanDefinition("scopedBeansConfiguration", new RootBeanDefinition(ScopedBeansConfiguration.class)); acx.addBeanFactoryPostProcessor(new JsfCdiToSpringBeanFactoryPostProcessor()); acx.refresh();//from w ww . j av a2 s .c om assertThat(acx.getBeanDefinition("sessionScopedClass").getScope()).isEqualTo(JsfCdiToSpring.SESSION); assertThat(acx.getBeanDefinition("sessionScopedBean").getScope()).isEqualTo(JsfCdiToSpring.SESSION); }
From source file:com.github.persapiens.jsfboot.annotations.JsfCdiToSpringScopeMetadadaResolverIT.java
public void testGenericBeanDefinition() { AnnotationMetadata annotationMetadata = new StandardAnnotationMetadata(SessionScopedClass.class); AnnotatedBeanDefinition annotatedBeanDefinition = new AnnotatedGenericBeanDefinition(annotationMetadata); GenericBeanDefinition beanDefinition = new GenericBeanDefinition(annotatedBeanDefinition); AnnotationScopeMetadataResolver annotationScopeMetadataResolver = new JsfCdiToSpringScopeMetadataResolver(); ScopeMetadata scopeMetadata = annotationScopeMetadataResolver.resolveScopeMetadata(beanDefinition); assertThat(scopeMetadata.getScopeName()).isEqualTo(JsfCdiToSpring.SINGLETON); }
From source file:com.github.persapiens.jsfboot.annotations.JsfCdiToSpringBeanNameGeneratorIT.java
public void testGenericBeanDefinition() { AnnotationMetadata annotationMetadata = new StandardAnnotationMetadata(SessionScopedClass.class); AnnotatedBeanDefinition annotatedBeanDefinition = new AnnotatedGenericBeanDefinition(annotationMetadata); GenericBeanDefinition beanDefinition = new GenericBeanDefinition(annotatedBeanDefinition); BeanDefinitionRegistry registry = new SimpleBeanDefinitionRegistry(); AnnotationBeanNameGenerator annotationBeanNameGeneratorannotationScopeMetadataResolver = new JsfCdiToSpringBeanNameGenerator(); annotationBeanNameGeneratorannotationScopeMetadataResolver.generateBeanName(beanDefinition, registry); assertThat(beanDefinition.getScope()).isEmpty(); }
From source file:org.joinfaces.annotations.JsfCdiToSpringApplicationBeanFactoryPostProcessorIT.java
@Test public void testNoScopedClass() { GenericApplicationContext acx = new GenericApplicationContext(); AnnotationConfigUtils.registerAnnotationConfigProcessors(acx); acx.registerBeanDefinition("noScopedClass", new AnnotatedGenericBeanDefinition(new StandardAnnotationMetadata(NoScopedClass.class))); acx.registerBeanDefinition("scopedBeansConfiguration", new RootBeanDefinition(ScopedBeansConfiguration.class)); acx.addBeanFactoryPostProcessor(new JsfCdiToSpringBeanFactoryPostProcessor()); acx.refresh();//from w w w.j a v a2 s. c o m assertThat(acx.getBeanDefinition("noScopedClass").getScope()).isEqualTo(""); assertThat(acx.getBeanDefinition("noScopedBean").getScope()).isEqualTo(""); }
From source file:org.codehaus.groovy.grails.orm.hibernate.GrailsHibernateDomainClass.java
/** * <p/>/* ww w . j a v a 2 s . c om*/ * Contructor to be used by all child classes to create a new instance * and get the name right. * * @param clazz the Grails class * @param sessionFactory The Hibernate SessionFactory instance * @param metaData The ClassMetaData for this class retrieved from the SF * @param defaultContraints The default global constraints definition */ public GrailsHibernateDomainClass(Class clazz, SessionFactory sessionFactory, ClassMetadata metaData, Map<String, Object> defaultContraints) { super(clazz, ""); // configure identity property this.metadata = new StandardAnnotationMetadata(clazz); String ident = metaData.getIdentifierPropertyName(); this.defaultConstraints = defaultContraints; if (ident != null) { Class identType = getPropertyType(ident); this.identifier = new GrailsHibernateDomainClassProperty(this, ident); this.identifier.setIdentity(true); this.identifier.setType(identType); propertyMap.put(ident, identifier); } // configure the version property final int versionIndex = metaData.getVersionProperty(); String versionPropertyName = null; if (versionIndex > -1) { versionPropertyName = metaData.getPropertyNames()[versionIndex]; this.version = new GrailsHibernateDomainClassProperty(this, versionPropertyName); } // configure remaining properties String[] propertyNames = metaData.getPropertyNames(); for (String propertyName : propertyNames) { if (!propertyName.equals(ident) && !(versionPropertyName != null && propertyName.equals(versionPropertyName))) { GrailsHibernateDomainClassProperty prop = new GrailsHibernateDomainClassProperty(this, propertyName); prop.setType(getPropertyType(propertyName)); Type hibernateType = metaData.getPropertyType(propertyName); // if its an association type if (hibernateType.isAssociationType()) { prop.setAssociation(true); // get the associated type from the session factory // and set it on the property AssociationType assType = (AssociationType) hibernateType; if (assType instanceof AnyType) continue; try { String associatedEntity = assType .getAssociatedEntityName((SessionFactoryImplementor) sessionFactory); ClassMetadata associatedMetaData = sessionFactory.getClassMetadata(associatedEntity); prop.setRelatedClassType(associatedMetaData.getMappedClass(EntityMode.POJO)); } catch (MappingException me) { // other side must be a value object if (hibernateType.isCollectionType()) { prop.setRelatedClassType(Collection.class); } } // configure type of relationship if (hibernateType.isCollectionType()) { prop.setOneToMany(true); } else if (hibernateType.isEntityType()) { prop.setManyToOne(true); // might not really be true, but for our // purposes this is ok prop.setOneToOne(true); } } propertyMap.put(propertyName, prop); } } this.properties = propertyMap.values().toArray(new GrailsDomainClassProperty[propertyMap.size()]); // process the constraints evaluateConstraints(defaultContraints); }