IDEMPIERE-1139 Can't replace or extend Server for AdempiereProcessor using plugin.

This commit is contained in:
Heng Sin Low 2013-07-05 17:32:16 +08:00
parent c7c0f5f8bb
commit df47fc59e4
27 changed files with 512 additions and 209 deletions

View File

@ -9,14 +9,13 @@ import java.util.Properties;
import org.adempiere.server.IServerFactory;
import org.compiere.model.MIMPProcessor;
import org.compiere.server.AdempiereServer;
import org.compiere.server.ReplicationProcessor;
/**
* @author hengsin
*
*/
public class ReplicationServerFactory implements IServerFactory {
public class ReplicationServerFactory implements IServerFactory<ReplicationProcessor, MIMPProcessor> {
/**
* default constructor
@ -28,17 +27,21 @@ public class ReplicationServerFactory implements IServerFactory {
* @see org.adempiere.server.IServerFactory#create()
*/
@Override
public AdempiereServer[] create(Properties ctx) {
List<AdempiereServer> list = new ArrayList<AdempiereServer>();
public ReplicationProcessor[] create(Properties ctx) {
List<ReplicationProcessor> list = new ArrayList<ReplicationProcessor>();
MIMPProcessor[] importModels = MIMPProcessor.getActive(ctx);
for (int i = 0; i < importModels.length; i++)
for (MIMPProcessor lp : importModels)
{
MIMPProcessor lp = importModels[i];
AdempiereServer server = new ReplicationProcessor(lp);
ReplicationProcessor server = new ReplicationProcessor(lp);
list.add(server);
}
AdempiereServer[] servers = list.toArray(new AdempiereServer[0]);
ReplicationProcessor[] servers = list.toArray(new ReplicationProcessor[0]);
return servers;
}
@Override
public Class<MIMPProcessor> getProcessorClass() {
return MIMPProcessor.class;
}
}

View File

@ -48,18 +48,17 @@ import org.compiere.model.MIMPProcessorLog;
public class ReplicationProcessor extends AdempiereServer {
/** Last Summary */
private StringBuffer m_summary = new StringBuffer();
protected StringBuffer m_summary = new StringBuffer();
/** Client info */
@SuppressWarnings("unused")
private MClient m_client = null;
protected MClient m_client = null;
private MIMPProcessor mImportProcessor = null;
protected MIMPProcessor mImportProcessor = null;
/**
* flag showing if process is working!
*/
private boolean isProcessRunning = false;
protected boolean isProcessRunning = false;
/*protected ReplicationProcessor(MIMPProcessor model, int initialNap) {
@ -75,10 +74,10 @@ public class ReplicationProcessor extends AdempiereServer {
}*/
public ReplicationProcessor(AdempiereProcessor model, int initialNap) {
super (model, initialNap);
mImportProcessor = (MIMPProcessor)model;
m_client = MClient.get(mImportProcessor.getCtx(), mImportProcessor.getAD_Client_ID());
}
super (model, initialNap);
mImportProcessor = (MIMPProcessor)model;
m_client = MClient.get(mImportProcessor.getCtx(), mImportProcessor.getAD_Client_ID());
}
public ReplicationProcessor(AdempiereProcessor model) {
super (model, 30);
mImportProcessor =(MIMPProcessor)model;

View File

@ -20,6 +20,11 @@
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.ds.core.builder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>

View File

@ -32,4 +32,8 @@ Import-Package: javax.jms;version="1.1.0",
org.restlet.service,
org.restlet.util
Export-Package: org.adempiere.server,
org.compiere.server
org.compiere.ldap,
org.compiere.server,
org.idempiere.server.factory
Bundle-ActivationPolicy: lazy
Service-Component: OSGI-INF/acctprocessorfactory.xml, OSGI-INF/alertprocessorfactory.xml, OSGI-INF/ldapprocessorfactory.xml, OSGI-INF/requestprocessorfactory.xml, OSGI-INF/schedulerfactory.xml, OSGI-INF/workflowprocessorfactory.xml

View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" name="org.idempiere.server.factory.defaultacctprocessor">
<implementation class="org.idempiere.server.factory.DefaultAcctProcessorFactory"/>
<property name="service.ranking" type="Integer" value="0"/>
<service>
<provide interface="org.adempiere.server.IServerFactory"/>
</service>
</scr:component>

View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" name="org.idempiere.server.factory.defaultalertprocessor">
<implementation class="org.idempiere.server.factory.DefaultAlertProcessorFactory"/>
<property name="service.ranking" type="Integer" value="0"/>
<service>
<provide interface="org.adempiere.server.IServerFactory"/>
</service>
</scr:component>

View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" name="org.idempiere.server.factory.defaultldapprocessor">
<implementation class="org.idempiere.server.factory.DefaultLDAPProcessorFactory"/>
<property name="service.ranking" type="Integer" value="0"/>
<service>
<provide interface="org.adempiere.server.IServerFactory"/>
</service>
</scr:component>

View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" name="org.idempiere.server.factory.defaultrequestprocessor">
<implementation class="org.idempiere.server.factory.DefaultRequestProcessorFactory"/>
<property name="service.ranking" type="Integer" value="0"/>
<service>
<provide interface="org.adempiere.server.IServerFactory"/>
</service>
</scr:component>

View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" name="org.idempiere.server.factory.defaultscheduler">
<implementation class="org.idempiere.server.factory.DefaultSchedulerFactory"/>
<property name="service.ranking" type="Integer" value="0"/>
<service>
<provide interface="org.adempiere.server.IServerFactory"/>
</service>
</scr:component>

View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" name="org.idempiere.server.factory.defaultworkflowprocessor">
<implementation class="org.idempiere.server.factory.DefaultWorkflowProcessorFactory"/>
<property name="service.ranking" type="Integer" value="0"/>
<service>
<provide interface="org.adempiere.server.IServerFactory"/>
</service>
</scr:component>

View File

@ -20,12 +20,19 @@ bin.includes = META-INF/,\
standard.css,\
webstart.jpg,\
zip.gif,\
plugin.xml
bin.excludes = src/**,\
.settings/**,\
.classpath,\
.project,\
build.properties
plugin.xml,\
OSGI-INF/acctprocessorfactory.xml,\
OSGI-INF/alertprocessorfactory.xml,\
OSGI-INF/ldapprocessorfactory.xml,\
OSGI-INF/requestprocessorfactory.xml,\
OSGI-INF/schedulerfactory.xml,\
OSGI-INF/workflowprocessorfactory.xml,\
OSGI-INF/
output.. = build/classes/
source.. = src/main/server/,\
src/main/servlet/
output.. = build/classes/
bin.excludes = src/**,\
.settings/**,\
.classpath,\
.project,\
build.properties

View File

@ -15,6 +15,7 @@ package org.adempiere.server;
import java.util.Properties;
import org.compiere.model.AdempiereProcessor;
import org.compiere.server.AdempiereServer;
/**
@ -22,8 +23,18 @@ import org.compiere.server.AdempiereServer;
* @author hengsin
*
*/
public interface IServerFactory {
public interface IServerFactory<S extends AdempiereServer, M extends AdempiereProcessor> {
// Class implementing this method must take into account if the server can be ran on this IP
public AdempiereServer[] create (Properties ctx);
/**
* @param ctx
* @return list of AdempiereServer
*/
public S[] create (Properties ctx);
/**
* The Adempiere Server Manager will used this to avoid running duplicate server for the same
* AdempiereProcessor model.
* @return Fully qualified AdempiereProcessor model class name
*/
public Class<M> getProcessorClass();
}

View File

@ -46,13 +46,13 @@ public class LdapProcessor extends AdempiereServer
} // LdapProcessor
/** The Concrete Model */
private MLdapProcessor m_model = null;
protected MLdapProcessor m_model = null;
/** Last Summary */
private StringBuffer m_summary = new StringBuffer();
protected StringBuffer m_summary = new StringBuffer();
/** Server Socket */
private ServerSocket m_serverSocket = null;
protected ServerSocket m_serverSocket = null;
/** Counter */
private int m_counter = 0;
protected int m_counter = 0;
/**

View File

@ -56,13 +56,13 @@ public class AcctProcessor extends AdempiereServer
} // AcctProcessor
/** The Concrete Model */
private MAcctProcessor m_model = null;
protected MAcctProcessor m_model = null;
/** Last Summary */
private StringBuffer m_summary = new StringBuffer();
protected StringBuffer m_summary = new StringBuffer();
/** Client onfo */
private MClient m_client = null;
protected MClient m_client = null;
/** Accounting Schemata */
private MAcctSchema[] m_ass = null;
protected MAcctSchema[] m_ass = null;
/**
* Work

View File

@ -20,22 +20,15 @@ import java.sql.Timestamp;
import java.util.Properties;
import java.util.logging.Level;
import org.compiere.ldap.LdapProcessor;
import org.compiere.model.AdempiereProcessor;
import org.compiere.model.AdempiereProcessor2;
import org.compiere.model.AdempiereProcessorLog;
import org.compiere.model.MAcctProcessor;
import org.compiere.model.MAlertProcessor;
import org.compiere.model.MClient;
import org.compiere.model.MLdapProcessor;
import org.compiere.model.MRequestProcessor;
import org.compiere.model.MSchedule;
import org.compiere.model.MScheduler;
import org.compiere.model.MSystem;
import org.compiere.util.CLogger;
import org.compiere.util.Env;
import org.compiere.util.TimeUtil;
import org.compiere.wf.MWorkflowProcessor;
/**
* Adempiere Server Base
@ -45,31 +38,6 @@ import org.compiere.wf.MWorkflowProcessor;
*/
public abstract class AdempiereServer implements Runnable
{
/**
* Create New Server Thead
* @param model model
* @return server tread or null
*/
public static AdempiereServer create (AdempiereProcessor model)
{
if (! isOKtoRunOnIP(model))
return null;
if (model instanceof MRequestProcessor)
return new RequestProcessor ((MRequestProcessor)model);
if (model instanceof MWorkflowProcessor)
return new WorkflowProcessor ((MWorkflowProcessor)model);
if (model instanceof MAcctProcessor)
return new AcctProcessor ((MAcctProcessor)model);
if (model instanceof MAlertProcessor)
return new AlertProcessor ((MAlertProcessor)model);
if (model instanceof MScheduler)
return new Scheduler ((MScheduler)model);
if (model instanceof MLdapProcessor)
return new LdapProcessor((MLdapProcessor)model);
//
throw new IllegalArgumentException("Unknown Processor");
} // create
/**************************************************************************
* Server Base Class

View File

@ -27,15 +27,10 @@ import java.util.logging.Level;
import org.adempiere.base.Service;
import org.adempiere.server.IServerFactory;
import org.compiere.Adempiere;
import org.compiere.model.MAcctProcessor;
import org.compiere.model.MAlertProcessor;
import org.compiere.model.MLdapProcessor;
import org.compiere.model.MRequestProcessor;
import org.compiere.model.MScheduler;
import org.compiere.model.AdempiereProcessor;
import org.compiere.model.MSession;
import org.compiere.util.CLogger;
import org.compiere.util.Env;
import org.compiere.wf.MWorkflowProcessor;
/**
* Adempiere Server Manager
@ -105,100 +100,36 @@ public class AdempiereServerMgr
* Start Environment
* @return true if started
*/
@SuppressWarnings("rawtypes")
public boolean startServers()
{
log.info("");
int noServers = 0;
m_servers=new ArrayList<ServerWrapper>();
// Accounting
MAcctProcessor[] acctModels = MAcctProcessor.getActive(m_ctx);
for (int i = 0; i < acctModels.length; i++)
{
MAcctProcessor pModel = acctModels[i];
AdempiereServer server = AdempiereServer.create(pModel);
if (server != null) {
// server.start();
// server.setPriority(Thread.NORM_PRIORITY-2);
m_servers.add(new ServerWrapper(server));
}
}
// Request
MRequestProcessor[] requestModels = MRequestProcessor.getActive(m_ctx);
for (int i = 0; i < requestModels.length; i++)
{
MRequestProcessor pModel = requestModels[i];
AdempiereServer server = AdempiereServer.create(pModel);
if (server != null) {
// server.start();
// server.setPriority(Thread.NORM_PRIORITY-2);
m_servers.add(new ServerWrapper(server));
}
}
// Workflow
MWorkflowProcessor[] workflowModels = MWorkflowProcessor.getActive(m_ctx);
for (int i = 0; i < workflowModels.length; i++)
{
MWorkflowProcessor pModel = workflowModels[i];
AdempiereServer server = AdempiereServer.create(pModel);
if (server != null) {
// server.start();
// server.setPriority(Thread.NORM_PRIORITY-2);
m_servers.add(new ServerWrapper(server));
}
}
// Alert
MAlertProcessor[] alertModels = MAlertProcessor.getActive(m_ctx);
for (int i = 0; i < alertModels.length; i++)
{
MAlertProcessor pModel = alertModels[i];
AdempiereServer server = AdempiereServer.create(pModel);
if (server != null) {
// server.start();
// server.setPriority(Thread.NORM_PRIORITY-2);
m_servers.add(new ServerWrapper(server));
}
}
// Scheduler
MScheduler[] schedulerModels = MScheduler.getActive(m_ctx);
for (int i = 0; i < schedulerModels.length; i++)
{
MScheduler pModel = schedulerModels[i];
AdempiereServer server = AdempiereServer.create(pModel);
if (server != null) {
// server.start();
// server.setPriority(Thread.NORM_PRIORITY-2);
m_servers.add(new ServerWrapper(server));
}
}
// LDAP
MLdapProcessor[] ldapModels = MLdapProcessor.getActive(m_ctx);
for (int i = 0; i < ldapModels.length; i++)
{
MLdapProcessor lp = ldapModels[i];
AdempiereServer server = AdempiereServer.create(lp);
if (server != null) {
// server.start();
// server.setPriority(Thread.NORM_PRIORITY-1);
m_servers.add(new ServerWrapper(server));
}
}
//osgi server
List<IServerFactory> serverFactoryList = Service.locator().list(IServerFactory.class).getServices();
if (serverFactoryList != null && !serverFactoryList.isEmpty())
{
List<String> processed = new ArrayList<String>();
for(IServerFactory factory : serverFactoryList )
{
AdempiereServer[] servers = factory.create(m_ctx);
if (servers != null && servers.length > 0)
String name = factory.getProcessorClass().getName();
if (!processed.contains(name))
{
for (AdempiereServer server : servers)
processed.add(name);
AdempiereServer[] servers = factory.create(m_ctx);
if (servers != null && servers.length > 0)
{
// server.start();
// server.setPriority(Thread.NORM_PRIORITY-1);
m_servers.add(new ServerWrapper(server));
}
}
for (AdempiereServer server : servers)
{
AdempiereProcessor model = server.getModel();
if (AdempiereServer.isOKtoRunOnIP(model)) {
m_servers.add(new ServerWrapper(server));
}
}
}
}
}
}

View File

@ -72,13 +72,13 @@ public class AlertProcessor extends AdempiereServer
} // AlertProcessor
/** The Concrete Model */
private MAlertProcessor m_model = null;
protected MAlertProcessor m_model = null;
/** Last Summary */
private StringBuffer m_summary = new StringBuffer();
protected StringBuffer m_summary = new StringBuffer();
/** Last Error Msg */
private StringBuffer m_errors = new StringBuffer();
protected StringBuffer m_errors = new StringBuffer();
/** Client info */
private MClient m_client = null;
protected MClient m_client = null;
/**
* Work
@ -119,7 +119,7 @@ public class AlertProcessor extends AdempiereServer
* @param alert alert
* @return true if processed
*/
private boolean processAlert (MAlert alert)
protected boolean processAlert (MAlert alert)
{
if (!alert.isValid())
return false;
@ -240,7 +240,7 @@ public class AlertProcessor extends AdempiereServer
* @param attachments
* @return how many email were sent
*/
private int notifyUsers(Collection<Integer> users, String subject, String message, Collection<File> attachments)
protected int notifyUsers(Collection<Integer> users, String subject, String message, Collection<File> attachments)
{
int countMail = 0;
for (int user_id : users) {
@ -289,7 +289,7 @@ public class AlertProcessor extends AdempiereServer
* @return data
* @throws Exception
*/
private ArrayList<ArrayList<Object>> getData (String sql, String trxName) throws Exception
protected ArrayList<ArrayList<Object>> getData (String sql, String trxName) throws Exception
{
ArrayList<ArrayList<Object>> data = new ArrayList<ArrayList<Object>>();
PreparedStatement pstmt = null;
@ -351,7 +351,7 @@ public class AlertProcessor extends AdempiereServer
* @return list of rows & values
* @throws Exception
*/
private String getPlainTextReport(MAlertRule rule, String sql, String trxName, Collection<File> attachments)
protected String getPlainTextReport(MAlertRule rule, String sql, String trxName, Collection<File> attachments)
throws Exception
{
StringBuilder result = new StringBuilder();
@ -407,7 +407,7 @@ public class AlertProcessor extends AdempiereServer
* @return summary message to be added into mail content
* @throws Exception
*/
private String getExcelReport(MAlertRule rule, String sql, String trxName, Collection<File> attachments)
protected String getExcelReport(MAlertRule rule, String sql, String trxName, Collection<File> attachments)
throws Exception
{
ArrayList<ArrayList<Object>> data = getData(sql, trxName);

View File

@ -69,30 +69,30 @@ public class EMailProcessor
} // EMail
/** EMail Host Parameter */
private String m_host = null;
protected String m_host = null;
/** EMail User Parameter */
private String m_user = null;
protected String m_user = null;
/** Password Parameter */
private String m_pass = null;
protected String m_pass = null;
/** Session */
private Session m_session = null;
protected Session m_session = null;
/** Store */
private Store m_store = null;
protected Store m_store = null;
/** Logger */
protected CLogger log = CLogger.getCLogger(getClass());
/** Process Error */
private static final int ERROR = 0;
protected static final int ERROR = 0;
/** Process Request */
private static final int REQUEST = 1;
protected static final int REQUEST = 1;
/** Process Workflow */
private static final int WORKFLOW = 2;
protected static final int WORKFLOW = 2;
/** Process Delivery Confirm */
private static final int DELIVERY = 9;
protected static final int DELIVERY = 9;
/**
* Process Messages in InBox
@ -130,7 +130,7 @@ public class EMailProcessor
* @return Session
* @throws Exception
*/
private Session getSession() throws Exception
protected Session getSession() throws Exception
{
if (m_session != null)
return m_session;
@ -155,7 +155,7 @@ public class EMailProcessor
* @return Store
* @throws Exception
*/
private Store getStore() throws Exception
protected Store getStore() throws Exception
{
if (m_store != null)
return m_store;
@ -177,7 +177,7 @@ public class EMailProcessor
* @return number of processed
* @throws Exception
*/
private int processInBox() throws Exception
protected int processInBox() throws Exception
{
// Folder
Folder folder;
@ -276,7 +276,7 @@ public class EMailProcessor
* @return Type of Message
* @throws Exception
*/
private int processMessage (Message msg) throws Exception
protected int processMessage (Message msg) throws Exception
{
dumpEnvelope (msg);
dumpBody (msg);
@ -301,7 +301,7 @@ public class EMailProcessor
* @param msg message
* @return subject or ""
*/
private String getSubject (Message msg)
protected String getSubject (Message msg)
{
try
{
@ -321,7 +321,7 @@ public class EMailProcessor
* @param msg Message
* @return message or ""
*/
private String getMessage (Part msg)
protected String getMessage (Part msg)
{
StringBuilder sb = new StringBuilder();
try
@ -406,7 +406,7 @@ public class EMailProcessor
* @param msg message
* @return delivery info or null
*/
private String getDeliveryReport (Part msg)
protected String getDeliveryReport (Part msg)
{
try
{
@ -451,7 +451,7 @@ public class EMailProcessor
* @return info or null
* @throws Exception
*/
private String getDeliveredReportDetail (Part part) throws Exception
protected String getDeliveredReportDetail (Part part) throws Exception
{
Object content = part.getContent();
if (content == null)
@ -504,7 +504,7 @@ public class EMailProcessor
* @param m message
* @throws Exception
*/
private void dumpEnvelope(Message m) throws Exception
protected void dumpEnvelope(Message m) throws Exception
{
printOut("-----------------------------------------------------------------");
Address[] a;
@ -613,7 +613,7 @@ public class EMailProcessor
* @param p
* @throws Exception
*/
private void dumpBody (Part p) throws Exception
protected void dumpBody (Part p) throws Exception
{
// http://www.iana.org/assignments/media-types/
printOut("=================================================================");
@ -688,7 +688,7 @@ public class EMailProcessor
* Print
* @param s string
*/
private static void printOut(String s)
protected static void printOut(String s)
{
// System.out.print(indentStr.substring(0, level * 2));
System.out.println(s);

View File

@ -57,11 +57,11 @@ public class RequestProcessor extends AdempiereServer
} // RequestProcessor
/** The Concrete Model */
private MRequestProcessor m_model = null;
protected MRequestProcessor m_model = null;
/** Last Summary */
private StringBuffer m_summary = new StringBuffer();
protected StringBuffer m_summary = new StringBuffer();
/** Client onfo */
private MClient m_client = null;
protected MClient m_client = null;
/**************************************************************************
* Do the actual Work
@ -90,7 +90,7 @@ public class RequestProcessor extends AdempiereServer
* Process requests.
* Scheduled - are they due?
*/
private void processRequests ()
protected void processRequests ()
{
/**
* Due Requests
@ -368,7 +368,7 @@ public class RequestProcessor extends AdempiereServer
* @param AD_Message message
* @return true if sent
*/
private boolean sendEmail (MRequest request, String AD_Message)
protected boolean sendEmail (MRequest request, String AD_Message)
{
// Alert: Request {0} overdue
String subject = Msg.getMsg(m_client.getAD_Language(), AD_Message,
@ -382,7 +382,7 @@ public class RequestProcessor extends AdempiereServer
* @param request request
* @return true if saved
*/
private boolean escalate (MRequest request)
protected boolean escalate (MRequest request)
{
// Get Supervisor
MUser supervisor = request.getSalesRep(); // self
@ -424,7 +424,7 @@ public class RequestProcessor extends AdempiereServer
/**************************************************************************
* Process Request Status
*/
private void processStatus()
protected void processStatus()
{
int count = 0;
// Requests with status with after timeout
@ -482,7 +482,7 @@ public class RequestProcessor extends AdempiereServer
/**
* Create ECR
*/
private void processECR()
protected void processECR()
{
// Get Requests with Request Type-AutoChangeRequest and Group with info
String sql = "SELECT * FROM R_Request r "
@ -543,7 +543,7 @@ public class RequestProcessor extends AdempiereServer
/**************************************************************************
* Create Reauest / Updates from EMail
*/
private void processEMail ()
protected void processEMail ()
{
// m_summary.append("Mail #").append(count)
// .append(" - ");
@ -553,7 +553,7 @@ public class RequestProcessor extends AdempiereServer
/**************************************************************************
* Allocate Sales Rep
*/
private void findSalesRep ()
protected void findSalesRep ()
{
int changed = 0;
int notFound = 0;
@ -614,7 +614,7 @@ public class RequestProcessor extends AdempiereServer
* @param request request
* @return SalesRep_ID user
*/
private int findSalesRep (MRequest request)
protected int findSalesRep (MRequest request)
{
String QText = request.getSummary();
if (QText == null)

View File

@ -69,14 +69,14 @@ public class Scheduler extends AdempiereServer
} // Scheduler
/** The Concrete Model */
private MScheduler m_model = null;
protected MScheduler m_model = null;
/** Last Summary */
private StringBuffer m_summary = new StringBuffer();
protected StringBuffer m_summary = new StringBuffer();
/** Transaction */
private Trx m_trx = null;
protected Trx m_trx = null;
// ctx for the report/process
Properties m_schedulerctx = new Properties();
protected Properties m_schedulerctx = new Properties();
/**
* Work
@ -148,7 +148,7 @@ public class Scheduler extends AdempiereServer
* @return summary
* @throws Exception
*/
private String runProcess(MProcess process) throws Exception
protected String runProcess(MProcess process) throws Exception
{
if (log.isLoggable(Level.INFO)) log.info(process.toString());
@ -278,7 +278,7 @@ public class Scheduler extends AdempiereServer
return pi.getSummary();
} // runProcess
private int getAD_User_ID() {
protected int getAD_User_ID() {
int AD_User_ID;
if (m_model.getSupervisor_ID() > 0)
AD_User_ID = m_model.getSupervisor_ID();
@ -295,7 +295,7 @@ public class Scheduler extends AdempiereServer
* Fill Parameter
* @param pInstance process instance
*/
private void fillParameter(MPInstance pInstance)
protected void fillParameter(MPInstance pInstance)
{
MSchedulerPara[] sParams = m_model.getParameters (false);
MPInstancePara[] iParams = pInstance.getParameters();

View File

@ -61,11 +61,11 @@ public class WorkflowProcessor extends AdempiereServer
} // WorkflowProcessor
/** The Concrete Model */
private MWorkflowProcessor m_model = null;
protected MWorkflowProcessor m_model = null;
/** Last Summary */
private StringBuffer m_summary = new StringBuffer();
protected StringBuffer m_summary = new StringBuffer();
/** Client onfo */
private MClient m_client = null;
protected MClient m_client = null;
/**
* Work
@ -90,7 +90,7 @@ public class WorkflowProcessor extends AdempiereServer
/**
* Continue Workflow After Sleep
*/
private void wakeup()
protected void wakeup()
{
String sql = "SELECT * "
+ "FROM AD_WF_Activity a "
@ -135,7 +135,7 @@ public class WorkflowProcessor extends AdempiereServer
/**
* Set/Increase Priority dynamically
*/
private void dynamicPriority()
protected void dynamicPriority()
{
// suspened activities with dynamic priority node
String sql = "SELECT * "
@ -184,7 +184,7 @@ public class WorkflowProcessor extends AdempiereServer
/**
* Send Alerts
*/
private void sendAlerts()
protected void sendAlerts()
{
// Alert over Priority
if (m_model.getAlertOverPriority() > 0)
@ -350,7 +350,7 @@ public class WorkflowProcessor extends AdempiereServer
* @param toSupervisor true if to Supervisor
* @return number of mails sent
*/
private int sendEmail (MWFActivity activity, String AD_Message,
protected int sendEmail (MWFActivity activity, String AD_Message,
boolean toProcess, boolean toSupervisor)
{
if (m_client == null || m_client.getAD_Client_ID() != activity.getAD_Client_ID())
@ -429,7 +429,7 @@ public class WorkflowProcessor extends AdempiereServer
* @param pdf optional pdf
* @return number of mail sent
*/
private int sendAlertToResponsible (MWFResponsible responsible,
protected int sendAlertToResponsible (MWFResponsible responsible,
ArrayList<Integer> list, MWFProcess process,
String subject, String message, File pdf)
{

View File

@ -0,0 +1,56 @@
/******************************************************************************
* Copyright (C) 2013 Heng Sin Low *
* Copyright (C) 2013 Trek Global *
* This program is free software; you can redistribute it and/or modify it *
* under the terms version 2 of the GNU General Public License as published *
* by the Free Software Foundation. This program is distributed in the hope *
* that it will be useful, but WITHOUT ANY WARRANTY; without even the implied *
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
* See the GNU General Public License for more details. *
* You should have received a copy of the GNU General Public License along *
* with this program; if not, write to the Free Software Foundation, Inc., *
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
*****************************************************************************/
package org.idempiere.server.factory;
import java.util.ArrayList;
import java.util.List;
import java.util.Properties;
import org.adempiere.server.IServerFactory;
import org.compiere.model.MAcctProcessor;
import org.compiere.server.AcctProcessor;
/**
* @author hengsin
*
*/
public class DefaultAcctProcessorFactory implements IServerFactory<AcctProcessor, MAcctProcessor> {
/**
* default constructor
*/
public DefaultAcctProcessorFactory() {
}
/* (non-Javadoc)
* @see org.adempiere.server.IServerFactory#create(java.util.Properties)
*/
@Override
public AcctProcessor[] create(Properties ctx) {
MAcctProcessor[] acctModels = MAcctProcessor.getActive(ctx);
List<AcctProcessor> list = new ArrayList<AcctProcessor>();
for (MAcctProcessor pModel : acctModels)
{
AcctProcessor processor = new AcctProcessor(pModel);
list.add(processor);
}
return list.toArray(new AcctProcessor[0]);
}
@Override
public Class<MAcctProcessor> getProcessorClass() {
return MAcctProcessor.class;
}
}

View File

@ -0,0 +1,53 @@
/******************************************************************************
* Copyright (C) 2013 Heng Sin Low *
* Copyright (C) 2013 Trek Global *
* This program is free software; you can redistribute it and/or modify it *
* under the terms version 2 of the GNU General Public License as published *
* by the Free Software Foundation. This program is distributed in the hope *
* that it will be useful, but WITHOUT ANY WARRANTY; without even the implied *
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
* See the GNU General Public License for more details. *
* You should have received a copy of the GNU General Public License along *
* with this program; if not, write to the Free Software Foundation, Inc., *
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
*****************************************************************************/
package org.idempiere.server.factory;
import java.util.ArrayList;
import java.util.List;
import java.util.Properties;
import org.adempiere.server.IServerFactory;
import org.compiere.model.MAlertProcessor;
import org.compiere.server.AlertProcessor;
/**
* @author hengsin
*
*/
public class DefaultAlertProcessorFactory implements IServerFactory<AlertProcessor, MAlertProcessor> {
/**
*
*/
public DefaultAlertProcessorFactory() {
}
@Override
public AlertProcessor[] create(Properties ctx) {
MAlertProcessor[] alertModels = MAlertProcessor.getActive(ctx);
List<AlertProcessor> list = new ArrayList<AlertProcessor>();
for (MAlertProcessor pModel : alertModels)
{
AlertProcessor server = new AlertProcessor(pModel);
list.add(server);
}
return list.toArray(new AlertProcessor[0]);
}
@Override
public Class<MAlertProcessor> getProcessorClass() {
return MAlertProcessor.class;
}
}

View File

@ -0,0 +1,52 @@
/******************************************************************************
* Copyright (C) 2013 Heng Sin Low *
* Copyright (C) 2013 Trek Global *
* This program is free software; you can redistribute it and/or modify it *
* under the terms version 2 of the GNU General Public License as published *
* by the Free Software Foundation. This program is distributed in the hope *
* that it will be useful, but WITHOUT ANY WARRANTY; without even the implied *
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
* See the GNU General Public License for more details. *
* You should have received a copy of the GNU General Public License along *
* with this program; if not, write to the Free Software Foundation, Inc., *
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
*****************************************************************************/
package org.idempiere.server.factory;
import java.util.ArrayList;
import java.util.List;
import java.util.Properties;
import org.adempiere.server.IServerFactory;
import org.compiere.ldap.LdapProcessor;
import org.compiere.model.MLdapProcessor;
/**
* @author hengsin
*
*/
public class DefaultLDAPProcessorFactory implements IServerFactory<LdapProcessor, MLdapProcessor> {
/**
* default constructor
*/
public DefaultLDAPProcessorFactory() {
}
@Override
public LdapProcessor[] create(Properties ctx) {
MLdapProcessor[] ldapModels = MLdapProcessor.getActive(ctx);
List<LdapProcessor> list = new ArrayList<LdapProcessor>();
for (MLdapProcessor lp : ldapModels)
{
LdapProcessor server = new LdapProcessor(lp);
list.add(server);
}
return list.toArray(new LdapProcessor[0]);
}
@Override
public Class<MLdapProcessor> getProcessorClass() {
return MLdapProcessor.class;
}
}

View File

@ -0,0 +1,55 @@
/******************************************************************************
* Copyright (C) 2013 Heng Sin Low *
* Copyright (C) 2013 Trek Global *
* This program is free software; you can redistribute it and/or modify it *
* under the terms version 2 of the GNU General Public License as published *
* by the Free Software Foundation. This program is distributed in the hope *
* that it will be useful, but WITHOUT ANY WARRANTY; without even the implied *
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
* See the GNU General Public License for more details. *
* You should have received a copy of the GNU General Public License along *
* with this program; if not, write to the Free Software Foundation, Inc., *
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
*****************************************************************************/
package org.idempiere.server.factory;
import java.util.ArrayList;
import java.util.List;
import java.util.Properties;
import org.adempiere.server.IServerFactory;
import org.compiere.model.MRequestProcessor;
import org.compiere.server.RequestProcessor;
/**
* @author hengsin
*
*/
public class DefaultRequestProcessorFactory implements IServerFactory<RequestProcessor, MRequestProcessor> {
/**
*
*/
public DefaultRequestProcessorFactory() {
}
/* (non-Javadoc)
* @see org.adempiere.server.IServerFactory#create(java.util.Properties)
*/
@Override
public RequestProcessor[] create(Properties ctx) {
MRequestProcessor[] requestModels = MRequestProcessor.getActive(ctx);
List<RequestProcessor> list = new ArrayList<RequestProcessor>();
for (MRequestProcessor pModel : requestModels)
{
RequestProcessor processor = new RequestProcessor(pModel);
list.add(processor);
}
return list.toArray(new RequestProcessor[0]);
}
@Override
public Class<MRequestProcessor> getProcessorClass() {
return MRequestProcessor.class;
}
}

View File

@ -0,0 +1,53 @@
/******************************************************************************
* Copyright (C) 2013 Heng Sin Low *
* Copyright (C) 2013 Trek Global *
* This program is free software; you can redistribute it and/or modify it *
* under the terms version 2 of the GNU General Public License as published *
* by the Free Software Foundation. This program is distributed in the hope *
* that it will be useful, but WITHOUT ANY WARRANTY; without even the implied *
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
* See the GNU General Public License for more details. *
* You should have received a copy of the GNU General Public License along *
* with this program; if not, write to the Free Software Foundation, Inc., *
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
*****************************************************************************/
package org.idempiere.server.factory;
import java.util.ArrayList;
import java.util.List;
import java.util.Properties;
import org.adempiere.server.IServerFactory;
import org.compiere.model.MScheduler;
import org.compiere.server.Scheduler;
/**
* @author hengsin
*
*/
public class DefaultSchedulerFactory implements IServerFactory<Scheduler, MScheduler> {
/**
* default constructor
*/
public DefaultSchedulerFactory() {
}
@Override
public Scheduler[] create(Properties ctx) {
MScheduler[] schedulerModels = MScheduler.getActive(ctx);
List<Scheduler> list = new ArrayList<Scheduler>();
for (MScheduler pModel : schedulerModels)
{
Scheduler server = new Scheduler(pModel);
list.add(server);
}
return list.toArray(new Scheduler[0]);
}
@Override
public Class<MScheduler> getProcessorClass() {
return MScheduler.class;
}
}

View File

@ -0,0 +1,58 @@
/******************************************************************************
* Copyright (C) 2013 Heng Sin Low *
* Copyright (C) 2013 Trek Global *
* This program is free software; you can redistribute it and/or modify it *
* under the terms version 2 of the GNU General Public License as published *
* by the Free Software Foundation. This program is distributed in the hope *
* that it will be useful, but WITHOUT ANY WARRANTY; without even the implied *
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
* See the GNU General Public License for more details. *
* You should have received a copy of the GNU General Public License along *
* with this program; if not, write to the Free Software Foundation, Inc., *
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
*****************************************************************************/
package org.idempiere.server.factory;
import java.util.ArrayList;
import java.util.List;
import java.util.Properties;
import org.adempiere.server.IServerFactory;
import org.compiere.server.WorkflowProcessor;
import org.compiere.wf.MWorkflowProcessor;
/**
* @author hengsin
*
*/
public class DefaultWorkflowProcessorFactory implements IServerFactory<WorkflowProcessor, MWorkflowProcessor> {
/**
*
*/
public DefaultWorkflowProcessorFactory() {
}
/* (non-Javadoc)
* @see org.adempiere.server.IServerFactory#create(java.util.Properties)
*/
@Override
public WorkflowProcessor[] create(Properties ctx) {
MWorkflowProcessor[] workflowModels = MWorkflowProcessor.getActive(ctx);
List<WorkflowProcessor> list = new ArrayList<WorkflowProcessor>();
for (MWorkflowProcessor pModel : workflowModels)
{
WorkflowProcessor server = new WorkflowProcessor(pModel);
list.add(server);
}
return list.toArray(new WorkflowProcessor[0]);
}
/* (non-Javadoc)
* @see org.adempiere.server.IServerFactory#getServerModelClass()
*/
@Override
public Class<MWorkflowProcessor> getProcessorClass() {
return MWorkflowProcessor.class;
}
}