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

io.github.factoryfx.copperbridge.CopperEngineContextFactory Maven / Gradle / Ivy

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

import java.util.Map;

import io.github.factoryfx.factory.attribute.dependency.FactoryAttribute;
import io.github.factoryfx.factory.attribute.types.StringAttribute;
import io.github.factoryfx.factory.FactoryBase;
import org.copperengine.core.tranzient.TransientScottyEngine;


public abstract class CopperEngineContextFactory> extends FactoryBase {

    public final StringAttribute dependencyInjectorType = new StringAttribute().labelText("DependencyInjectorType");

    public final FactoryAttribute> transientScottyEngine = new FactoryAttribute>().labelText("Transient engine").nullable();
    public final FactoryAttribute> persistentScottyEngine = new FactoryAttribute>().labelText("Persistent engine").nullable();

    public CopperEngineContextFactory(){
        configLifeCycle().setCreator(()->{
            // Here we need to break the ffx dependency injection, because we don't need a new engine in case of a dependency change
            CopperEngineContext dependencyInjector = new CopperEngineContext(dependencyInjectorType.get(), createDependencyHashMap());
            if(transientScottyEngine.instance()!=null) transientScottyEngine.instance().setDependencyInjector(dependencyInjector);
            if(persistentScottyEngine.instance()!=null) persistentScottyEngine.instance().persistentProcessingEngine.setDependencyInjector(dependencyInjector);
            return dependencyInjector;
        });
    }

    public abstract Map createDependencyHashMap();
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy