modifieds example to creates less cognitive load for a reader (#8018)
This commit is contained in:
@@ -5,10 +5,10 @@ import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.FilterType;
|
||||
|
||||
@Configuration
|
||||
@ComponentScan(includeFilters = @ComponentScan.Filter(type = FilterType.ASPECTJ,
|
||||
pattern = "com.baeldung.componentscan.filter.aspectj.* "
|
||||
+ "&& !(com.baeldung.componentscan.filter.aspectj.L* "
|
||||
+ "|| com.baeldung.componentscan.filter.aspectj.C*)"))
|
||||
@ComponentScan(includeFilters = @ComponentScan.Filter(type = FilterType.ASPECTJ,
|
||||
pattern = "com.baeldung.componentscan.filter.aspectj.* "
|
||||
+ "&& !(com.baeldung.componentscan.filter.aspectj.L* "
|
||||
+ "|| com.baeldung.componentscan.filter.aspectj.C*)"))
|
||||
public class ComponentScanAspectJFilterApp {
|
||||
public static void main(String[] args) {
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.baeldung.componentscan.filter.custom;
|
||||
|
||||
public class Cat extends Pet {
|
||||
public class Cat {
|
||||
}
|
||||
|
||||
@@ -12,11 +12,8 @@ public class ComponentScanCustomFilter implements TypeFilter {
|
||||
@Override
|
||||
public boolean match(MetadataReader metadataReader, MetadataReaderFactory metadataReaderFactory) throws IOException {
|
||||
ClassMetadata classMetadata = metadataReader.getClassMetadata();
|
||||
String superClass = classMetadata.getSuperClassName();
|
||||
if (Pet.class.getName()
|
||||
.equalsIgnoreCase(superClass)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
String fullyQualifiedName = classMetadata.getClassName();
|
||||
String className = fullyQualifiedName.substring(fullyQualifiedName.lastIndexOf(".") + 1);
|
||||
return className.length() > 5 ? true : false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.baeldung.componentscan.filter.custom;
|
||||
|
||||
public class Pet {
|
||||
public class Elephant {
|
||||
}
|
||||
@@ -5,7 +5,7 @@ import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.FilterType;
|
||||
|
||||
@Configuration
|
||||
@ComponentScan(includeFilters = @ComponentScan.Filter(type = FilterType.REGEX, pattern = ".*[t]"))
|
||||
@ComponentScan(includeFilters = @ComponentScan.Filter(type = FilterType.REGEX, pattern = ".*(nt)"))
|
||||
public class ComponentScanRegexFilterApp {
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
Reference in New Issue
Block a user