/* * Decompiled with CFR 0.152. */ package com.tridium.sys.schema; import com.tridium.sys.Nre; import com.tridium.sys.schema.Introspector; import com.tridium.sys.schema.SimpleType; import com.tridium.util.EscUtil; import java.lang.ref.WeakReference; import java.util.Hashtable; import java.util.WeakHashMap; import javax.baja.log.Log; import javax.baja.spy.Spy; import javax.baja.spy.SpyDir; import javax.baja.spy.SpyWriter; import javax.baja.sys.BValue; import javax.baja.sys.Sys; import javax.baja.sys.Type; import javax.baja.sys.TypeIntrospectionException; import javax.baja.sys.TypeNotFoundException; import javax.baja.util.BTypeSpec; /* * Illegal identifiers - consider using --renameillegalidents true */ public class SchemaManager { static Log log = Log.getLog("sys.schema"); Type booleanType; Type integerType; Type longType; Type floatType; Type doubleType; Type stringType; private int nextId; private Type[] types; private Hashtable byClass; private boolean verbose; static /* synthetic */ Class class$java$lang$String; public synchronized Type getType(int n) { Type type = null; try { type = this.types[n]; } catch (ArrayIndexOutOfBoundsException arrayIndexOutOfBoundsException) {} if (type == null) { throw new TypeNotFoundException(String.valueOf(n)); } return type; } public synchronized Type getType(Class clazz) { Type type = (Type)this.byClass.get(clazz); if (type != null) { return type; } if (clazz == Boolean.TYPE) { return this.getBooleanType(); } if (clazz == Integer.TYPE) { return this.getIntegerType(); } if (clazz == Long.TYPE) { return this.getLongType(); } if (clazz == Float.TYPE) { return this.getFloatType(); } if (clazz == Double.TYPE) { return this.getDoubleType(); } Class clazz2 = class$java$lang$String; if (clazz2 == null) { clazz2 = class$java$lang$String = SchemaManager.class("[Ljava.lang.String;", false); } if (clazz == clazz2) { return this.getStringType(); } try { clazz.newInstance(); } catch (Throwable throwable) {} type = (Type)this.byClass.get(clazz); if (type != null) { return type; } try { clazz.getField("TYPE").get(null); } catch (Throwable throwable) {} type = (Type)this.byClass.get(clazz); if (type != null) { return type; } throw new TypeNotFoundException(clazz.getName()); } public synchronized Type[] getTypes() { Type[] typeArray = new Type[this.nextId]; System.arraycopy(this.types, 0, typeArray, 0, typeArray.length); return typeArray; } public synchronized Type load(Class clazz) { int n = -1; n = this.nextId++; Type type = this.load(n, clazz); if (n >= this.types.length) { int n2 = Math.max(this.types.length * 2, n + 10); Type[] typeArray = new Type[n2]; System.arraycopy(this.types, 0, typeArray, 0, this.types.length); this.types = typeArray; } this.byClass.put(type.getTypeClass(), type); this.types[n] = type; return this.types[n]; } /* * Enabled aggressive block sorting * Enabled unnecessary exception pruning * Enabled aggressive exception aggregation */ private final Type load(int n, Class clazz) { Type type; long l = System.currentTimeMillis(); try { try { type = Introspector.create(n, clazz).introspect(); Object var6_5 = null; if (!this.verbose) return type; } catch (TypeIntrospectionException typeIntrospectionException) { log.error("Cannot load type for \"" + clazz.getName() + '\"'); throw typeIntrospectionException; } catch (Throwable throwable) { throwable.printStackTrace(); log.error("ERROR: Cannot load type for \"" + clazz.getName() + '\"', throwable); throw new TypeIntrospectionException(clazz, throwable.toString()); } } catch (Throwable throwable) { Object var6_6 = null; if (!this.verbose) throw throwable; long l2 = System.currentTimeMillis(); log.trace("Loaded \"" + clazz.getName() + "\" [" + (l2 - l) + "ms]"); throw throwable; } long l3 = System.currentTimeMillis(); log.trace("Loaded \"" + clazz.getName() + "\" [" + (l3 - l) + "ms]"); return type; } public void postInit() { Nre.spySysManagers.add("schemaManager", new Page()); } final Type getBooleanType() { if (this.booleanType == null) { this.booleanType = Sys.getType("baja:Boolean"); } return this.booleanType; } final Type getIntegerType() { if (this.integerType == null) { this.integerType = Sys.getType("baja:Integer"); } return this.integerType; } final Type getLongType() { if (this.longType == null) { this.longType = Sys.getType("baja:Long"); } return this.longType; } final Type getFloatType() { if (this.floatType == null) { this.floatType = Sys.getType("baja:Float"); } return this.floatType; } final Type getDoubleType() { if (this.doubleType == null) { this.doubleType = Sys.getType("baja:Double"); } return this.doubleType; } final Type getStringType() { if (this.stringType == null) { this.stringType = Sys.getType("baja:String"); } return this.stringType; } 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.nextId = 0; this.types = new Type[256]; this.byClass = new Hashtable(); this.verbose = true; } public SchemaManager() { this.this(); } /* * Illegal identifiers - consider using --renameillegalidents true */ public class Page extends SpyDir { public Spy find(String string) { return new CachePage(BTypeSpec.make(EscUtil.slot.unescape(string))); } public void write(SpyWriter spyWriter) throws Exception { spyWriter.startTable(true); String string = "Loaded Types"; if (SimpleType.internDebug) { string = string + " (Max Intern Ticks = " + SimpleType.maxInternTicks + ')'; if (SimpleType.maxCacheSize != Integer.MAX_VALUE) { string = string + " - Intern Max Cache Size = " + SimpleType.maxCacheSize; } } spyWriter.trTitle(string, 4); int n = 0; while (n < SchemaManager.this.types.length) { Type type = SchemaManager.this.types[n]; if (SchemaManager.this.types[n] != null) { WeakHashMap weakHashMap = null; if (type instanceof SimpleType) { weakHashMap = ((SimpleType)type).internMap; } spyWriter.tr("" + type.getId(), type.getModule().getModuleName(), type.getTypeName(), this.hyperlink(spyWriter, type, weakHashMap)); } ++n; } spyWriter.endTable(); } String hyperlink(SpyWriter spyWriter, Type type, WeakHashMap weakHashMap) { if (weakHashMap != null && weakHashMap.size() > 0) { String string = "Intern Size = " + weakHashMap.size() + " (Reuse count = " + ((SimpleType)type).reuseCounter + ')'; BTypeSpec bTypeSpec = type.getTypeSpec(); try { return "" + string + ""; } catch (Exception exception) { exception.printStackTrace(); } } else if (type instanceof SimpleType && !((SimpleType)type).interningEnabled()) { return "Interning disabled"; } return ""; } } /* * Illegal identifiers - consider using --renameillegalidents true */ class CachePage extends SpyDir { BTypeSpec typeSpec; /* * WARNING - Removed try catching itself - possible behaviour change. * Enabled aggressive block sorting * Enabled unnecessary exception pruning * Enabled aggressive exception aggregation */ public Spy find(String string) { Type type; if (!string.equals("clear") || !((type = this.typeSpec.getResolvedType()) instanceof SimpleType)) return this; WeakHashMap weakHashMap = ((SimpleType)type).internMap; synchronized (weakHashMap) { ((SimpleType)type).internMap.clear(); ((SimpleType)type).reuseCounter = 0L; return this; } } /* * WARNING - Removed try catching itself - possible behaviour change. * Unable to fully structure code * Enabled aggressive block sorting * Enabled unnecessary exception pruning * Enabled aggressive exception aggregation */ public void write(SpyWriter var1_1) throws Exception { block14: { var2_2 = 0; var3_3 = null; var4_4 = this.typeSpec.getResolvedType(); if (var4_4 instanceof SimpleType) { var3_3 = ((SimpleType)var4_4).internMap; } if (var3_3 != null) { var2_2 = var3_3.size(); } var1_1.startTable(true); var5_5 = SimpleType.internDebug; var6_6 = var5_5 + 1; var7_7 = var2_2 + " Interned Instances of " + this.typeSpec + " (Reuse count = " + ((SimpleType)var4_4).reuseCounter + ')'; if (var2_2 > 0) { var7_7 = var7_7 + " Clear Intern Cache"; } var1_1.trTitle(var7_7, var6_6); if (var5_5 != 0) { var1_1.w("Reuse CounttoString()\n"); } else { var1_1.w("toString()\n"); } if (var3_3 == null) break block14; var8_8 = null; var9_9 = var3_3; synchronized (var9_9) { var8_8 = var3_3.values().toArray(); // MONITOREXIT @DISABLED, blocks:[0, 1] lbl29 : MonitorExitStatement: MONITOREXIT : var9_9 if (var8_8 == null) break block14; var11_10 = 0; if (true) ** GOTO lbl52 } do { var12_11 = (WeakReference)var8_8[var11_10]; var13_12 = null; if (var12_11 != null) { var13_12 = (BValue)var12_11.get(); } if (var13_12 != null) { if (var5_5 != 0) { var14_13 = (Integer)((SimpleType)var4_4).counterMap.get(var13_12); var15_14 = "0"; if (var14_13 != null) { var15_14 = "" + var14_13; } var1_1.tr(var15_14, var13_12.toString()); } else { var1_1.tr(var13_12.toString()); } } ++var11_10; lbl52: // 2 sources } while (var11_10 < var8_8.length); } var1_1.endTable(); } CachePage(BTypeSpec bTypeSpec) { this.typeSpec = bTypeSpec; } } }