de.factoryfx.server.rest.MicroserviceResourceFactory Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of microserviceRestServer Show documentation
Show all versions of microserviceRestServer Show documentation
factoryfx dependency injection framework
package de.factoryfx.server.rest;
import java.util.Optional;
import java.util.function.Predicate;
import java.util.function.Supplier;
import de.factoryfx.data.attribute.types.ObjectValueAttribute;
import de.factoryfx.factory.FactoryBase;
import de.factoryfx.factory.atrribute.FactoryPolymorphicReferenceAttribute;
import de.factoryfx.server.Microservice;
import de.factoryfx.server.user.AuthorizedUser;
import de.factoryfx.server.user.nop.NoUserManagement;
import de.factoryfx.server.user.UserManagement;
import de.factoryfx.server.user.nop.NoUserManagementFactory;
import de.factoryfx.server.user.persistent.PersistentUserManagementFactory;
/**
*
* @param visitor
* @param root
* @param Summary Data form storage history
*/
public class MicroserviceResourceFactory,S> extends FactoryBase,V,R> {
public final FactoryPolymorphicReferenceAttribute userManagement = new FactoryPolymorphicReferenceAttribute().setupUnsafe(UserManagement.class, NoUserManagementFactory.class, PersistentUserManagementFactory.class).labelText("resource");
public final ObjectValueAttribute>> authorizedKeyUserEvaluator= new ObjectValueAttribute>>().labelText("authorizedKeyUserEvaluator").nullable();
public final ObjectValueAttribute> emptyVisitorCreator= new ObjectValueAttribute>().labelText("emptyVisitorCreator").nullable();
@SuppressWarnings("unchecked")
public MicroserviceResourceFactory(){
configLiveCycle().setCreator(() -> {
Predicate> authorizedKeyUserEvaluator = this.authorizedKeyUserEvaluator.get();
if (authorizedKeyUserEvaluator==null) {
authorizedKeyUserEvaluator=(u)->true;
}
UserManagement userManagementInstance = userManagement.instance();
if (userManagementInstance==null) {
userManagementInstance=new NoUserManagement();
}
Microservice microservice = (Microservice)utilityFactory().getMicroservice();
return new MicroserviceResource<>(microservice, userManagementInstance,authorizedKeyUserEvaluator,emptyVisitorCreator.get());
});
config().setDisplayTextProvider(()->"Resource");
}
}