private static final ExpressionEngineFactory initialize(Map factoryMap) {
assert factoryMap != null;
NetUIConfig config = ConfigUtil.getConfig();
ExpressionLanguagesConfig elConfig = config.getExpressionLanguages();
assert elConfig != null;
ExpressionLanguageConfig[] els = elConfig.getExpressionLanguages();
assert els != null;
if(els != null) {
for(int i = 0; i < els.length; i++) {
String name = els[i].getName();
String className = els[i].getFactoryClass();
ExpressionEngineFactory factory = null;
try {
Class type = Class.forName(className);
factory = (ExpressionEngineFactory)type.newInstance();
} catch(ClassNotFoundException cnf) {
if(LOGGER.isWarnEnabled())
LOGGER.warn("Could not create an ExpressionEngineFactory for type \"" + className +
"\" because the implementation class could not be found.");
continue;
} catch(Exception ex) {
assert ex instanceof IllegalAccessException || ex instanceof InstantiationException;
if(LOGGER.isWarnEnabled())
LOGGER.warn("Could not create an ExpressionEngineFactory for type \"" + className +
"\" because an error occurred creating the factory. Cause: " + ex, ex);
continue;
}
if(factoryMap.containsKey(name))
if(LOGGER.isWarnEnabled())
LOGGER.warn("Overwriting a previously defined ExpressionEngineFactory named \"" + name +
"\" with a new ExpressionEngineFactory of type \"" + className + "\"");
else
LOGGER.info("Adding an ExpressionEngineFactory named \"" + name + "\" with implementation \"" + className + "\"");
factoryMap.put(name, factory);
}
}
ExpressionEngineFactory defaultEngineFactory = null;
String defaultLanguage = elConfig.getDefaultLanguage();
if(defaultLanguage != null) {
defaultEngineFactory = (ExpressionEngineFactory)factoryMap.get(defaultLanguage);
if(defaultEngineFactory != null) {
if(LOGGER.isInfoEnabled())
LOGGER.info("Using a default expression evaluator of type \"" + factoryMap.get(defaultLanguage).getClass().getName() + "\"");