2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6 * Copyright (C) 2017 Huawei Technologies Co., Ltd. All rights reserved.
7 * ================================================================================
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
19 * ============LICENSE_END=========================================================
22 package org.onap.so.bpmn.common.workflow.service;
24 import java.util.Optional;
26 import org.camunda.bpm.engine.ProcessEngineServices;
27 import org.camunda.bpm.engine.ProcessEngines;
28 import org.springframework.stereotype.Service;
31 * Base class for services that must be process-engine aware. The only
32 * process engine currently supported is the "default" process engine.
35 public class ProcessEngineAwareService {
37 private final String processEngineName = "default";
38 private volatile Optional<ProcessEngineServices> pes4junit = Optional.empty();
41 * Gets the process engine name.
42 * @return the process engine name
44 public String getProcessEngineName() {
45 return processEngineName;
49 * Gets process engine services.
50 * @return process engine services
52 public ProcessEngineServices getProcessEngineServices() {
53 return pes4junit.orElse(ProcessEngines.getProcessEngine(
54 getProcessEngineName()));
58 * Allows a particular process engine to be specified, overriding the
59 * usual process engine lookup by name. Intended primarily for the
60 * unit test environment.
61 * @param pes process engine services
63 public void setProcessEngineServices4junit(ProcessEngineServices pes) {
64 pes4junit = Optional.ofNullable(pes);