/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
package org.ocelotds.cache;

import java.io.InputStream;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import javax.enterprise.context.ApplicationScoped;
import javax.inject.Inject;
import org.ocelotds.Constants;
import org.ocelotds.annotations.OcelotLogger;
import org.slf4j.Logger;

/**
 *
 * @author hhfrancois
 */
@ApplicationScoped
public class CacheParamNameServices {
	Map<String, List<String>> map = new HashMap();
	
	@Inject
	@OcelotLogger
	private Logger logger;

	public List<String> getMethodParamNames(Class cls, String methodName) {
		String key = cls.getName()+"."+methodName;
		if(!map.containsKey(key)) {
			String fn = cls.getSimpleName()+".properties";
			List<String> result = new ArrayList();
			try (InputStream in = cls.getResourceAsStream(fn);) {
				Properties properties = new Properties();
				properties.load(in);
				String property = properties.getProperty(key);
				result = Arrays.asList(property.split(Constants.Cache.PARAMNAME_SEPARATOR));
			} catch (Throwable ex) {
				logger.error("Error, loading "+key+"/"+fn, ex);
			}
			map.put(key, result);
		}
		return map.get(key);
	}
}

@@ -378,40 +378,141 @@
 til.
-Map;%0Aimport java.util.Properties
+Locale;%0Aimport java.util.Map;%0Aimport java.util.MissingResourceException;%0Aimport java.util.Properties;%0Aimport java.util.ResourceBundle
 ;%0Aim
@@ -1035,222 +1035,151 @@
 %0A%09%09%09
-String fn = cls.getSimpleName()+%22.properties%22;%0A%09%09%09List%3CString%3E result = new ArrayList();%0A%09%09%09try (InputStream in = cls.getResourceAsStream(fn);) %7B%0A%09%09%09%09Properties properties = new Properties();%0A%09%09%09%09properties.load(in
+List%3CString%3E result = new ArrayList();%0A%09%09%09try %7B%0A%09%09%09%09ResourceBundle rb = ResourceBundle.getBundle(cls.getName(), Locale.US, cls.getClassLoader()
 );%0A%09
@@ -1203,30 +1203,20 @@
 y = 
-properties.getProperty
+rb.getString
 (key
@@ -1307,83 +1307,45 @@
 %09%09%09%7D
- 
 catch
- (Throwable ex) %7B%0A%09%09%09%09logger.error(%22Error, loading %22+key+%22/%22+fn, ex);
+(MissingResourceException mre) %7B
 %0A%09%09%09

use resourceBundle instead Properties