diff --git a/org.adempiere.replication.server/src/org/adempiere/server/rpl/imp/ReplicationServerFactory.java b/org.adempiere.replication.server/src/org/adempiere/server/rpl/imp/ReplicationServerFactory.java index 9a29c4ee09..59ba473e00 100644 --- a/org.adempiere.replication.server/src/org/adempiere/server/rpl/imp/ReplicationServerFactory.java +++ b/org.adempiere.replication.server/src/org/adempiere/server/rpl/imp/ReplicationServerFactory.java @@ -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 { /** * default constructor @@ -28,17 +27,21 @@ public class ReplicationServerFactory implements IServerFactory { * @see org.adempiere.server.IServerFactory#create() */ @Override - public AdempiereServer[] create(Properties ctx) { - List list = new ArrayList(); + public ReplicationProcessor[] create(Properties ctx) { + List list = new ArrayList(); 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 getProcessorClass() { + return MIMPProcessor.class; + } + } diff --git a/org.adempiere.replication.server/src/org/compiere/server/ReplicationProcessor.java b/org.adempiere.replication.server/src/org/compiere/server/ReplicationProcessor.java index 39be155dd3..a86279ab57 100644 --- a/org.adempiere.replication.server/src/org/compiere/server/ReplicationProcessor.java +++ b/org.adempiere.replication.server/src/org/compiere/server/ReplicationProcessor.java @@ -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; diff --git a/org.adempiere.server/.project b/org.adempiere.server/.project index 2ea4fe630b..3b30177424 100644 --- a/org.adempiere.server/.project +++ b/org.adempiere.server/.project @@ -20,6 +20,11 @@ + + org.eclipse.pde.ds.core.builder + + + org.eclipse.jdt.core.javanature diff --git a/org.adempiere.server/META-INF/MANIFEST.MF b/org.adempiere.server/META-INF/MANIFEST.MF index 2a64795b6c..fb1bb1f0cc 100644 --- a/org.adempiere.server/META-INF/MANIFEST.MF +++ b/org.adempiere.server/META-INF/MANIFEST.MF @@ -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 diff --git a/org.adempiere.server/OSGI-INF/acctprocessorfactory.xml b/org.adempiere.server/OSGI-INF/acctprocessorfactory.xml new file mode 100644 index 0000000000..ab965f7a41 --- /dev/null +++ b/org.adempiere.server/OSGI-INF/acctprocessorfactory.xml @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/org.adempiere.server/OSGI-INF/alertprocessorfactory.xml b/org.adempiere.server/OSGI-INF/alertprocessorfactory.xml new file mode 100644 index 0000000000..ef40ea2b28 --- /dev/null +++ b/org.adempiere.server/OSGI-INF/alertprocessorfactory.xml @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/org.adempiere.server/OSGI-INF/ldapprocessorfactory.xml b/org.adempiere.server/OSGI-INF/ldapprocessorfactory.xml new file mode 100644 index 0000000000..7373533582 --- /dev/null +++ b/org.adempiere.server/OSGI-INF/ldapprocessorfactory.xml @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/org.adempiere.server/OSGI-INF/requestprocessorfactory.xml b/org.adempiere.server/OSGI-INF/requestprocessorfactory.xml new file mode 100644 index 0000000000..edd62584bb --- /dev/null +++ b/org.adempiere.server/OSGI-INF/requestprocessorfactory.xml @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/org.adempiere.server/OSGI-INF/schedulerfactory.xml b/org.adempiere.server/OSGI-INF/schedulerfactory.xml new file mode 100644 index 0000000000..4947ceef93 --- /dev/null +++ b/org.adempiere.server/OSGI-INF/schedulerfactory.xml @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/org.adempiere.server/OSGI-INF/workflowprocessorfactory.xml b/org.adempiere.server/OSGI-INF/workflowprocessorfactory.xml new file mode 100644 index 0000000000..e1c53aa8f1 --- /dev/null +++ b/org.adempiere.server/OSGI-INF/workflowprocessorfactory.xml @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/org.adempiere.server/build.properties b/org.adempiere.server/build.properties index 2510288944..2eee8015ad 100644 --- a/org.adempiere.server/build.properties +++ b/org.adempiere.server/build.properties @@ -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 diff --git a/org.adempiere.server/src/main/server/org/adempiere/server/IServerFactory.java b/org.adempiere.server/src/main/server/org/adempiere/server/IServerFactory.java index 0f3fb37610..3373273e5c 100644 --- a/org.adempiere.server/src/main/server/org/adempiere/server/IServerFactory.java +++ b/org.adempiere.server/src/main/server/org/adempiere/server/IServerFactory.java @@ -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 { - // 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 getProcessorClass(); } diff --git a/org.adempiere.server/src/main/server/org/compiere/ldap/LdapProcessor.java b/org.adempiere.server/src/main/server/org/compiere/ldap/LdapProcessor.java index 173a093e20..9f34cb1a33 100644 --- a/org.adempiere.server/src/main/server/org/compiere/ldap/LdapProcessor.java +++ b/org.adempiere.server/src/main/server/org/compiere/ldap/LdapProcessor.java @@ -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; /** diff --git a/org.adempiere.server/src/main/server/org/compiere/server/AcctProcessor.java b/org.adempiere.server/src/main/server/org/compiere/server/AcctProcessor.java index d55381e212..7e51963cab 100644 --- a/org.adempiere.server/src/main/server/org/compiere/server/AcctProcessor.java +++ b/org.adempiere.server/src/main/server/org/compiere/server/AcctProcessor.java @@ -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 diff --git a/org.adempiere.server/src/main/server/org/compiere/server/AdempiereServer.java b/org.adempiere.server/src/main/server/org/compiere/server/AdempiereServer.java index bdd8e2c77c..4afb642e17 100644 --- a/org.adempiere.server/src/main/server/org/compiere/server/AdempiereServer.java +++ b/org.adempiere.server/src/main/server/org/compiere/server/AdempiereServer.java @@ -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 diff --git a/org.adempiere.server/src/main/server/org/compiere/server/AdempiereServerMgr.java b/org.adempiere.server/src/main/server/org/compiere/server/AdempiereServerMgr.java index 32f5ca73da..4b057eeaff 100644 --- a/org.adempiere.server/src/main/server/org/compiere/server/AdempiereServerMgr.java +++ b/org.adempiere.server/src/main/server/org/compiere/server/AdempiereServerMgr.java @@ -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(); - // 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 serverFactoryList = Service.locator().list(IServerFactory.class).getServices(); if (serverFactoryList != null && !serverFactoryList.isEmpty()) { + List processed = new ArrayList(); 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)); + } + } + } + } } } diff --git a/org.adempiere.server/src/main/server/org/compiere/server/AlertProcessor.java b/org.adempiere.server/src/main/server/org/compiere/server/AlertProcessor.java index d0da2a0fa7..94b6277ec5 100644 --- a/org.adempiere.server/src/main/server/org/compiere/server/AlertProcessor.java +++ b/org.adempiere.server/src/main/server/org/compiere/server/AlertProcessor.java @@ -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 users, String subject, String message, Collection attachments) + protected int notifyUsers(Collection users, String subject, String message, Collection attachments) { int countMail = 0; for (int user_id : users) { @@ -289,7 +289,7 @@ public class AlertProcessor extends AdempiereServer * @return data * @throws Exception */ - private ArrayList> getData (String sql, String trxName) throws Exception + protected ArrayList> getData (String sql, String trxName) throws Exception { ArrayList> data = new ArrayList>(); 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 attachments) + protected String getPlainTextReport(MAlertRule rule, String sql, String trxName, Collection 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 attachments) + protected String getExcelReport(MAlertRule rule, String sql, String trxName, Collection attachments) throws Exception { ArrayList> data = getData(sql, trxName); diff --git a/org.adempiere.server/src/main/server/org/compiere/server/EMailProcessor.java b/org.adempiere.server/src/main/server/org/compiere/server/EMailProcessor.java index 9dd5e44496..b8784359b9 100644 --- a/org.adempiere.server/src/main/server/org/compiere/server/EMailProcessor.java +++ b/org.adempiere.server/src/main/server/org/compiere/server/EMailProcessor.java @@ -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); diff --git a/org.adempiere.server/src/main/server/org/compiere/server/RequestProcessor.java b/org.adempiere.server/src/main/server/org/compiere/server/RequestProcessor.java index 18dff4c00c..290222801c 100644 --- a/org.adempiere.server/src/main/server/org/compiere/server/RequestProcessor.java +++ b/org.adempiere.server/src/main/server/org/compiere/server/RequestProcessor.java @@ -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) diff --git a/org.adempiere.server/src/main/server/org/compiere/server/Scheduler.java b/org.adempiere.server/src/main/server/org/compiere/server/Scheduler.java index 5d96657b73..ebfb545f66 100644 --- a/org.adempiere.server/src/main/server/org/compiere/server/Scheduler.java +++ b/org.adempiere.server/src/main/server/org/compiere/server/Scheduler.java @@ -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(); diff --git a/org.adempiere.server/src/main/server/org/compiere/server/WorkflowProcessor.java b/org.adempiere.server/src/main/server/org/compiere/server/WorkflowProcessor.java index 9939007cb1..bcab69ed55 100644 --- a/org.adempiere.server/src/main/server/org/compiere/server/WorkflowProcessor.java +++ b/org.adempiere.server/src/main/server/org/compiere/server/WorkflowProcessor.java @@ -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 list, MWFProcess process, String subject, String message, File pdf) { diff --git a/org.adempiere.server/src/main/server/org/idempiere/server/factory/DefaultAcctProcessorFactory.java b/org.adempiere.server/src/main/server/org/idempiere/server/factory/DefaultAcctProcessorFactory.java new file mode 100644 index 0000000000..db63a121c5 --- /dev/null +++ b/org.adempiere.server/src/main/server/org/idempiere/server/factory/DefaultAcctProcessorFactory.java @@ -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 { + + /** + * 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 list = new ArrayList(); + for (MAcctProcessor pModel : acctModels) + { + AcctProcessor processor = new AcctProcessor(pModel); + list.add(processor); + } + return list.toArray(new AcctProcessor[0]); + } + + @Override + public Class getProcessorClass() { + return MAcctProcessor.class; + } + +} diff --git a/org.adempiere.server/src/main/server/org/idempiere/server/factory/DefaultAlertProcessorFactory.java b/org.adempiere.server/src/main/server/org/idempiere/server/factory/DefaultAlertProcessorFactory.java new file mode 100644 index 0000000000..58d31341c6 --- /dev/null +++ b/org.adempiere.server/src/main/server/org/idempiere/server/factory/DefaultAlertProcessorFactory.java @@ -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 { + + /** + * + */ + public DefaultAlertProcessorFactory() { + } + + @Override + public AlertProcessor[] create(Properties ctx) { + MAlertProcessor[] alertModels = MAlertProcessor.getActive(ctx); + List list = new ArrayList(); + for (MAlertProcessor pModel : alertModels) + { + AlertProcessor server = new AlertProcessor(pModel); + list.add(server); + } + return list.toArray(new AlertProcessor[0]); + } + + @Override + public Class getProcessorClass() { + return MAlertProcessor.class; + } + +} diff --git a/org.adempiere.server/src/main/server/org/idempiere/server/factory/DefaultLDAPProcessorFactory.java b/org.adempiere.server/src/main/server/org/idempiere/server/factory/DefaultLDAPProcessorFactory.java new file mode 100644 index 0000000000..11201a53d9 --- /dev/null +++ b/org.adempiere.server/src/main/server/org/idempiere/server/factory/DefaultLDAPProcessorFactory.java @@ -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 { + + /** + * default constructor + */ + public DefaultLDAPProcessorFactory() { + } + + @Override + public LdapProcessor[] create(Properties ctx) { + MLdapProcessor[] ldapModels = MLdapProcessor.getActive(ctx); + List list = new ArrayList(); + for (MLdapProcessor lp : ldapModels) + { + LdapProcessor server = new LdapProcessor(lp); + list.add(server); + } + return list.toArray(new LdapProcessor[0]); + } + + @Override + public Class getProcessorClass() { + return MLdapProcessor.class; + } +} diff --git a/org.adempiere.server/src/main/server/org/idempiere/server/factory/DefaultRequestProcessorFactory.java b/org.adempiere.server/src/main/server/org/idempiere/server/factory/DefaultRequestProcessorFactory.java new file mode 100644 index 0000000000..0801a62a19 --- /dev/null +++ b/org.adempiere.server/src/main/server/org/idempiere/server/factory/DefaultRequestProcessorFactory.java @@ -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 { + + /** + * + */ + 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 list = new ArrayList(); + for (MRequestProcessor pModel : requestModels) + { + RequestProcessor processor = new RequestProcessor(pModel); + list.add(processor); + } + return list.toArray(new RequestProcessor[0]); + } + + @Override + public Class getProcessorClass() { + return MRequestProcessor.class; + } +} diff --git a/org.adempiere.server/src/main/server/org/idempiere/server/factory/DefaultSchedulerFactory.java b/org.adempiere.server/src/main/server/org/idempiere/server/factory/DefaultSchedulerFactory.java new file mode 100644 index 0000000000..052f28e5be --- /dev/null +++ b/org.adempiere.server/src/main/server/org/idempiere/server/factory/DefaultSchedulerFactory.java @@ -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 { + + /** + * default constructor + */ + public DefaultSchedulerFactory() { + } + + @Override + public Scheduler[] create(Properties ctx) { + MScheduler[] schedulerModels = MScheduler.getActive(ctx); + List list = new ArrayList(); + for (MScheduler pModel : schedulerModels) + { + Scheduler server = new Scheduler(pModel); + list.add(server); + } + return list.toArray(new Scheduler[0]); + } + + @Override + public Class getProcessorClass() { + return MScheduler.class; + } + +} diff --git a/org.adempiere.server/src/main/server/org/idempiere/server/factory/DefaultWorkflowProcessorFactory.java b/org.adempiere.server/src/main/server/org/idempiere/server/factory/DefaultWorkflowProcessorFactory.java new file mode 100644 index 0000000000..98dea95fc3 --- /dev/null +++ b/org.adempiere.server/src/main/server/org/idempiere/server/factory/DefaultWorkflowProcessorFactory.java @@ -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 { + + /** + * + */ + 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 list = new ArrayList(); + 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 getProcessorClass() { + return MWorkflowProcessor.class; + } +}