2 * ============LICENSE_START=======================================================
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.openecomp.mso.asdc;
24 import javax.annotation.PreDestroy;
25 import javax.ejb.ConcurrencyManagement;
26 import javax.ejb.ConcurrencyManagementType;
27 import javax.ejb.Lock;
28 import javax.ejb.LockType;
29 import javax.ejb.Schedule;
30 import javax.ejb.Singleton;
31 import javax.ejb.Startup;
33 import org.openecomp.mso.asdc.client.ASDCGlobalController;
34 import org.openecomp.mso.logger.MsoLogger;
36 @Singleton(name = "ASDCController")
39 @ConcurrencyManagement(ConcurrencyManagementType.CONTAINER)
40 public class ASDCControllerSingleton {
42 private static final MsoLogger LOGGER = MsoLogger.getMsoLogger (MsoLogger.Catalog.ASDC);
43 private static boolean working = false;
45 private ASDCGlobalController globalController = new ASDCGlobalController ();
48 * Main Constructor of the ASDC Singleton
50 public ASDCControllerSingleton () {
53 @Schedule(second ="30", minute = "*", hour = "*", persistent = false)
54 public void periodicControllerTask () {
56 LOGGER.debug ("Another thread is already trying to init ASDC, cancel this periodic call");
62 globalController.updateControllersConfigIfNeeded();
63 globalController.checkInStoppedState();
71 private void terminate () {
72 globalController.closeASDC ();
75 private static synchronized boolean isWorking () {
76 return ASDCControllerSingleton.working;
79 private static synchronized void setWorking (boolean working) {
80 ASDCControllerSingleton.working = working;