/* Dump some debugging information, just in case */
this.logger.debug("Configuring schema parser " + selectionKey + " as "
+ className + " from " + configuration.getLocation());
/* Try to load and instantiate the SchemaParser */
final SchemaParser schemaParser;
try {
/* Load the class */
final Class clazz = Class.forName(className);
/* ClassCastExceptions normally don't come with messages (darn) */
if (! SchemaParser.class.isAssignableFrom(clazz)) {
String message = "Class " + className + " doesn't implement the "
+ SchemaParser.class.getName() + " interface";
throw new ConfigurationException(message, configuration);
}
/* We only support ThreadSafe SchemaParser instances */
if (! ThreadSafe.class.isAssignableFrom(clazz)) {
String message = "Class " + className + " doesn't implement the "
+ ThreadSafe.class.getName() + " interface";
throw new ConfigurationException(message, configuration);
}
/* Instantiate and set up the new SchemaParser */
schemaParser = (SchemaParser) clazz.newInstance();
this.setupComponent(selectionKey, schemaParser, configuration);
} catch (ConfigurationException exception) {
throw exception;
} catch (Exception exception) {
String message = "Unable to instantiate SchemaParser " + className;
throw new ConfigurationException(message, configuration, exception);
}
/* Store this instance (and report about it) */
this.components.put(selectionKey, schemaParser);
this.logger.debug("SchemaParser \"" + selectionKey + "\" instantiated" +
" from class " + className);
/* Analyze the grammars provided by the current SchemaParser */
String grammars[] = schemaParser.getSupportedGrammars();
if (grammars == null) continue;
/* Iterate through the grammars and store them (default lookup) */
for (int k = 0; k < grammars.length; k++) {
if (this.grammars.containsKey(grammars[k])) {