io.github.factoryfx.jetty.UpdateableServletFactory Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jettyFactory Show documentation
Show all versions of jettyFactory Show documentation
factoryfx dependency injection framework
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());
});
}
}