2 * ============LICENSE_START=======================================================
3 * feature-test-transaction
4 * ================================================================================
5 * Copyright (C) 2017 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;
28 * TestTransactionFeature implements the PolicyControllerFeatureAPI.
29 * TestTransactionFeature is the 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() &&
43 !controller.isLocked() &&
44 controller.getDrools().isBrained())
45 TestTransaction.manager.register(controller);
51 public boolean afterLock(PolicyController controller) {
52 logger.info("controller {} locked", controller.getName());
54 TestTransaction.manager.unregister(controller);
59 public boolean afterUnlock(PolicyController controller) {
60 logger.info("controller {} unlocked", controller.getName());
62 if (controller.isAlive() &&
63 !controller.isLocked() &&
64 controller.getDrools().isBrained())
65 TestTransaction.manager.register(controller);
71 public boolean beforeStop(PolicyController controller) {
72 logger.info("controller {} stopping", controller.getName());
74 TestTransaction.manager.unregister(controller);
80 public int getSequenceNumber() {