public static List getConfiguredValue()

in core/api/src/main/java/org/apache/myfaces/extensions/cdi/core/api/util/ConfigUtils.java [52:183]


    public static List<String> getConfiguredValue(String key)
    {
        List<String> result = new ArrayList<String>();
        Map<String, String> cache = getPropertyCache();

        String configKey = key;

        int endOfPrefixIndex = key.indexOf(".");
        if(endOfPrefixIndex > -1)
        {
            configKey = key.substring(endOfPrefixIndex + 1);
        }
        else
        {
            endOfPrefixIndex = 0;
        }

        String configuredValue = cache.get(key);

        if(configuredValue == null)
        {
            configuredValue = cache.get(configKey);
        }

        if("".equals(configuredValue))
        {
            return Collections.emptyList();
        }

        if(configuredValue != null)
        {
            result.add(configuredValue);
        }
        else
        {
            String bundleName;

            //TODO
            if (key.contains("@") && key.lastIndexOf("@") < endOfPrefixIndex)
            {
                bundleName = key.substring(0, key.indexOf("."));
                bundleName = bundleName.replace("@", ".");
            }
            else
            {
                bundleName = BASE_NAME + key.substring(0, endOfPrefixIndex);
            }

            ResourceBundle resourceBundle;

            try
            {
                try
                {
                    resourceBundle = ResourceBundle
                            .getBundle(bundleName, Locale.getDefault(), ClassUtils.getClassLoader(null));
                }
                //fallback - see EXTCDI-268
                catch (MissingResourceException e)
                {
                    try
                    {
                        resourceBundle = ResourceBundle
                                .getBundle(bundleName, Locale.getDefault(), ConfigUtils.class.getClassLoader());
                    }
                    catch (MissingResourceException e2)
                    {
                        resourceBundle = null;
                    }
                }

                if (resourceBundle == null)
                {
                    try
                    {
                        resourceBundle = ResourceBundle.getBundle(FILE_NAME);
                    }
                    //fallback - see EXTCDI-268
                    catch (MissingResourceException e2)
                    {
                        try
                        {
                            resourceBundle = ResourceBundle
                                    .getBundle(FILE_NAME, Locale.getDefault(), ConfigUtils.class.getClassLoader());
                        }
                        catch (MissingResourceException e3)
                        {
                            resourceBundle = null;
                        }
                    }
                }

                if (resourceBundle != null)
                {
                    try
                    {
                        configuredValue = resourceBundle.getString(configKey);
                        result.add(configuredValue);
                        cache.put(configKey, configuredValue);
                    }
                    catch (MissingResourceException e)
                    {
                        resourceBundle = null;
                    }
                }

                if (resourceBundle == null)
                {
                    Properties properties = getProperties("META-INF/" + FILE_NAME + ".properties");

                    if (properties != null)
                    {
                        configuredValue = properties.getProperty(configKey);
                        result.add(configuredValue);
                        cache.put(configKey, configuredValue);
                    }
                }

                if (configuredValue == null)
                {
                    cache.put(configKey, "");
                    return Collections.emptyList();
                }
            }
            catch (Exception e)
            {
                cache.put(configKey, "");
                return Collections.emptyList();
            }
        }
        return result;
    }