2 * ============LICENSE_START=======================================================
3 * feature-test-transaction
4 * ================================================================================
5 * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
21 package org.onap.policy.drools.testtransaction;
23 import org.onap.policy.drools.features.PolicyControllerFeatureApi;
24 import org.onap.policy.drools.system.PolicyController;
25 import org.slf4j.Logger;
26 import org.slf4j.LoggerFactory;
29 * TestTransactionFeature implements the PolicyControllerFeatureAPI. TestTransactionFeature is the
30 * interface to the TestTransaction feature logic.
32 public class TestTransactionFeature implements PolicyControllerFeatureApi {
34 // get an instance of logger
35 private static final Logger logger = LoggerFactory.getLogger(TestTransactionFeature.class);
38 public boolean afterStart(PolicyController controller) {
40 logger.info("TEST_TRANSACTION FEATURE LOADED");
42 if (controller.isAlive() && !controller.isLocked() && controller.getDrools().isBrained()) {
43 getTestTransMgr().register(controller);
49 public boolean afterLock(PolicyController controller) {
50 logger.info("controller {} locked", controller.getName());
52 getTestTransMgr().unregister(controller);
57 public boolean afterUnlock(PolicyController controller) {
58 logger.info("controller {} unlocked", controller.getName());
60 if (controller.isAlive() && !controller.isLocked() && controller.getDrools().isBrained()) {
61 getTestTransMgr().register(controller);
68 public boolean beforeStop(PolicyController controller) {
69 logger.info("controller {} stopping", controller.getName());
71 getTestTransMgr().unregister(controller);
77 public int getSequenceNumber() {
82 * Gets the test transaction manager.
83 * @return the test transaction manager
85 protected TestTransaction getTestTransMgr() {
86 return TestTransaction.manager;