/* * Decompiled with CFR 0.152. * * Could not load the following classes: * javax.baja.nre.util.SortUtil */ package com.tridium.sys.engine; import com.tridium.sys.Nre; import java.util.ArrayList; import java.util.HashMap; import javax.baja.log.Log; import javax.baja.nre.util.SortUtil; import javax.baja.spy.SpyDir; import javax.baja.spy.SpyWriter; import javax.baja.sys.BComponent; import javax.baja.sys.BComponentEvent; import javax.baja.sys.BasicContext; import javax.baja.sys.Clock; import javax.baja.sys.Context; import javax.baja.sys.Subscriber; /* * Illegal identifiers - consider using --renameillegalidents true */ public class LeaseManager { static final Log log = Log.getLog("sys.lease"); HashMap map; public final Subscriber subscriber; public long getLeaseExpiration(BComponent bComponent) { Entry entry = (Entry)this.map.get(bComponent); if (entry == null) { return -1; } return entry.expiration; } public void lease(BComponent bComponent, int n, long l) { this.subscriber.subscribe(bComponent, n, (Context)new LeaseContext(l)); } public void lease(BComponent[] bComponentArray, int n, long l) { this.subscriber.subscribe(bComponentArray, n, (Context)new LeaseContext(l)); } /* * WARNING - Removed try catching itself - possible behaviour change. * Enabled aggressive block sorting * Enabled unnecessary exception pruning * Enabled aggressive exception aggregation */ void checkLease(BComponent bComponent, LeaseContext leaseContext) { HashMap hashMap = this.map; synchronized (hashMap) { block6: { Entry entry; block5: { entry = (Entry)this.map.get(bComponent); if (entry != null) break block5; entry = new Entry(); entry.component = bComponent; entry.expiration = leaseContext.expiration; this.map.put(bComponent, entry); if (log.isTraceOn()) { log.trace("Lease new: " + bComponent.toPathString() + ' ' + leaseContext.millis + "ms"); } break block6; } entry.expiration = Math.max(entry.expiration, leaseContext.expiration); if (log.isTraceOn()) { log.trace("Lease renew: " + bComponent.toPathString() + ' ' + leaseContext.millis + "ms"); } } return; } } public void postInit() { Nre.spySysManagers.add("leaseManager", new SummaryPage()); } private final /* synthetic */ void this() { this.map = new HashMap(); this.subscriber = new LeaseSubscriber(); } public LeaseManager() { this.this(); new LeaseThread().start(); } static class Entry { BComponent component; long expiration; Entry() { } } static class LeaseContext extends BasicContext { long millis; long expiration; LeaseContext(long l) { this.millis = l; this.expiration = Clock.ticks() + l; } } /* * Illegal identifiers - consider using --renameillegalidents true */ public class SummaryPage extends SpyDir { public void write(SpyWriter spyWriter) throws Exception { Object[] objectArray = LeaseManager.this.map.values().toArray(new Entry[LeaseManager.this.map.size()]); Object[] objectArray2 = new String[objectArray.length]; int n = 0; while (n < objectArray2.length) { objectArray2[n] = "" + ((Entry)objectArray[n]).component.getNavOrd(); ++n; } SortUtil.sort((Object[])objectArray2, (Object[])objectArray); spyWriter.startTable(true); spyWriter.trTitle("Lease Manager", 3); spyWriter.w("