use of org.openecard.addon.sal.SALProtocolProxy in project open-ecard by ecsec.
the class AddonManager method getSALProtocol.
/**
* Get a specific SALProtocol.
*
* @param addonSpec {@link AddonSpecification} which contains the description of the {@link SALProtocol}.
* @param uri The {@link ProtocolPluginSpecification#uri} to identify the requested SALProtocol.
* @return The requested SALProtocol object or NULL if no such object was found.
*/
public SALProtocol getSALProtocol(@Nonnull AddonSpecification addonSpec, @Nonnull String uri) {
SALProtocol salProt = cache.getSALProtocol(addonSpec, uri);
// TODO: find a better way to deal with the reuse of protocol plugins
// if (salProt != null) {
// // protocol cached so return it
// return salProt;
// }
ProtocolPluginSpecification protoSpec = addonSpec.searchSALActionByURI(uri);
if (protoSpec == null) {
LOG.error("Requested SAL Protocol {} does not exist in Add-on {}.", uri, addonSpec.getId());
} else {
String className = protoSpec.getClassName();
try {
ClassLoader cl = registry.downloadAddon(addonSpec);
SALProtocolProxy protoFactory = new SALProtocolProxy(className, cl);
Context aCtx = createContext(addonSpec);
protoFactory.init(aCtx);
cache.addSALProtocol(addonSpec, uri, protoFactory);
return protoFactory;
} catch (ActionInitializationException e) {
LOG.error("Initialization of SAL Protocol failed", e);
} catch (AddonException ex) {
LOG.error("Failed to download Add-on.", ex);
}
}
return null;
}
use of org.openecard.addon.sal.SALProtocolProxy in project open-ecard by ecsec.
the class CacheTest method addWithFilledCache.
@Test
public void addWithFilledCache() {
SALProtocolProxy proxy4 = new SALProtocolProxy(null, null);
AddonSpecification spec4 = new AddonSpecification();
String id4 = "test4";
spec4.setId(id4);
spec4.setVersion("1.0.0");
cache.addSALProtocol(spec4, id4, proxy4);
IFDProtocolProxy proxy3 = new IFDProtocolProxy(null, null);
AddonSpecification spec2 = new AddonSpecification();
String id1 = "test1";
spec2.setId(id1);
spec2.setVersion("1.0.0");
cache.addIFDProtocol(spec2, id1, proxy3);
AppPluginActionProxy proxy = new AppPluginActionProxy(null, null);
AddonSpecification spec1 = new AddonSpecification();
String id0 = "test2";
spec1.setId(id0);
spec1.setVersion("1.0.0");
cache.addAppPluginAction(spec1, id0, proxy);
AppExtensionActionProxy proxy2 = new AppExtensionActionProxy(null, null);
int initialHash = proxy2.hashCode();
AddonSpecification spec = new AddonSpecification();
String id = "test";
spec.setId(id);
spec.setVersion("1.0.0");
cache.addAppExtensionAction(spec, id, proxy2);
// now get it back from the cache
AppExtensionAction proto = cache.getAppExtensionAction(spec, id);
Assert.assertEquals(proto.hashCode(), initialHash);
}
use of org.openecard.addon.sal.SALProtocolProxy in project open-ecard by ecsec.
the class CacheTest method addSALProtocol.
@Test
public void addSALProtocol() {
SALProtocolProxy proxy = new SALProtocolProxy(null, null);
int initialHash = proxy.hashCode();
AddonSpecification spec = new AddonSpecification();
String id = "test";
spec.setId(id);
spec.setVersion("1.0.0");
cache.addSALProtocol(spec, id, proxy);
// now get it back from the cache
SALProtocol proto = cache.getSALProtocol(spec, id);
Assert.assertEquals(proto.hashCode(), initialHash);
}
use of org.openecard.addon.sal.SALProtocolProxy in project open-ecard by ecsec.
the class CacheTest method removeMulti.
@Test
public void removeMulti() {
SALProtocolProxy proxy4 = new SALProtocolProxy(null, null);
AddonSpecification spec4 = new AddonSpecification();
String id4 = "test4";
spec4.setId(id4);
spec4.setVersion("1.0.0");
cache.addSALProtocol(spec4, id4, proxy4);
IFDProtocolProxy proxy3 = new IFDProtocolProxy(null, null);
AddonSpecification spec2 = new AddonSpecification();
String id1 = "test1";
spec2.setId(id1);
spec2.setVersion("1.0.0");
cache.addIFDProtocol(spec2, id1, proxy3);
AppPluginActionProxy proxy = new AppPluginActionProxy(null, null);
AddonSpecification spec1 = new AddonSpecification();
String id0 = "test2";
spec1.setId(id0);
spec1.setVersion("1.0.0");
cache.addAppPluginAction(spec1, id0, proxy);
AppExtensionActionProxy proxy2 = new AppExtensionActionProxy(null, null);
AddonSpecification spec = new AddonSpecification();
String id = "test";
spec.setId(id);
spec.setVersion("1.0.0");
cache.addAppExtensionAction(spec, id, proxy2);
cache.removeCacheEntry(spec, id);
cache.removeCacheEntry(spec1, id0);
// now get it back from the cache
AppExtensionAction proto = cache.getAppExtensionAction(spec, id);
AppPluginAction action = cache.getAppPluginAction(spec1, id0);
Assert.assertNull(proto);
Assert.assertNull(action);
}
Aggregations