Search in sources :

Example 1 with DRIVER_READ

use of org.onosproject.security.AppPermission.Type.DRIVER_READ in project onos by opennetworkinglab.

the class DriverRegistryManager method getDriver.

@Override
public Driver getDriver(String mfr, String hw, String sw) {
    checkPermission(DRIVER_READ);
    // First attempt a literal search.
    Driver driver = driverByKey.get(key(mfr, hw, sw));
    if (driver != null) {
        return driver;
    }
    // Otherwise, sweep through the key space and attempt to match using
    // regular expression matching.
    Optional<Driver> optional = driverByKey.values().stream().filter(d -> matches(d, mfr, hw, sw)).findFirst();
    // If no matching driver is found, return default.
    return optional.orElse(drivers.get(DEFAULT));
}
Also used : ListenerRegistry(org.onosproject.event.ListenerRegistry) DeviceService(org.onosproject.net.device.DeviceService) ComponentContext(org.osgi.service.component.ComponentContext) LoggerFactory(org.slf4j.LoggerFactory) AppGuard.checkPermission(org.onosproject.security.AppGuard.checkPermission) Strings.isNullOrEmpty(com.google.common.base.Strings.isNullOrEmpty) DriverEvent(org.onosproject.net.driver.DriverEvent) ComponentService(org.onosproject.component.ComponentService) Component(org.osgi.service.component.annotations.Component) Behaviour(org.onosproject.net.driver.Behaviour) DriverRegistry(org.onosproject.net.driver.DriverRegistry) Map(java.util.Map) DriverProvider(org.onosproject.net.driver.DriverProvider) Activate(org.osgi.service.component.annotations.Activate) Driver(org.onosproject.net.driver.Driver) DefaultDriverProvider(org.onosproject.net.driver.DefaultDriverProvider) ComponentConfigService(org.onosproject.cfg.ComponentConfigService) DriverListener(org.onosproject.net.driver.DriverListener) Tools.get(org.onlab.util.Tools.get) ImmutableSet(com.google.common.collect.ImmutableSet) Logger(org.slf4j.Logger) Properties(java.util.Properties) Tools.nullIsNotFound(org.onlab.util.Tools.nullIsNotFound) DRIVER_REDUCED(org.onosproject.net.driver.DriverEvent.Type.DRIVER_REDUCED) Deactivate(org.osgi.service.component.annotations.Deactivate) EventDeliveryService(org.onosproject.event.EventDeliveryService) Set(java.util.Set) REQUIRED_DRIVERS_DEFAULT(org.onosproject.net.driver.impl.OsgiPropertyConstants.REQUIRED_DRIVERS_DEFAULT) DRIVER_READ(org.onosproject.security.AppPermission.Type.DRIVER_READ) REQUIRED_DRIVERS(org.onosproject.net.driver.impl.OsgiPropertyConstants.REQUIRED_DRIVERS) Maps(com.google.common.collect.Maps) Sets(com.google.common.collect.Sets) ReferenceCardinality(org.osgi.service.component.annotations.ReferenceCardinality) DRIVER_ENHANCED(org.onosproject.net.driver.DriverEvent.Type.DRIVER_ENHANCED) DriverAdminService(org.onosproject.net.driver.DriverAdminService) Modified(org.osgi.service.component.annotations.Modified) Optional(java.util.Optional) Reference(org.osgi.service.component.annotations.Reference) Dictionary(java.util.Dictionary) Driver(org.onosproject.net.driver.Driver)

Aggregations

Strings.isNullOrEmpty (com.google.common.base.Strings.isNullOrEmpty)1 ImmutableSet (com.google.common.collect.ImmutableSet)1 Maps (com.google.common.collect.Maps)1 Sets (com.google.common.collect.Sets)1 Dictionary (java.util.Dictionary)1 Map (java.util.Map)1 Optional (java.util.Optional)1 Properties (java.util.Properties)1 Set (java.util.Set)1 Tools.get (org.onlab.util.Tools.get)1 Tools.nullIsNotFound (org.onlab.util.Tools.nullIsNotFound)1 ComponentConfigService (org.onosproject.cfg.ComponentConfigService)1 ComponentService (org.onosproject.component.ComponentService)1 EventDeliveryService (org.onosproject.event.EventDeliveryService)1 ListenerRegistry (org.onosproject.event.ListenerRegistry)1 DeviceService (org.onosproject.net.device.DeviceService)1 Behaviour (org.onosproject.net.driver.Behaviour)1 DefaultDriverProvider (org.onosproject.net.driver.DefaultDriverProvider)1 Driver (org.onosproject.net.driver.Driver)1 DriverAdminService (org.onosproject.net.driver.DriverAdminService)1