本文整理汇总了Java中org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider.addExcludeFilter方法的典型用法代码示例。如果您正苦于以下问题:Java ClassPathScanningCandidateComponentProvider.addExcludeFilter方法的具体用法?Java ClassPathScanningCandidateComponentProvider.addExcludeFilter怎么用?Java ClassPathScanningCandidateComponentProvider.addExcludeFilter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider
的用法示例。
在下文中一共展示了ClassPathScanningCandidateComponentProvider.addExcludeFilter方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: afterPropertiesSet
import org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider; //导入方法依赖的package包/类
@Override
public void afterPropertiesSet() throws Exception {
// on recherche toutes les classes concrètes du package à la recherche de celles qui sont annotées 'TipiTopProcess'
final ClassPathScanningCandidateComponentProvider scanner = new ClassPathScanningCandidateComponentProvider(false) {
@Override
protected boolean isCandidateComponent(AnnotatedBeanDefinition beanDefinition) {
return beanDefinition.getMetadata().isConcrete();
}
};
scanner.addIncludeFilter(new AnnotationTypeFilter(TipiTopProcess.class));
if (excludeFilters != null) {
for (TypeFilter filter : excludeFilters) {
scanner.addExcludeFilter(filter);
}
}
Set<BeanDefinition> beans = scanner.findCandidateComponents(aPackage);
LOGGER.info("Registering " + beans.size() + " Tipi activities");
for (BeanDefinition bean : beans) {
Class<?> clazz = Class.forName(bean.getBeanClassName());
registerClass(clazz);
}
}
示例2: populateTriggerVOs
import org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider; //导入方法依赖的package包/类
private void populateTriggerVOs() throws ClassNotFoundException {
ClassPathScanningCandidateComponentProvider scanner = new ClassPathScanningCandidateComponentProvider(true);
scanner.addIncludeFilter(new AnnotationTypeFilter(TriggerIndex.class));
scanner.addExcludeFilter(new AnnotationTypeFilter(Controller.class));
for (String pkg : getBasePkgNames()) {
for (BeanDefinition bd : scanner.findCandidateComponents(pkg)) {
Class<?> triggerVO = Class.forName(bd.getBeanClassName());
if (!triggerVO.isAnnotationPresent(Entity.class)) {
throw new IllegalArgumentException(String.format("Class[%s] is annotated by @TriggerIndex, but not annotated by @Entity",
triggerVO.getName()));
}
triggerVOs.add(triggerVO);
popluateTriggerVONamesCascade(triggerVO);
}
}
}
示例3: generateApiMessageGroovyClass
import org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider; //导入方法依赖的package包/类
private void generateApiMessageGroovyClass(StringBuilder sb, List<String> basePkgs) {
ClassPathScanningCandidateComponentProvider scanner = new ClassPathScanningCandidateComponentProvider(true);
scanner.addIncludeFilter(new AssignableTypeFilter(APIMessage.class));
scanner.addIncludeFilter(new AssignableTypeFilter(APIReply.class));
scanner.addIncludeFilter(new AssignableTypeFilter(APIEvent.class));
scanner.addExcludeFilter(new AnnotationTypeFilter(Controller.class));
scanner.addExcludeFilter(new AnnotationTypeFilter(Component.class));
for (String pkg : basePkgs) {
for (BeanDefinition bd : scanner.findCandidateComponents(pkg)) {
try {
Class<?> clazz = Class.forName(bd.getBeanClassName());
//classToApiMessageGroovyClass(sb, clazz);
classToApiMessageGroovyInformation(sb, clazz);
} catch (ClassNotFoundException e) {
logger.warn(String.format("Unable to generate groovy class for %s", bd.getBeanClassName()), e);
}
}
}
}
示例4: generateInventoryPythonClass
import org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider; //导入方法依赖的package包/类
private void generateInventoryPythonClass(StringBuilder sb, List<String> basePkgs) {
List<String> inventoryPython = new ArrayList<>();
ClassPathScanningCandidateComponentProvider scanner = new ClassPathScanningCandidateComponentProvider(false);
scanner.addIncludeFilter(new AnnotationTypeFilter(PythonClassInventory.class));
scanner.addExcludeFilter(new AnnotationTypeFilter(Component.class));
for (String pkg : basePkgs) {
for (BeanDefinition bd : scanner.findCandidateComponents(pkg).stream().sorted((bd1, bd2) -> {
return bd1.getBeanClassName().compareTo(bd2.getBeanClassName());
}).collect(Collectors.toList())) {
try {
Class<?> clazz = Class.forName(bd.getBeanClassName());
if (isPythonClassGenerated(clazz)) {
/* This class was generated as other's parent class */
continue;
}
inventoryPython.add(classToInventoryPythonClass(clazz));
} catch (Exception e) {
logger.warn(String.format("Unable to generate python class for %s", bd.getBeanClassName()), e);
}
}
}
for (String invstr : inventoryPython) {
sb.append(invstr);
}
}
示例5: scanDeployer
import org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider; //导入方法依赖的package包/类
private void scanDeployer() {
ClassPathScanningCandidateComponentProvider scanner = new ClassPathScanningCandidateComponentProvider(true);
scanner.addIncludeFilter(new AssignableTypeFilter(AbstractDeployer.class));
scanner.addExcludeFilter(new AnnotationTypeFilter(Controller.class));
scanner.addExcludeFilter(new AnnotationTypeFilter(org.springframework.stereotype.Component.class));
for (BeanDefinition bd : scanner.findCandidateComponents("org.zstack.test")) {
try {
Class<?> clazz = Class.forName(bd.getBeanClassName());
AbstractDeployer d = (AbstractDeployer) clazz.newInstance();
deployers.put(d.getSupportedDeployerClassType(), d);
logger.debug(String.format("Scanned a deployer[%s] supporting %s", d.getClass().getName(), d.getSupportedDeployerClassType()));
} catch (Exception e) {
logger.warn(String.format("unable to create deployer[%s], it's probably there are some beans requried by deployer is not loaded, skip it. error message:\n%s", bd.getBeanClassName(), e.getMessage()));
}
}
}
示例6: start
import org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider; //导入方法依赖的package包/类
@Override
public boolean start() {
try {
ClassPathScanningCandidateComponentProvider scanner = new ClassPathScanningCandidateComponentProvider(true);
scanner.addIncludeFilter(new AnnotationTypeFilter(Inventory.class));
scanner.addExcludeFilter(new AnnotationTypeFilter(Controller.class));
scanner.addExcludeFilter(new AnnotationTypeFilter(org.springframework.stereotype.Component.class));
for (String pkg : getBasePkgNames()) {
for (BeanDefinition bd : scanner.findCandidateComponents(pkg)) {
Class<?> inventoryClass = Class.forName(bd.getBeanClassName());
Inventory invat = inventoryClass.getAnnotation(Inventory.class);
Info info = new Info();
info.inventory = invat;
info.inventoryClass = inventoryClass;
inventoryMapping.put(invat.mappingVOClass(), info);
}
}
} catch (Exception e) {
throw new CloudRuntimeException(e);
}
return true;
}
示例7: generate
import org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider; //导入方法依赖的package包/类
public static void generate(String exportPath, List<String> basePkgs) {
try {
if (exportPath == null) {
exportPath = PathUtil.join(System.getProperty("user.home"), "zstack-inventory-query-details");
}
if (basePkgs == null || basePkgs.isEmpty()) {
basePkgs = new ArrayList<String>(1);
basePkgs.add("org.zstack");
}
FileUtils.deleteDirectory(new File(exportPath));
File folder = new File(exportPath);
folder.mkdirs();
String folderName = folder.getAbsolutePath();
ClassPathScanningCandidateComponentProvider scanner = new ClassPathScanningCandidateComponentProvider(false);
scanner.addIncludeFilter(new AnnotationTypeFilter(Inventory.class));
scanner.addExcludeFilter(new AnnotationTypeFilter(Controller.class));
scanner.addExcludeFilter(new AnnotationTypeFilter(Component.class));
for (String pkg : basePkgs) {
for (BeanDefinition bd : scanner.findCandidateComponents(pkg)) {
Class<?> clazz = Class.forName(bd.getBeanClassName());
generateInventoryDetails(folderName, clazz);
}
}
} catch (Exception e) {
throw new CloudRuntimeException(e);
}
}
示例8: populateInventoryIndexer
import org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider; //导入方法依赖的package包/类
private void populateInventoryIndexer() throws URISyntaxException, ClassNotFoundException, NoSuchMethodException {
ClassPathScanningCandidateComponentProvider scanner = new ClassPathScanningCandidateComponentProvider(true);
scanner.addIncludeFilter(new AnnotationTypeFilter(Inventory.class));
scanner.addExcludeFilter(new AnnotationTypeFilter(Controller.class));
for (String pkg : getBasePkgNames()) {
for (BeanDefinition bd : scanner.findCandidateComponents(pkg)) {
Class<?> inventoryClass = Class.forName(bd.getBeanClassName());
Inventory invat = inventoryClass.getAnnotation(Inventory.class);
if (!triggerVOs.contains(invat.mappingVOClass())) {
String err = String.format("Inventory[%s]'s mapping VO class[%s] is not annotated by @TriggerIndex", inventoryClass.getName(), invat
.mappingVOClass().getName());
throw new IllegalArgumentException(err);
}
String mappingClassSimpleName = invat.mappingVOClass().getSimpleName();
IndexerInfo info = voClassToIndexerMapping.get(mappingClassSimpleName);
if (info == null) {
String invName = inventoryClass.getSimpleName();
info = new IndexerInfo();
info.url = String.format("%s/%s/%s", elasticSearchBaseUrl, invName.toLowerCase(), invName);
info.inventoryClass = inventoryClass;
info.inventoryName = invName;
info.mappingVOClass = invat.mappingVOClass();
info.valueOfMethod = getValueOfMethodOfInventoryClass(inventoryClass);
info.entityIdField = getEntityIdFieldFromClass(info.mappingVOClass);
info.entityIdField.setAccessible(true);
voClassToIndexerMapping.put(mappingClassSimpleName, info);
}
}
}
}
示例9: handle
import org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider; //导入方法依赖的package包/类
private void handle(APIGenerateSqlVOViewMsg msg) {
try {
ClassPathScanningCandidateComponentProvider scanner = new ClassPathScanningCandidateComponentProvider(true);
scanner.addIncludeFilter(new AnnotationTypeFilter(EO.class));
scanner.addExcludeFilter(new AnnotationTypeFilter(Controller.class));
scanner.addExcludeFilter(new AnnotationTypeFilter(Component.class));
StringBuilder sb = new StringBuilder();
for (String pkg : msg.getBasePackageNames()) {
for (BeanDefinition bd : scanner.findCandidateComponents(pkg)) {
Class<?> entityClazz = Class.forName(bd.getBeanClassName());
generateVOViewSql(sb, entityClazz);
}
}
String exportPath = PathUtil.join(System.getProperty("user.home"), "zstack-mysql-view");
FileUtils.deleteDirectory(new File(exportPath));
File folder = new File(exportPath);
folder.mkdirs();
File outfile = new File(PathUtil.join(exportPath, "view.sql"));
FileUtils.writeStringToFile(outfile, sb.toString());
APIGenerateSqlVOViewEvent evt = new APIGenerateSqlVOViewEvent(msg.getId());
bus.publish(evt);
} catch (Exception e) {
throw new CloudRuntimeException(e);
}
}
示例10: generateApiMessagePythonClass
import org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider; //导入方法依赖的package包/类
private void generateApiMessagePythonClass(StringBuilder sb, List<String> basePkgs) {
generateSessionPythonClass(sb);
generateErrorCodePythonClass(sb);
generateBaseApiMessagePythonClass(sb);
ClassPathScanningCandidateComponentProvider scanner = new ClassPathScanningCandidateComponentProvider(true);
scanner.addIncludeFilter(new AssignableTypeFilter(APIMessage.class));
scanner.addIncludeFilter(new AssignableTypeFilter(APIReply.class));
scanner.addExcludeFilter(new AnnotationTypeFilter(Controller.class));
scanner.addExcludeFilter(new AnnotationTypeFilter(NoPython.class));
scanner.addExcludeFilter(new AnnotationTypeFilter(Component.class));
List<String> apiNames = new ArrayList<>(100);
for (String pkg : basePkgs) {
for (BeanDefinition bd : scanner.findCandidateComponents(pkg).stream().sorted(Comparator.comparing(BeanDefinition::getBeanClassName)).collect(Collectors.toList())) {
try {
Class<?> clazz = Class.forName(bd.getBeanClassName());
if (clazz == APIMessage.class || clazz == APIListMessage.class || clazz == APIDeleteMessage.class || clazz == APISearchMessage.class) {
continue;
}
if (TypeUtils.isTypeOf(clazz, APISearchMessage.class, APIListMessage.class, APIGetMessage.class)) {
continue;
}
if (Modifier.isAbstract(clazz.getModifiers())) {
continue;
}
if (isPythonClassGenerated(clazz)) {
/* This class was generated as other's parent class */
continue;
}
sb.append(classToApiMessagePythonClass(clazz));
apiNames.add(clazz.getSimpleName());
} catch (ClassNotFoundException e) {
logger.warn(String.format("Unable to generate python class for %s", bd.getBeanClassName()), e);
}
}
}
apiNames.remove(APIMessage.class.getSimpleName());
apiNames.remove(APIListMessage.class.getSimpleName());
apiNames.remove(APIDeleteMessage.class.getSimpleName());
apiNames.remove(APISearchMessage.class.getSimpleName());
generateApiNameList(sb, apiNames);
}
示例11: generateApiJsonTemplate
import org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider; //导入方法依赖的package包/类
public void generateApiJsonTemplate(String exportPath, List<String> basePkgs) throws IOException {
generatedPythonClassName = new HashSet<>();
if (exportPath == null) {
exportPath = PathUtil.join(System.getProperty("user.home"), "zstack-python-template");
}
if (basePkgs == null || basePkgs.isEmpty()) {
basePkgs = new ArrayList<>(1);
basePkgs.add("org.zstack");
}
FileUtils.deleteDirectory(new File(exportPath));
File folder = new File(exportPath);
folder.mkdirs();
File jsonFolder = new File(PathUtil.join(folder.getAbsolutePath(), "json"));
jsonFolder.mkdirs();
File pythonFolder = new File(PathUtil.join(folder.getAbsolutePath(), "python"));
pythonFolder.mkdirs();
// write api_messages.py
{
StringBuilder apiNameBuilder = new StringBuilder();
apiNameBuilder.append("api_names = [\n");
ClassPathScanningCandidateComponentProvider scanner = new ClassPathScanningCandidateComponentProvider(false);
scanner.addIncludeFilter(new AssignableTypeFilter(APIEvent.class));
scanner.addIncludeFilter(new AssignableTypeFilter(APIReply.class));
scanner.addIncludeFilter(new AssignableTypeFilter(APIMessage.class));
scanner.addExcludeFilter(new AnnotationTypeFilter(Controller.class));
scanner.addExcludeFilter(new AnnotationTypeFilter(Component.class));
for (String pkg : basePkgs) {
for (BeanDefinition bd : scanner.findCandidateComponents(pkg)) {
Class<?> clazz = null;
try {
clazz = Class.forName(bd.getBeanClassName());
logger.debug(String.format("dumping message: %s", bd.getBeanClassName()));
String template = RESTApiJsonTemplateGenerator.dump(clazz);
FileUtils.write(new File(PathUtil.join(jsonFolder.getAbsolutePath(),
clazz.getName() + ".json")), template);
} catch (Exception e) {
logger.warn(String.format("Unable to generate json template for %s", bd.getBeanClassName()), e);
}
if (clazz != null && APIMessage.class.isAssignableFrom(clazz)) {
if (TypeUtils.isTypeOf(clazz, APISearchMessage.class, APIGetMessage.class, APIListMessage.class)) {
continue;
}
apiNameBuilder.append(String.format("%s'%s',\n", whiteSpace(4), clazz.getName()));
}
}
}
apiNameBuilder.append("]\n");
FileUtils.write(new File(PathUtil.join(pythonFolder.getAbsolutePath(), "api_messages.py")),
apiNameBuilder.toString());
}
// write inventory.py
{
StringBuilder pysb = new StringBuilder();
generateMandoryFieldClass(pysb);
generateApiMessagePythonClass(pysb, basePkgs);
generateInventoryPythonClass(pysb, basePkgs);
generateConstantPythonClass(pysb, basePkgs);
generateGlobalConfigPythonConstant(pysb);
for (PythonApiBindingWriter writer : pythonApiBindingWriters) {
pysb.append("\n");
writer.writePython(pysb);
}
String pyStr = pysb.toString();
FileUtils.write(new File(PathUtil.join(pythonFolder.getAbsolutePath(), "inventory.py")), pyStr);
}
// write api_actions.py
{
PythonApiActionGenerator.generatePythonApiAction(basePkgs, pythonFolder.getAbsolutePath());
}
logger.info(String.format("Generated result in %s", folder.getAbsolutePath()));
generatedPythonClassName = null;
}