org.springframework.core.type.ClassMetadata Java Examples

The following examples show how to use org.springframework.core.type.ClassMetadata. 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: MyBatisXmlParser.java    From jstarcraft-core with Apache License 2.0 6 votes vote down vote up
private String[] getResources(String packageName) {
    try {
        // 搜索资源
        String packageSearchPath = ResourcePatternResolver.CLASSPATH_ALL_URL_PREFIX + ClassUtils.convertClassNameToResourcePath(SystemPropertyUtils.resolvePlaceholders(packageName)) + "/" + DEFAULT_RESOURCE_PATTERN;
        Resource[] resources = resourcePatternResolver.getResources(packageSearchPath);
        // 提取资源
        Set<String> names = new HashSet<String>();
        for (Resource resource : resources) {
            if (!resource.isReadable()) {
                continue;
            }
            // 判断是否静态资源
            MetadataReader metadataReader = metadataReaderFactory.getMetadataReader(resource);
            ClassMetadata classMetadata = metadataReader.getClassMetadata();
            names.add(classMetadata.getClassName());
        }
        return names.toArray(new String[0]);
    } catch (IOException exception) {
        String message = "无法获取资源";
        LOGGER.error(message, exception);
        throw new StorageConfigurationException(message, exception);
    }
}
 
Example #2
Source File: AutoJsonRpcClientProxyCreator.java    From jsonrpc4j with MIT License 6 votes vote down vote up
@Override
public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) {
	SimpleMetadataReaderFactory metadataReaderFactory = new SimpleMetadataReaderFactory(applicationContext);
	DefaultListableBeanFactory defaultListableBeanFactory = (DefaultListableBeanFactory) beanFactory;
	String resolvedPath = resolvePackageToScan();
	logger.debug("Scanning '{}' for JSON-RPC service interfaces.", resolvedPath);
	try {
		for (Resource resource : applicationContext.getResources(resolvedPath)) {
			if (resource.isReadable()) {
				MetadataReader metadataReader = metadataReaderFactory.getMetadataReader(resource);
				ClassMetadata classMetadata = metadataReader.getClassMetadata();
				AnnotationMetadata annotationMetadata = metadataReader.getAnnotationMetadata();
				String jsonRpcPathAnnotation = JsonRpcService.class.getName();
				if (annotationMetadata.isAnnotated(jsonRpcPathAnnotation)) {
					String className = classMetadata.getClassName();
					String path = (String) annotationMetadata.getAnnotationAttributes(jsonRpcPathAnnotation).get("value");
					logger.debug("Found JSON-RPC service to proxy [{}] on path '{}'.", className, path);
					registerJsonProxyBean(defaultListableBeanFactory, className, path);
				}
			}
		}
	} catch (IOException e) {
		throw new IllegalStateException(format("Cannot scan package '%s' for classes.", resolvedPath), e);
	}
}
 
Example #3
Source File: MangoDaoScanner.java    From mango with Apache License 2.0 6 votes vote down vote up
private List<Class<?>> findMangoDaoClasses() {
  try {
    List<Class<?>> daos = new ArrayList<Class<?>>();
    ResourcePatternResolver resourcePatternResolver = new PathMatchingResourcePatternResolver();
    MetadataReaderFactory metadataReaderFactory = new CachingMetadataReaderFactory(resourcePatternResolver);
    for (String locationPattern : locationPatterns) {
      Resource[] rs = resourcePatternResolver.getResources(locationPattern);
      for (Resource r : rs) {
        MetadataReader reader = metadataReaderFactory.getMetadataReader(r);
        AnnotationMetadata annotationMD = reader.getAnnotationMetadata();
        if (annotationMD.hasAnnotation(DB.class.getName())) {
          ClassMetadata clazzMD = reader.getClassMetadata();
          daos.add(Class.forName(clazzMD.getClassName()));
        }
      }
    }
    return daos;
  } catch (Exception e) {
    throw new IllegalStateException(e.getMessage(), e);
  }
}
 
Example #4
Source File: MyTypeFilter.java    From code with Apache License 2.0 6 votes vote down vote up
/**
 * 自定义包扫描过滤规则
 *
 * @param metadataReader 读取到当前正在扫描的类的信息
 * @param metadataReaderFactory 获取其他任何类型
 * @return boolean
 */
@Override
public boolean match(MetadataReader metadataReader, MetadataReaderFactory metadataReaderFactory) throws IOException {
    // 获取当前正在扫描的类注解的信息
    AnnotationMetadata annotationMetadata = metadataReader.getAnnotationMetadata();
    // 获取当前正在扫描的类的信息
    ClassMetadata classMetadata = metadataReader.getClassMetadata();
    // 获取类名
    String className = classMetadata.getClassName();
    System.out.println("扫描的类——》" + className);
    // 根据类名进行过滤
    if (className.contains("Book")) {
        return true;
    }
    // 证明filter在Conditional之前拦截
    //Annotation[] annotations = classMetadata.getClass().getAnnotations();
    //for (Annotation annotation : annotations) {
    //    if (annotation.annotationType() == Conditional.class) {
    //        return false;
    //    }
    //}
    //return true;
    return false;
}
 
Example #5
Source File: OSSCondition.java    From jeecg-boot-with-activiti with MIT License 6 votes vote down vote up
@Override
public ConditionOutcome getMatchOutcome(ConditionContext context, AnnotatedTypeMetadata metadata) {
	String sourceClass = "";
	if (metadata instanceof ClassMetadata) {
		sourceClass = ((ClassMetadata) metadata).getClassName();
	}
	ConditionMessage.Builder message = ConditionMessage.forCondition("OSS", sourceClass);
	Environment environment = context.getEnvironment();
	try {
		BindResult<OSSType> specified = Binder.get(environment).bind("oss.type", OSSType.class);
		if (!specified.isBound()) {
			return ConditionOutcome.match(message.because("automatic OSS type"));
		}
		OSSType required = OSSConfigurations.getType(((AnnotationMetadata) metadata).getClassName());
		if (specified.get() == required) {
			return ConditionOutcome.match(message.because(specified.get() + " OSS type"));
		}
	}
	catch (BindException ex) {
	}
	return ConditionOutcome.noMatch(message.because("unknown OSS type"));
}
 
Example #6
Source File: ZipkinSenderCondition.java    From spring-cloud-sleuth with Apache License 2.0 6 votes vote down vote up
@Override
public ConditionOutcome getMatchOutcome(ConditionContext context,
		AnnotatedTypeMetadata md) {
	String sourceClass = "";
	if (md instanceof ClassMetadata) {
		sourceClass = ((ClassMetadata) md).getClassName();
	}
	ConditionMessage.Builder message = ConditionMessage.forCondition("ZipkinSender",
			sourceClass);
	String property = context.getEnvironment()
			.getProperty("spring.zipkin.sender.type");
	if (StringUtils.isEmpty(property)) {
		return ConditionOutcome.match(message.because("automatic sender type"));
	}
	String senderType = getType(((AnnotationMetadata) md).getClassName());
	if (property.equalsIgnoreCase(senderType)) {
		return ConditionOutcome.match(message.because(property + " sender type"));
	}
	return ConditionOutcome.noMatch(message.because(property + " sender type"));
}
 
Example #7
Source File: CubaClientTestCase.java    From cuba with Apache License 2.0 6 votes vote down vote up
protected List<String> getClasses(Resource[] resources) {
    List<String> classNames = new ArrayList<>();

    for (Resource resource : resources) {
        if (resource.isReadable()) {
            MetadataReader metadataReader;
            try {
                metadataReader = metadataReaderFactory.getMetadataReader(resource);
            } catch (IOException e) {
                throw new RuntimeException("Unable to read metadata resource", e);
            }

            AnnotationMetadata annotationMetadata = metadataReader.getAnnotationMetadata();
            if (annotationMetadata.isAnnotated(com.haulmont.chile.core.annotations.MetaClass.class.getName())
                    || annotationMetadata.isAnnotated(MappedSuperclass.class.getName())
                    || annotationMetadata.isAnnotated(Entity.class.getName())) {
                ClassMetadata classMetadata = metadataReader.getClassMetadata();
                classNames.add(classMetadata.getClassName());
            }
        }
    }
    return classNames;
}
 
Example #8
Source File: MangoDaoAutoCreator.java    From mango-spring-boot-starter with Apache License 2.0 6 votes vote down vote up
private List<Class<?>> findMangoDaoClasses(String packages) {
    try {
        List<Class<?>> daos = new ArrayList<Class<?>>();
        ResourcePatternResolver resourcePatternResolver = new PathMatchingResourcePatternResolver();
        MetadataReaderFactory metadataReaderFactory = new CachingMetadataReaderFactory(resourcePatternResolver);
        for (String locationPattern : getLocationPattern(packages)) {
            Resource[] rs = resourcePatternResolver.getResources(locationPattern);
            for (Resource r : rs) {
                MetadataReader reader = metadataReaderFactory.getMetadataReader(r);
                AnnotationMetadata annotationMD = reader.getAnnotationMetadata();
                if (annotationMD.hasAnnotation(DB.class.getName())) {
                    ClassMetadata clazzMD = reader.getClassMetadata();
                    daos.add(Class.forName(clazzMD.getClassName()));
                }
            }
        }
        return daos;
    } catch (Exception e) {
        throw new IllegalStateException(e.getMessage(), e);
    }
}
 
Example #9
Source File: AppPropertiesLocator.java    From cuba with Apache License 2.0 5 votes vote down vote up
protected Set<Class> findConfigInterfaces() {
    if (interfacesCache == null) {
        synchronized (this) {
            if (interfacesCache == null) {
                log.trace("Locating config interfaces");
                Set<String> cache = new HashSet<>();
                for (String rootPackage : metadata.getRootPackages()) {
                    String packagePrefix = rootPackage.replace(".", "/") + "/**/*.class";
                    String packageSearchPath = ResourcePatternResolver.CLASSPATH_ALL_URL_PREFIX + packagePrefix;
                    Resource[] resources;
                    try {
                        resources = resourcePatternResolver.getResources(packageSearchPath);
                        for (Resource resource : resources) {
                            if (resource.isReadable()) {
                                MetadataReader metadataReader = metadataReaderFactory.getMetadataReader(resource);
                                ClassMetadata classMetadata = metadataReader.getClassMetadata();
                                if (classMetadata.isInterface()) {
                                    for (String intf : classMetadata.getInterfaceNames()) {
                                        if (Config.class.getName().equals(intf)) {
                                            cache.add(classMetadata.getClassName());
                                            break;
                                        }
                                    }
                                }
                            }
                        }
                    } catch (IOException e) {
                        throw new RuntimeException("Error searching for Config interfaces", e);
                    }
                }
                log.trace("Found config interfaces: {}", cache);
                interfacesCache = cache;
            }
        }
    }
    return interfacesCache.stream()
            .map(ReflectionHelper::getClass)
            .collect(Collectors.toSet());
}
 
Example #10
Source File: BerkeleyXmlParser.java    From jstarcraft-core with Apache License 2.0 5 votes vote down vote up
private String[] getResources(String packageName) {
    try {
        // 搜索资源
        String packageSearchPath = ResourcePatternResolver.CLASSPATH_ALL_URL_PREFIX + ClassUtils.convertClassNameToResourcePath(SystemPropertyUtils.resolvePlaceholders(packageName)) + "/" + DEFAULT_RESOURCE_PATTERN;
        Resource[] resources = resourcePatternResolver.getResources(packageSearchPath);
        // 提取资源
        Set<String> names = new HashSet<String>();
        String entity = Entity.class.getName();
        String persistent = Persistent.class.getName();
        for (Resource resource : resources) {
            if (!resource.isReadable()) {
                continue;
            }
            // 判断是否静态资源
            MetadataReader metadataReader = metadataReaderFactory.getMetadataReader(resource);
            AnnotationMetadata annotationMetadata = metadataReader.getAnnotationMetadata();
            if (!annotationMetadata.hasAnnotation(entity) && !annotationMetadata.hasAnnotation(persistent)) {
                continue;
            }
            ClassMetadata classMetadata = metadataReader.getClassMetadata();
            names.add(classMetadata.getClassName());
        }
        return names.toArray(new String[0]);
    } catch (IOException exception) {
        String message = "无法获取资源";
        LOGGER.error(message, exception);
        throw new StorageConfigurationException(message, exception);
    }
}
 
Example #11
Source File: LuceneXmlParser.java    From jstarcraft-core with Apache License 2.0 5 votes vote down vote up
private String[] getResources(String packageName) {
    try {
        // 搜索资源
        String packageSearchPath = ResourcePatternResolver.CLASSPATH_ALL_URL_PREFIX + ClassUtils.convertClassNameToResourcePath(SystemPropertyUtils.resolvePlaceholders(packageName)) + "/" + DEFAULT_RESOURCE_PATTERN;
        Resource[] resources = resourcePatternResolver.getResources(packageSearchPath);
        // 提取资源
        Set<String> names = new HashSet<String>();
        String document = LuceneConfiguration.class.getName();
        for (Resource resource : resources) {
            if (!resource.isReadable()) {
                continue;
            }
            // 判断是否静态资源
            MetadataReader metadataReader = metadataReaderFactory.getMetadataReader(resource);
            AnnotationMetadata annotationMetadata = metadataReader.getAnnotationMetadata();
            if (!annotationMetadata.hasAnnotation(document)) {
                continue;
            }
            ClassMetadata classMetadata = metadataReader.getClassMetadata();
            names.add(classMetadata.getClassName());
        }
        return names.toArray(new String[0]);
    } catch (IOException exception) {
        String message = "无法获取资源";
        LOGGER.error(message, exception);
        throw new StorageConfigurationException(message, exception);
    }
}
 
Example #12
Source File: CodecXmlParser.java    From jstarcraft-core with Apache License 2.0 5 votes vote down vote up
/**
 * 获取指定包下的静态资源对象
 * 
 * @param packageName 包名
 * @return
 * @throws IOException
 */
private String[] getResources(String packageName) {
    try {
        // 搜索资源
        String packageSearchPath = ResourcePatternResolver.CLASSPATH_ALL_URL_PREFIX + ClassUtils.convertClassNameToResourcePath(SystemPropertyUtils.resolvePlaceholders(packageName)) + "/" + DEFAULT_RESOURCE_PATTERN;
        Resource[] resources = this.resourcePatternResolver.getResources(packageSearchPath);
        // 提取资源
        Set<String> names = new HashSet<String>();
        String name = ProtocolConfiguration.class.getName();
        for (Resource resource : resources) {
            if (!resource.isReadable()) {
                continue;
            }
            // 判断是否静态资源
            MetadataReader metadataReader = this.metadataReaderFactory.getMetadataReader(resource);
            ClassMetadata classMetadata = metadataReader.getClassMetadata();
            AnnotationMetadata annotationMetadata = metadataReader.getAnnotationMetadata();
            if (annotationMetadata.hasAnnotation(name)) {
                names.add(classMetadata.getClassName());
            } else {
                String[] interfaceNames = classMetadata.getInterfaceNames();
                for (String interfaceName : interfaceNames) {
                    metadataReader = this.metadataReaderFactory.getMetadataReader(interfaceName);
                    annotationMetadata = metadataReader.getAnnotationMetadata();
                    if (annotationMetadata.hasAnnotation(name)) {
                        names.add(classMetadata.getClassName());
                        break;
                    }
                }
            }
        }
        return names.toArray(new String[0]);
    } catch (IOException exception) {
        throw new RuntimeException(exception);
    }
}
 
Example #13
Source File: CommunicationXmlParser.java    From jstarcraft-core with Apache License 2.0 5 votes vote down vote up
private String[] getResources(String packageName) {
    try {
        // 搜索资源
        String packageSearchPath = ResourcePatternResolver.CLASSPATH_ALL_URL_PREFIX + ClassUtils.convertClassNameToResourcePath(SystemPropertyUtils.resolvePlaceholders(packageName)) + "/" + DEFAULT_RESOURCE_PATTERN;
        Resource[] resources = resourcePatternResolver.getResources(packageSearchPath);
        // 提取资源
        Set<String> names = new HashSet<String>();
        String name = CommunicationModule.class.getName();
        for (Resource resource : resources) {
            if (!resource.isReadable()) {
                continue;
            }
            // 判断是否静态资源
            MetadataReader metadataReader = metadataReaderFactory.getMetadataReader(resource);
            AnnotationMetadata annotationMetadata = metadataReader.getAnnotationMetadata();
            if (!annotationMetadata.hasAnnotation(name)) {
                continue;
            }
            ClassMetadata classMetadata = metadataReader.getClassMetadata();
            names.add(classMetadata.getClassName());
        }
        return names.toArray(new String[0]);
    } catch (IOException exception) {
        String message = "无法获取资源";
        LOGGER.error(message, exception);
        throw new CommunicationConfigurationException(message, exception);
    }
}
 
Example #14
Source File: MyTypeFilter.java    From SpringAll with MIT License 5 votes vote down vote up
@Override
public boolean match(MetadataReader metadataReader, MetadataReaderFactory metadataReaderFactory) {
    // 获取当前正在扫描的类的注解信息
    AnnotationMetadata annotationMetadata = metadataReader.getAnnotationMetadata();
    // 获取当前正在扫描的类的类信息
    ClassMetadata classMetadata = metadataReader.getClassMetadata();
    // 获取当前正在扫描的类的路径等信息
    Resource resource = metadataReader.getResource();

    String className = classMetadata.getClassName();
    return StringUtils.hasText("er");
}
 
Example #15
Source File: ClassMetadataReadingVisitorMemberClassTests.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
@Override
public ClassMetadata getClassMetadataFor(Class<?> clazz) {
	try {
		MetadataReader reader =
			new SimpleMetadataReaderFactory().getMetadataReader(clazz.getName());
		return reader.getAnnotationMetadata();
	} catch (IOException ex) {
		throw new IllegalStateException(ex);
	}
}
 
Example #16
Source File: CacheXmlParser.java    From jstarcraft-core with Apache License 2.0 5 votes vote down vote up
private String[] getResources(String packageName) {
    try {
        // 搜索资源
        String packageSearchPath = ResourcePatternResolver.CLASSPATH_ALL_URL_PREFIX + ClassUtils.convertClassNameToResourcePath(SystemPropertyUtils.resolvePlaceholders(packageName)) + "/" + DEFAULT_RESOURCE_PATTERN;
        Resource[] resources = resourcePatternResolver.getResources(packageSearchPath);
        // 提取资源
        Set<String> names = new HashSet<String>();
        String name = CacheConfiguration.class.getName();
        for (Resource resource : resources) {
            if (!resource.isReadable()) {
                continue;
            }
            // 判断是否静态资源
            MetadataReader metadataReader = metadataReaderFactory.getMetadataReader(resource);
            AnnotationMetadata annotationMetadata = metadataReader.getAnnotationMetadata();
            if (!annotationMetadata.hasAnnotation(name)) {
                continue;
            }
            ClassMetadata classMetadata = metadataReader.getClassMetadata();
            names.add(classMetadata.getClassName());
        }
        return names.toArray(new String[0]);
    } catch (IOException exception) {
        String message = "无法获取资源";
        LOGGER.error(message, exception);
        throw new CacheConfigurationException(message, exception);
    }
}
 
Example #17
Source File: ActionsImport.java    From data-prep with Apache License 2.0 5 votes vote down vote up
@Override
public boolean match(MetadataReader metadataReader, MetadataReaderFactory metadataReaderFactory)
        throws IOException {
    final ClassMetadata classMetadata = metadataReader.getClassMetadata();
    try {
        final Class<?> clazz = Class.forName(classMetadata.getClassName());
        return AnnotationUtils.findAnnotation(clazz, Action.class) != null;
    } catch (Throwable e) { // NOSONAR
        LOGGER.debug("Unable to filter class {}.", classMetadata.getClassName(), e);
    }
    return false;
}
 
Example #18
Source File: ComponentScanCustomFilter.java    From tutorials with MIT License 5 votes vote down vote up
@Override
public boolean match(MetadataReader metadataReader, MetadataReaderFactory metadataReaderFactory) throws IOException {
    ClassMetadata classMetadata = metadataReader.getClassMetadata();
    String fullyQualifiedName = classMetadata.getClassName();
    String className = fullyQualifiedName.substring(fullyQualifiedName.lastIndexOf(".") + 1);
    return className.length() > 5 ? true : false;
}
 
Example #19
Source File: ResourceXmlParser.java    From jstarcraft-core with Apache License 2.0 5 votes vote down vote up
private String[] getResources(String packageName) {
    try {
        // 搜索资源
        String packageSearchPath = ResourcePatternResolver.CLASSPATH_ALL_URL_PREFIX + ClassUtils.convertClassNameToResourcePath(SystemPropertyUtils.resolvePlaceholders(packageName)) + "/" + DEFAULT_RESOURCE_PATTERN;
        Resource[] resources = resourcePatternResolver.getResources(packageSearchPath);
        // 提取资源
        Set<String> names = new HashSet<String>();
        String name = ResourceConfiguration.class.getName();
        for (Resource resource : resources) {
            if (!resource.isReadable()) {
                continue;
            }
            // 判断是否静态资源
            MetadataReader metadataReader = metadataReaderFactory.getMetadataReader(resource);
            AnnotationMetadata annotationMetadata = metadataReader.getAnnotationMetadata();
            if (!annotationMetadata.hasAnnotation(name)) {
                continue;
            }
            ClassMetadata classMetadata = metadataReader.getClassMetadata();
            names.add(classMetadata.getClassName());
        }
        return names.toArray(new String[0]);
    } catch (IOException exception) {
        String message = "无法获取资源";
        logger.error(message, exception);
        throw new StorageException(message, exception);
    }
}
 
Example #20
Source File: MongoXmlParser.java    From jstarcraft-core with Apache License 2.0 5 votes vote down vote up
private String[] getResources(String packageName) {
    try {
        // 搜索资源
        String packageSearchPath = ResourcePatternResolver.CLASSPATH_ALL_URL_PREFIX + ClassUtils.convertClassNameToResourcePath(SystemPropertyUtils.resolvePlaceholders(packageName)) + "/" + DEFAULT_RESOURCE_PATTERN;
        Resource[] resources = resourcePatternResolver.getResources(packageSearchPath);
        // 提取资源
        Set<String> names = new HashSet<String>();
        String document = Document.class.getName();
        for (Resource resource : resources) {
            if (!resource.isReadable()) {
                continue;
            }
            // 判断是否静态资源
            MetadataReader metadataReader = metadataReaderFactory.getMetadataReader(resource);
            AnnotationMetadata annotationMetadata = metadataReader.getAnnotationMetadata();
            if (!annotationMetadata.hasAnnotation(document)) {
                continue;
            }
            ClassMetadata classMetadata = metadataReader.getClassMetadata();
            names.add(classMetadata.getClassName());
        }
        return names.toArray(new String[0]);
    } catch (IOException exception) {
        String message = "无法获取资源";
        LOGGER.error(message, exception);
        throw new StorageConfigurationException(message, exception);
    }
}
 
Example #21
Source File: SimpleMetadataReader.java    From thinking-in-spring-boot-samples with Apache License 2.0 5 votes vote down vote up
public ClassMetadata getClassMetadata() {
    if (this.classMetadata == null) {
        ClassMetadataReadingVisitor visitor = new ClassMetadataReadingVisitor();
        this.classReader.accept(visitor, true);
        this.classMetadata = visitor;
    }
    return this.classMetadata;
}
 
Example #22
Source File: RpcDefinitionPostProcessor.java    From joyrpc with Apache License 2.0 5 votes vote down vote up
@Override
public boolean match(MetadataReader metadataReader, MetadataReaderFactory metadataReaderFactory) {
    ClassMetadata classMetadata = metadataReader.getClassMetadata();
    if (classMetadata.isConcrete() && !classMetadata.isAnnotation()) {
        //找到类
        Class<?> clazz = resolveClassName(classMetadata.getClassName(), classLoader);
        //判断是否Public
        if (Modifier.isPublic(clazz.getModifiers())) {
            Class<?> targetClass = clazz;
            while (targetClass != null && targetClass != Object.class) {
                //处理类上的服务提供者注解
                if (getProviderAnnotation(targetClass) != null) {
                    return true;
                }
                //处理字段的消费者注解
                for (Field field : targetClass.getDeclaredFields()) {
                    if (!Modifier.isFinal(field.getModifiers())
                            && !Modifier.isStatic(field.getModifiers())
                            && getConsumerAnnotation(field) != null) {
                        return true;
                    }
                }
                //处理方法上的消费者注解
                for (Method method : clazz.getDeclaredMethods()) {
                    if (!Modifier.isStatic(method.getModifiers())
                            && Modifier.isPublic(method.getModifiers())
                            && method.getParameterCount() == 1
                            && method.getName().startsWith("set")
                            && getConsumerAnnotation(method) != null) {
                        return true;
                    }
                }
                targetClass = targetClass.getSuperclass();
            }

        }
    }
    return false;
}
 
Example #23
Source File: ClassMetadataReadingVisitorMemberClassTests.java    From java-technology-stack with MIT License 5 votes vote down vote up
@Override
public ClassMetadata getClassMetadataFor(Class<?> clazz) {
	try {
		MetadataReader reader =
			new SimpleMetadataReaderFactory().getMetadataReader(clazz.getName());
		return reader.getAnnotationMetadata();
	}
	catch (IOException ex) {
		throw new IllegalStateException(ex);
	}
}
 
Example #24
Source File: ClassMetadataReadingVisitorMemberClassTests.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@Override
public ClassMetadata getClassMetadataFor(Class<?> clazz) {
	try {
		MetadataReader reader =
			new SimpleMetadataReaderFactory().getMetadataReader(clazz.getName());
		return reader.getAnnotationMetadata();
	}
	catch (IOException ex) {
		throw new IllegalStateException(ex);
	}
}
 
Example #25
Source File: SimpleMetadataReader.java    From spring-analysis-note with MIT License 4 votes vote down vote up
@Override
public ClassMetadata getClassMetadata() {
	return this.annotationMetadata;
}
 
Example #26
Source File: RegexPatternTypeFilter.java    From spring-analysis-note with MIT License 4 votes vote down vote up
@Override
protected boolean match(ClassMetadata metadata) {
	return this.pattern.matcher(metadata.getClassName()).matches();
}
 
Example #27
Source File: SimpleMetadataReader.java    From java-technology-stack with MIT License 4 votes vote down vote up
@Override
public ClassMetadata getClassMetadata() {
	return this.classMetadata;
}
 
Example #28
Source File: RegexPatternTypeFilter.java    From java-technology-stack with MIT License 4 votes vote down vote up
@Override
protected boolean match(ClassMetadata metadata) {
	return this.pattern.matcher(metadata.getClassName()).matches();
}
 
Example #29
Source File: RegexPatternTypeFilter.java    From spring4-understanding with Apache License 2.0 4 votes vote down vote up
@Override
protected boolean match(ClassMetadata metadata) {
	return this.pattern.matcher(metadata.getClassName()).matches();
}
 
Example #30
Source File: SimpleMetadataReader.java    From spring4-understanding with Apache License 2.0 4 votes vote down vote up
@Override
public ClassMetadata getClassMetadata() {
	return this.classMetadata;
}