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

io.github.factoryfx.microservice.rest.MicroserviceResourceFactory Maven / Gradle / Ivy

There is a newer version: 2.0.25
Show newest version
package io.github.factoryfx.microservice.rest;

import io.github.factoryfx.factory.FactoryBase;
import io.github.factoryfx.factory.attribute.dependency.FactoryPolymorphicAttribute;
import io.github.factoryfx.server.Microservice;
import io.github.factoryfx.server.user.nop.NoUserManagement;
import io.github.factoryfx.server.user.UserManagement;
import io.github.factoryfx.server.user.nop.NoUserManagementFactory;
import io.github.factoryfx.server.user.persistent.PersistentUserManagementFactory;

/**
 * usage example: (in a FactoryTreeBuilder)
*
 * {@code
    new JettyServerBuilder<>(new ShopJettyServerFactory())
        .withHost("localhost").withPort(8089)
        .withResource(context.getUnsafe(MicroserviceDomResourceFactory.class))
        ...

    factoryTreeBuilder.addFactory(MicroserviceDomResourceFactory.class, Scope.SINGLETON, context -> {
        return new MicroserviceDomResourceFactory();
    });
 * }
 * 
* (the messed up generics are caused by java limitations) * * @param root * @param Summary Data form storage history */ public class MicroserviceResourceFactory,S> extends FactoryBase,R> { public final FactoryPolymorphicAttribute userManagement = new FactoryPolymorphicAttribute().setupUnsafe(UserManagement.class, NoUserManagementFactory.class, PersistentUserManagementFactory.class).labelText("resource").nullable(); @SuppressWarnings("unchecked") public MicroserviceResourceFactory(){ configLifeCycle().setCreator(() -> { UserManagement userManagementInstance = userManagement.instance(); if (userManagementInstance==null) { userManagementInstance=new NoUserManagement(); } Microservice microservice = (Microservice) utility().getMicroservice(); return new MicroserviceResource<>(microservice, userManagementInstance); }); config().setDisplayTextProvider(()->"Resource"); } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy