Search in sources :

Example 1 with ProcessEngineInfoImpl

use of org.activiti.engine.impl.ProcessEngineInfoImpl in project Activiti by Activiti.

the class ProcessEngines method initProcessEngineFromSpringResource.

protected static void initProcessEngineFromSpringResource(URL resource) {
    try {
        Class<?> springConfigurationHelperClass = ReflectUtil.loadClass("org.activiti.spring.SpringConfigurationHelper");
        Method method = springConfigurationHelperClass.getDeclaredMethod("buildProcessEngine", new Class<?>[] { URL.class });
        ProcessEngine processEngine = (ProcessEngine) method.invoke(null, new Object[] { resource });
        String processEngineName = processEngine.getName();
        ProcessEngineInfo processEngineInfo = new ProcessEngineInfoImpl(processEngineName, resource.toString(), null);
        processEngineInfosByName.put(processEngineName, processEngineInfo);
        processEngineInfosByResourceUrl.put(resource.toString(), processEngineInfo);
    } catch (Exception e) {
        throw new ActivitiException("couldn't initialize process engine from spring configuration resource " + resource.toString() + ": " + e.getMessage(), e);
    }
}
Also used : ProcessEngineInfoImpl(org.activiti.engine.impl.ProcessEngineInfoImpl) Method(java.lang.reflect.Method) MalformedURLException(java.net.MalformedURLException) IOException(java.io.IOException)

Example 2 with ProcessEngineInfoImpl

use of org.activiti.engine.impl.ProcessEngineInfoImpl in project Activiti by Activiti.

the class JsonProcessEngineInfoConverter method toJsonObject.

public JSONObject toJsonObject(ProcessEngineInfo processEngineInfo) {
    ProcessEngineInfoImpl processEngineInfoImpl = (ProcessEngineInfoImpl) processEngineInfo;
    JSONObject jsonObject = new JSONObject();
    jsonObject.put("name", processEngineInfoImpl.getName());
    jsonObject.put("resourceUrl", processEngineInfoImpl.getResourceUrl());
    jsonObject.put("exception", processEngineInfoImpl.getException());
    return jsonObject;
}
Also used : ProcessEngineInfoImpl(org.activiti.engine.impl.ProcessEngineInfoImpl) JSONObject(org.activiti.engine.impl.util.json.JSONObject)

Example 3 with ProcessEngineInfoImpl

use of org.activiti.engine.impl.ProcessEngineInfoImpl in project Activiti by Activiti.

the class ProcessEngines method initProcessEnginFromResource.

private static ProcessEngineInfo initProcessEnginFromResource(URL resourceUrl) {
    ProcessEngineInfo processEngineInfo = processEngineInfosByResourceUrl.get(resourceUrl.toString());
    // if there is an existing process engine info
    if (processEngineInfo != null) {
        // remove that process engine from the member fields
        processEngineInfos.remove(processEngineInfo);
        if (processEngineInfo.getException() == null) {
            String processEngineName = processEngineInfo.getName();
            processEngines.remove(processEngineName);
            processEngineInfosByName.remove(processEngineName);
        }
        processEngineInfosByResourceUrl.remove(processEngineInfo.getResourceUrl());
    }
    String resourceUrlString = resourceUrl.toString();
    try {
        log.info("initializing process engine for resource {}", resourceUrl);
        ProcessEngine processEngine = buildProcessEngine(resourceUrl);
        String processEngineName = processEngine.getName();
        log.info("initialised process engine {}", processEngineName);
        processEngineInfo = new ProcessEngineInfoImpl(processEngineName, resourceUrlString, null);
        processEngines.put(processEngineName, processEngine);
        processEngineInfosByName.put(processEngineName, processEngineInfo);
    } catch (Throwable e) {
        log.error("Exception while initializing process engine: {}", e.getMessage(), e);
        processEngineInfo = new ProcessEngineInfoImpl(null, resourceUrlString, getExceptionString(e));
    }
    processEngineInfosByResourceUrl.put(resourceUrlString, processEngineInfo);
    processEngineInfos.add(processEngineInfo);
    return processEngineInfo;
}
Also used : ProcessEngineInfoImpl(org.activiti.engine.impl.ProcessEngineInfoImpl)

Aggregations

ProcessEngineInfoImpl (org.activiti.engine.impl.ProcessEngineInfoImpl)3 IOException (java.io.IOException)1 Method (java.lang.reflect.Method)1 MalformedURLException (java.net.MalformedURLException)1 JSONObject (org.activiti.engine.impl.util.json.JSONObject)1