try {
className = reader.readLine();
} catch (IOException e) {
Message msg = ERR_CLASS_LOADER_CANNOT_READ_MANIFEST_FILE.get(String
.valueOf(e.getMessage()));
throw new InitializationException(msg, e);
}
// Break out when the end of the manifest is reached.
if (className == null) {
break;
}
// Skip blank lines.
className = className.trim();
if (className.length() == 0) {
continue;
}
// Skip lines beginning with #.
if (className.startsWith("#")) {
continue;
}
TRACER.debugMessage(DebugLogLevel.INFO, "Loading class " + className);
// Load the class and get an instance of it if it is a definition.
Class<?> theClass;
try {
theClass = Class.forName(className, true, loader);
} catch (Exception e) {
Message msg = ERR_CLASS_LOADER_CANNOT_LOAD_CLASS.get(className, String
.valueOf(e.getMessage()));
throw new InitializationException(msg, e);
}
if (AbstractManagedObjectDefinition.class.isAssignableFrom(theClass)) {
// We need to instantiate it using its getInstance() static method.
Method method;
try {
method = theClass.getMethod("getInstance");
} catch (Exception e) {
Message msg = ERR_CLASS_LOADER_CANNOT_FIND_GET_INSTANCE_METHOD.get(
className, String.valueOf(e.getMessage()));
throw new InitializationException(msg, e);
}
// Get the definition instance.
AbstractManagedObjectDefinition<?, ?> d;
try {
d = (AbstractManagedObjectDefinition<?, ?>) method.invoke(null);
} catch (Exception e) {
Message msg = ERR_CLASS_LOADER_CANNOT_INVOKE_GET_INSTANCE_METHOD.get(
className, String.valueOf(e.getMessage()));
throw new InitializationException(msg, e);
}
definitions.add(d);
}
}
// Initialize any definitions that were loaded.
for (AbstractManagedObjectDefinition<?, ?> d : definitions) {
try {
d.initialize();
} catch (Exception e) {
Message msg = ERR_CLASS_LOADER_CANNOT_INITIALIZE_DEFN.get(d.getName(),
d.getClass().getName(), String.valueOf(e.getMessage()));
throw new InitializationException(msg, e);
}
}
}