/*
 * (C) Copyright 2014 Kurento (http://kurento.org/)
 * 
 * All rights reserved. This program and the accompanying materials are made
 * available under the terms of the GNU Lesser General Public License (LGPL)
 * version 2.1 which accompanies this distribution, and is available at
 * http://www.gnu.org/licenses/lgpl-2.1.html
 * 
 * This library 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 GNU Lesser General Public License for more
 * details.
 */
package org.kurento.tutorial.helloworld;

import org.kurento.client.KurentoClient;
import org.kurento.commons.PropertiesManager;
import org.kurento.repository.rest.RepositoryRestApi;
import org.kurento.repository.rest.RestServiceProvider;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.socket.config.annotation.EnableWebSocket;
import org.springframework.web.socket.config.annotation.WebSocketConfigurer;
import org.springframework.web.socket.config.annotation.WebSocketHandlerRegistry;

/**
 * Hello World (WebRTC in loopback with recording) main class.
 * 
 * @author Boni Garcia (bgarcia@gsyc.es)
 * @author Radu Tom Vlad (rvlad@naevatec.com)
 * @since 6.1.1
 */
@Configuration
@EnableWebSocket
@EnableAutoConfiguration
public class HelloWorldRecApp implements WebSocketConfigurer {

	final static String DEFAULT_KMS_WS_URI = "ws://localhost:8888/kurento";
	final static String DEFAULT_REPOSITORY_SERVER_URI = "http://localhost:7676";

	final static String REPOSITORY_SERVER_URI = System.getProperty(
			"repository.uri", DEFAULT_REPOSITORY_SERVER_URI);
	final static String KMS_WS_URI = System.getProperty("kms.ws.uri",
			DEFAULT_KMS_WS_URI);

	@Bean
	public HelloWorldRecHandler handler() {
		return new HelloWorldRecHandler();
	}

	@Bean
	public KurentoClient kurentoClient() {
		return KurentoClient.create(PropertiesManager.getProperty("kms.ws.uri",
				KMS_WS_URI));
	}

	@Override
	public void registerWebSocketHandlers(WebSocketHandlerRegistry registry) {
		registry.addHandler(handler(), "/helloworld");
	}

	@Bean
	public RepositoryRestApi repositoryServiceProvider() {
		if (REPOSITORY_SERVER_URI.startsWith("file://"))
			return null;
		return RestServiceProvider.create(REPOSITORY_SERVER_URI)
				.getRestService();
	}

	@Bean
	public UserRegistry registry() {
		return new UserRegistry();
	}

	public static void main(String[] args) throws Exception {
		new SpringApplication(HelloWorldRecApp.class).run(args);
	}
}

@@ -803,25 +803,31 @@
 .rest.Re
-stService
+positoryRestApi
 Provider
@@ -1790,32 +1790,36 @@
 VER_URI = System
+%0A%09%09%09
 .getProperty(%0A%09%09
@@ -1815,20 +1815,16 @@
 roperty(
-%0A%09%09%09
 %22reposit
@@ -2123,16 +2123,21 @@
 .create(
+%0A%09%09%09%09
 Properti
@@ -2171,21 +2171,17 @@
 ws.uri%22,
-%0A%09%09%09%09
+ 
 KMS_WS_U
@@ -2443,16 +2443,18 @@
 le://%22))
+ %7B
 %0A%09%09%09retu
@@ -2462,16 +2462,20 @@
 n null;%0A
+%09%09%7D%0A
 %09%09return
@@ -2477,25 +2477,31 @@
 eturn Re
-stService
+positoryRestApi
 Provider
@@ -2534,30 +2534,8 @@
 URI)
-%0A%09%09%09%09.getRestService()
 ;%0A%09%7D

Refactor RestApiProvider to RepositoryRestApiProvider