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

com.github.lontime.extcopper.container.AbstractTransientEngineContainer Maven / Gradle / Ivy

There is a newer version: 1.4.0
Show newest version
package com.github.lontime.extcopper.container;

import com.github.lontime.extcopper.common.ProcessingEngineWrapper;
import com.github.lontime.extcopper.configuration.OptionResolver;
import com.github.lontime.extcopper.configuration.TransienceOption;
import com.github.lontime.extcopper.impl.ClasspathTransientEngineFactory;
import org.copperengine.core.DependencyInjector;
import org.copperengine.core.tranzient.TransientScottyEngine;
import org.copperengine.core.util.PojoDependencyInjector;

/**
 * AbstractTransientEngineContainer.
 * @author lontime
 * @since 1.0
 */
public abstract class AbstractTransientEngineContainer implements EngineContainer {

    private TransientScottyEngine processingEngine;

    private TransienceOption option;

    private DependencyInjector dependencyInjector;

    public AbstractTransientEngineContainer() {
        this.dependencyInjector = new PojoDependencyInjector();
        this.option = OptionResolver.getInstance().getTransienceOption();
    }

    @Override
    public void setDependencyInjector(DependencyInjector dependencyInjector) {
        this.dependencyInjector = dependencyInjector;
    }

    @Override
    public void initialize() {
        if (option == null) {
            return;
        }
        this.processingEngine = new ClasspathTransientEngineFactory(option, dependencyInjector).create();
    }

    @Override
    public void stop() {
        if (this.processingEngine != null) {
            this.processingEngine.shutdown();
        }
    }

    @Override
    public ProcessingEngineWrapper getEngine() {
        return ProcessingEngineWrapper.from(this.processingEngine);
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy