Search in sources :

Example 1 with ApplicationEvent

use of org.onosproject.app.ApplicationEvent in project onos by opennetworkinglab.

the class SimpleApplicationStore method activate.

@Override
public void activate(ApplicationId appId) {
    Application app = apps.get(appId);
    if (app != null) {
        setActive(appId.name());
        states.put(appId, ACTIVE);
        delegate.notify(new ApplicationEvent(APP_ACTIVATED, app));
    }
}
Also used : ApplicationEvent(org.onosproject.app.ApplicationEvent) Application(org.onosproject.core.Application) DefaultApplication(org.onosproject.core.DefaultApplication)

Example 2 with ApplicationEvent

use of org.onosproject.app.ApplicationEvent in project onos by opennetworkinglab.

the class SimpleApplicationStore method setPermissions.

@Override
public void setPermissions(ApplicationId appId, Set<Permission> permissions) {
    Application app = getApplication(appId);
    if (app != null) {
        this.permissions.put(appId, permissions);
        delegate.notify(new ApplicationEvent(APP_PERMISSIONS_CHANGED, app));
    }
}
Also used : ApplicationEvent(org.onosproject.app.ApplicationEvent) Application(org.onosproject.core.Application) DefaultApplication(org.onosproject.core.DefaultApplication)

Example 3 with ApplicationEvent

use of org.onosproject.app.ApplicationEvent in project onos by opennetworkinglab.

the class SimpleApplicationStore method deactivate.

@Override
public void deactivate(ApplicationId appId) {
    Application app = apps.get(appId);
    if (app != null) {
        clearActive(appId.name());
        states.put(appId, INSTALLED);
        delegate.notify(new ApplicationEvent(APP_DEACTIVATED, app));
    }
}
Also used : ApplicationEvent(org.onosproject.app.ApplicationEvent) Application(org.onosproject.core.Application) DefaultApplication(org.onosproject.core.DefaultApplication)

Example 4 with ApplicationEvent

use of org.onosproject.app.ApplicationEvent in project onos by opennetworkinglab.

the class DistributedApplicationStore method setupApplicationAndNotify.

private void setupApplicationAndNotify(ApplicationId appId, Application app, InternalState state) {
    // ACTIVATED state is handled separately in NextAppToActivateValueListener
    if (state == INSTALLED) {
        fetchBitsIfNeeded(app);
        if (log.isTraceEnabled()) {
            log.trace("{} has been installed", app.id());
        }
        notifyDelegate(new ApplicationEvent(APP_INSTALLED, app));
    } else if (state == DEACTIVATED) {
        if (log.isTraceEnabled()) {
            log.trace("{} has been deactivated", app.id());
        }
        clearActive(appId.name());
        notifyDelegate(new ApplicationEvent(APP_DEACTIVATED, app));
        localStartedApps.remove(appId.name());
    }
}
Also used : ApplicationEvent(org.onosproject.app.ApplicationEvent)

Example 5 with ApplicationEvent

use of org.onosproject.app.ApplicationEvent in project onos by opennetworkinglab.

the class DistributedApplicationStore method setPermissions.

@Override
public void setPermissions(ApplicationId appId, Set<Permission> permissions) {
    AtomicBoolean permissionsChanged = new AtomicBoolean(false);
    Versioned<InternalApplicationHolder> appHolder = apps.computeIf(appId, v -> v != null && !Sets.symmetricDifference(v.permissions(), permissions).isEmpty(), (k, v) -> {
        permissionsChanged.set(true);
        return new InternalApplicationHolder(v.app(), v.state(), ImmutableSet.copyOf(permissions));
    });
    if (permissionsChanged.get()) {
        if (log.isTraceEnabled()) {
            log.trace("Permission changed for {}", appId);
        }
        notifyDelegate(new ApplicationEvent(APP_PERMISSIONS_CHANGED, appHolder.value().app()));
    }
}
Also used : AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) ApplicationEvent(org.onosproject.app.ApplicationEvent)

Aggregations

ApplicationEvent (org.onosproject.app.ApplicationEvent)8 DefaultApplication (org.onosproject.core.DefaultApplication)6 Application (org.onosproject.core.Application)5 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)2 ApplicationDescription (org.onosproject.app.ApplicationDescription)2 ApplicationId (org.onosproject.core.ApplicationId)2 Charsets (com.google.common.base.Charsets)1 MoreObjects (com.google.common.base.MoreObjects)1 Preconditions (com.google.common.base.Preconditions)1 Throwables (com.google.common.base.Throwables)1 ImmutableSet (com.google.common.collect.ImmutableSet)1 Lists (com.google.common.collect.Lists)1 Maps (com.google.common.collect.Maps)1 Multimap (com.google.common.collect.Multimap)1 Multimaps.newSetMultimap (com.google.common.collect.Multimaps.newSetMultimap)1 Multimaps.synchronizedSetMultimap (com.google.common.collect.Multimaps.synchronizedSetMultimap)1 Sets (com.google.common.collect.Sets)1 ByteStreams.toByteArray (com.google.common.io.ByteStreams.toByteArray)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 IOException (java.io.IOException)1