/**
 * ShinyProxy
 *
 * Copyright (C) 2016-2021 Open Analytics
 *
 * ===========================================================================
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the Apache License as published by
 * The Apache Software Foundation, either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * Apache License for more details.
 *
 * You should have received a copy of the Apache License
 * along with this program.  If not, see <http://www.apache.org/licenses/>
 */
package eu.openanalytics.shinyproxy;

import javax.annotation.PostConstruct;
import javax.inject.Inject;

import eu.openanalytics.containerproxy.model.runtime.runtimevalues.RuntimeValueKeyRegistry;
import eu.openanalytics.shinyproxy.runtimevalues.AppInstanceKey;
import eu.openanalytics.shinyproxy.runtimevalues.MaxInstancesKey;
import eu.openanalytics.shinyproxy.runtimevalues.PublicPathKey;
import eu.openanalytics.shinyproxy.runtimevalues.WebSocketReconnectionModeKey;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.env.Environment;

import eu.openanalytics.containerproxy.service.HeartbeatService;

@Configuration
public class ShinyProxyConfiguration {

	@Inject
	private Environment environment;
	
	@Inject
	private HeartbeatService heartbeatService;
	
	@PostConstruct
	public void init() {
		// Enable heartbeat unless explicitly disabled.
		boolean enabled = Boolean.valueOf(environment.getProperty("proxy.heartbeat-enabled", "true"));
		heartbeatService.setEnabled(enabled);
	}

	static {
		RuntimeValueKeyRegistry.addRuntimeValueKey(PublicPathKey.inst);
		RuntimeValueKeyRegistry.addRuntimeValueKey(AppInstanceKey.inst);
		RuntimeValueKeyRegistry.addRuntimeValueKey(WebSocketReconnectionModeKey.inst);
		RuntimeValueKeyRegistry.addRuntimeValueKey(MaxInstancesKey.inst);
	}
}

@@ -1177,24 +1177,99 @@
 icPathKey;%0D%0A
+import eu.openanalytics.shinyproxy.runtimevalues.ShinyForceFullReloadKey;%0D%0A
 import eu.op
@@ -1974,26 +1974,27 @@
 alueKey(
-PublicPath
+AppInstance
 Key.inst
@@ -2038,35 +2038,35 @@
 imeValueKey(
-App
+Max
 Instance
 Key.inst);%0D%0A
@@ -2045,32 +2045,33 @@
 eKey(MaxInstance
+s
 Key.inst);%0D%0A%09%09Ru
@@ -2115,33 +2115,95 @@
 Key(
-WebSocketReconnectionMode
+PublicPathKey.inst);%0D%0A%09%09RuntimeValueKeyRegistry.addRuntimeValueKey(ShinyForceFullReload
 Key.
@@ -2251,36 +2251,49 @@
 imeValueKey(
-MaxInstances
+WebSocketReconnectionMode
 Key.inst);%0D%0A

Add missing runtimevalues to registry