org.springframework.core.type.filter.TypeFilter Java Examples
The following examples show how to use
org.springframework.core.type.filter.TypeFilter.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: GroovyScanner.java From nh-micro with Apache License 2.0 | 5 votes |
public void registerDefaultFilters() { this.addIncludeFilter(new TypeFilter() { @Override public boolean match(MetadataReader metadataReader, MetadataReaderFactory metadataReaderFactory) throws IOException { //add 201806 ninghao boolean flag=metadataReader.getAnnotationMetadata().hasAnnotation("com.nh.micro.service.InjectGroovy"); return flag; } }); }
Example #2
Source File: ClassPathScanningCandidateComponentProvider.java From spring-analysis-note with MIT License | 5 votes |
/** * Determine if the index can be used by this instance. * @return {@code true} if the index is available and the configuration of this * instance is supported by it, {@code false} otherwise * @since 5.0 */ private boolean indexSupportsIncludeFilters() { for (TypeFilter includeFilter : this.includeFilters) { if (!indexSupportsIncludeFilter(includeFilter)) { return false; } } return true; }
Example #3
Source File: RpcInvokerAnnotationScanner.java From hasting with MIT License | 5 votes |
public RpcInvokerAnnotationScanner(BeanDefinitionRegistry registry,Map<String,AbstractRpcClient> rpcClients) { super(registry,false); this.rpcClients = rpcClients; super.addIncludeFilter(new TypeFilter(){ @Override public boolean match(MetadataReader metadataReader,MetadataReaderFactory metadataReaderFactory)throws IOException { String className = metadataReader.getClassMetadata().getClassName(); return acceptClassName(className); } }); }
Example #4
Source File: ClassPathScanningCandidateComponentProvider.java From spring-analysis-note with MIT License | 5 votes |
/** * Determine if the specified include {@link TypeFilter} is supported by the index. * @param filter the filter to check * @return whether the index supports this include filter * @since 5.0 * @see #extractStereotype(TypeFilter) */ private boolean indexSupportsIncludeFilter(TypeFilter filter) { if (filter instanceof AnnotationTypeFilter) { Class<? extends Annotation> annotation = ((AnnotationTypeFilter) filter).getAnnotationType(); return (AnnotationUtils.isAnnotationDeclaredLocally(Indexed.class, annotation) || annotation.getName().startsWith("javax.")); } if (filter instanceof AssignableTypeFilter) { Class<?> target = ((AssignableTypeFilter) filter).getTargetType(); return AnnotationUtils.isAnnotationDeclaredLocally(Indexed.class, target); } return false; }
Example #5
Source File: ClassPathJaxb2TypeScanner.java From spring-analysis-note with MIT License | 5 votes |
protected boolean isJaxb2Class(MetadataReader reader, MetadataReaderFactory factory) throws IOException { for (TypeFilter filter : JAXB2_TYPE_FILTERS) { if (filter.match(reader, factory) && !reader.getClassMetadata().isInterface() ) { return true; } } return false; }
Example #6
Source File: LocalSessionFactoryBuilder.java From spring-analysis-note with MIT License | 5 votes |
/** * Check whether any of the configured entity type filters matches * the current class descriptor contained in the metadata reader. */ private boolean matchesEntityTypeFilter(MetadataReader reader, MetadataReaderFactory readerFactory) throws IOException { if (this.entityTypeFilters != null) { for (TypeFilter filter : this.entityTypeFilters) { if (filter.match(reader, readerFactory)) { return true; } } } return false; }
Example #7
Source File: ComponentScanBeanDefinitionParser.java From java-technology-stack with MIT License | 5 votes |
@SuppressWarnings("unchecked") protected TypeFilter createTypeFilter(Element element, @Nullable ClassLoader classLoader, ParserContext parserContext) throws ClassNotFoundException { String filterType = element.getAttribute(FILTER_TYPE_ATTRIBUTE); String expression = element.getAttribute(FILTER_EXPRESSION_ATTRIBUTE); expression = parserContext.getReaderContext().getEnvironment().resolvePlaceholders(expression); if ("annotation".equals(filterType)) { return new AnnotationTypeFilter((Class<Annotation>) ClassUtils.forName(expression, classLoader)); } else if ("assignable".equals(filterType)) { return new AssignableTypeFilter(ClassUtils.forName(expression, classLoader)); } else if ("aspectj".equals(filterType)) { return new AspectJTypeFilter(expression, classLoader); } else if ("regex".equals(filterType)) { return new RegexPatternTypeFilter(Pattern.compile(expression)); } else if ("custom".equals(filterType)) { Class<?> filterClass = ClassUtils.forName(expression, classLoader); if (!TypeFilter.class.isAssignableFrom(filterClass)) { throw new IllegalArgumentException( "Class is not assignable to [" + TypeFilter.class.getName() + "]: " + expression); } return (TypeFilter) BeanUtils.instantiateClass(filterClass); } else { throw new IllegalArgumentException("Unsupported filter type: " + filterType); } }
Example #8
Source File: ComponentScanBeanDefinitionParser.java From spring-analysis-note with MIT License | 5 votes |
@SuppressWarnings("unchecked") protected TypeFilter createTypeFilter(Element element, @Nullable ClassLoader classLoader, ParserContext parserContext) throws ClassNotFoundException { String filterType = element.getAttribute(FILTER_TYPE_ATTRIBUTE); String expression = element.getAttribute(FILTER_EXPRESSION_ATTRIBUTE); expression = parserContext.getReaderContext().getEnvironment().resolvePlaceholders(expression); if ("annotation".equals(filterType)) { return new AnnotationTypeFilter((Class<Annotation>) ClassUtils.forName(expression, classLoader)); } else if ("assignable".equals(filterType)) { return new AssignableTypeFilter(ClassUtils.forName(expression, classLoader)); } else if ("aspectj".equals(filterType)) { return new AspectJTypeFilter(expression, classLoader); } else if ("regex".equals(filterType)) { return new RegexPatternTypeFilter(Pattern.compile(expression)); } else if ("custom".equals(filterType)) { Class<?> filterClass = ClassUtils.forName(expression, classLoader); if (!TypeFilter.class.isAssignableFrom(filterClass)) { throw new IllegalArgumentException( "Class is not assignable to [" + TypeFilter.class.getName() + "]: " + expression); } return (TypeFilter) BeanUtils.instantiateClass(filterClass); } else { throw new IllegalArgumentException("Unsupported filter type: " + filterType); } }
Example #9
Source File: DefaultPersistenceUnitManager.java From spring-analysis-note with MIT License | 5 votes |
/** * Check whether any of the configured entity type filters matches * the current class descriptor contained in the metadata reader. */ private boolean matchesFilter(MetadataReader reader, MetadataReaderFactory readerFactory) throws IOException { for (TypeFilter filter : entityTypeFilters) { if (filter.match(reader, readerFactory)) { return true; } } return false; }
Example #10
Source File: AbstractRetrofitClientsRegistrar.java From spring-cloud-square with Apache License 2.0 | 5 votes |
@Override public boolean match(MetadataReader metadataReader, MetadataReaderFactory metadataReaderFactory) throws IOException { for (TypeFilter filter : this.delegates) { if (!filter.match(metadataReader, metadataReaderFactory)) { return false; } } return true; }
Example #11
Source File: DefaultPersistenceUnitManager.java From java-technology-stack with MIT License | 5 votes |
/** * Check whether any of the configured entity type filters matches * the current class descriptor contained in the metadata reader. */ private boolean matchesFilter(MetadataReader reader, MetadataReaderFactory readerFactory) throws IOException { for (TypeFilter filter : entityTypeFilters) { if (filter.match(reader, readerFactory)) { return true; } } return false; }
Example #12
Source File: HandlerAnnotationFactoryBean.java From MultimediaDesktop with Apache License 2.0 | 5 votes |
/** * 检查当前扫描到的Bean含有任何一个指定的注解标记 * * @param reader * @param readerFactory * @return * @throws IOException */ private boolean matchesEntityTypeFilter(MetadataReader reader, MetadataReaderFactory readerFactory) throws IOException { if (!this.typeFilters.isEmpty()) { for (TypeFilter filter : this.typeFilters) { if (filter.match(reader, readerFactory)) { return true; } } } return false; }
Example #13
Source File: LocalSessionFactoryBuilder.java From java-technology-stack with MIT License | 5 votes |
/** * Check whether any of the configured entity type filters matches * the current class descriptor contained in the metadata reader. */ private boolean matchesEntityTypeFilter(MetadataReader reader, MetadataReaderFactory readerFactory) throws IOException { if (this.entityTypeFilters != null) { for (TypeFilter filter : this.entityTypeFilters) { if (filter.match(reader, readerFactory)) { return true; } } } return false; }
Example #14
Source File: ClassPathJaxb2TypeScanner.java From java-technology-stack with MIT License | 5 votes |
protected boolean isJaxb2Class(MetadataReader reader, MetadataReaderFactory factory) throws IOException { for (TypeFilter filter : JAXB2_TYPE_FILTERS) { if (filter.match(reader, factory) && !reader.getClassMetadata().isInterface() ) { return true; } } return false; }
Example #15
Source File: CmisRegistrar.java From spring-content with Apache License 2.0 | 5 votes |
public boolean match(MetadataReader metadataReader, MetadataReaderFactory metadataReaderFactory) throws IOException { for (TypeFilter filter : delegates) { if (!filter.match(metadataReader, metadataReaderFactory)) { return false; } } return true; }
Example #16
Source File: HibernateMappingContextConfiguration.java From gorm-hibernate5 with Apache License 2.0 | 5 votes |
/** * Check whether any of the configured entity type filters matches * the current class descriptor contained in the metadata reader. */ protected boolean matchesFilter(MetadataReader reader, MetadataReaderFactory readerFactory) throws IOException { for (TypeFilter filter : ENTITY_TYPE_FILTERS) { if (filter.match(reader, readerFactory)) { return true; } } return false; }
Example #17
Source File: FeignClientsRegistrar.java From spring-cloud-openfeign with Apache License 2.0 | 5 votes |
@Override public boolean match(MetadataReader metadataReader, MetadataReaderFactory metadataReaderFactory) throws IOException { for (TypeFilter filter : this.delegates) { if (!filter.match(metadataReader, metadataReaderFactory)) { return false; } } return true; }
Example #18
Source File: LocalSessionFactoryBuilder.java From spring4-understanding with Apache License 2.0 | 5 votes |
/** * Check whether any of the configured entity type filters matches * the current class descriptor contained in the metadata reader. */ private boolean matchesEntityTypeFilter(MetadataReader reader, MetadataReaderFactory readerFactory) throws IOException { if (this.entityTypeFilters != null) { for (TypeFilter filter : this.entityTypeFilters) { if (filter.match(reader, readerFactory)) { return true; } } } return false; }
Example #19
Source File: NettyRpcRegistrar.java From BootNettyRpc with Apache License 2.0 | 5 votes |
@Override public boolean match(MetadataReader metadataReader, MetadataReaderFactory metadataReaderFactory) throws IOException { for (TypeFilter filter : this.delegates) { if (!filter.match( metadataReader, metadataReaderFactory )) { return false; } } return true; }
Example #20
Source File: ClassPathJaxb2TypeScanner.java From spring4-understanding with Apache License 2.0 | 5 votes |
protected boolean isJaxb2Class(MetadataReader reader, MetadataReaderFactory factory) throws IOException { for (TypeFilter filter : JAXB2_TYPE_FILTERS) { if (filter.match(reader, factory) && !reader.getClassMetadata().isInterface() ) { return true; } } return false; }
Example #21
Source File: LocalSessionFactoryBuilder.java From spring4-understanding with Apache License 2.0 | 5 votes |
/** * Check whether any of the configured entity type filters matches * the current class descriptor contained in the metadata reader. */ private boolean matchesEntityTypeFilter(MetadataReader reader, MetadataReaderFactory readerFactory) throws IOException { if (this.entityTypeFilters != null) { for (TypeFilter filter : this.entityTypeFilters) { if (filter.match(reader, readerFactory)) { return true; } } } return false; }
Example #22
Source File: AnnotationSessionFactoryBean.java From spring4-understanding with Apache License 2.0 | 5 votes |
/** * Check whether any of the configured entity type filters matches * the current class descriptor contained in the metadata reader. */ private boolean matchesEntityTypeFilter(MetadataReader reader, MetadataReaderFactory readerFactory) throws IOException { if (this.entityTypeFilters != null) { for (TypeFilter filter : this.entityTypeFilters) { if (filter.match(reader, readerFactory)) { return true; } } } return false; }
Example #23
Source File: DefaultPersistenceUnitManager.java From spring4-understanding with Apache License 2.0 | 5 votes |
/** * Check whether any of the configured entity type filters matches * the current class descriptor contained in the metadata reader. */ private boolean matchesFilter(MetadataReader reader, MetadataReaderFactory readerFactory) throws IOException { for (TypeFilter filter : entityTypeFilters) { if (filter.match(reader, readerFactory)) { return true; } } return false; }
Example #24
Source File: ComponentScanBeanDefinitionParser.java From spring4-understanding with Apache License 2.0 | 5 votes |
@SuppressWarnings("unchecked") protected TypeFilter createTypeFilter(Element element, ClassLoader classLoader, ParserContext parserContext) { String filterType = element.getAttribute(FILTER_TYPE_ATTRIBUTE); String expression = element.getAttribute(FILTER_EXPRESSION_ATTRIBUTE); expression = parserContext.getReaderContext().getEnvironment().resolvePlaceholders(expression); try { if ("annotation".equals(filterType)) { return new AnnotationTypeFilter((Class<Annotation>) classLoader.loadClass(expression)); } else if ("assignable".equals(filterType)) { return new AssignableTypeFilter(classLoader.loadClass(expression)); } else if ("aspectj".equals(filterType)) { return new AspectJTypeFilter(expression, classLoader); } else if ("regex".equals(filterType)) { return new RegexPatternTypeFilter(Pattern.compile(expression)); } else if ("custom".equals(filterType)) { Class<?> filterClass = classLoader.loadClass(expression); if (!TypeFilter.class.isAssignableFrom(filterClass)) { throw new IllegalArgumentException( "Class is not assignable to [" + TypeFilter.class.getName() + "]: " + expression); } return (TypeFilter) BeanUtils.instantiateClass(filterClass); } else { throw new IllegalArgumentException("Unsupported filter type: " + filterType); } } catch (ClassNotFoundException ex) { throw new FatalBeanException("Type filter class not found: " + expression, ex); } }
Example #25
Source File: ComponentScanBeanDefinitionParser.java From lams with GNU General Public License v2.0 | 5 votes |
@SuppressWarnings("unchecked") protected TypeFilter createTypeFilter(Element element, ClassLoader classLoader, ParserContext parserContext) { String filterType = element.getAttribute(FILTER_TYPE_ATTRIBUTE); String expression = element.getAttribute(FILTER_EXPRESSION_ATTRIBUTE); expression = parserContext.getReaderContext().getEnvironment().resolvePlaceholders(expression); try { if ("annotation".equals(filterType)) { return new AnnotationTypeFilter((Class<Annotation>) classLoader.loadClass(expression)); } else if ("assignable".equals(filterType)) { return new AssignableTypeFilter(classLoader.loadClass(expression)); } else if ("aspectj".equals(filterType)) { return new AspectJTypeFilter(expression, classLoader); } else if ("regex".equals(filterType)) { return new RegexPatternTypeFilter(Pattern.compile(expression)); } else if ("custom".equals(filterType)) { Class<?> filterClass = classLoader.loadClass(expression); if (!TypeFilter.class.isAssignableFrom(filterClass)) { throw new IllegalArgumentException( "Class is not assignable to [" + TypeFilter.class.getName() + "]: " + expression); } return (TypeFilter) BeanUtils.instantiateClass(filterClass); } else { throw new IllegalArgumentException("Unsupported filter type: " + filterType); } } catch (ClassNotFoundException ex) { throw new FatalBeanException("Type filter class not found: " + expression, ex); } }
Example #26
Source File: DefaultPersistenceUnitManager.java From lams with GNU General Public License v2.0 | 5 votes |
/** * Check whether any of the configured entity type filters matches * the current class descriptor contained in the metadata reader. */ private boolean matchesFilter(MetadataReader reader, MetadataReaderFactory readerFactory) throws IOException { for (TypeFilter filter : entityTypeFilters) { if (filter.match(reader, readerFactory)) { return true; } } return false; }
Example #27
Source File: GroovyScanner.java From nh-micro with Apache License 2.0 | 5 votes |
public void registerDefaultFilters() { this.addIncludeFilter(new TypeFilter() { @Override public boolean match(MetadataReader metadataReader, MetadataReaderFactory metadataReaderFactory) throws IOException { //add 201806 ninghao boolean flag=metadataReader.getAnnotationMetadata().hasAnnotation("com.nh.micro.service.InjectGroovy"); return flag; } }); }
Example #28
Source File: LocalSessionFactoryBuilder.java From lams with GNU General Public License v2.0 | 5 votes |
/** * Check whether any of the configured entity type filters matches * the current class descriptor contained in the metadata reader. */ private boolean matchesEntityTypeFilter(MetadataReader reader, MetadataReaderFactory readerFactory) throws IOException { if (this.entityTypeFilters != null) { for (TypeFilter filter : this.entityTypeFilters) { if (filter.match(reader, readerFactory)) { return true; } } } return false; }
Example #29
Source File: AnnotationSessionFactoryBean.java From lams with GNU General Public License v2.0 | 5 votes |
/** * Check whether any of the configured entity type filters matches * the current class descriptor contained in the metadata reader. */ private boolean matchesEntityTypeFilter(MetadataReader reader, MetadataReaderFactory readerFactory) throws IOException { if (this.entityTypeFilters != null) { for (TypeFilter filter : this.entityTypeFilters) { if (filter.match(reader, readerFactory)) { return true; } } } return false; }
Example #30
Source File: LocalSessionFactoryBuilder.java From lams with GNU General Public License v2.0 | 5 votes |
/** * Check whether any of the configured entity type filters matches * the current class descriptor contained in the metadata reader. */ private boolean matchesEntityTypeFilter(MetadataReader reader, MetadataReaderFactory readerFactory) throws IOException { if (this.entityTypeFilters != null) { for (TypeFilter filter : this.entityTypeFilters) { if (filter.match(reader, readerFactory)) { return true; } } } return false; }