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

de.factoryfx.server.rest.MicroserviceResourceFactory Maven / Gradle / Ivy

There is a newer version: 2.0.25
Show newest version
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");
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy