[ 1731053 ] Refactoring of ProcessCtl and ServerBean
This commit is contained in:
parent
2ec286a428
commit
a566f922f0
|
|
@ -27,6 +27,7 @@ import java.util.logging.*;
|
||||||
import javax.ejb.*;
|
import javax.ejb.*;
|
||||||
import javax.sql.*;
|
import javax.sql.*;
|
||||||
|
|
||||||
|
import org.adempiere.util.ProcessUtil;
|
||||||
import org.compiere.*;
|
import org.compiere.*;
|
||||||
import org.compiere.acct.*;
|
import org.compiere.acct.*;
|
||||||
import org.compiere.model.*;
|
import org.compiere.model.*;
|
||||||
|
|
@ -250,51 +251,13 @@ public class ServerBean implements SessionBean
|
||||||
*/
|
*/
|
||||||
public ProcessInfo process (Properties ctx, ProcessInfo pi)
|
public ProcessInfo process (Properties ctx, ProcessInfo pi)
|
||||||
{
|
{
|
||||||
String className = pi.getClassName();
|
|
||||||
log.info(className + " - " + pi);
|
|
||||||
m_processCount++;
|
m_processCount++;
|
||||||
// Get Class
|
|
||||||
Class clazz = null;
|
|
||||||
try
|
|
||||||
{
|
|
||||||
clazz = Class.forName (className);
|
|
||||||
}
|
|
||||||
catch (ClassNotFoundException ex)
|
|
||||||
{
|
|
||||||
log.log(Level.WARNING, className, ex);
|
|
||||||
pi.setSummary ("ClassNotFound", true);
|
|
||||||
return pi;
|
|
||||||
}
|
|
||||||
// Get Process
|
|
||||||
SvrProcess process = null;
|
|
||||||
try
|
|
||||||
{
|
|
||||||
process = (SvrProcess)clazz.newInstance ();
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
log.log(Level.WARNING, "Instance for " + className, ex);
|
|
||||||
pi.setSummary ("InstanceError", true);
|
|
||||||
return pi;
|
|
||||||
}
|
|
||||||
// Start Process
|
// Start Process
|
||||||
String trxName = pi.getTransactionName();
|
String trxName = pi.getTransactionName();
|
||||||
if (trxName == null) trxName = Trx.createTrxName("ServerPrc");
|
if (trxName == null) trxName = Trx.createTrxName("ServerPrc");
|
||||||
Trx trx = Trx.get(trxName, true);
|
Trx trx = Trx.get(trxName, true);
|
||||||
try
|
ProcessUtil.startJavaProcess(pi, trx);
|
||||||
{
|
|
||||||
boolean ok = process.startProcess (ctx, pi, trx);
|
|
||||||
pi = process.getProcessInfo();
|
|
||||||
trx.commit(true);
|
|
||||||
trx.close();
|
|
||||||
}
|
|
||||||
catch (Exception ex1)
|
|
||||||
{
|
|
||||||
trx.rollback();
|
|
||||||
trx.close();
|
|
||||||
pi.setSummary ("ProcessError", true);
|
|
||||||
return pi;
|
|
||||||
}
|
|
||||||
return pi;
|
return pi;
|
||||||
} // process
|
} // process
|
||||||
|
|
||||||
|
|
@ -312,13 +275,7 @@ public class ServerBean implements SessionBean
|
||||||
{
|
{
|
||||||
log.info ("[" + m_no + "] " + AD_Workflow_ID);
|
log.info ("[" + m_no + "] " + AD_Workflow_ID);
|
||||||
m_workflowCount++;
|
m_workflowCount++;
|
||||||
MWorkflow wf = MWorkflow.get (ctx, AD_Workflow_ID);
|
ProcessUtil.startWorkFlow(ctx, pi, AD_Workflow_ID);
|
||||||
MWFProcess wfProcess = null;
|
|
||||||
if (pi.isBatch())
|
|
||||||
wfProcess = wf.start(pi); // may return null
|
|
||||||
else
|
|
||||||
wfProcess = wf.startWait(pi); // may return null
|
|
||||||
log.fine(pi.toString());
|
|
||||||
return pi;
|
return pi;
|
||||||
} // workflow
|
} // workflow
|
||||||
|
|
||||||
|
|
@ -622,33 +579,10 @@ public class ServerBean implements SessionBean
|
||||||
{
|
{
|
||||||
validateSecurityToken(token);
|
validateSecurityToken(token);
|
||||||
|
|
||||||
String sql = "{call " + procedureName + "(?)}";
|
|
||||||
Trx trx = null;
|
Trx trx = null;
|
||||||
if (trxName != null)
|
if (trxName != null)
|
||||||
trx = Trx.get(trxName, true);
|
trx = Trx.get(trxName, true);
|
||||||
try
|
ProcessUtil.startDatabaseProcedure(processInfo, procedureName, trx);
|
||||||
{
|
|
||||||
CallableStatement cstmt = DB.prepareCall(sql, ResultSet.CONCUR_UPDATABLE, trxName);
|
|
||||||
cstmt.setInt(1, processInfo.getAD_PInstance_ID());
|
|
||||||
cstmt.executeUpdate();
|
|
||||||
cstmt.close();
|
|
||||||
if (trx != null && trx.isActive())
|
|
||||||
{
|
|
||||||
trx.commit(true);
|
|
||||||
trx.close();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
log.log(Level.SEVERE, sql, e);
|
|
||||||
if (trx != null && trx.isActive())
|
|
||||||
{
|
|
||||||
trx.rollback();
|
|
||||||
trx.close();
|
|
||||||
}
|
|
||||||
processInfo.setSummary (Msg.getMsg(Env.getCtx(), "ProcessRunError") + " " + e.getLocalizedMessage());
|
|
||||||
processInfo.setError (true);
|
|
||||||
}
|
|
||||||
return processInfo;
|
return processInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue