use of org.openecard.addon.manifest.AddonSpecification in project open-ecard by ecsec.
the class AddonFileSystemMonitor method extractSpec.
private AddonSpecification extractSpec(Path file) throws WSMarshallerException, MultipleAddonRegistration {
if (isJarFile(file, true)) {
// now check if there is a manifest
ManifestExtractor mfEx = new ManifestExtractor();
AddonSpecification spec = mfEx.getAddonSpecificationFromFile(file.toFile());
// return the manifest if a valid addon file was found
if (spec != null) {
Set<AddonSpecification> plugins = fileRegistry.listAddons();
// TODO: this is in general a problem, because it may replace the addon on next start
for (AddonSpecification desc : plugins) {
if (desc.getId().equals(spec.getId())) {
String msg = String.format("The addon with id %s is already registered.", desc.getId());
logger.debug("Addon '{}' is already registered by another bundle.", file.toFile().getName());
throw new MultipleAddonRegistration(msg, spec);
}
}
return spec;
}
}
return null;
}
use of org.openecard.addon.manifest.AddonSpecification in project open-ecard by ecsec.
the class AddonFileSystemMonitor method addAddon.
private void addAddon(Path file) throws WSMarshallerException {
logger.info("Trying to register addon {}.", file.getFileName());
String fName = file.toFile().getName();
try {
AddonSpecification spec = extractSpec(file);
if (spec != null) {
fileRegistry.register(spec, file.toFile());
manager.loadLoadOnStartupActions(spec);
logger.info("Successfully registered {} as addon.", fName);
} else {
logger.error("The jar file {} does not seem to be an add-on.", fName);
}
} catch (MultipleAddonRegistration ex) {
logger.error("The jar file {} is an already registered add-on.", fName);
}
}
use of org.openecard.addon.manifest.AddonSpecification in project open-ecard by ecsec.
the class AddonFileSystemMonitor method removeAddon.
private void removeAddon(Path file) {
logger.info("Trying to remove addon {}.", file.getFileName());
// check if we are dealing with a registered jar file
AddonSpecification spec = getCurrentSpec(file);
if (spec != null) {
// call the destroy method of all actions and protocols
manager.unloadAddon(spec);
// remove configuration file
AddonProperties addonProps = new AddonProperties(spec);
addonProps.removeConfiguration();
// remove from file registry
fileRegistry.unregister(file.toFile());
logger.info("Succesfully removed add-on {}.", file.toFile().getName());
}
}
use of org.openecard.addon.manifest.AddonSpecification in project open-ecard by ecsec.
the class AddonSelector method getIFDProtocol.
public IFDProtocol getIFDProtocol(@Nonnull String uri) throws AddonNotFoundException {
Set<AddonSpecification> addons = manager.getRegistry().searchIFDProtocol(uri);
if (addons.isEmpty()) {
throw new AddonNotFoundException("No Add-on for IFD protocol '" + uri + "' found.");
}
AddonSpecification addon = strategy.select(addons);
return manager.getIFDProtocol(addon, uri);
}
use of org.openecard.addon.manifest.AddonSpecification in project open-ecard by ecsec.
the class AddonSelector method getAppExtensionAction.
public AppExtensionAction getAppExtensionAction(@Nonnull String actionId) throws AddonNotFoundException {
Set<AddonSpecification> addons = manager.getRegistry().searchByActionId(actionId);
if (addons.isEmpty()) {
throw new AddonNotFoundException("No Add-on for action ID '" + actionId + "' found.");
}
AddonSpecification addon = strategy.select(addons);
return manager.getAppExtensionAction(addon, actionId);
}
Aggregations