{
if( key == null )
return getDefaultFactory();
// Already loaded ?
DefinitionsFactory factory = (DefinitionsFactory)loaded.get( key );
if( factory != null )
{ // yes, stop loading
return factory;
} // end if
// Try to load file associated to key. If fail, stop and return default factory.
XmlDefinitionsSet lastXmlFile = parseXmlKeyFile( servletContext, "_" + (String)key, null );
if( lastXmlFile == null )
{
if( DefinitionsUtil.userDebugLevel > DefinitionsUtil.NO_DEBUG )
System.out.println( "Warning : No definition factory associated to key '"
+ key + "'. Use default factory instead." );
factory = getDefaultFactory();
loaded.put( key, factory );
return factory;
} // end if
// Parse default file, and add key file.
XmlDefinitionsSet rootXmlConfig = parseXmlKeyFile( servletContext, "", null );
rootXmlConfig.extend(lastXmlFile);
rootXmlConfig.resolveInheritances();
factory = new DefinitionsFactory(rootXmlConfig);
loaded.put( key, factory );
// User help
if( DefinitionsUtil.userDebugLevel > DefinitionsUtil.NO_DEBUG )
System.out.println( factory );
// return last available found !