X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=bpmn%2FMSOCommonBPMN%2Fsrc%2Fmain%2Fjava%2Forg%2Fopenecomp%2Fmso%2Fbpmn%2Fcommon%2Fworkflow%2Fservice%2FProcessEngineAwareService.java;fp=bpmn%2FMSOCommonBPMN%2Fsrc%2Fmain%2Fjava%2Forg%2Fopenecomp%2Fmso%2Fbpmn%2Fcommon%2Fworkflow%2Fservice%2FWorkflowAsyncCommonResource.java;h=dbb6674a64fd26a8fe6bee3d054df566a1ff164d;hb=d750eabf5de2423f0a7c89ffbfbcc0d65bb4623e;hp=4534b56efcf7e6f500f6ee2021a5149434c4dbb5;hpb=3935e84e0306183450fc080a09fcc1d13ced345e;p=so.git diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/workflow/service/WorkflowAsyncCommonResource.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/workflow/service/ProcessEngineAwareService.java similarity index 50% rename from bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/workflow/service/WorkflowAsyncCommonResource.java rename to bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/workflow/service/ProcessEngineAwareService.java index 4534b56efc..dbb6674a64 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/workflow/service/WorkflowAsyncCommonResource.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/workflow/service/ProcessEngineAwareService.java @@ -1,32 +1,64 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.bpmn.common.workflow.service; - -import org.camunda.bpm.engine.ProcessEngineServices; -import org.camunda.bpm.engine.ProcessEngines; - - -public class WorkflowAsyncCommonResource extends WorkflowAsyncResource { - - protected ProcessEngineServices getProcessEngineServices() { - return pes4junit.orElse(ProcessEngines.getProcessEngine("infrastructure")); - } -} +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2017 Huawei Technologies Co., Ltd. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.bpmn.common.workflow.service; + +import java.util.Optional; + +import org.camunda.bpm.engine.ProcessEngineServices; +import org.camunda.bpm.engine.ProcessEngines; + +/** + * Base class for services that must be process-engine aware. The only + * process engine currently supported is the "default" process engine. + */ +public class ProcessEngineAwareService { + + private final String processEngineName = "default"; + private volatile Optional pes4junit = Optional.empty(); + + /** + * Gets the process engine name. + * @return the process engine name + */ + public String getProcessEngineName() { + return processEngineName; + } + + /** + * Gets process engine services. + * @return process engine services + */ + public ProcessEngineServices getProcessEngineServices() { + return pes4junit.orElse(ProcessEngines.getProcessEngine( + getProcessEngineName())); + } + + /** + * Allows a particular process engine to be specified, overriding the + * usual process engine lookup by name. Intended primarily for the + * unit test environment. + * @param pes process engine services + */ + public void setProcessEngineServices4junit(ProcessEngineServices pes) { + pes4junit = Optional.ofNullable(pes); + } +}