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

io.github.factoryfx.jetty.UpdateableServletFactory Maven / Gradle / Ivy

There is a newer version: 3.2.1
Show newest version
package io.github.factoryfx.jetty;

import io.github.factoryfx.factory.util.LanguageText;
import io.github.factoryfx.factory.validation.ValidationResult;
import io.github.factoryfx.factory.FactoryBase;
import io.github.factoryfx.factory.attribute.dependency.FactoryListAttribute;

import java.util.HashSet;

public class UpdateableServletFactory> extends FactoryBase {

    public final FactoryListAttribute> servletAndPaths = new FactoryListAttribute>().labelText("servletAndPaths");

    public UpdateableServletFactory() {
        this.configLifeCycle().setCreator(() -> new UpdateableServlet(servletAndPaths.instances()));
        this.configLifeCycle().setUpdater(updateableServlet -> {
            updateableServlet.update(servletAndPaths.instances());
        });
        servletAndPaths.validation(list -> {
            HashSet paths = new HashSet<>();
            for (ServletAndPathFactory path : list) {
                if (!paths.add(path.pathSpec.get())){
                    return new ValidationResult(true,new LanguageText().en("duplicate path"));
                }
            }
            return new ValidationResult(false,new LanguageText());
        });
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy