niagara-ax/modules/cfr_output/com/tridium/fox/sys/broker/BFoxComponentSpace.java
2026-03-17 13:31:18 -07:00

564 lines
19 KiB
Java

/*
* Decompiled with CFR 0.152.
*
* Could not load the following classes:
* com.tridium.sys.schema.ComponentSlotMap
* com.tridium.sys.transfer.DeleteOp
* com.tridium.sys.transfer.RemoteTransferSpace
* com.tridium.sys.transfer.TransferResult
* com.tridium.sys.transfer.TransferStrategy
* javax.baja.log.Log
* javax.baja.naming.BOrd
* javax.baja.naming.OrdQuery
* javax.baja.naming.SlotPath
* javax.baja.naming.UnresolvedException
* javax.baja.net.NotConnectedException
* javax.baja.nre.util.Array
* javax.baja.space.BComponentSpace
* javax.baja.space.LoadCallbacks
* javax.baja.space.SubscribeCallbacks
* javax.baja.space.TrapCallbacks
* javax.baja.spy.SpyWriter
* javax.baja.sync.BProxyComponentSpace
* javax.baja.sync.SyncBuffer
* javax.baja.sync.SyncOp
* javax.baja.sync.Transaction
* javax.baja.sync.TrapToSyncBuffer
* javax.baja.sys.Action
* javax.baja.sys.ActionInvokeException
* javax.baja.sys.BAbsTime
* javax.baja.sys.BComplex
* javax.baja.sys.BComponent
* javax.baja.sys.BObject
* javax.baja.sys.BValue
* javax.baja.sys.Clock
* javax.baja.sys.Context
* javax.baja.sys.CopyHints
* javax.baja.sys.Property
* javax.baja.sys.Slot
* javax.baja.sys.Sys
* javax.baja.sys.Type
* javax.baja.util.LexiconText
* javax.baja.virtual.BVirtualComponent
* javax.baja.virtual.VirtualPath
*/
package com.tridium.fox.sys.broker;
import com.tridium.fox.sys.BFoxChannelRegistry;
import com.tridium.fox.sys.BFoxSession;
import com.tridium.fox.sys.BIFoxProxySpace;
import com.tridium.fox.sys.broker.BBrokerChannel;
import com.tridium.sys.schema.ComponentSlotMap;
import com.tridium.sys.transfer.DeleteOp;
import com.tridium.sys.transfer.RemoteTransferSpace;
import com.tridium.sys.transfer.TransferResult;
import com.tridium.sys.transfer.TransferStrategy;
import java.util.HashMap;
import java.util.Iterator;
import javax.baja.log.Log;
import javax.baja.naming.BOrd;
import javax.baja.naming.OrdQuery;
import javax.baja.naming.SlotPath;
import javax.baja.naming.UnresolvedException;
import javax.baja.net.NotConnectedException;
import javax.baja.nre.util.Array;
import javax.baja.space.BComponentSpace;
import javax.baja.space.LoadCallbacks;
import javax.baja.space.SubscribeCallbacks;
import javax.baja.space.TrapCallbacks;
import javax.baja.spy.SpyWriter;
import javax.baja.sync.BProxyComponentSpace;
import javax.baja.sync.SyncBuffer;
import javax.baja.sync.SyncOp;
import javax.baja.sync.Transaction;
import javax.baja.sync.TrapToSyncBuffer;
import javax.baja.sys.Action;
import javax.baja.sys.ActionInvokeException;
import javax.baja.sys.BAbsTime;
import javax.baja.sys.BComplex;
import javax.baja.sys.BComponent;
import javax.baja.sys.BObject;
import javax.baja.sys.BValue;
import javax.baja.sys.Clock;
import javax.baja.sys.Context;
import javax.baja.sys.CopyHints;
import javax.baja.sys.Property;
import javax.baja.sys.Slot;
import javax.baja.sys.Sys;
import javax.baja.sys.Type;
import javax.baja.util.LexiconText;
import javax.baja.virtual.BVirtualComponent;
import javax.baja.virtual.VirtualPath;
/*
* Illegal identifiers - consider using --renameillegalidents true
*/
public abstract class BFoxComponentSpace
extends BProxyComponentSpace
implements RemoteTransferSpace,
BIFoxProxySpace {
public static final Type TYPE;
public static final Log log;
BBrokerChannel channel;
HashMap subscribed;
boolean spaceReadonly;
long defaultLeaseTime;
static /* synthetic */ Class class$com$tridium$fox$sys$broker$BFoxComponentSpace;
static /* synthetic */ Class class$java$lang$String;
static /* synthetic */ Class class$javax$baja$sys$BComponent;
public Type getType() {
return TYPE;
}
public void init(BFoxSession bFoxSession) throws Exception {
BFoxChannelRegistry bFoxChannelRegistry = bFoxSession.getConnection().getChannels();
this.channel = bFoxChannelRegistry.getSysChannel().makeBrokerChannel(this);
}
public void cleanup(BFoxSession bFoxSession) throws Exception {
BFoxChannelRegistry bFoxChannelRegistry = bFoxSession.getConnection().getChannels();
this.channel.cleanupClient();
bFoxChannelRegistry.remove(this.channel.getPropertyInParent());
this.channel = null;
}
public boolean isSpaceReadonly() {
return this.spaceReadonly;
}
public long getDefaultLeaseTime() {
return this.defaultLeaseTime;
}
protected BComponent loadByHandle(Object object) {
SlotPath slotPath = this.handleToSlotPath(object);
if (slotPath == null) {
throw new UnresolvedException(String.valueOf(object));
}
try {
return (BComponent)BOrd.make((OrdQuery)slotPath).get((BObject)this);
}
catch (Throwable throwable) {
log.error("loadByHandle(" + object + "): " + throwable);
throw BFoxSession.toException(throwable);
}
}
public SlotPath handleToSlotPath(Object object) {
SlotPath slotPath = super.handleToSlotPath(object);
if (slotPath != null) {
return slotPath;
}
try {
return this.channel().handleToPath(new Object[]{object})[0];
}
catch (Throwable throwable) {
log.error("handleToSlotPath(" + object + "): " + throwable);
throw BFoxSession.toException(throwable);
}
}
public SlotPath[] handlesToSlotPaths(Object[] objectArray) {
boolean bl = true;
SlotPath[] slotPathArray = new SlotPath[objectArray.length];
int n = 0;
while (n < slotPathArray.length) {
slotPathArray[n] = super.handleToSlotPath(objectArray[n]);
if (slotPathArray[n] == null) {
bl = false;
break;
}
++n;
}
if (bl) {
return slotPathArray;
}
try {
return this.channel().handleToPath(objectArray);
}
catch (Throwable throwable) {
log.error("handlesToSlotPaths(" + objectArray.length + "): " + throwable);
throw BFoxSession.toException(throwable);
}
}
public Object fw(int n, Object object, Object object2, Object object3, Object object4) {
switch (n) {
case 103: {
return this.generateHandles((Integer)object);
}
case 104: {
this.ensureLoaded((SlotPath[])object);
return null;
}
case 106: {
return this.delete((DeleteOp)object, false);
}
case 107: {
return this.delete((DeleteOp)object, true);
}
case 109: {
return this.rpc((BComponent)object, (String)object2, (BValue)object3);
}
}
return super.fw(n, object, object2, object3, object4);
}
private final Object[] generateHandles(int n) {
try {
return this.channel().generateHandles(n);
}
catch (Throwable throwable) {
log.error("generateHandles(): " + throwable);
throw BFoxSession.toException(throwable);
}
}
private final DeleteOp delete(DeleteOp deleteOp, boolean bl) {
try {
deleteOp = this.channel().delete(deleteOp, bl);
this.sync();
return deleteOp;
}
catch (Throwable throwable) {
log.error("deleteOp(): " + throwable);
throw BFoxSession.toException(throwable);
}
}
private final BValue rpc(BComponent bComponent, String string, BValue bValue) {
try {
return this.channel().rpc(bComponent, string, bValue);
}
catch (Throwable throwable) {
log.error("rpc(): " + throwable);
throw BFoxSession.toException(throwable);
}
}
public final BBrokerChannel channel() throws Exception {
if (this.channel == null) {
throw new NotConnectedException();
}
return this.channel;
}
public void ensureLoaded(SlotPath[] slotPathArray) {
try {
Class clazz = class$java$lang$String;
if (clazz == null) {
clazz = class$java$lang$String = BFoxComponentSpace.class("[Ljava.lang.String;", false);
}
Array array = new Array(clazz);
HashMap<Slot, Slot> hashMap = new HashMap<Slot, Slot>();
StringBuffer stringBuffer = new StringBuffer();
int n = 0;
while (n < slotPathArray.length) {
SlotPath slotPath = slotPathArray[n];
boolean bl = slotPath instanceof VirtualPath;
stringBuffer.setLength(0);
if (bl) {
stringBuffer.append("virtual:");
} else {
stringBuffer.append("slot:");
}
BComponent bComponent = this.getRootComponent();
int n2 = 0;
while (n2 < slotPath.depth()) {
Object object;
String string = slotPath.nameAt(n2);
stringBuffer.append('/').append(string);
if (bl) {
string = SlotPath.escape((String)string);
}
if (bComponent instanceof BComplex) {
ComponentSlotMap componentSlotMap;
object = ((BComplex)bComponent).getSlot(string);
if (object instanceof Property) {
bComponent = ((BComplex)bComponent).get((Property)object);
} else if (object == null) {
bComponent = null;
}
if (bComponent instanceof BComponent && !(componentSlotMap = (ComponentSlotMap)bComponent.fw(1)).isBrokerPropsLoaded() && !(bComponent instanceof BVirtualComponent)) {
bComponent = null;
}
}
if (bComponent == null && hashMap.get(object = stringBuffer.toString()) == null) {
hashMap.put((Slot)object, (Slot)object);
array.add(object);
}
++n2;
}
++n;
}
if (array.size() == 0) {
return;
}
this.channel().ensureLoaded((String[])array.trim(), 0);
}
catch (Throwable throwable) {
log.error("ensureLoaded(): " + throwable);
throw BFoxSession.toException(throwable);
}
}
public Transaction newTransaction(Context context) {
return new Transaction((BComponentSpace)this, context){
public final void commit(Context context) throws Exception {
BFoxComponentSpace.this.channel().syncToMaster((SyncBuffer)this);
}
};
}
public void sync() throws Exception {
this.channel().syncFromMaster();
}
public boolean fireDirectCallbacks() {
return false;
}
public TransferResult transfer(TransferStrategy transferStrategy) throws Exception {
try {
return this.channel().transfer(transferStrategy);
}
catch (Exception exception) {
throw BFoxSession.toException(exception);
}
}
public void spy(SpyWriter spyWriter) throws Exception {
super.spy(spyWriter);
spyWriter.startProps("Subscribed");
Iterator iterator = this.subscribed.keySet().iterator();
while (iterator.hasNext()) {
BComponent bComponent = (BComponent)iterator.next();
BAbsTime bAbsTime = (BAbsTime)this.subscribed.get(bComponent);
spyWriter.tr((Object)bComponent.toPathString(), (Object)bAbsTime);
}
spyWriter.endProps();
}
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.subscribed = new HashMap();
this.spaceReadonly = false;
this.defaultLeaseTime = 60000L;
}
public BFoxComponentSpace(String string, LexiconText lexiconText, BOrd bOrd) {
super(string, lexiconText, bOrd);
this.this();
this.setLoadCallbacks(new FoxLoadCallbacks());
this.setTrapCallbacks((TrapCallbacks)new FoxTrapCallbacks());
this.setSubscribeCallbacks(new FoxSubscribeCallbacks());
}
static {
Class clazz = class$com$tridium$fox$sys$broker$BFoxComponentSpace;
if (clazz == null) {
clazz = class$com$tridium$fox$sys$broker$BFoxComponentSpace = BFoxComponentSpace.class("[Lcom.tridium.fox.sys.broker.BFoxComponentSpace;", false);
}
TYPE = Sys.loadType((Class)clazz);
log = Log.getLog((String)"FoxSpace");
}
/*
* Illegal identifiers - consider using --renameillegalidents true
*/
class FoxLoadCallbacks
extends LoadCallbacks {
public boolean isLazyLoad() {
return true;
}
public void loadSlots(BComponent bComponent) {
try {
BFoxComponentSpace.this.channel().load(bComponent, 0);
}
catch (Throwable throwable) {
log.error("loadSlots(" + bComponent.toPathString() + "): " + throwable);
throw BFoxSession.toException(throwable);
}
}
public BValue[] newCopy(BValue[] bValueArray, CopyHints copyHints) {
try {
return BFoxComponentSpace.this.channel().copy(bValueArray, copyHints);
}
catch (Throwable throwable) {
log.error("newCopy():" + throwable);
throw BFoxSession.toException(throwable);
}
}
FoxLoadCallbacks() {
}
}
/*
* Illegal identifiers - consider using --renameillegalidents true
*/
class FoxTrapCallbacks
extends TrapToSyncBuffer {
public SyncBuffer getBuffer() {
return new AutoCommitSyncBuffer((BComponentSpace)BFoxComponentSpace.this);
}
public BValue invoke(BComponent bComponent, Action action, BValue bValue, Context context) {
try {
return BFoxComponentSpace.this.channel().invoke(bComponent, action, bValue);
}
catch (Exception exception) {
log.error("Cannot invoke: " + bComponent.toPathString() + '.' + action);
throw new ActionInvokeException((Throwable)exception);
}
}
FoxTrapCallbacks() {
}
}
/*
* Illegal identifiers - consider using --renameillegalidents true
*/
class FoxSubscribeCallbacks
extends SubscribeCallbacks {
public void update(BComponent bComponent, int n) {
try {
BFoxComponentSpace.this.channel().load(bComponent, n);
}
catch (Throwable throwable) {
log.error("update(" + bComponent.toPathString() + "): " + throwable);
throw BFoxSession.toException(throwable);
}
}
/*
* WARNING - Removed try catching itself - possible behaviour change.
* Enabled aggressive block sorting
* Enabled unnecessary exception pruning
* Enabled aggressive exception aggregation
*/
public void subscribe(BComponent[] bComponentArray, int n) {
HashMap hashMap;
if (n == 0) {
hashMap = BFoxComponentSpace.this.subscribed;
synchronized (hashMap) {
Class clazz = class$javax$baja$sys$BComponent;
if (clazz == null) {
clazz = class$javax$baja$sys$BComponent = BFoxComponentSpace.class("[Ljavax.baja.sys.BComponent;", false);
}
Array array = new Array(clazz);
int n2 = 0;
while (true) {
if (n2 >= bComponentArray.length) {
if (array.size() != 0) break;
return;
}
if (BFoxComponentSpace.this.subscribed.get(bComponentArray[n2]) == null) {
array.add((Object)bComponentArray[n2]);
}
++n2;
}
bComponentArray = (BComponent[])array.trim();
}
}
try {
BFoxComponentSpace.this.channel().subscribe(bComponentArray, n);
}
catch (Throwable throwable) {
log.error("subscribe(" + bComponentArray[0].toPathString() + "): " + throwable);
throw BFoxSession.toException(throwable);
}
hashMap = BFoxComponentSpace.this.subscribed;
synchronized (hashMap) {
int n3 = 0;
while (n3 < bComponentArray.length) {
this.addToSubscribed(bComponentArray[n3], n);
++n3;
}
return;
}
}
void addToSubscribed(BComponent bComponent, int n) {
BFoxComponentSpace.this.subscribed.put(bComponent, Clock.time());
if (n > 0) {
BComponent[] bComponentArray = bComponent.getChildComponents();
int n2 = 0;
while (n2 < bComponentArray.length) {
this.addToSubscribed(bComponentArray[n2], n - 1);
++n2;
}
}
}
/*
* WARNING - Removed try catching itself - possible behaviour change.
* Enabled aggressive block sorting
* Enabled unnecessary exception pruning
* Enabled aggressive exception aggregation
*/
public void unsubscribe(BComponent[] bComponentArray) {
HashMap hashMap = BFoxComponentSpace.this.subscribed;
synchronized (hashMap) {
int n = 0;
while (n < bComponentArray.length) {
BFoxComponentSpace.this.subscribed.remove(bComponentArray[n]);
++n;
}
}
try {
BFoxComponentSpace.this.channel().unsubscribe(bComponentArray);
return;
}
catch (NotConnectedException notConnectedException) {
return;
}
catch (Exception exception) {
log.error("Cannot unsubscribe: " + bComponentArray[0].toPathString(), (Throwable)exception);
}
}
FoxSubscribeCallbacks() {
}
}
/*
* Illegal identifiers - consider using --renameillegalidents true
*/
class AutoCommitSyncBuffer
extends SyncBuffer {
public void add(SyncOp syncOp) {
super.add(syncOp);
try {
BFoxComponentSpace.this.channel().syncToMaster(this);
}
catch (Throwable throwable) {
log.error("AutoCommitSyncBuffer: " + throwable);
throw BFoxSession.toException(throwable);
}
}
AutoCommitSyncBuffer(BComponentSpace bComponentSpace) {
super(bComponentSpace, false);
}
}
}