public Module add(File jarFile) {
/* Get the error logger */
Logger logger = ModuleManager.getLogger();
/* First attempt to open the URL as a module */
Module module = null;
try {
module = ModuleFactory.open(jarFile);
} catch (java.lang.Exception excp) {
/* Log the error and return false */
logger.log(Level.WARNING, "[MODULES] PENDING Failed to Open Module "
+ jarFile, excp);
return null;
}
/* Next, see the module already exists, log warning and continue */
if (this.pendingModules.containsKey(module.getName()) == true) {
logger.log(Level.INFO, "[MODULES] PENDING Module already exists "
+ module.getName());
}
/* Add to the pending/ directory */
File file = this.addToPending(module.getName(), jarFile);
if (file == null) {
logger.log(Level.WARNING, "[MODULES] PENDING Failed to add " +
module.getName());
return null;
}
/* Re-open the module in the new directory */
try {
module = ModuleFactory.open(file);
if (logger.isLoggable(Level.FINE)) {
logger.fine("Add pending module " + module);
}
} catch (java.lang.Exception excp) {
/* Log the error and return false */
logger.log(Level.WARNING, "[MODULES] PENDING Failed to Open Module "
+ file, excp);
return null;
}
/* If successful, add to the list of pending modules */
this.pendingModules.put(module.getName(), module);
return module;
}