Search in sources :

Example 1 with ProcessEngineProvider

use of org.camunda.bpm.engine.rest.spi.ProcessEngineProvider in project camunda-bpm-platform by camunda.

the class NamedProcessEngineRestServiceImpl method getProcessEngineProvider.

protected ProcessEngineProvider getProcessEngineProvider() {
    ServiceLoader<ProcessEngineProvider> serviceLoader = ServiceLoader.load(ProcessEngineProvider.class);
    Iterator<ProcessEngineProvider> iterator = serviceLoader.iterator();
    if (iterator.hasNext()) {
        ProcessEngineProvider provider = iterator.next();
        return provider;
    } else {
        throw new RestException(Status.INTERNAL_SERVER_ERROR, "No process engine provider found");
    }
}
Also used : RestException(org.camunda.bpm.engine.rest.exception.RestException) ProcessEngineProvider(org.camunda.bpm.engine.rest.spi.ProcessEngineProvider)

Example 2 with ProcessEngineProvider

use of org.camunda.bpm.engine.rest.spi.ProcessEngineProvider in project camunda-bpm-platform by camunda.

the class EngineUtil method lookupProcessEngine.

/**
 * Look up the process engine from the {@link ProcessEngineProvider}. If engineName is null, the default engine is returned.
 * @param engineName
 * @return
 */
public static ProcessEngine lookupProcessEngine(String engineName) {
    ServiceLoader<ProcessEngineProvider> serviceLoader = ServiceLoader.load(ProcessEngineProvider.class);
    Iterator<ProcessEngineProvider> iterator = serviceLoader.iterator();
    if (iterator.hasNext()) {
        ProcessEngineProvider provider = iterator.next();
        if (engineName == null) {
            return provider.getDefaultProcessEngine();
        } else {
            return provider.getProcessEngine(engineName);
        }
    } else {
        throw new RestException(Status.INTERNAL_SERVER_ERROR, "Could not find an implementation of the " + ProcessEngineProvider.class + "- SPI");
    }
}
Also used : RestException(org.camunda.bpm.engine.rest.exception.RestException) ProcessEngineProvider(org.camunda.bpm.engine.rest.spi.ProcessEngineProvider)

Example 3 with ProcessEngineProvider

use of org.camunda.bpm.engine.rest.spi.ProcessEngineProvider in project camunda-bpm-platform by camunda.

the class NamedProcessEngineRestServiceImpl method getProcessEngineNames.

@GET
@Produces(MediaType.APPLICATION_JSON)
public List<ProcessEngineDto> getProcessEngineNames() {
    ProcessEngineProvider provider = getProcessEngineProvider();
    Set<String> engineNames = provider.getProcessEngineNames();
    List<ProcessEngineDto> results = new ArrayList<ProcessEngineDto>();
    for (String engineName : engineNames) {
        ProcessEngineDto dto = new ProcessEngineDto();
        dto.setName(engineName);
        results.add(dto);
    }
    return results;
}
Also used : ProcessEngineDto(org.camunda.bpm.engine.rest.dto.ProcessEngineDto) ArrayList(java.util.ArrayList) ProcessEngineProvider(org.camunda.bpm.engine.rest.spi.ProcessEngineProvider) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Example 4 with ProcessEngineProvider

use of org.camunda.bpm.engine.rest.spi.ProcessEngineProvider in project camunda-bpm-platform by camunda.

the class AbstractRestServiceTest method getProcessEngine.

protected ProcessEngine getProcessEngine(String name) {
    ServiceLoader<ProcessEngineProvider> serviceLoader = ServiceLoader.load(ProcessEngineProvider.class);
    Iterator<ProcessEngineProvider> iterator = serviceLoader.iterator();
    if (iterator.hasNext()) {
        ProcessEngineProvider provider = iterator.next();
        return provider.getProcessEngine(name);
    } else {
        throw new ProcessEngineException("No provider found");
    }
}
Also used : MockedProcessEngineProvider(org.camunda.bpm.engine.rest.spi.impl.MockedProcessEngineProvider) ProcessEngineProvider(org.camunda.bpm.engine.rest.spi.ProcessEngineProvider) ProcessEngineException(org.camunda.bpm.engine.ProcessEngineException)

Example 5 with ProcessEngineProvider

use of org.camunda.bpm.engine.rest.spi.ProcessEngineProvider in project camunda-bpm-platform by camunda.

the class AbstractRestServiceTest method setupTestScenario.

protected static void setupTestScenario() throws IOException {
    setupRestAssured();
    ServiceLoader<ProcessEngineProvider> serviceLoader = ServiceLoader.load(ProcessEngineProvider.class);
    Iterator<ProcessEngineProvider> iterator = serviceLoader.iterator();
    if (iterator.hasNext()) {
        MockedProcessEngineProvider provider = (MockedProcessEngineProvider) iterator.next();
        // reset engine mocks before every test
        provider.resetEngines();
        processEngine = provider.getDefaultProcessEngine();
    }
}
Also used : MockedProcessEngineProvider(org.camunda.bpm.engine.rest.spi.impl.MockedProcessEngineProvider) MockedProcessEngineProvider(org.camunda.bpm.engine.rest.spi.impl.MockedProcessEngineProvider) ProcessEngineProvider(org.camunda.bpm.engine.rest.spi.ProcessEngineProvider)

Aggregations

ProcessEngineProvider (org.camunda.bpm.engine.rest.spi.ProcessEngineProvider)5 RestException (org.camunda.bpm.engine.rest.exception.RestException)2 MockedProcessEngineProvider (org.camunda.bpm.engine.rest.spi.impl.MockedProcessEngineProvider)2 ArrayList (java.util.ArrayList)1 GET (javax.ws.rs.GET)1 Produces (javax.ws.rs.Produces)1 ProcessEngineException (org.camunda.bpm.engine.ProcessEngineException)1 ProcessEngineDto (org.camunda.bpm.engine.rest.dto.ProcessEngineDto)1