示例#1
0
  @Around("execution(@ConfigureAgentEnabled void org.jmonitor..*Test.*())")
  public void aroundConfigureAgentEnabledPointcut(ProceedingJoinPoint joinPoint) throws Throwable {

    ConfigureAgentEnabled annotation = getAnnotation(ConfigureAgentEnabled.class, joinPoint);
    AgentConfigurationImpl mutableConfiguration = getMutableAgentConfiguration();
    boolean previousValue = mutableConfiguration.isEnabled();
    // set it to annotated value
    mutableConfiguration.setEnabled(annotation.value());
    ConfigurationServiceImpl.getInstance().updateAgentConfiguration(mutableConfiguration);
    try {
      joinPoint.proceed();
    } finally {
      // set it back to original value
      mutableConfiguration.setEnabled(previousValue);
      ConfigurationServiceImpl.getInstance().updateAgentConfiguration(mutableConfiguration);
    }
  }
示例#2
0
  @Around("execution(@ConfigureAgentStackTraceInitialDelayMillis void org.jmonitor..*Test.*())")
  public void aroundConfigureAgentStackTraceInitialDelayMillisPointcut(
      ProceedingJoinPoint joinPoint) throws Throwable {

    ConfigureAgentStackTraceInitialDelayMillis annotation =
        getAnnotation(ConfigureAgentStackTraceInitialDelayMillis.class, joinPoint);
    AgentConfigurationImpl mutableConfiguration = getMutableAgentConfiguration();
    int previousValue = mutableConfiguration.getStackTraceInitialDelayMillis();
    // set it to annotated value
    mutableConfiguration.setStackTraceInitialDelayMillis(annotation.value());
    ConfigurationServiceImpl.getInstance().updateAgentConfiguration(mutableConfiguration);
    try {
      joinPoint.proceed();
    } finally {
      // set it back to original value
      mutableConfiguration.setStackTraceInitialDelayMillis(previousValue);
      ConfigurationServiceImpl.getInstance().updateAgentConfiguration(mutableConfiguration);
    }
  }