Due to a ransomware attack, the wiki was reverted to a July 2022 version. . We apologize for the lack of a more recent valid backup.
...
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
// new imports import org.apache.felix.scr.annotations.Property; //Attention - will use below import static com.google.common.base.Strings.isNullOrEmpty; // ...<snip>... public class NullLinkProvider extends AbstractProvider implements LinkProvider { // ...<snip>... // Default values for tunable parameters private static final boolean FLICKER = false; private static final int DEFAULT_RATE = 3000; @Property(name = "flicker", boolValue = FLICKER, label = "Setting to flap links") private boolean flicker = FLICKER; @Property(name = "eventRate", intValue = DEFAULT_RATE, label = "Duration between Link Event") private int eventRate = DEFAULT_RATE; // ...<snip>... |
...
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
@Modified public boolean modified(ComponentContext context) { // if there's no file, fall back to defaults if (context == null) { log.info("No configs, using defaults: flicker={}, eventRate={}", FLICKER, DEFAULT_RATE); return false; } Dictionary<?, ?> properties = context.getProperties(); boolean flickSetting; int newRate; // try to extract values keyed on the parameters' names try { // Attention!!! properties.get() already return the object of corresponding Class Object String s = (String) properties.get("flicker"); flickSetting = isNullOrEmpty(s) == null ? flicker : (Boolean)ss.trim().equals("true"); s = properties.get("eventRate"); newRate = isNullOrEmpty(s) == null ? eventRate : (Integer)sInteger.parseInt(s.trim()); } catch (Exception e) { log.warn(e.getMessage()); flickSetting = flicker; newRate = eventRate; } if (flicker != flickSetting) { flicker = flickSetting; } // launch a LinkDriver with the new values, if they were changed if (flicker) { if (eventRate != newRate) { eventRate = newRate; } linkDriver.submit(new LinkDriver()); log.info("Using settings: flicker={}, eventRate={}", flicker, eventRate); return true; } return false; } |
...