@Override public void registerBeanDefinitions(AnnotationMetadata importingClassMetadata, BeanDefinitionRegistry registry) { logger.debug("Searching for mappers annotated with @Mapper"); ClassPathMapperScanner scanner = new ClassPathMapperScanner(registry); try { if (this.resourceLoader != null) { scanner.setResourceLoader(this.resourceLoader); } List<String> packages = AutoConfigurationPackages.get(this.beanFactory); if (logger.isDebugEnabled()) { for (String pkg : packages) { logger.debug("Using auto-configuration base package '" + pkg + "'"); } } scanner.setAnnotationClass(Mapper.class); scanner.registerFilters(); scanner.doScan(StringUtils.toStringArray(packages)); } catch (IllegalStateException ex) { logger.debug("Could not determine auto-configuration package, automatic mapper scanning disabled." + ex); } }
@Override public void registerBeanDefinitions(AnnotationMetadata importingClassMetadata, BeanDefinitionRegistry registry) { logger.debug("Searching for mappers annotated with @Mapper"); ClassPathMapperScanner scanner = new ClassPathMapperScanner(registry); scanner.setMapperProperties(environment); try { if (this.resourceLoader != null) { scanner.setResourceLoader(this.resourceLoader); } List<String> packages = AutoConfigurationPackages.get(this.beanFactory); if (logger.isDebugEnabled()) { for (String pkg : packages) { logger.debug("Using auto-configuration base package '{}'", pkg); } } scanner.setAnnotationClass(Mapper.class); scanner.registerFilters(); scanner.doScan(StringUtils.toStringArray(packages)); } catch (IllegalStateException ex) { logger.debug("Could not determine auto-configuration package, automatic mapper scanning disabled.", ex); } }
private void createClassPathMapperScanner(BeanDefinitionRegistry registry, String prefixName) { ClassPathMapperScanner scanner = new ClassPathMapperScanner(registry); try { if (this.resourceLoader != null) { scanner.setResourceLoader(this.resourceLoader); } List<String> packages = AutoConfigurationPackages.get(beanFactory); packages.forEach(pkg -> log.info("Using auto-configuration base package '{}'", pkg)); scanner.setAnnotationClass(Mapper.class); scanner.setSqlSessionFactoryBeanName(prefixName + "SessionFactory"); scanner.registerFilters(); scanner.doScan(StringUtils.toStringArray(packages)); } catch (IllegalStateException ex) { log.info("Could not determine auto-configuration package", ex); } }
@Test public void hasRecreateSchemaActionSet() { createTestKeyspaceIfNotExists(); this.context = new AnnotationConfigApplicationContext(); String cityPackage = City.class.getPackage().getName(); AutoConfigurationPackages.register(this.context, cityPackage); EnvironmentTestUtils.addEnvironment(this.context, "spring.data.cassandra.schemaAction:RECREATE_DROP_UNUSED", "spring.data.cassandra.keyspaceName:boot_test"); this.context.register(CassandraAutoConfiguration.class, CassandraDataAutoConfiguration.class); this.context.refresh(); CassandraSessionFactoryBean bean = this.context .getBean(CassandraSessionFactoryBean.class); assertThat(bean.getSchemaAction()).isEqualTo(SchemaAction.RECREATE_DROP_UNUSED); }
@Override public void registerBeanDefinitions(AnnotationMetadata importingClassMetadata, BeanDefinitionRegistry registry) { logger.debug("Searching for mappers annotated with @Mapper"); ClassPathMapperScanner scanner = new ClassPathMapperScanner(registry); try { if (this.resourceLoader != null) { scanner.setResourceLoader(this.resourceLoader); } List<String> packages = AutoConfigurationPackages.get(this.beanFactory); if (logger.isDebugEnabled()) { packages.forEach(pkg -> logger.debug("Using auto-configuration base package '{}'", pkg)); } scanner.setAnnotationClass(Mapper.class); scanner.registerFilters(); scanner.doScan(StringUtils.toStringArray(packages)); } catch (IllegalStateException ex) { logger.debug("Could not determine auto-configuration package, automatic mapper scanning disabled.", ex); } }
@Bean public DaoScannerConfigurer getScannerConfigurer() { // Try to use @EnableAutoConfiguration base packages List<String> basePackages = null; try { basePackages = AutoConfigurationPackages.get(context); } catch (Exception e) { } if (basePackages == null || basePackages.size() == 0) return null; DaoScannerConfigurer cfg = new DaoScannerConfigurer(); cfg.setBasePackage(basePackages.stream().collect( Collectors.joining(","))); return cfg; }
@Override public void registerBeanDefinitions(AnnotationMetadata metadata, BeanDefinitionRegistry registry) { final AnnotationAttributes attributes = AnnotationAttributes .fromMap(metadata.getAnnotationAttributes( TestAutoConfigurationPackage.class.getName(), true)); AutoConfigurationPackages.register(registry, ClassUtils.getPackageName(attributes.getString("value"))); }
@Override public void registerBeanDefinitions(AnnotationMetadata importingClassMetadata, BeanDefinitionRegistry registry) { List<String> packages = AutoConfigurationPackages.get(beanFactory); registerDubboService(packages, registry); registerDubboReference(registry); }
private String[] getPackagesToScan() { List<String> packages = EntityScanPackages.get(this.applicationContext) .getPackageNames(); if (packages.isEmpty() && AutoConfigurationPackages.has(this.applicationContext)) { packages = AutoConfigurationPackages.get(this.applicationContext); } return packages.toArray(new String[packages.size()]); }
@Bean @ConditionalOnMissingBean public CassandraMappingContext cassandraMapping() throws ClassNotFoundException { BasicCassandraMappingContext context = new BasicCassandraMappingContext(); List<String> packages = EntityScanPackages.get(this.beanFactory) .getPackageNames(); if (packages.isEmpty() && AutoConfigurationPackages.has(this.beanFactory)) { packages = AutoConfigurationPackages.get(this.beanFactory); } if (!packages.isEmpty()) { context.setInitialEntitySet(CassandraEntityClassScanner.scan(packages)); } return context; }
private List<String> getPackages() { List<String> packages = EntityScanPackages.get(this.context).getPackageNames(); if (packages.isEmpty() && AutoConfigurationPackages.has(this.context)) { packages = AutoConfigurationPackages.get(this.context); } return packages; }
protected String[] getPackagesToScan() { List<String> packages = EntityScanPackages.get(this.beanFactory) .getPackageNames(); if (packages.isEmpty() && AutoConfigurationPackages.has(this.beanFactory)) { packages = AutoConfigurationPackages.get(this.beanFactory); } return packages.toArray(new String[packages.size()]); }
@Test public void usesAutoConfigurationPackageToPickUpDocumentTypes() { this.context = new AnnotationConfigApplicationContext(); String cityPackage = City.class.getPackage().getName(); AutoConfigurationPackages.register(this.context, cityPackage); this.context.register(MongoAutoConfiguration.class, MongoDataAutoConfiguration.class); this.context.refresh(); assertDomainTypesDiscovered(this.context.getBean(MongoMappingContext.class), City.class); }
@Test public void usesAutoConfigurationPackageToPickUpDomainTypes() { this.context = new AnnotationConfigApplicationContext(); String cityPackage = City.class.getPackage().getName(); AutoConfigurationPackages.register(this.context, cityPackage); this.context.register(Neo4jDataAutoConfiguration.class); this.context.refresh(); assertDomainTypesDiscovered(this.context.getBean(Neo4jMappingContext.class), City.class); }
@Test public void hasDefaultSchemaActionSet() { this.context = new AnnotationConfigApplicationContext(); String cityPackage = City.class.getPackage().getName(); AutoConfigurationPackages.register(this.context, cityPackage); this.context.register(CassandraAutoConfiguration.class, CassandraDataAutoConfiguration.class); this.context.refresh(); CassandraSessionFactoryBean bean = this.context .getBean(CassandraSessionFactoryBean.class); assertThat(bean.getSchemaAction()).isEqualTo(SchemaAction.NONE); }
private static Collection<String> getMappingBasePackages(BeanFactory beanFactory) { try { return AutoConfigurationPackages.get(beanFactory); } catch (IllegalStateException ex) { // no auto-configuration package registered yet return Collections.emptyList(); } }
protected String[] getPackagesToScan() { if (AutoConfigurationPackages.has(this.beanFactory)) { List<String> basePackages = AutoConfigurationPackages .get(this.beanFactory); return basePackages.toArray(new String[basePackages.size()]); } return new String[0]; }
protected String[] getPackagesToScan() { if (AutoConfigurationPackages.has(this.beanFactory)) { List<String> basePackages = AutoConfigurationPackages.get(this.beanFactory); return basePackages.toArray(new String[basePackages.size()]); } return NO_PACKAGES; }
@Test public void usesAutoConfigurationPackageToPickUpDomainTypes() { String cityPackage = City.class.getPackage().getName(); AutoConfigurationPackages.register(this.context, cityPackage); this.context.register(Neo4jAutoConfiguration.class); this.context.refresh(); assertDomainTypesDiscovered(this.context.getBean(Neo4jMappingContext.class), City.class); }
@Bean @ConditionalOnMissingBean public CassandraMappingContext cassandraMapping() throws ClassNotFoundException { BasicCassandraMappingContext bean = new BasicCassandraMappingContext(); bean.setInitialEntitySet(CassandraEntityClassScanner.scan(AutoConfigurationPackages.get(beanFactory))); bean.setBeanClassLoader(beanFactory.getClass().getClassLoader()); return bean; }
@BeforeMethod public void beforeTest() { PowerMockito.mockStatic(AutoConfigurationPackages.class); List<String> packages = new ArrayList<String>(); packages.add("com.paypal.springboot.resteasy.sample"); PowerMockito.when(AutoConfigurationPackages.get(any(BeanFactory.class))).thenReturn(packages); }
@Override public void registerBeanDefinitions(AnnotationMetadata importingClassMetadata, BeanDefinitionRegistry registry) { AutoConfigurationPackages.register(registry, EventPublication.class.getPackage().getName()); }
@Override public void registerBeanDefinitions(AnnotationMetadata metadata, BeanDefinitionRegistry registry) { doScan(AutoConfigurationPackages.get(beanFactory), scanner, registry); }
@Override public void registerBeanDefinitions(AnnotationMetadata arg0, BeanDefinitionRegistry registry) { AutoConfigurationPackages.register(registry, RestifyAutoConfigurationTest.class.getPackage().getName()); }
protected Iterable<String> getBasePackages() { return AutoConfigurationPackages.get(this.beanFactory); }
protected String[] getBasePackages() { return AutoConfigurationPackages.get(this.getBeanFactory()).toArray(new String[] {}); }