/*
 * Copyright 2014 Click Travel Ltd
 *
 * 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.
 * 
 */
package com.clicktravel.cheddar.server.application.lifecycle;

import static com.clicktravel.cheddar.server.application.lifecycle.LifecycleStatus.INACTIVE;
import static com.clicktravel.cheddar.server.application.lifecycle.LifecycleStatus.RUNNING;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

@Component
public class LifecycleStatusHolder {

    private volatile LifecycleStatus lifecycleStatus;

    @Autowired
    public LifecycleStatusHolder(@Value("${blue.green.mode}") final boolean blueGreenMode) {
        lifecycleStatus = blueGreenMode ? INACTIVE : RUNNING;
    }

    public LifecycleStatus getLifecycleStatus() {
        return lifecycleStatus;
    }

    public void setLifecycleStatus(final LifecycleStatus lifecycleStatus) {
        this.lifecycleStatus = lifecycleStatus;
    }

}

@@ -844,16 +844,73 @@
 NNING;%0A%0A
+import org.slf4j.Logger;%0Aimport org.slf4j.LoggerFactory;%0A
 import o
@@ -1122,16 +1122,87 @@
 lder %7B%0A%0A
+    private final Logger logger = LoggerFactory.getLogger(getClass());%0A
     priv
@@ -1321,11 +1321,20 @@
 een.
-mod
+startup:fals
 e%7D%22)
@@ -1361,15 +1361,83 @@
 reen
-Mode) %7B
+Startup) %7B%0A        logger.debug(%22Blue-green startup: %22 + blueGreenStartup);
 %0A   
@@ -1472,12 +1472,15 @@
 reen
-Mode
+Startup
  ? I

Allow blue-green startup to be specified from "-Dblue.green.startup" param.