Search in sources :

Example 1 with AppExtensionAction

use of org.openecard.addon.bind.AppExtensionAction in project open-ecard by ecsec.

the class AddonManager method getAppExtensionAction.

/**
 * Get a specific AppExtensionAction.
 *
 * @param addonSpec {@link AddonSpecification} which contains the description of the {@link AppExtensionAction}.
 * @param actionId	The {@link AppExtensionSpecification#id} to identify the requested AppExtensionAction.
 * @return The AppExtensionAction which corresponds the given {@code actionId} or NULL if no AppExtensionAction with
 * the given {@code actionId} exists.
 */
public AppExtensionAction getAppExtensionAction(@Nonnull AddonSpecification addonSpec, @Nonnull String actionId) {
    // get extension from cache
    AppExtensionAction appExtAction = cache.getAppExtensionAction(addonSpec, actionId);
    if (appExtAction != null) {
        // AppExtensionAction cached so return it
        return appExtAction;
    }
    AppExtensionSpecification protoSpec = addonSpec.searchByActionId(actionId);
    if (protoSpec == null) {
        LOG.error("Requested Extension {} does not exist in Add-on {}.", actionId, addonSpec.getId());
    } else {
        String className = protoSpec.getClassName();
        try {
            ClassLoader cl = registry.downloadAddon(addonSpec);
            AppExtensionActionProxy protoFactory = new AppExtensionActionProxy(className, cl);
            Context aCtx = createContext(addonSpec);
            protoFactory.init(aCtx);
            cache.addAppExtensionAction(addonSpec, actionId, protoFactory);
            return protoFactory;
        } catch (ActionInitializationException e) {
            LOG.error("Initialization of AppExtensionAction failed", e);
        } catch (AddonException ex) {
            LOG.error("Failed to download Add-on.", ex);
        }
    }
    return null;
}
Also used : AppExtensionAction(org.openecard.addon.bind.AppExtensionAction) AppExtensionSpecification(org.openecard.addon.manifest.AppExtensionSpecification) AppExtensionActionProxy(org.openecard.addon.bind.AppExtensionActionProxy)

Example 2 with AppExtensionAction

use of org.openecard.addon.bind.AppExtensionAction in project open-ecard by ecsec.

the class CacheTest method wrongGetOperation.

@Test
public void wrongGetOperation() {
    AppPluginActionProxy proxy = new AppPluginActionProxy(null, null);
    AddonSpecification spec = new AddonSpecification();
    String id = "test";
    spec.setId(id);
    spec.setVersion("1.0.0");
    cache.addAppPluginAction(spec, id, proxy);
    // now get it back from the cache
    AppExtensionAction proto = cache.getAppExtensionAction(spec, id);
    Assert.assertNull(proto);
}
Also used : AppExtensionAction(org.openecard.addon.bind.AppExtensionAction) AppPluginActionProxy(org.openecard.addon.bind.AppPluginActionProxy) AddonSpecification(org.openecard.addon.manifest.AddonSpecification) Test(org.testng.annotations.Test)

Example 3 with AppExtensionAction

use of org.openecard.addon.bind.AppExtensionAction 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);
}
Also used : AppExtensionAction(org.openecard.addon.bind.AppExtensionAction) AppPluginActionProxy(org.openecard.addon.bind.AppPluginActionProxy) IFDProtocolProxy(org.openecard.addon.ifd.IFDProtocolProxy) SALProtocolProxy(org.openecard.addon.sal.SALProtocolProxy) AddonSpecification(org.openecard.addon.manifest.AddonSpecification) AppExtensionActionProxy(org.openecard.addon.bind.AppExtensionActionProxy) Test(org.testng.annotations.Test)

Example 4 with AppExtensionAction

use of org.openecard.addon.bind.AppExtensionAction in project open-ecard by ecsec.

the class CacheTest method addAppExtAction.

@Test
public void addAppExtAction() {
    AppExtensionActionProxy proxy = new AppExtensionActionProxy(null, null);
    int initialHash = proxy.hashCode();
    AddonSpecification spec = new AddonSpecification();
    String id = "test";
    spec.setId(id);
    spec.setVersion("1.0.0");
    cache.addAppExtensionAction(spec, id, proxy);
    // now get it back from the cache
    AppExtensionAction proto = cache.getAppExtensionAction(spec, id);
    Assert.assertEquals(proto.hashCode(), initialHash);
}
Also used : AppExtensionAction(org.openecard.addon.bind.AppExtensionAction) AddonSpecification(org.openecard.addon.manifest.AddonSpecification) AppExtensionActionProxy(org.openecard.addon.bind.AppExtensionActionProxy) Test(org.testng.annotations.Test)

Example 5 with AppExtensionAction

use of org.openecard.addon.bind.AppExtensionAction 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);
}
Also used : AppExtensionAction(org.openecard.addon.bind.AppExtensionAction) AppPluginActionProxy(org.openecard.addon.bind.AppPluginActionProxy) IFDProtocolProxy(org.openecard.addon.ifd.IFDProtocolProxy) SALProtocolProxy(org.openecard.addon.sal.SALProtocolProxy) AddonSpecification(org.openecard.addon.manifest.AddonSpecification) AppExtensionActionProxy(org.openecard.addon.bind.AppExtensionActionProxy) AppPluginAction(org.openecard.addon.bind.AppPluginAction) Test(org.testng.annotations.Test)

Aggregations

AppExtensionAction (org.openecard.addon.bind.AppExtensionAction)5 AppExtensionActionProxy (org.openecard.addon.bind.AppExtensionActionProxy)4 AddonSpecification (org.openecard.addon.manifest.AddonSpecification)4 Test (org.testng.annotations.Test)4 AppPluginActionProxy (org.openecard.addon.bind.AppPluginActionProxy)3 IFDProtocolProxy (org.openecard.addon.ifd.IFDProtocolProxy)2 SALProtocolProxy (org.openecard.addon.sal.SALProtocolProxy)2 AppPluginAction (org.openecard.addon.bind.AppPluginAction)1 AppExtensionSpecification (org.openecard.addon.manifest.AppExtensionSpecification)1