public AgentConfig environmentToConfiguration(Environment environment,long platformId){
  AgentConfig agentConfiguration=new AgentConfig();
  agentConfiguration.setPlatformId(platformId);
  if (CollectionUtils.isNotEmpty(environment.getPlatformSensorConfigs())) {
    Collection<PlatformSensorTypeConfig> platformSensorTypeConfigs=new ArrayList<>();
    for (    IPlatformSensorConfig platformSensorConfig : environment.getPlatformSensorConfigs()) {
      if (platformSensorConfig.isActive()) {
        platformSensorTypeConfigs.add(getPlatformSensorTypeConfig(platformId,platformSensorConfig));
      }
    }
    agentConfiguration.setPlatformSensorTypeConfigs(platformSensorTypeConfigs);
  }
 else {
    agentConfiguration.setPlatformSensorTypeConfigs(Collections.<PlatformSensorTypeConfig>emptyList());
  }
  if (CollectionUtils.isNotEmpty(environment.getMethodSensorConfigs())) {
    Collection<MethodSensorTypeConfig> methodSensorTypeConfigs=new ArrayList<>();
    for (    IMethodSensorConfig methodSensorConfig : environment.getMethodSensorConfigs()) {
      methodSensorTypeConfigs.add(getMethodSensorTypeConfig(platformId,methodSensorConfig));
    }
    agentConfiguration.setMethodSensorTypeConfigs(methodSensorTypeConfigs);
  }
 else {
    agentConfiguration.setMethodSensorTypeConfigs(Collections.<MethodSensorTypeConfig>emptyList());
  }
  IExceptionSensorConfig exceptionSensorConfig=environment.getExceptionSensorConfig();
  if (null != exceptionSensorConfig) {
    agentConfiguration.setExceptionSensorTypeConfig(getExceptionSensorTypeConfig(platformId,exceptionSensorConfig));
  }
  JmxSensorConfig jmxSensorConfig=environment.getJmxSensorConfig();
  if (null != jmxSensorConfig) {
    agentConfiguration.setJmxSensorTypeConfig(getJmxSensorTypeConfig(platformId,jmxSensorConfig));
  }
  IStrategyConfig bufferStrategyConfig=environment.getBufferStrategyConfig();
  agentConfiguration.setBufferStrategyConfig(new StrategyConfig(bufferStrategyConfig.getClassName(),bufferStrategyConfig.getSettings()));
  IStrategyConfig sendingStrategyConfig=environment.getSendingStrategyConfig();
  agentConfiguration.setSendingStrategyConfig(new StrategyConfig(sendingStrategyConfig.getClassName(),sendingStrategyConfig.getSettings()));
  Collection<ExcludeRule> excludeRules=configurationResolver.getAllExcludeRules(environment);
  if (CollectionUtils.isNotEmpty(excludeRules)) {
    Collection<IMatchPattern> excludeClassesPatterns=new ArrayList<>();
    for (    ExcludeRule excludeRule : excludeRules) {
      excludeClassesPatterns.add(PatternFactory.getPattern(excludeRule.getClassName()));
    }
    agentConfiguration.setExcludeClassesPatterns(excludeClassesPatterns);
  }
 else {
    agentConfiguration.setExcludeClassesPatterns(Collections.<IMatchPattern>emptyList());
  }
  agentConfiguration.setConfigurationInfo(configurationResolver.getConfigurationInfo(environment));
  return agentConfiguration;
}

public AgentConfig environmentToConfiguration ( Environment environment , long platformId ) { AgentConfig agentConfiguration = new AgentConfig ( ) ; agentConfiguration . setPlatformId ( platformId ) ; if ( CollectionUtils . isNotEmpty ( environment . getPlatformSensorConfigs ( ) ) ) { Collection < PlatformSensorTypeConfig > platformSensorTypeConfigs = new ArrayList < > ( ) ; for ( IPlatformSensorConfig platformSensorConfig : environment . getPlatformSensorConfigs ( ) ) { if ( platformSensorConfig . isActive ( ) ) { platformSensorTypeConfigs . add ( getPlatformSensorTypeConfig ( platformId , platformSensorConfig ) ) ; } } agentConfiguration . setPlatformSensorTypeConfigs ( platformSensorTypeConfigs ) ; } else { agentConfiguration . setPlatformSensorTypeConfigs ( Collections . < PlatformSensorTypeConfig > emptyList ( ) ) ; } if ( CollectionUtils . isNotEmpty ( environment . getMethodSensorConfigs ( ) ) ) { Collection < MethodSensorTypeConfig > methodSensorTypeConfigs = new ArrayList < > ( ) ; for ( IMethodSensorConfig methodSensorConfig : environment . getMethodSensorConfigs ( ) ) { methodSensorTypeConfigs . add ( getMethodSensorTypeConfig ( platformId , methodSensorConfig ) ) ; } agentConfiguration . setMethodSensorTypeConfigs ( methodSensorTypeConfigs ) ; } else { agentConfiguration . setMethodSensorTypeConfigs ( Collections . < MethodSensorTypeConfig > emptyList ( ) ) ; } IExceptionSensorConfig exceptionSensorConfig = environment . getExceptionSensorConfig ( ) ; if ( null != exceptionSensorConfig ) { agentConfiguration . setExceptionSensorTypeConfig ( getExceptionSensorTypeConfig ( platformId , exceptionSensorConfig ) ) ; } JmxSensorConfig jmxSensorConfig = environment . getJmxSensorConfig ( ) ; if ( null != jmxSensorConfig ) { agentConfiguration . setJmxSensorTypeConfig ( getJmxSensorTypeConfig ( platformId , jmxSensorConfig ) ) ; } IStrategyConfig bufferStrategyConfig = environment . getBufferStrategyConfig ( ) ; agentConfiguration . setBufferStrategyConfig ( new StrategyConfig ( bufferStrategyConfig . getClassName ( ) , bufferStrategyConfig . getSettings ( ) ) ) ; IStrategyConfig sendingStrategyConfig = environment . getSendingStrategyConfig ( ) ; agentConfiguration . setSendingStrategyConfig ( new StrategyConfig ( sendingStrategyConfig . getClassName ( ) , sendingStrategyConfig . getSettings ( ) ) ) ; Collection < ExcludeRule > excludeRules = configurationResolver . getAllExcludeRules ( environment ) ; if ( CollectionUtils . isNotEmpty ( excludeRules ) ) { Collection < IMatchPattern > excludeClassesPatterns = new ArrayList < > ( ) ; for ( ExcludeRule excludeRule : excludeRules ) { excludeClassesPatterns . add ( PatternFactory . getPattern ( excludeRule . getClassName ( ) ) ) ; } agentConfiguration . setExcludeClassesPatterns ( excludeClassesPatterns ) ; } else { agentConfiguration . setExcludeClassesPatterns ( Collections . < IMatchPattern > emptyList ( ) ) ; } agentConfiguration . setConfigurationInfo ( configurationResolver . getConfigurationInfo ( environment ) ) ; return agentConfiguration ; }
returns proper configuration for the agent with the correctly set ids for the agent and sensors .
