Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/*
* Copyright (c) MuleSoft, Inc. All rights reserved. http://www.mulesoft.com
* The software in this package is published under the terms of the CPAL v1.0
* license, a copy of which has been included with this distribution in the
* LICENSE.txt file.
*/
package org.mule.test.infrastructure.process;
import java.io.File;
import java.io.IOException;
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
import java.util.regex.Pattern;
import org.apache.commons.exec.CommandLine;
import org.apache.commons.exec.DefaultExecutor;
import org.apache.commons.exec.ExecuteException;
import org.apache.commons.exec.ExecuteWatchdog;
import org.apache.commons.exec.PumpStreamHandler;
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.FilenameUtils;
import org.apache.commons.io.filefilter.FileFilterUtils;
import org.apache.commons.io.filefilter.IOFileFilter;
public abstract class Controller
{
protected static final String ANCHOR_SUFFIX = "-anchor.txt";
private static final IOFileFilter ANCHOR_FILTER = FileFilterUtils.suffixFileFilter(ANCHOR_SUFFIX);
protected static final String STATUS = "Mule Enterprise Edition is running \\(([0-9]+)\\)\\.";
protected static final Pattern STATUS_PATTERN = Pattern.compile(STATUS);
private static final int DEFAULT_TIMEOUT = 30000;
private static final String MULE_HOME_VARIABLE = "MULE_HOME";
private static final String DOMAIN_DEPLOY_ERROR = "Error deploying domain %s.";
private static final String ANCHOR_DELETE_ERROR = "Could not delete anchor file [%s] when stopping Mule Runtime.";
private static final String ADD_LIBRARY_ERROR = "Error copying jar file [%s] to lib directory [%s].";
private static final int IS_RUNNING_STATUS_CODE = 0;
protected String muleHome;
protected String muleBin;
protected File domainsDir;
protected File appsDir;
protected File libsDir;
protected int timeout;
public Controller(String muleHome, int timeout)
{
this.muleHome = muleHome;
this.muleBin = getMuleBin();
this.domainsDir = new File(muleHome + "/domains");
this.appsDir = new File(muleHome + "/apps/");
this.libsDir = new File(muleHome + "/lib/user");
this.timeout = timeout != 0 ? timeout : DEFAULT_TIMEOUT;
}
public abstract String getMuleBin();
public void start(String[] args)
{
int error = runSync("start", args);
if (error != 0)
{
throw new MuleControllerException("The mule instance couldn't be started");
}
}
public void stop(String[] args)
{
int error = runSync("stop", args);
verify(error == 0, "The mule instance couldn't be stopped");
deleteAnchors();
}
public abstract int status(String... args);
public abstract int getProcessId();
public void restart(String[] args)
{
int error = runSync("restart", args);
if (error != 0)
{
throw new MuleControllerException("The mule instance couldn't be restarted");
}
}
protected int runSync(String command, String... args)
{
Map