Search in sources :

Example 1 with StartupService

use of org.apache.ofbiz.service.config.model.StartupService in project ofbiz-framework by apache.

the class ServiceDispatcher method runStartupServices.

// run startup services
private synchronized int runStartupServices() {
    if (!enableSvcs || jm == null) {
        return 0;
    }
    int servicesScheduled = 0;
    List<StartupService> startupServices = null;
    try {
        startupServices = ServiceConfigUtil.getServiceEngine().getStartupServices();
    } catch (GenericConfigException e) {
        Debug.logWarning(e, "Exception thrown while getting service config: ", module);
        return 0;
    }
    for (StartupService startupService : startupServices) {
        String serviceName = startupService.getName();
        String runtimeDataId = startupService.getRuntimeDataId();
        int runtimeDelay = startupService.getRuntimeDelay();
        String sendToPool = startupService.getRunInPool();
        if (UtilValidate.isEmpty(sendToPool)) {
            try {
                sendToPool = ServiceConfigUtil.getServiceEngine().getThreadPool().getSendToPool();
            } catch (GenericConfigException e) {
                Debug.logError(e, "Unable to get send pool in service [" + serviceName + "]: ", module);
            }
        }
        // current time + 1 sec delay + extended delay
        long runtime = System.currentTimeMillis() + 1000 + runtimeDelay;
        try {
            jm.schedule(sendToPool, serviceName, runtimeDataId, runtime);
        } catch (JobManagerException e) {
            Debug.logError(e, "Unable to schedule service [" + serviceName + "]", module);
        }
    }
    return servicesScheduled;
}
Also used : GenericConfigException(org.apache.ofbiz.base.config.GenericConfigException) StartupService(org.apache.ofbiz.service.config.model.StartupService) JobManagerException(org.apache.ofbiz.service.job.JobManagerException)

Aggregations

GenericConfigException (org.apache.ofbiz.base.config.GenericConfigException)1 StartupService (org.apache.ofbiz.service.config.model.StartupService)1 JobManagerException (org.apache.ofbiz.service.job.JobManagerException)1