All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.fluxtion.server.plugin.spring.SpringEventHandlerBuilder Maven / Gradle / Ivy

There is a newer version: 0.1.6
Show newest version
/*
 * 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);
            }
        });
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy