workflow.java
来自「SHARK工作流引擎的启动测试」· Java 代码 · 共 97 行
JAVA
97 行
package third;
import utils.Util;
import java.util.Properties;
import java.io.FileInputStream;
import org.enhydra.shark.Shark;
import org.enhydra.shark.api.client.wfservice.SharkConnection;
import org.enhydra.shark.api.client.wfservice.ConnectFailed;
import org.enhydra.shark.api.client.wfservice.SharkInterface;
import org.enhydra.shark.api.client.wfbase.BaseException;
/**
* @author rross
*/
public class Workflow
{
public static final String SHARK_INSTALL_DIR = "C:/Shark";
private Properties props = new Properties();
private String userName = "admin";
private String password = "enhydra";
/**
* Initializes the shark engine.
*/
public void init()
{
try
{
String path = Util.forceSlash(SHARK_INSTALL_DIR) + "Shark.conf";
props.load(new FileInputStream(path));
System.out.println("Fixing up Shark config");
// Make SURE every instance of shark that connects to the same database uses a different
// enginename.
props.setProperty("enginename", "thirdEngine");
Util.prependPath(props, "EXTERNAL_PACKAGES_REPOSITORY", SHARK_INSTALL_DIR);
Util.prependPath(props, "DatabaseManager.LogFile", SHARK_INSTALL_DIR);
Util.prependPath(props, "DatabaseManager.ConfigurationDir", SHARK_INSTALL_DIR);
Util.prependPath(props, "log4j.appender.Database.File", SHARK_INSTALL_DIR);
Util.prependPath(props, "log4j.appender.XMLOutFormatForPersistence.File", SHARK_INSTALL_DIR);
Util.prependPath(props, "log4j.appender.XMLOutFormatForPackageEvents.File", SHARK_INSTALL_DIR);
Util.prependPath(props, "log4j.appender.SharkExecution.File", SHARK_INSTALL_DIR);
Util.prependPath(props, "log4j.appender.XMLOutFormatForExecution.File", SHARK_INSTALL_DIR);
Util.prependPath(props, "log4j.appender.PackageEvents.File", SHARK_INSTALL_DIR);
Shark.configure(props);
}
catch (Exception e)
{
// It's not like I am going to revive the thing if it crashes...
e.printStackTrace();
}
}
/**
* Login into Shark
*
* @return a SharkConnection object that has successfully
*/
public SharkConnection login()
{
SharkConnection conn = Shark.getInstance().getSharkConnection();
try
{
conn.connect(userName, password, props.getProperty("enginename"), null);
}
catch (BaseException e)
{
e.printStackTrace();
}
catch (ConnectFailed connectFailed)
{
connectFailed.printStackTrace();
}
return conn;
}
public static void main(String[] args)
{
Workflow wf = new Workflow();
wf.init();
SharkConnection conn = wf.login();
if (conn == null)
System.out.println("Unable to connect to Shark");
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?