Search in sources :

Example 1 with ServiceEcas

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

the class ServiceEcaUtil method readConfig.

public static void readConfig() {
    // Only proceed if the cache hasn't already been populated, caller should be using reloadConfig() in that situation
    if (UtilValidate.isNotEmpty(ecaCache)) {
        return;
    }
    List<Future<List<ServiceEcaRule>>> futures = new LinkedList<Future<List<ServiceEcaRule>>>();
    List<ServiceEcas> serviceEcasList = null;
    try {
        serviceEcasList = ServiceConfigUtil.getServiceEngine().getServiceEcas();
    } catch (GenericConfigException e) {
        // FIXME: Refactor API so exceptions can be thrown and caught.
        Debug.logError(e, module);
        throw new RuntimeException(e.getMessage());
    }
    for (ServiceEcas serviceEcas : serviceEcasList) {
        ResourceHandler handler = new MainResourceHandler(ServiceConfigUtil.getServiceEngineXmlFileName(), serviceEcas.getLoader(), serviceEcas.getLocation());
        futures.add(ExecutionPool.GLOBAL_FORK_JOIN.submit(createEcaLoaderCallable(handler)));
    }
    // get all of the component resource eca stuff, ie specified in each ofbiz-component.xml file
    for (ComponentConfig.ServiceResourceInfo componentResourceInfo : ComponentConfig.getAllServiceResourceInfos("eca")) {
        futures.add(ExecutionPool.GLOBAL_FORK_JOIN.submit(createEcaLoaderCallable(componentResourceInfo.createResourceHandler())));
    }
    for (List<ServiceEcaRule> handlerRules : ExecutionPool.getAllFutures(futures)) {
        mergeEcaDefinitions(handlerRules);
    }
}
Also used : ResourceHandler(org.apache.ofbiz.base.config.ResourceHandler) MainResourceHandler(org.apache.ofbiz.base.config.MainResourceHandler) LinkedList(java.util.LinkedList) GenericConfigException(org.apache.ofbiz.base.config.GenericConfigException) ServiceEcas(org.apache.ofbiz.service.config.model.ServiceEcas) MainResourceHandler(org.apache.ofbiz.base.config.MainResourceHandler) ComponentConfig(org.apache.ofbiz.base.component.ComponentConfig) Future(java.util.concurrent.Future) List(java.util.List) LinkedList(java.util.LinkedList)

Aggregations

LinkedList (java.util.LinkedList)1 List (java.util.List)1 Future (java.util.concurrent.Future)1 ComponentConfig (org.apache.ofbiz.base.component.ComponentConfig)1 GenericConfigException (org.apache.ofbiz.base.config.GenericConfigException)1 MainResourceHandler (org.apache.ofbiz.base.config.MainResourceHandler)1 ResourceHandler (org.apache.ofbiz.base.config.ResourceHandler)1 ServiceEcas (org.apache.ofbiz.service.config.model.ServiceEcas)1