protected Item loadItem(File file) throws AccessControlException {
Configuration config = getItemConfiguration(file);
String fileName = file.getName();
String id = fileName.substring(0, fileName.length() - getSuffix().length());
Item item = (Item) this.items.get(id);
String klass = ItemConfiguration.getItemClass(config);
if (item == null) {
try {
Class[] paramTypes = { ItemManager.class, Logger.class };
Constructor ctor = Class.forName(klass).getConstructor(paramTypes);
Object[] params = { this, getLogger() };
item = (Item) ctor.newInstance(params);
} catch (Exception e) {
String errorMsg = "Exception when trying to instanciate: " + klass
+ " with exception: " + e.fillInStackTrace();
// an exception occured when trying to instanciate
// a user.
getLogger().error(errorMsg);
throw new AccessControlException(errorMsg, e);
}
}
try {
item.configure(config);
} catch (ConfigurationException e) {
String errorMsg = "Exception when trying to configure: " + klass;
throw new AccessControlException(errorMsg, e);
}
return item;