com.fluxtion.server.plugin.spring.SpringEventHandlerBuilder Maven / Gradle / Ivy
/*
* SPDX-FileCopyrightText: © 2024 Gregory Higgins
* SPDX-License-Identifier: AGPL-3.0-only
*/
package com.fluxtion.server.plugin.spring;
import com.fluxtion.compiler.extern.spring.FluxtionSpring;
import com.fluxtion.runtime.EventProcessor;
import com.fluxtion.runtime.audit.EventLogControlEvent;
import lombok.Data;
import java.nio.file.Path;
import java.util.function.Supplier;
@Data
public class SpringEventHandlerBuilder> implements Supplier {
private String springFile;
private boolean addEventAuditor = true;
private EventLogControlEvent.LogLevel auditLogLevel;
@Override
@SuppressWarnings("unchecked")
public T get() {
Path springFilePath = Path.of(springFile);
if (!springFilePath.toFile().exists()) {
throw new RuntimeException("File not found: " + springFile);
}
return (T) FluxtionSpring.compile(springFilePath, cfg -> {
if (addEventAuditor) {
cfg.addEventAudit(auditLogLevel != null ? auditLogLevel : EventLogControlEvent.LogLevel.INFO);
}
});
}
}