Search in sources :

Example 1 with SubstitutionFactoryFactory

use of com.nextdoor.bender.operation.substitution.SubstitutionFactoryFactory in project bender by Nextdoor.

the class GelfOperationFactory method setConf.

@Override
public void setConf(AbstractConfig config) {
    this.config = (GelfOperationConfig) config;
    ArrayList<SubstitutionConfig> subConfigs = new ArrayList<SubstitutionConfig>();
    subConfigs.add(new StaticSubstitutionConfig("version", "1.1", true));
    if (this.config.getSrcHostField() != null) {
        subConfigs.add(new FieldSubstitutionConfig("host", this.config.getSrcHostField(), false, true, true));
    }
    if (this.config.getSrcShortMessageField() != null) {
        subConfigs.add(new FieldSubstitutionConfig("short_message", this.config.getSrcShortMessageField(), false, true, true));
    }
    if (this.config.getSrcFullMessageField() != null) {
        subConfigs.add(new FieldSubstitutionConfig("full_message", this.config.getSrcFullMessageField(), false, false, true));
    }
    if (this.config.getSrcTimestampField() != null) {
        subConfigs.add(new FieldSubstitutionConfig("timestamp", this.config.getSrcTimestampField(), false, false, true));
    }
    if (this.config.getSrcLevelField() != null) {
        subConfigs.add(new FieldSubstitutionConfig("level", this.config.getSrcLevelField(), false, false, true));
    }
    if (this.config.getSrcFacilityField() != null) {
        subConfigs.add(new FieldSubstitutionConfig("facility", this.config.getSrcFacilityField(), false, false, true));
    }
    if (this.config.getSrcLineNumberField() != null) {
        subConfigs.add(new FieldSubstitutionConfig("line", this.config.getSrcLineNumberField(), false, false, true));
    }
    if (this.config.getSrcFileField() != null) {
        subConfigs.add(new FieldSubstitutionConfig("file", this.config.getSrcFileField(), false, false, true));
    }
    List<Substitution> substitutions = new ArrayList<Substitution>(subConfigs.size());
    SubstitutionFactoryFactory sff = new SubstitutionFactoryFactory();
    for (SubstitutionConfig subConfig : subConfigs) {
        try {
            substitutions.add(sff.getFactory(subConfig).newInstance());
        } catch (ClassNotFoundException e) {
            throw new RuntimeException(e);
        }
    }
    this.substitutions = substitutions;
    this.subConfigs = subConfigs;
}
Also used : StaticSubstitutionConfig(com.nextdoor.bender.operation.substitution.ztatic.StaticSubstitutionConfig) Substitution(com.nextdoor.bender.operation.substitution.Substitution) FieldSubstitutionConfig(com.nextdoor.bender.operation.substitution.field.FieldSubstitutionConfig) ArrayList(java.util.ArrayList) SubstitutionConfig(com.nextdoor.bender.operation.substitution.SubstitutionConfig) FieldSubstitutionConfig(com.nextdoor.bender.operation.substitution.field.FieldSubstitutionConfig) StaticSubstitutionConfig(com.nextdoor.bender.operation.substitution.ztatic.StaticSubstitutionConfig) SubstitutionFactoryFactory(com.nextdoor.bender.operation.substitution.SubstitutionFactoryFactory)

Aggregations

Substitution (com.nextdoor.bender.operation.substitution.Substitution)1 SubstitutionConfig (com.nextdoor.bender.operation.substitution.SubstitutionConfig)1 SubstitutionFactoryFactory (com.nextdoor.bender.operation.substitution.SubstitutionFactoryFactory)1 FieldSubstitutionConfig (com.nextdoor.bender.operation.substitution.field.FieldSubstitutionConfig)1 StaticSubstitutionConfig (com.nextdoor.bender.operation.substitution.ztatic.StaticSubstitutionConfig)1 ArrayList (java.util.ArrayList)1