org.aspectj.lang.Aspects.hasAspect()方法的使用及代码示例

x33g5p2x  于2022-01-17 转载在 其他  
字(1.4k)|赞(0)|评价(0)|浏览(98)

本文整理了Java中org.aspectj.lang.Aspects.hasAspect()方法的一些代码示例,展示了Aspects.hasAspect()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Aspects.hasAspect()方法的具体详情如下:
包路径:org.aspectj.lang.Aspects
类名称:Aspects
方法名:hasAspect

Aspects.hasAspect介绍

[英]Returns true if singleton aspect or percflow / percflowbelow aspect is bound
[中]如果绑定了singleton方面或percflow/percflowbelow方面,则返回true

代码示例

代码示例来源:origin: dsyer/spring-boot-aspectj

@Override
public ConditionOutcome getMatchOutcome(ConditionContext context,
    AnnotatedTypeMetadata metadata) {
  if (Aspects.hasAspect(TimingInterceptor.class)) {
    return ConditionOutcome.match("AspectJ weaving");
  }
  return ConditionOutcome.noMatch("AspectJ not weaving");
}

代码示例来源:origin: org.parallelj/parallelj-core

/**
 * Return the values of the attributes
 * 
 * @param executable
 *            an instance of a class annotated by {@link Program} or by
 *            {@link Executable}
 * @return the values of the attributes or an empty map if the parameter is
 *         <code>null</code> or if the class is not annotated by
 *         {@link Program} or by {@link Executable}
 */
public static Map<String, String> attributes(Object executable) {
  if (executable == null
      || !Aspects.hasAspect(PerExecutable.class,
          executable.getClass())) {
    return empty;
  }
  PerExecutable perExecutable = Aspects.aspectOf(PerExecutable.class,
      executable.getClass());
  if (perExecutable.executable != null) {
    return perExecutable.executable.values(executable);
  } else {
    return empty;
  }
}

相关文章