// Path: src/main/java/com/wk/lodge/composite/repository/DeviceLimiter.java
// public class DeviceLimiter {
//     private HashMap<String,Integer> maxDevicesPerSession;
//     private float minDistanceThresholdBetweenDevices;
//     private float maxDistanceThresholdBetweenDevices;
// 
//     public DeviceLimiter(HashMap<String,Integer> maxDevicesPerSession, float minDistanceThresholdBetweenDevices, float maxDistanceThresholdBetweenDevices){
//         this.maxDevicesPerSession = maxDevicesPerSession;
//         this.minDistanceThresholdBetweenDevices = minDistanceThresholdBetweenDevices;
//         this.maxDistanceThresholdBetweenDevices = maxDistanceThresholdBetweenDevices;
//     }
//     public HashMap<String,Integer> getMaxDevicesPerSession() {
//         return maxDevicesPerSession;
//     }
//     public float getMinDistanceThresholdBetweenDevices() {
//         return minDistanceThresholdBetweenDevices;
//     }
//     public float getMaxDistanceThresholdBetweenDevices() {
//         return maxDistanceThresholdBetweenDevices;
//     }
// 
//     public int getMaxDevicesPerSessionForGame(String applicationId){
//         return maxDevicesPerSession.get(applicationId);
//     }
// 
// }
// 
// Path: src/main/java/com/wk/lodge/composite/service/RoomService.java
// public class RoomService {
//     private HashMap<String,String[]> roomNames;
//     public RoomService(){}
//     public RoomService(HashMap<String, String[]> roomNames){
//         this.roomNames = roomNames;
//     }
// 
//     public String[] getRoomNamesForApplication(String applicationId){
//         if(roomNames.containsKey(applicationId)){
//             return roomNames.get(applicationId);
//         }
//         else{
//             return null;
//         }
//     }
// }


import com.wk.lodge.composite.repository.DeviceLimiter;
import com.wk.lodge.composite.service.RoomService;
import org.lightcouch.CouchDbClient;
import org.lightcouch.CouchDbProperties;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;
import org.springframework.context.annotation.PropertySources;
import org.springframework.context.support.PropertySourcesPlaceholderConfigurer;
import java.util.HashMap;
    @Value(value = "${couchdb.host}") private String couchDbHostname;
    @Value(value = "${couchdb.port}") private int couchDbHostPort;
    @Value(value = "${couchdb.createdb.if-not-exist}") private boolean couchDbCreateIfNotExist;
    @Value(value = "${couchdb.protocol}") private String couchDbProtocol;
    @Value(value = "${couchdb.max.connections}") private int couchDbMaxConnections;
    @Value(value = "${couchdb.sessions.database.name}") private String sessionDatabaseName;
    @Value(value = "${couchdb.username}") private String couchDbAdminUser;
    @Value(value = "${couchdb.password}") private String couchDbAdminPassword;

    @Bean
    public static PropertySourcesPlaceholderConfigurer
    getPropertySourcesPlaceholderConfigurer(){
        return new PropertySourcesPlaceholderConfigurer();
    }

    @Bean(destroyMethod = "shutdown")
    public CouchDbClient couchDbSessionClient(){
        CouchDbProperties couchDbProperties = new CouchDbProperties();
        couchDbProperties.setHost(couchDbHostname);
        couchDbProperties.setPort(couchDbHostPort);
        couchDbProperties.setCreateDbIfNotExist(couchDbCreateIfNotExist);
        couchDbProperties.setProtocol(couchDbProtocol);
        couchDbProperties.setMaxConnections(couchDbMaxConnections);
        couchDbProperties.setDbName(sessionDatabaseName);
        couchDbProperties.setUsername(couchDbAdminUser);
        couchDbProperties.setPassword(couchDbAdminPassword);
        return new CouchDbClient(couchDbProperties);
    }

    @Bean
// Path: src/main/java/com/wk/lodge/composite/repository/DeviceLimiter.java
// public class DeviceLimiter {
//     private HashMap<String,Integer> maxDevicesPerSession;
//     private float minDistanceThresholdBetweenDevices;
//     private float maxDistanceThresholdBetweenDevices;
// 
//     public DeviceLimiter(HashMap<String,Integer> maxDevicesPerSession, float minDistanceThresholdBetweenDevices, float maxDistanceThresholdBetweenDevices){
//         this.maxDevicesPerSession = maxDevicesPerSession;
//         this.minDistanceThresholdBetweenDevices = minDistanceThresholdBetweenDevices;
//         this.maxDistanceThresholdBetweenDevices = maxDistanceThresholdBetweenDevices;
//     }
//     public HashMap<String,Integer> getMaxDevicesPerSession() {
//         return maxDevicesPerSession;
//     }
//     public float getMinDistanceThresholdBetweenDevices() {
//         return minDistanceThresholdBetweenDevices;
//     }
//     public float getMaxDistanceThresholdBetweenDevices() {
//         return maxDistanceThresholdBetweenDevices;
//     }
// 
//     public int getMaxDevicesPerSessionForGame(String applicationId){
//         return maxDevicesPerSession.get(applicationId);
//     }
// 
// }
// 
// Path: src/main/java/com/wk/lodge/composite/service/RoomService.java
// public class RoomService {
//     private HashMap<String,String[]> roomNames;
//     public RoomService(){}
//     public RoomService(HashMap<String, String[]> roomNames){
//         this.roomNames = roomNames;
//     }
// 
//     public String[] getRoomNamesForApplication(String applicationId){
//         if(roomNames.containsKey(applicationId)){
//             return roomNames.get(applicationId);
//         }
//         else{
//             return null;
//         }
//     }
// }


// Path: src/main/java/com/wk/lodge/composite/config/RootConfig.java
import com.wk.lodge.composite.repository.DeviceLimiter;
import com.wk.lodge.composite.service.RoomService;
import org.lightcouch.CouchDbClient;
import org.lightcouch.CouchDbProperties;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;
import org.springframework.context.annotation.PropertySources;
import org.springframework.context.support.PropertySourcesPlaceholderConfigurer;
import java.util.HashMap;

    @Value(value = "${couchdb.host}") private String couchDbHostname;
    @Value(value = "${couchdb.port}") private int couchDbHostPort;
    @Value(value = "${couchdb.createdb.if-not-exist}") private boolean couchDbCreateIfNotExist;
    @Value(value = "${couchdb.protocol}") private String couchDbProtocol;
    @Value(value = "${couchdb.max.connections}") private int couchDbMaxConnections;
    @Value(value = "${couchdb.sessions.database.name}") private String sessionDatabaseName;
    @Value(value = "${couchdb.username}") private String couchDbAdminUser;
    @Value(value = "${couchdb.password}") private String couchDbAdminPassword;

    @Bean
    public static PropertySourcesPlaceholderConfigurer
    getPropertySourcesPlaceholderConfigurer(){
        return new PropertySourcesPlaceholderConfigurer();
    }

    @Bean(destroyMethod = "shutdown")
    public CouchDbClient couchDbSessionClient(){
        CouchDbProperties couchDbProperties = new CouchDbProperties();
        couchDbProperties.setHost(couchDbHostname);
        couchDbProperties.setPort(couchDbHostPort);
        couchDbProperties.setCreateDbIfNotExist(couchDbCreateIfNotExist);
        couchDbProperties.setProtocol(couchDbProtocol);
        couchDbProperties.setMaxConnections(couchDbMaxConnections);
        couchDbProperties.setDbName(sessionDatabaseName);
        couchDbProperties.setUsername(couchDbAdminUser);
        couchDbProperties.setPassword(couchDbAdminPassword);
        return new CouchDbClient(couchDbProperties);
    }

    @Bean
    public DeviceLimiter getDeviceLimiter(){