Java 类org.springframework.core.annotation.AnnotatedElementUtils 实例源码

项目:spring-cloud-sockets    文件:DispatcherHandler.java   
@Override
public void afterPropertiesSet() throws Exception {
    String[] beanNames = BeanFactoryUtils.beanNamesForTypeIncludingAncestors(this.applicationContext, Object.class);
    for(String beanName : beanNames){
        Class<?> beanType = this.applicationContext.getType(beanName);
        if(beanType != null){
            final Class<?> userType = ClassUtils.getUserClass(beanType);
            ReflectionUtils.doWithMethods(userType, method -> {
                if(AnnotatedElementUtils.findMergedAnnotation(method, ReactiveSocket.class) != null) {
                    ServiceMethodInfo info = new ServiceMethodInfo(method);
                    logger.info("Registering remote endpoint at path {}, exchange {} for method {}", info.getMappingInfo().getPath(), info.getMappingInfo().getExchangeMode(), method);
                    MethodHandler methodHandler = new MethodHandler(applicationContext.getBean(beanName), info);
                    mappingHandlers.add(methodHandler);
                }
            });
        }
    }
    initDefaultConverters();
}
项目:cuba-scheduler-annotation    文件:ScheduledTaskLoader.java   
/**
 * The method scans all beans, that contain methods,
 * annotated as {@link ScheduledBeanMethod}
 */
@Override
public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
    Class<?> targetClass = AopUtils.getTargetClass(bean);

    Map<Method, Set<ScheduledBeanMethod>> annotatedMethods = MethodIntrospector.selectMethods(targetClass,
            (MethodIntrospector.MetadataLookup<Set<ScheduledBeanMethod>>) method -> {
                Set<ScheduledBeanMethod> scheduledMethods = AnnotatedElementUtils.getMergedRepeatableAnnotations(
                        method, ScheduledBeanMethod.class, ScheduledBeanMethods.class);
                return (!scheduledMethods.isEmpty() ? scheduledMethods : null);
            });

    for (Map.Entry<Method, Set<ScheduledBeanMethod>> entry : annotatedMethods.entrySet()) {
        scheduleAnnotatedMethods.add(new ScheduledMethodContext(beanName, entry.getKey(), entry.getValue()));
    }

    return bean;
}
项目:spring-domain-events    文件:CompletionRegisteringBeanPostProcessor.java   
@Override
public void doWith(Method method) throws IllegalArgumentException, IllegalAccessException {

    if (methodFound) {
        return;
    }

    TransactionalEventListener listener = AnnotatedElementUtils.findMergedAnnotation(method,
            TransactionalEventListener.class);

    if (listener == null) {
        return;
    }

    this.methodFound = true;

    bean = createCompletionRegisteringProxy(bean);
}
项目:embedded-database-spring-test    文件:EmbeddedPostgresContextCustomizerFactory.java   
@Override
public void customizeContext(ConfigurableApplicationContext context, MergedContextConfiguration mergedConfig) {
    Class<?> testClass = mergedConfig.getTestClass();
    FlywayTest flywayAnnotation = AnnotatedElementUtils.findMergedAnnotation(testClass, FlywayTest.class);

    BeanDefinitionRegistry registry = getBeanDefinitionRegistry(context);
    RootBeanDefinition registrarDefinition = new RootBeanDefinition();

    registrarDefinition.setBeanClass(PreloadableEmbeddedPostgresRegistrar.class);
    registrarDefinition.getConstructorArgumentValues()
            .addIndexedArgumentValue(0, databaseAnnotation);
    registrarDefinition.getConstructorArgumentValues()
            .addIndexedArgumentValue(1, flywayAnnotation);

    registry.registerBeanDefinition("preloadableEmbeddedPostgresRegistrar", registrarDefinition);
}
项目:bekit    文件:ListenNodeDecidedResolver.java   
@Override
public void init(Method listenMethod) {
    TheFlowListener theFlowListenerAnnotation = AnnotatedElementUtils.findMergedAnnotation(listenMethod.getDeclaringClass(), TheFlowListener.class);
    if (theFlowListenerAnnotation == null) {
        throw new IllegalArgumentException("@ListenNodeDecided只能标注在特定流程监听器(@TheFlowListener)的方法上");
    }
    // 校验入参
    Class[] parameterTypes = listenMethod.getParameterTypes();
    if (parameterTypes.length != 2) {
        throw new RuntimeException("监听节点选择方法" + ClassUtils.getQualifiedMethodName(listenMethod) + "的入参必须是(String, TargetContext)");
    }
    if (parameterTypes[0] != String.class || parameterTypes[1] != TargetContext.class) {
        throw new RuntimeException("监听节点选择方法" + ClassUtils.getQualifiedMethodName(listenMethod) + "的入参必须是(String, TargetContext)");
    }
    eventType = new TheFlowEventType(theFlowListenerAnnotation.flow(), NodeDecidedEvent.class);
}
项目:bekit    文件:ListenFlowExceptionResolver.java   
@Override
public void init(Method listenMethod) {
    TheFlowListener theFlowListenerAnnotation = AnnotatedElementUtils.findMergedAnnotation(listenMethod.getDeclaringClass(), TheFlowListener.class);
    if (theFlowListenerAnnotation == null) {
        throw new IllegalArgumentException("@ListenFlowException只能标注在特定流程监听器(@TheFlowListener)的方法上");
    }
    // 校验入参
    Class[] parameterTypes = listenMethod.getParameterTypes();
    if (parameterTypes.length != 2) {
        throw new RuntimeException("监听流程异常方法" + ClassUtils.getQualifiedMethodName(listenMethod) + "的入参必须是(Throwable, TargetContext)");
    }
    if (parameterTypes[0] != Throwable.class || parameterTypes[1] != TargetContext.class) {
        throw new RuntimeException("监听流程异常方法" + ClassUtils.getQualifiedMethodName(listenMethod) + "的入参必须是(Throwable, TargetContext)");
    }
    eventType = new TheFlowEventType(theFlowListenerAnnotation.flow(), FlowExceptionEvent.class);
}
项目:bekit    文件:ListenerParser.java   
/**
 * 解析监听器
 *
 * @param listener 监听器
 * @return 监听器执行器
 */
public static ListenerExecutor parseListener(Object listener) {
    // 获取目标class(应对AOP代理情况)
    Class<?> listenerClass = AopUtils.getTargetClass(listener);
    logger.debug("解析监听器:{}", ClassUtils.getQualifiedName(listenerClass));
    // 此处得到的@Listener是已经经过@AliasFor属性别名进行属性同步后的结果
    Listener listenerAnnotation = AnnotatedElementUtils.findMergedAnnotation(listenerClass, Listener.class);
    // 创建监听器执行器
    ListenerExecutor listenerExecutor = new ListenerExecutor(listener, listenerAnnotation.type(), listenerAnnotation.priority(), parseEventTypeResolver(listenerAnnotation.type()));
    for (Method method : listenerClass.getDeclaredMethods()) {
        Listen listenAnnotation = AnnotatedElementUtils.findMergedAnnotation(method, Listen.class);
        if (listenAnnotation != null) {
            ListenExecutor listenExecutor = parseListen(listenAnnotation, method);
            listenerExecutor.addListenExecutor(listenExecutor);
        }
    }
    listenerExecutor.validate();

    return listenerExecutor;
}
项目:FastBootWeixin    文件:WxMappingHandlerMapping.java   
private WxMappingInfo createWxMappingInfo(AnnotatedElement element) {
    WxButton wxButton = AnnotatedElementUtils.findMergedAnnotation(element, WxButton.class);
    // 由于这个机制,所以无法为同一个方法绑定多个WxButton、WxEventMapping、WxMessageMapping
    if (wxButton != null) {
        return createWxButtonMappingInfo(wxButton);
    }
    WxMessageMapping wxMessageMapping = AnnotatedElementUtils.findMergedAnnotation(element, WxMessageMapping.class);
    if (wxMessageMapping != null) {
        return createWxMessageMappingInfo(wxMessageMapping);
    }
    WxEventMapping wxEventMapping = AnnotatedElementUtils.findMergedAnnotation(element, WxEventMapping.class);
    if (wxEventMapping != null) {
        return createWxEventMappingInfo(wxEventMapping);
    }
    return null;
}
项目:configcenter    文件:ListenConfigModifiedResolver.java   
@Override
public void init(Method listenMethod) {
    ConfigListener configListenerAnnotation = AnnotatedElementUtils.findMergedAnnotation(listenMethod.getDeclaringClass(), ConfigListener.class);
    if (configListenerAnnotation == null) {
        throw new IllegalArgumentException("@ListenConfigModified只能标注在配置监听器(@ConfigListener)的方法上");
    }
    // 校验入参
    Class[] parameterTypes = listenMethod.getParameterTypes();
    if (parameterTypes.length != 1) {
        throw new RuntimeException("监听配置被修改方法" + ClassUtils.getQualifiedMethodName(listenMethod) + "的入参必须是(List<ModifiedProperty>)");
    }
    if (parameterTypes[0] != List.class) {
        throw new RuntimeException("监听配置被修改方法" + ClassUtils.getQualifiedMethodName(listenMethod) + "的入参必须是(List<ModifiedProperty>)");
    }
    ResolvableType resolvableType = ResolvableType.forMethodParameter(listenMethod, 0);
    if (resolvableType.getGeneric(0).resolve(Object.class) != ModifiedProperty.class) {
        throw new RuntimeException("监听配置被修改方法" + ClassUtils.getQualifiedMethodName(listenMethod) + "的入参必须是(List<ModifiedProperty>)");
    }
    // 设置事件类型
    ListenConfigModified listenConfigModifiedAnnotation = AnnotatedElementUtils.findMergedAnnotation(listenMethod, ListenConfigModified.class);
    eventType = new ConfigModifiedEventType(configListenerAnnotation.configContextName(), listenConfigModifiedAnnotation.prefix());
}
项目:spring4-understanding    文件:StandardAnnotationMetadata.java   
@Override
public boolean hasAnnotatedMethods(String annotationName) {
    try {
        Method[] methods = getIntrospectedClass().getDeclaredMethods();
        for (Method method : methods) {
            if (!method.isBridge() && method.getAnnotations().length > 0 &&
                    AnnotatedElementUtils.isAnnotated(method, annotationName)) {
                return true;
            }
        }
        return false;
    }
    catch (Throwable ex) {
        throw new IllegalStateException("Failed to introspect annotated methods on " + getIntrospectedClass(), ex);
    }
}
项目:spring4-understanding    文件:StandardAnnotationMetadata.java   
@Override
public Set<MethodMetadata> getAnnotatedMethods(String annotationName) {
    try {
        Method[] methods = getIntrospectedClass().getDeclaredMethods();
        Set<MethodMetadata> annotatedMethods = new LinkedHashSet<MethodMetadata>();
        for (Method method : methods) {
            if (!method.isBridge() && method.getAnnotations().length > 0 &&
                    AnnotatedElementUtils.isAnnotated(method, annotationName)) {
                annotatedMethods.add(new StandardMethodMetadata(method, this.nestedAnnotationsAsMap));
            }
        }
        return annotatedMethods;
    }
    catch (Throwable ex) {
        throw new IllegalStateException("Failed to introspect annotated methods on " + getIntrospectedClass(), ex);
    }
}
项目:spring4-understanding    文件:ResponseStatusExceptionResolver.java   
@Override
protected ModelAndView doResolveException(HttpServletRequest request, HttpServletResponse response,
        Object handler, Exception ex) {

    ResponseStatus responseStatus = AnnotatedElementUtils.findMergedAnnotation(ex.getClass(), ResponseStatus.class);
    if (responseStatus != null) {
        try {
            return resolveResponseStatus(responseStatus, request, response, handler, ex);
        }
        catch (Exception resolveEx) {
            logger.warn("Handling of @ResponseStatus resulted in Exception", resolveEx);
        }
    }
    else if (ex.getCause() instanceof Exception) {
        ex = (Exception) ex.getCause();
        return doResolveException(request, response, handler, ex);
    }
    return null;
}
项目:spring4-understanding    文件:CrossOriginTests.java   
@Override
protected RequestMappingInfo getMappingForMethod(Method method, Class<?> handlerType) {
    RequestMapping annotation = AnnotatedElementUtils.findMergedAnnotation(method, RequestMapping.class);
    if (annotation != null) {
        return new RequestMappingInfo(
                new PatternsRequestCondition(annotation.value(), getUrlPathHelper(), getPathMatcher(), true, true),
                new RequestMethodsRequestCondition(annotation.method()),
                new ParamsRequestCondition(annotation.params()),
                new HeadersRequestCondition(annotation.headers()),
                new ConsumesRequestCondition(annotation.consumes(), annotation.headers()),
                new ProducesRequestCondition(annotation.produces(), annotation.headers()), null);
    }
    else {
        return null;
    }
}
项目:spring4-understanding    文件:TransactionalTestExecutionListener.java   
/**
 * Retrieve the {@link TransactionConfigurationAttributes} for the
 * supplied {@link TestContext} whose {@linkplain Class test class}
 * may optionally declare or inherit
 * {@link TransactionConfiguration @TransactionConfiguration}.
 * <p>If {@code @TransactionConfiguration} is not present for the
 * supplied {@code TestContext}, a default instance of
 * {@code TransactionConfigurationAttributes} will be used instead.
 * @param testContext the test context for which the configuration
 * attributes should be retrieved
 * @return the TransactionConfigurationAttributes instance for this listener,
 * potentially cached
 * @see TransactionConfigurationAttributes#TransactionConfigurationAttributes()
 */
@SuppressWarnings("deprecation")
TransactionConfigurationAttributes retrieveConfigurationAttributes(TestContext testContext) {
    if (this.configurationAttributes == null) {
        Class<?> clazz = testContext.getTestClass();

        TransactionConfiguration txConfig = AnnotatedElementUtils.findMergedAnnotation(clazz,
            TransactionConfiguration.class);
        if (logger.isDebugEnabled()) {
            logger.debug(String.format("Retrieved @TransactionConfiguration [%s] for test class [%s].",
                txConfig, clazz.getName()));
        }

        TransactionConfigurationAttributes configAttributes = (txConfig == null ? defaultTxConfigAttributes
                : new TransactionConfigurationAttributes(txConfig.transactionManager(), txConfig.defaultRollback()));

        if (logger.isDebugEnabled()) {
            logger.debug(String.format("Using TransactionConfigurationAttributes %s for test class [%s].",
                configAttributes, clazz.getName()));
        }
        this.configurationAttributes = configAttributes;
    }
    return this.configurationAttributes;
}
项目:spring4-understanding    文件:AbstractDirtiesContextTestExecutionListener.java   
/**
 * Perform the actual work for {@link #beforeTestClass} and {@link #afterTestClass}
 * by dirtying the context if appropriate (i.e., according to the required mode).
 * @param testContext the test context whose application context should
 * potentially be marked as dirty; never {@code null}
 * @param requiredClassMode the class mode required for a context to
 * be marked dirty in the current phase; never {@code null}
 * @throws Exception allows any exception to propagate
 * @since 4.2
 * @see #dirtyContext
 */
protected void beforeOrAfterTestClass(TestContext testContext, ClassMode requiredClassMode) throws Exception {
    Assert.notNull(testContext, "TestContext must not be null");
    Assert.notNull(requiredClassMode, "requiredClassMode must not be null");

    Class<?> testClass = testContext.getTestClass();
    Assert.notNull(testClass, "The test class of the supplied TestContext must not be null");

    DirtiesContext dirtiesContext = AnnotatedElementUtils.findMergedAnnotation(testClass, DirtiesContext.class);
    boolean classAnnotated = (dirtiesContext != null);
    ClassMode classMode = (classAnnotated ? dirtiesContext.classMode() : null);

    if (logger.isDebugEnabled()) {
        String phase = (requiredClassMode.name().startsWith("BEFORE") ? "Before" : "After");
        logger.debug(String.format(
            "%s test class: context %s, class annotated with @DirtiesContext [%s] with mode [%s].", phase,
            testContext, classAnnotated, classMode));
    }

    if (classMode == requiredClassMode) {
        dirtyContext(testContext, dirtiesContext.hierarchyMode());
    }
}
项目:line-bot-sdk-java    文件:LineMessageHandlerSupport.java   
private HandlerMethod getMethodHandlerMethodFunction(Object consumer, Method method) {
    final EventMapping mapping = AnnotatedElementUtils.getMergedAnnotation(method, EventMapping.class);
    if (mapping == null) {
        return null;
    }

    Preconditions.checkState(method.getParameterCount() == 1,
                             "Number of parameter should be 1. But {}",
                             (Object[]) method.getParameterTypes());
    // TODO: Support more than 1 argument. Like MVC's argument resolver?

    final Type type = method.getGenericParameterTypes()[0];

    final Predicate<Event> predicate = new EventPredicate(type);
    return new HandlerMethod(predicate, consumer, method,
                             getPriority(mapping, type));
}
项目:spring    文件:StandardAnnotationMetadata.java   
@Override
public boolean hasAnnotatedMethods(String annotationName) {
    try {
        Method[] methods = getIntrospectedClass().getDeclaredMethods();
        for (Method method : methods) {
            if (!method.isBridge() && method.getAnnotations().length > 0 &&
                    AnnotatedElementUtils.isAnnotated(method, annotationName)) {
                return true;
            }
        }
        return false;
    }
    catch (Throwable ex) {
        throw new IllegalStateException("Failed to introspect annotated methods on " + getIntrospectedClass(), ex);
    }
}
项目:spring    文件:StandardAnnotationMetadata.java   
@Override
public Set<MethodMetadata> getAnnotatedMethods(String annotationName) {
    try {
        Method[] methods = getIntrospectedClass().getDeclaredMethods();
        Set<MethodMetadata> annotatedMethods = new LinkedHashSet<MethodMetadata>();
        for (Method method : methods) {
            if (!method.isBridge() && method.getAnnotations().length > 0 &&
                    AnnotatedElementUtils.isAnnotated(method, annotationName)) {
                annotatedMethods.add(new StandardMethodMetadata(method, this.nestedAnnotationsAsMap));
            }
        }
        return annotatedMethods;
    }
    catch (Throwable ex) {
        throw new IllegalStateException("Failed to introspect annotated methods on " + getIntrospectedClass(), ex);
    }
}
项目:spring-cloud-sockets    文件:ServiceMethodInfo.java   
public ServiceMethodInfo(Method method) {
    this.method = method;
    ReactiveSocket annotated = AnnotatedElementUtils.findMergedAnnotation(method, ReactiveSocket.class);
    if(annotated == null){
        throw new IllegalStateException("Service methods must be annotated with a one of {@OneWayMapping, @RequestOneMapping, @RequestManyMapping, @RequestStreamMapping} ");
    }
    this.mappingInfo = new ServiceMappingInfo(annotated.value(), annotated.mimeType(), annotated.exchangeMode());
    this.returnType = ResolvableType.forMethodReturnType(method);
    findPayloadParameter();
    validate();

}
项目:autotest    文件:AutoTestExtension.java   
@Override
public boolean supportsParameter(ParameterContext parameterContext, ExtensionContext extensionContext) throws ParameterResolutionException {
    java.lang.reflect.Parameter parameter = parameterContext.getParameter();
    Executable executable = parameter.getDeclaringExecutable();
    return (executable instanceof Constructor && AnnotatedElementUtils.hasAnnotation(executable, Autowired.class))
            || isAutowirable(parameter);
}
项目:spring-domain-events    文件:PersistentApplicationEventMulticaster.java   
private static boolean isTransactionalApplicationEventListener(ApplicationListener<?> listener) {

        Class<?> targetClass = AopUtils.getTargetClass(listener);

        if (!ApplicationListenerMethodAdapter.class.isAssignableFrom(targetClass)) {
            return false;
        }

        Field field = ReflectionUtils.findField(ApplicationListenerMethodAdapter.class, "method");
        ReflectionUtils.makeAccessible(field);
        Method method = (Method) ReflectionUtils.getField(field, listener);

        return AnnotatedElementUtils.hasAnnotation(method, TransactionalEventListener.class);
    }
项目:embedded-database-spring-test    文件:EmbeddedPostgresContextCustomizerFactory.java   
@Override
public ContextCustomizer createContextCustomizer(Class<?> testClass, List<ContextConfigurationAttributes> configAttributes) {
    AutoConfigureEmbeddedDatabase databaseAnnotation = AnnotatedElementUtils.findMergedAnnotation(testClass, AutoConfigureEmbeddedDatabase.class);

    if (databaseAnnotation != null
            && databaseAnnotation.type() == EmbeddedDatabaseType.POSTGRES
            && databaseAnnotation.replace() != Replace.NONE) {
        return new PreloadableEmbeddedPostgresContextCustomizer(databaseAnnotation);
    }

    return null;
}
项目:lams    文件:JtaTransactionAnnotationParser.java   
@Override
public TransactionAttribute parseTransactionAnnotation(AnnotatedElement ae) {
    AnnotationAttributes ann = AnnotatedElementUtils.getAnnotationAttributes(ae, javax.transaction.Transactional.class.getName());
    if (ann != null) {
        return parseTransactionAnnotation(ann);
    }
    else {
        return null;
    }
}
项目:lams    文件:SpringTransactionAnnotationParser.java   
@Override
public TransactionAttribute parseTransactionAnnotation(AnnotatedElement ae) {
    AnnotationAttributes ann = AnnotatedElementUtils.getAnnotationAttributes(ae, Transactional.class.getName());
    if (ann != null) {
        return parseTransactionAnnotation(ann);
    }
    else {
        return null;
    }
}
项目:lams    文件:AutowiredAnnotationBeanPostProcessor.java   
private AnnotationAttributes findAutowiredAnnotation(AccessibleObject ao) {
    for (Class<? extends Annotation> type : this.autowiredAnnotationTypes) {
        AnnotationAttributes annotation = AnnotatedElementUtils.getAnnotationAttributes(ao, type.getName());
        if (annotation != null) {
            return annotation;
        }
    }
    return null;
}
项目:amanda    文件:FileServerUtil.java   
/**
 * Url获取函数,作为函数传入StorageService。
 * @param path
 * @return FileInfo
 */
public static String getPathUrl(Path path) {
    String resourcePath = path.getName(0).relativize(path).toString().replace("\\", "/");
    String methodName = path.toFile().isDirectory() ? "viewDir" : "serveFile";
    Method method;
    try {
        method = FileServerEndpoint.class.getDeclaredMethod(methodName, HttpServletRequest.class);
    } catch (NoSuchMethodException e) {
        throw new IllegalArgumentException("No " + methodName + " method in " + FileServerEndpoint.class.getSimpleName());
    }

    String methodPath;
    RequestMapping requestMapping = AnnotatedElementUtils.findMergedAnnotation(method, RequestMapping.class);

    if (requestMapping == null) {
        throw new IllegalArgumentException("No @RequestMapping on: " + method.toGenericString());
    }
    String[] paths = requestMapping.path();
    if (ObjectUtils.isEmpty(paths) || StringUtils.isEmpty(paths[0])) {
        methodPath = "/";
    }else {
        methodPath = paths[0].substring(0, paths[0].length() - 2);
    }

    String baseUrl = MvcUriComponentsBuilder
            .fromController(FileServerEndpoint.class)
            .build().toString();

    String pathUrl = baseUrl + methodPath + resourcePath;

    return pathUrl;
}
项目:spring-data-ebean    文件:EbeanQueryMethod.java   
@SuppressWarnings( {"rawtypes", "unchecked"})
private <T> T getMergedOrDefaultAnnotationValue(String attribute, Class annotationType, Class<T> targetType) {
  Annotation annotation = AnnotatedElementUtils.findMergedAnnotation(method, annotationType);
  if (annotation == null) {
    return targetType.cast(AnnotationUtils.getDefaultValue(annotationType, attribute));
  }

  return targetType.cast(AnnotationUtils.getValue(annotation, attribute));
}
项目:FastBootWeixin    文件:WxMappingHandlerMapping.java   
@Override
protected HandlerMethod createHandlerMethod(Object handler, Method method) {
    if (handler instanceof String) {
        String beanName = (String) handler;
        handler = this.getApplicationContext().getAutowireCapableBeanFactory().getBean(beanName);
    }
    if (AnnotatedElementUtils.hasAnnotation(method, WxAsyncMessage.class) || AnnotatedElementUtils.hasAnnotation(handler.getClass(), WxAsyncMessage.class)) {
        return new HandlerMethod(wxAsyncHandlerFactory.createHandler(handler), method);
    } else {
        return new HandlerMethod(handler, method);
    }
}
项目:FastBootWeixin    文件:WxApiTypeInfo.java   
/**
 * @param clazz       代理类
 * @param defaultHost 默认host
 */
public WxApiTypeInfo(Class clazz, String defaultHost) {
    this.clazz = clazz;
    WxApiRequest wxApiRequest = AnnotatedElementUtils.findMergedAnnotation(clazz, WxApiRequest.class);
    String host = getTypeWxApiHost(wxApiRequest, defaultHost);
    String typePath = getTypeWxApiRequestPath(wxApiRequest);
    // 固定https请求
    propertyPrefix = getTypeWxApiPropertyPrefix(wxApiRequest);
    baseBuilder = UriComponentsBuilder.newInstance().scheme("https").host(host).path(typePath);
}
项目:FastBootWeixin    文件:WxApiMethodInfo.java   
private String getMethodWxApiRequestPath(Method method) {
    WxApiRequest wxApiRequest = AnnotatedElementUtils.findMergedAnnotation(method, WxApiRequest.class);
    if (wxApiRequest == null || StringUtils.isEmpty(wxApiRequest.path()) || ValueConstants.DEFAULT_NONE.equals(wxApiRequest.path())) {
        // 默认情况下取方法名为变量名,尝试从环境变量中获取信息
        return WxContextUtils.resolveStringValue("${" + this.wxApiTypeInfo.getPropertyPrefix() + "." + method.getName() + "}");
    }
    return wxApiRequest.path();
}
项目:spring-data-mybatis    文件:DefaultMybatisEntityMetadata.java   
@Override
public String getEntityName() {
    Entity entity = AnnotatedElementUtils.findMergedAnnotation(domainType, Entity.class);
    boolean hasName = null != entity && StringUtils.hasText(entity.name());

    return hasName ? entity.name() : domainType.getSimpleName();
}
项目:spring-data-mybatis    文件:MybatisQueryMethod.java   
private <T> T getMergedOrDefaultAnnotationValue(String attribute, Class annotationType, Class<T> targetType) {

        Annotation annotation = AnnotatedElementUtils.findMergedAnnotation(method, annotationType);
        if (annotation == null) {
            return targetType.cast(AnnotationUtils.getDefaultValue(annotationType, attribute));
        }

        return targetType.cast(AnnotationUtils.getValue(annotation, attribute));
    }
项目:hsweb-framework    文件:FixUseSupperClassAnnotationParser.java   
protected Collection<CacheOperation> parseCacheAnnotations(DefaultCacheConfig cachingConfig, AnnotatedElement ae) {
    Collection<CacheOperation> ops = null;

    Collection<Cacheable> cacheables = AnnotatedElementUtils.getAllMergedAnnotations(ae, Cacheable.class);
    if (!cacheables.isEmpty()) {
        ops = lazyInit(ops);
        for (Cacheable cacheable : cacheables) {
            ops.add(parseCacheableAnnotation(ae, cachingConfig, cacheable));
        }
    }
    Collection<CacheEvict> evicts = AnnotatedElementUtils.getAllMergedAnnotations(ae, CacheEvict.class);
    if (!evicts.isEmpty()) {
        ops = lazyInit(ops);
        for (CacheEvict evict : evicts) {
            ops.add(parseEvictAnnotation(ae, cachingConfig, evict));
        }
    }
    Collection<CachePut> puts = AnnotatedElementUtils.getAllMergedAnnotations(ae, CachePut.class);
    if (!puts.isEmpty()) {
        ops = lazyInit(ops);
        for (CachePut put : puts) {
            ops.add(parsePutAnnotation(ae, cachingConfig, put));
        }
    }
    Collection<Caching> cachings = AnnotatedElementUtils.getAllMergedAnnotations(ae, Caching.class);
    if (!cachings.isEmpty()) {
        ops = lazyInit(ops);
        for (Caching caching : cachings) {
            Collection<CacheOperation> cachingOps = parseCachingAnnotation(ae, cachingConfig, caching);
            if (cachingOps != null) {
                ops.addAll(cachingOps);
            }
        }
    }

    return ops;
}
项目:hsweb-framework    文件:FixUseSupperClassAnnotationParser.java   
/**
 * Provides the {@link DefaultCacheConfig} instance for the specified {@link Class}.
 *
 * @param target the class-level to handle
 * @return the default config (never {@code null})
 */
DefaultCacheConfig getDefaultCacheConfig(Class<?> target) {
    CacheConfig annotation = AnnotatedElementUtils.getMergedAnnotation(target, CacheConfig.class);
    if (annotation != null) {
        return new DefaultCacheConfig(annotation.cacheNames(), annotation.keyGenerator(),
                annotation.cacheManager(), annotation.cacheResolver());
    }
    return new DefaultCacheConfig();
}
项目:spring4-understanding    文件:ApplicationListenerMethodAdapter.java   
/**
 * Return the condition to use.
 * <p>Matches the {@code condition} attribute of the {@link EventListener}
 * annotation or any matching attribute on a composed annotation that
 * is meta-annotated with {@code @EventListener}.
 */
protected String getCondition() {
    if (this.condition == null) {
        EventListener eventListener = AnnotatedElementUtils.findMergedAnnotation(this.method, EventListener.class);
        if (eventListener != null) {
            this.condition = eventListener.condition();
        }
    }
    return this.condition;
}
项目:spring4-understanding    文件:JtaTransactionAnnotationParser.java   
@Override
public TransactionAttribute parseTransactionAnnotation(AnnotatedElement ae) {
    AnnotationAttributes attributes = AnnotatedElementUtils.getMergedAnnotationAttributes(ae, javax.transaction.Transactional.class);
    if (attributes != null) {
        return parseTransactionAnnotation(attributes);
    }
    else {
        return null;
    }
}
项目:spring4-understanding    文件:SpringTransactionAnnotationParser.java   
@Override
public TransactionAttribute parseTransactionAnnotation(AnnotatedElement ae) {
    AnnotationAttributes attributes = AnnotatedElementUtils.getMergedAnnotationAttributes(ae, Transactional.class);
    if (attributes != null) {
        return parseTransactionAnnotation(attributes);
    }
    else {
        return null;
    }
}
项目:spring4-understanding    文件:ApplicationListenerMethodTransactionalAdapter.java   
static TransactionalEventListener findAnnotation(Method method) {
    TransactionalEventListener annotation =
            AnnotatedElementUtils.findMergedAnnotation(method, TransactionalEventListener.class);
    if (annotation == null) {
        throw new IllegalStateException("No TransactionalEventListener annotation found on '" + method + "'");
    }
    return annotation;
}
项目:spring4-understanding    文件:MvcUriComponentsBuilder.java   
private static String getTypeRequestMapping(Class<?> controllerType) {
    Assert.notNull(controllerType, "'controllerType' must not be null");
    RequestMapping requestMapping = AnnotatedElementUtils.findMergedAnnotation(controllerType, RequestMapping.class);
    if (requestMapping == null) {
        return "/";
    }
    String[] paths = requestMapping.path();
    if (ObjectUtils.isEmpty(paths) || StringUtils.isEmpty(paths[0])) {
        return "/";
    }
    if (paths.length > 1 && logger.isWarnEnabled()) {
        logger.warn("Multiple paths on controller " + controllerType.getName() + ", using first one");
    }
    return paths[0];
}
项目:spring4-understanding    文件:MvcUriComponentsBuilder.java   
private static String getMethodRequestMapping(Method method) {
    Assert.notNull(method, "'method' must not be null");
    RequestMapping requestMapping = AnnotatedElementUtils.findMergedAnnotation(method, RequestMapping.class);
    if (requestMapping == null) {
        throw new IllegalArgumentException("No @RequestMapping on: " + method.toGenericString());
    }
    String[] paths = requestMapping.path();
    if (ObjectUtils.isEmpty(paths) || StringUtils.isEmpty(paths[0])) {
        return "/";
    }
    if (paths.length > 1 && logger.isWarnEnabled()) {
        logger.warn("Multiple paths on method " + method.toGenericString() + ", using first one");
    }
    return paths[0];
}