Package betsy.bpel.virtual.host.engines

Source Code of betsy.bpel.virtual.host.engines.VirtualBpelgEngine

package betsy.bpel.virtual.host.engines;

import betsy.bpel.engines.bpelg.BpelgEngine;
import betsy.bpel.model.BPELProcess;
import betsy.bpel.virtual.common.messages.collect_log_files.LogFilesRequest;
import betsy.bpel.virtual.common.messages.deploy.DeployRequest;
import betsy.bpel.virtual.common.messages.deploy.FileMessage;
import betsy.bpel.virtual.host.ServiceAddress;

import java.io.IOException;
import java.nio.file.Path;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Set;

import static betsy.common.config.Configuration.get;

public class VirtualBpelgEngine extends AbstractVirtualEngine {

    public static final int HTTP_PORT = 8080;

    public VirtualBpelgEngine() {
        super();
        this.defaultEngine = new BpelgEngine();
    }

    @Override
    public String getName() {
        return "bpelg_v";
    }

    @Override
    public List<ServiceAddress> getVerifiableServiceAddresses() {
        List<ServiceAddress> saList = new LinkedList<>();
        saList.add(new ServiceAddress("http://localhost:" + HTTP_PORT + "/bpel-g/services"));
        return saList;
    }

    @Override
    public Set<Integer> getRequiredPorts() {
        Set<Integer> portList = new HashSet<>();
        portList.add(HTTP_PORT);
        return portList;
    }

    @Override
    public String getEndpointUrl(BPELProcess process) {
        // is not delegated because of the dependency to the local Tomcat
        return "http://localhost:" + HTTP_PORT + "/bpel-g/services/" + process.getName() + "TestInterfaceService";
    }

    @Override
    public void buildArchives(BPELProcess process) {
        // use default engine's operations
        defaultEngine.buildArchives(process);
    }

    @Override
    public Path getXsltPath() {
        return defaultEngine.getXsltPath();
    }

    @Override
    public DeployRequest buildDeployRequest(BPELProcess process) throws IOException {
        DeployRequest operation = new DeployRequest();
        operation.setFileMessage(FileMessage.build(process.getTargetPackageFilePath("zip")));
        operation.setEngineName(getName());
        operation.setProcessName(process.getName());
        operation.setDeploymentLogFilePath(get("virtual.engines.bpelg_v.deploymentLogFile"));
        operation.setDeploymentDir(get("virtual.engines.bpelg_v.deploymentDir"));
        operation.setDeployTimeout(Integer.parseInt(get("virtual.engines.bpelg_v.deploymentTimeout")));

        return operation;
    }

    @Override
    public LogFilesRequest buildLogFilesRequest() {
        LogFilesRequest request = new LogFilesRequest();
        request.getPaths().add(get("virtual.engines.bpelg_v.bvmsDir") + "/log");
        request.getPaths().add(get("virtual.engines.bpelg_v.logfileDir"));
        return request;
    }

    @Override
    public boolean getHeadlessModeOption() {
        return Boolean.valueOf(get("virtual.engines.bpelg_v.headless"));
    }

    @Override
    public boolean saveStateInsteadOfShutdown() {
        return Boolean.valueOf(get("virtual.engines.bpelg_v.shutdownSaveState"));
    }
}
TOP

Related Classes of betsy.bpel.virtual.host.engines.VirtualBpelgEngine

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.