package com.ejie.m62fb.utils.properties;

import org.springframework.beans.factory.BeanFactory;
import org.springframework.context.support.ClassPathXmlApplicationContext;

/**
 * AppResourcesUtil.
 * 
XXXX
 */
public class AppResourcesUtil {

	private static AppPropertiesUtils props;
	private static AppMessagesUtils messages;

	static {

		ClassPathXmlApplicationContext appContext = new ClassPathXmlApplicationContext(
		"spring/resource-config.xml");

		// An ApplicationContext is just a BeanFactory
		BeanFactory factory = appContext;

		// Bean encargado del fichero properties
		AppResourcesUtil.props = (AppPropertiesUtils) factory
		.getBean("appProperties");

		// Bean encargado de los ficheros de literales
		AppResourcesUtil.messages = (AppMessagesUtils) factory
		.getBean("appMessages");
	}

	/**
	 * Constructor privado
	 */
	private AppResourcesUtil() {

	}

	/**
	 * 
	 * @return AppPropertiesUtils
	 */
	public static AppPropertiesUtils getProps() {
		return AppResourcesUtil.props;
	}

	/**
	 * 
	 * @param props
	 *            AppPropertiesUtils
	 */
	public static void setProps(AppPropertiesUtils props) {
		AppResourcesUtil.props = props;
	}

	/**
	 * 
	 * @return AppMessagesUtils
	 */
	public static AppMessagesUtils getMessages() {
		return AppResourcesUtil.messages;
	}

	/**
	 * 
	 * @param messages
	 *            AppMessagesUtils
	 */
	public static void setMessages(AppMessagesUtils messages) {
		AppResourcesUtil.messages = messages;
	}
}