2026-03-17 13:31:18 -07:00

308 lines
10 KiB
Java

/*
* Decompiled with CFR 0.152.
*
* Could not load the following classes:
* javax.baja.nre.util.Array
*/
package javax.baja.sys;
import com.tridium.sys.schema.ComponentSlotMap;
import com.tridium.util.ObjectUtil;
import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;
import javax.baja.naming.BOrd;
import javax.baja.naming.BatchResolve;
import javax.baja.nre.util.Array;
import javax.baja.space.BComponentSpace;
import javax.baja.spy.SpyWriter;
import javax.baja.sys.BComponent;
import javax.baja.sys.BComponentEvent;
import javax.baja.sys.BComponentEventMask;
import javax.baja.sys.BObject;
import javax.baja.sys.Context;
/*
* Illegal identifiers - consider using --renameillegalidents true
*/
public abstract class Subscriber {
private HashMap subscriptions;
private BComponentEventMask mask;
static /* synthetic */ Class class$javax$baja$sys$BComponent;
public final synchronized boolean isSubscribed(BComponent bComponent) {
boolean bl = false;
if (this.subscriptions.get(bComponent) != null) {
bl = true;
}
return bl;
}
public final synchronized boolean isSubscribed(BComponent[] bComponentArray) {
int n = 0;
while (n < bComponentArray.length) {
if (this.subscriptions.get(bComponentArray[n]) == null) {
return false;
}
++n;
}
return true;
}
public final int getSubscriptionCount() {
return this.subscriptions.size();
}
public final synchronized BComponent[] getSubscriptions() {
Collection collection = this.subscriptions.values();
return collection.toArray(new BComponent[collection.size()]);
}
public final synchronized void subscribe(BComponent bComponent) {
this.subscribe(bComponent, 0, null);
}
public final synchronized void subscribe(BComponent bComponent, int n) {
this.subscribe(bComponent, n, null);
}
public final synchronized void subscribe(BComponent bComponent, int n, Context context) {
this.subscribe(new BComponent[]{bComponent}, n, context);
}
/*
* WARNING - Removed back jump from a try to a catch block - possible behaviour change.
* Unable to fully structure code
* Enabled aggressive block sorting
* Enabled unnecessary exception pruning
* Enabled aggressive exception aggregation
*/
public final synchronized void subscribe(BComponent[] var1_1, int var2_2, Context var3_3) {
if (var1_1.length == 0) {
return;
}
try {
var7_4 = 0;
while (true) {
block10: {
if (var7_4 < var1_1.length) break block10;
this.updateSpaceSubscription(var1_1, true, var2_2);
this.doSubscribe(var1_1, var2_2, var3_3);
** GOTO lbl-1000
}
if (this.subscriptions.get(var1_1[var7_4]) == null) {
((ComponentSlotMap)var1_1[var7_4].getSlotMap()).setPendingSubscribe(this);
}
++var7_4;
}
}
catch (Throwable var4_5) {
var5_6 = null;
var6_8 = 0;
}
while (true) {
if (var6_8 >= var1_1.length) {
throw var4_5;
}
((ComponentSlotMap)var1_1[var6_8].getSlotMap()).clearPendingSubscribe(this);
++var6_8;
}
lbl-1000:
// 1 sources
{
var5_7 = null;
var6_9 = 0;
}
while (true) {
if (var6_9 >= var1_1.length) {
return;
}
((ComponentSlotMap)var1_1[var6_9].getSlotMap()).clearPendingSubscribe(this);
++var6_9;
}
}
public final BComponent[] subscribe(BComponentSpace bComponentSpace, BOrd[] bOrdArray, int n, Context context) {
BatchResolve batchResolve = new BatchResolve(bOrdArray).resolve(bComponentSpace, context);
BComponent[] bComponentArray = new BComponent[bOrdArray.length];
int n2 = 0;
while (n2 < bComponentArray.length) {
bComponentArray[n2] = (BComponent)batchResolve.get(n2);
++n2;
}
this.subscribe(bComponentArray, n, context);
return bComponentArray;
}
private final void doSubscribe(BComponent[] bComponentArray, int n, Context context) {
int n2 = 0;
while (n2 < bComponentArray.length) {
this.doSubscribe(bComponentArray[n2], n, context);
++n2;
}
}
private final void doSubscribe(BComponent bComponent, int n, Context context) {
if (this.subscriptions.get(bComponent) == null) {
this.subscriptions.put(bComponent, bComponent);
((ComponentSlotMap)bComponent.getSlotMap()).subscribe(this);
}
try {
this.subscribed(bComponent, context);
}
catch (Throwable throwable) {
throwable.printStackTrace();
}
if (n > 0) {
bComponent.loadSlots();
BComponent[] bComponentArray = bComponent.getChildComponents();
int n2 = 0;
while (n2 < bComponentArray.length) {
this.doSubscribe(bComponentArray[n2], n - 1, context);
++n2;
}
}
}
public final synchronized void unsubscribe(BComponent bComponent) {
this.unsubscribe(bComponent, null);
}
public final synchronized void unsubscribe(BComponent bComponent, Context context) {
this.unsubscribe(new BComponent[]{bComponent}, context);
}
public final synchronized void unsubscribe(BComponent[] bComponentArray, Context context) {
if (bComponentArray.length == 0) {
return;
}
this.doUnsubscribe(bComponentArray, context);
}
public final synchronized void unsubscribeAll() {
this.unsubscribe(this.getSubscriptions(), null);
}
private final void doUnsubscribe(BComponent[] bComponentArray, Context context) {
int n = 0;
while (n < bComponentArray.length) {
if (this.isSubscribed(bComponentArray[n])) {
this.subscriptions.remove(bComponentArray[n]);
((ComponentSlotMap)bComponentArray[n].getSlotMap()).unsubscribe(this);
}
++n;
}
this.updateSpaceSubscription(bComponentArray, false, 0);
n = 0;
while (n < bComponentArray.length) {
try {
this.unsubscribed(bComponentArray[n], context);
}
catch (Throwable throwable) {
throwable.printStackTrace();
}
++n;
}
}
private final void updateSpaceSubscription(BComponent[] bComponentArray, boolean bl, int n) {
BComponentSpace bComponentSpace;
BObject bObject;
HashMap<BComponentSpace, Array> hashMap = new HashMap<BComponentSpace, Array>();
int n2 = 0;
while (n2 < bComponentArray.length) {
bObject = bComponentArray[n2];
if (bl || !((BComponent)bObject).isSubscribed()) {
bComponentSpace = ((BComponent)bObject).getComponentSpace();
Array array = (Array)hashMap.get(bComponentSpace);
if (array == null) {
Class clazz = class$javax$baja$sys$BComponent;
if (clazz == null) {
clazz = Subscriber.class("[Ljavax.baja.sys.BComponent;", false);
}
array = new Array(clazz);
hashMap.put(bComponentSpace, array);
}
array.add((Object)bObject);
}
++n2;
}
Iterator iterator = hashMap.keySet().iterator();
while (iterator.hasNext()) {
bObject = (BComponentSpace)iterator.next();
if (bObject == null) continue;
bComponentSpace = (Array)hashMap.get(bObject);
if (bl) {
((BComponentSpace)bObject).getSubscribeCallbacks().subscribe((BComponent[])bComponentSpace.trim(), n);
continue;
}
((BComponentSpace)bObject).getSubscribeCallbacks().unsubscribe((BComponent[])bComponentSpace.trim());
}
}
public final BComponentEventMask getMask() {
return this.mask;
}
public final void setMask(BComponentEventMask bComponentEventMask) {
this.mask = bComponentEventMask;
}
public abstract void event(BComponentEvent var1);
protected void subscribed(BComponent bComponent, Context context) {
}
protected void unsubscribed(BComponent bComponent, Context context) {
}
public synchronized void gc() {
int n = 0;
BComponent[] bComponentArray = this.getSubscriptions();
int n2 = 0;
while (n2 < bComponentArray.length) {
if (!bComponentArray[n2].isMounted()) {
this.unsubscribe(bComponentArray[n2], null);
++n;
}
++n2;
}
}
public void spy(SpyWriter spyWriter) {
spyWriter.startTable(true);
BComponent[] bComponentArray = this.getSubscriptions();
spyWriter.trTitle("Subscriptions (" + bComponentArray.length + " Components)", 1);
int n = 0;
while (n < bComponentArray.length) {
spyWriter.tr("<a href='" + ObjectUtil.toSpyRelative(bComponentArray[n]) + "'>" + bComponentArray[n].toPathString() + "</a>");
++n;
}
spyWriter.endTable();
}
static /* synthetic */ Class class(String string, boolean bl) {
try {
Class<?> clazz = Class.forName(string);
if (!bl) {
clazz = clazz.getComponentType();
}
return clazz;
}
catch (ClassNotFoundException classNotFoundException) {
throw new NoClassDefFoundError(classNotFoundException.getMessage());
}
}
private final /* synthetic */ void this() {
this.subscriptions = new HashMap();
this.mask = BComponentEventMask.PROPERTY_EVENTS;
}
public Subscriber() {
this.this();
}
}