link start!

This commit is contained in:
cherubin
2026-03-17 13:31:18 -07:00
commit 08abe87cfb
5910 changed files with 386288 additions and 0 deletions
@@ -0,0 +1,51 @@
/*
* Decompiled with CFR 0.152.
*/
package com.tridium.sys;
import com.tridium.sys.resource.ResourceReport;
import javax.baja.sys.BInterface;
import javax.baja.sys.Sys;
import javax.baja.sys.Type;
public interface BIPlatform
extends BInterface {
public static final Type TYPE;
public void initPlatform() throws Exception;
public void poll();
public int getCpuUsage();
public int getMemoryUsage();
public boolean isFlashFileSystem();
public int getTotalMemory();
public String checkForStationFault();
public void queryResources(ResourceReport var1);
public void reportSummaryFields(String[] var1, String[] var2);
public void stationStarted();
public void resetLocalDaemonSession();
public boolean isStationAutoSaveEnabled();
public long getStationAutoSaveFrequency();
public int getStationSaveBackupCount();
static {
Class clazz = 1.class$com$tridium$sys$BIPlatform;
if (clazz == null) {
clazz = 1.class$com$tridium$sys$BIPlatform = 1.class("[Lcom.tridium.sys.BIPlatform;", false);
}
TYPE = Sys.loadType(clazz);
}
}
@@ -0,0 +1,96 @@
/*
* Decompiled with CFR 0.152.
*/
package com.tridium.sys;
import com.tridium.sys.BIPlatform;
import com.tridium.sys.resource.ResourceReport;
import javax.baja.sys.BObject;
import javax.baja.sys.Sys;
import javax.baja.sys.Type;
/*
* Illegal identifiers - consider using --renameillegalidents true
*/
public class BNullPlatform
extends BObject
implements BIPlatform {
public static final Type TYPE;
static /* synthetic */ Class class$com$tridium$sys$BNullPlatform;
public Type getType() {
return TYPE;
}
public void poll() {
}
public boolean isFlashFileSystem() {
return false;
}
public int getCpuUsage() {
return 0;
}
public int getTotalMemory() {
return 0;
}
public int getMemoryUsage() {
return 0;
}
public void initPlatform() {
}
public void stationStarted() {
}
public boolean isStationAutoSaveEnabled() {
return true;
}
public long getStationAutoSaveFrequency() {
return 3600000L;
}
public int getStationSaveBackupCount() {
return 3;
}
public void resetLocalDaemonSession() {
}
public String checkForStationFault() {
return null;
}
public void queryResources(ResourceReport resourceReport) {
}
public void reportSummaryFields(String[] stringArray, String[] stringArray2) {
}
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());
}
}
static {
Class clazz = class$com$tridium$sys$BNullPlatform;
if (clazz == null) {
clazz = class$com$tridium$sys$BNullPlatform = BNullPlatform.class("[Lcom.tridium.sys.BNullPlatform;", false);
}
TYPE = Sys.loadType(clazz);
}
}
@@ -0,0 +1,20 @@
/*
* Decompiled with CFR 0.152.
*/
package com.tridium.sys;
import java.io.File;
import java.io.InputStream;
public interface BootEnv {
public File getBajaHome();
public File findModule(String var1) throws Exception;
public File findTimeZoneDatabase() throws Exception;
public boolean isRemote();
public InputStream read(String var1) throws Exception;
}
@@ -0,0 +1,212 @@
/*
* Decompiled with CFR 0.152.
*/
package com.tridium.sys;
import com.tridium.sys.Nre;
import com.tridium.sys.NreLib;
import com.tridium.sys.registry.NRegistry;
import com.tridium.sys.station.Station;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.util.Vector;
import javax.baja.log.Log;
import javax.baja.sys.Sys;
/*
* Illegal identifiers - consider using --renameillegalidents true
*/
public class Console
extends Thread {
private Log log;
private PrintWriter out;
private BufferedReader in;
private boolean isAlive;
private boolean noBlock;
private boolean ready;
public void usage() {
this.out.println();
this.out.println("Niagara Runtime Environment Console");
this.out.println(" help Display this list of commands");
this.out.println(" version Display version");
this.out.println(" save Save the station database");
this.out.println(" quit Quit with orderly shutdown");
this.out.println(" kill Exit VM without an orderly shutdown");
this.out.println(" threads Produce a VM thread dump");
this.out.println(" gc Force a garbage collection cycle");
this.out.println(" heap Display heap usage");
this.out.println();
}
public void save() {
try {
Station.saveAsync(null);
}
catch (Exception exception) {
exception.printStackTrace();
}
}
public void quit() {
this.log.message("Quit");
try {
Station.shutdown(true);
}
catch (Exception exception) {
exception.printStackTrace();
}
}
public void kill() {
this.log.message("Killed");
this.out.flush();
System.exit(0);
}
public void dumpThreads() {
NreLib.dumpThreads();
}
public void dumpHeap() {
long l = Runtime.getRuntime().totalMemory() / 1024L;
long l2 = Runtime.getRuntime().freeMemory() / 1024L;
this.out.println("totalMemory: " + l + "kb");
this.out.println("freeMemory: " + l2 + "kb");
this.out.println("usedMemory: " + (l - l2) + "kb");
}
public void command(String[] stringArray) throws Exception {
String string = stringArray[0].trim().toLowerCase();
if (string.equals("")) {
return;
}
if (string.equals("version")) {
Nre.version();
return;
}
if (string.equals("save")) {
this.save();
return;
}
if (string.equals("quit")) {
this.quit();
return;
}
if (string.equals("kill")) {
this.kill();
return;
}
if (string.equals("threads")) {
this.dumpThreads();
return;
}
if (string.equals("gc")) {
System.out.println("Running gc");
System.gc();
return;
}
if (string.equals("heap")) {
this.dumpHeap();
return;
}
if (string.equals("resetdaemon")) {
Nre.getPlatform().resetLocalDaemonSession();
return;
}
if (string.equals("syncmodules")) {
((NRegistry)Sys.getRegistry()).syncModules();
return;
}
this.out.print("Invalid command: ");
this.out.print(string);
this.out.println();
this.usage();
}
String[] read() {
String string = this.readLine();
Vector<String> vector = new Vector<String>();
StringTokenizer stringTokenizer = new StringTokenizer(string);
while (stringTokenizer.hasMoreTokens()) {
vector.addElement(stringTokenizer.nextToken());
}
if (vector.size() == 0) {
vector.addElement("");
}
Object[] objectArray = new String[vector.size()];
vector.copyInto(objectArray);
return objectArray;
}
public String readLine() {
String string = null;
try {
if (this.noBlock) {
while (this.isAlive && !this.in.ready()) {
try {
Thread.sleep(200L);
}
catch (Exception exception) {}
}
}
if (this.isAlive) {
string = this.in.readLine();
}
}
catch (Exception exception) {}
if (string == null) {
try {
Thread.sleep(200L);
}
catch (Exception exception) {}
return "";
}
return string;
}
public void ready() {
this.ready = true;
this.prompt();
}
public void run() {
while (this.isAlive) {
try {
if (this.ready) {
this.prompt();
}
this.command(this.read());
}
catch (Throwable throwable) {
this.log.error("Command failed", throwable);
}
}
}
private final void prompt() {
this.out.print("niagara>");
this.out.flush();
}
private final /* synthetic */ void this() {
this.log = Log.getLog("console");
this.isAlive = true;
this.ready = false;
}
public Console() {
this(new BufferedReader(new InputStreamReader(System.in)), new PrintWriter(System.out));
}
public Console(BufferedReader bufferedReader, PrintWriter printWriter) {
super("Nre:Console");
this.this();
this.in = bufferedReader;
this.out = printWriter;
this.noBlock = Nre.args.hasOption("daemonspawn");
}
}
@@ -0,0 +1,50 @@
/*
* Decompiled with CFR 0.152.
*/
package com.tridium.sys;
import com.tridium.sys.BootEnv;
import com.tridium.sys.Nre;
import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
public class DefaultBootEnv
implements BootEnv {
public File getBajaHome() {
File file;
String string = System.getProperty("baja.home");
if (string == null) {
Nre.fatal("Missing \"baja.home\" system property");
}
if (!(file = new File(string.replace('/', File.separatorChar))).exists()) {
Nre.fatal("Invalid dir for 'baja.home': " + string);
}
return file;
}
public File findModule(String string) throws Exception {
File file;
File file2 = new File(Nre.bajaHome, "modules" + File.separator + string + ".jar");
if (!file2.exists() && (file = new File(Nre.bajaHome, "modules" + File.separator + string + ".sjar")).exists()) {
return file;
}
return file2;
}
public File findTimeZoneDatabase() throws Exception {
File file = new File(Nre.bajaHome, "lib" + File.separator + "timezones.jar");
return file.exists() ? file : null;
}
public boolean isRemote() {
return false;
}
public InputStream read(String string) throws Exception {
string = string.replace('/', File.separatorChar);
return new BufferedInputStream(new FileInputStream(new File(Nre.bajaHome, string)));
}
}
+901
View File
@@ -0,0 +1,901 @@
/*
* Decompiled with CFR 0.152.
*
* Could not load the following classes:
* com.tridium.nre.security.ISecurityInfoProvider
* com.tridium.nre.security.KeyRing
* com.tridium.nre.security.KeyRingFactory
* com.tridium.nre.security.SecurityInitializer
* com.tridium.nre.security.fips.EntrustProviderManager
* javax.baja.nre.util.Array
* javax.baja.nre.util.ByteArrayUtil
* javax.baja.nre.util.TextUtil
*/
package com.tridium.sys;
import com.tridium.nre.security.ISecurityInfoProvider;
import com.tridium.nre.security.KeyRing;
import com.tridium.nre.security.KeyRingFactory;
import com.tridium.nre.security.SecurityInitializer;
import com.tridium.nre.security.fips.EntrustProviderManager;
import com.tridium.sys.BIPlatform;
import com.tridium.sys.BNullPlatform;
import com.tridium.sys.BootEnv;
import com.tridium.sys.DefaultBootEnv;
import com.tridium.sys.NreLib;
import com.tridium.sys.engine.EngineManager;
import com.tridium.sys.engine.LeaseManager;
import com.tridium.sys.license.NLicenseManager;
import com.tridium.sys.metrics.Metrics;
import com.tridium.sys.module.ModuleClassLoader;
import com.tridium.sys.module.ModuleManager;
import com.tridium.sys.module.NModule;
import com.tridium.sys.registry.NRegistry;
import com.tridium.sys.resource.ResourceManager;
import com.tridium.sys.schema.SchemaManager;
import com.tridium.sys.service.ServiceManager;
import com.tridium.sys.session.NSessionManager;
import com.tridium.sys.session.SessionManager;
import com.tridium.sys.spy.LogSetupSpy;
import com.tridium.sys.spy.SysInfoSpy;
import com.tridium.sys.spy.SystemPropertiesSpy;
import com.tridium.sys.spy.UtilSpy;
import com.tridium.sys.station.StationManager;
import com.tridium.sys.stdout.StdoutManager;
import com.tridium.util.CommandLineArguments;
import com.tridium.util.ThrowableUtil;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.security.MessageDigest;
import java.security.Provider;
import java.util.ArrayList;
import java.util.Enumeration;
import java.util.Iterator;
import java.util.Locale;
import java.util.Properties;
import java.util.StringTokenizer;
import java.util.TimeZone;
import javax.baja.file.BFileSystem;
import javax.baja.license.FeatureNotLicensedException;
import javax.baja.log.Log;
import javax.baja.nav.BNavRoot;
import javax.baja.nre.util.Array;
import javax.baja.nre.util.ByteArrayUtil;
import javax.baja.nre.util.TextUtil;
import javax.baja.registry.ModuleInfo;
import javax.baja.registry.TypeInfo;
import javax.baja.security.Auditor;
import javax.baja.security.crypto.CertManagerFactory;
import javax.baja.spy.BSpySpace;
import javax.baja.spy.ObjectSpy;
import javax.baja.spy.Spy;
import javax.baja.spy.SpyDir;
import javax.baja.sys.BModuleSpace;
import javax.baja.sys.ModuleNotFoundException;
import javax.baja.sys.Sys;
import javax.baja.util.BUuid;
import javax.baja.util.PatternFilter;
/*
* Illegal identifiers - consider using --renameillegalidents true
*/
public class Nre {
private static final String J9_PROVIDER = "com.tridium.j9.provider.J9BasicProvider";
private static final String NIAGARA_PROVIDER = "com.tridium.niagara.provider.NiagaraBasicProvider";
private static final String BC_PROVIDER = "org.bouncycastle.jce.provider.BouncyCastleProvider";
public static final long bootTime = System.currentTimeMillis();
public static BootEnv bootEnv;
public static CommandLineArguments args;
public static String commandLine;
public static File bajaHome;
public static File userHome;
public static File credentialsHome;
public static File stationHome;
public static StdoutManager stdoutManager;
public static ModuleManager moduleManager;
public static NRegistry registryManager;
public static SchemaManager schemaManager;
public static EngineManager engineManager;
public static LeaseManager leaseManager;
public static ServiceManager serviceManager;
public static NLicenseManager licenseManager;
public static StationManager stationManager;
public static ResourceManager resourceManager;
public static Metrics.Recount metricsRecount;
public static NSessionManager sessionManager;
public static ThreadGroup mainThreadGroup;
public static SpyDir spySysManagers;
public static String language;
public static Auditor auditor;
public static int unitConversion;
public static String vmUuid;
public static Class launchedClass;
private static ISecurityInfoProvider secInfProvider;
static boolean isBooted;
static BIPlatform platform;
static boolean isStation;
static boolean isRemote;
static boolean hasBootClass;
private static final String NRE_PROP = "cmdline::";
static /* synthetic */ Class array$Ljava$lang$String;
static /* synthetic */ Class class$java$lang$String;
static /* synthetic */ Class class$com$tridium$sys$Nre;
static /* synthetic */ Class class$javax$baja$registry$ModuleInfo;
static void usage() {
Nre.println("");
Nre.println("usage:");
Nre.println(" nre [options] <class> [args]*");
Nre.println("parameters:");
Nre.println(" class classname or module:classname to execute");
Nre.println(" args arguments to pass through to main");
Nre.println("options:");
Nre.println(" -version print nre version");
Nre.println(" -modules:<x> print modules which match specified pattern");
Nre.println(" -hostid print system host id");
Nre.println(" -licenses print licensing summary");
Nre.println(" -props dump system properties");
Nre.println(" -locale:<x> set the default locale (en_US)");
Nre.println(" -@<option> pass option to Java VM");
Nre.println(" -testheap test max heap size");
Nre.println(" -buildreg force rebuild of the registry");
Nre.println("");
}
public static void main(String[] stringArray) {
try {
String[] stringArray2;
StringBuffer stringBuffer = new StringBuffer("nre");
int n = 0;
while (n < stringArray.length) {
stringBuffer.append(' ').append(stringArray[n]);
++n;
}
commandLine = stringBuffer.toString();
args = new CommandLineArguments(stringArray);
if (args.hasOption("version")) {
Nre.version();
return;
}
if (args.hasOption("modules")) {
Nre.modules(args.getOption("modules"));
return;
}
if (args.hasOption("hostid")) {
Nre.hostId();
return;
}
if (args.hasOption("km")) {
Nre.initKm();
return;
}
if (args.hasOption("licenses")) {
Nre.licenses();
return;
}
if (args.hasOption("props")) {
Nre.dumpProps();
return;
}
if (args.hasOption("testheap")) {
Nre.testheap();
return;
}
if (args.hasOption("buildreg")) {
Nre.buildreg();
return;
}
if (Nre.args.parameters.length < 1) {
Nre.usage();
return;
}
Nre.boot();
Log.getLog("sys").message("Baja runtime booted (\"" + bajaHome + "\") on " + NreLib.getHostId());
String string = args.getOption("locale");
if (string != null) {
Nre.setDefaultLocale(string);
} else {
Nre.setDefaultLocale(Locale.getDefault());
}
NModule nModule = null;
String string2 = Nre.args.parameters[0];
int n2 = string2.indexOf(58);
if (n2 > 0) {
stringArray2 = string2.substring(0, n2);
string2 = string2.substring(n2 + 1);
try {
nModule = moduleManager.loadModule((String)stringArray2);
}
catch (ModuleNotFoundException moduleNotFoundException) {
Nre.fatal("FATAL: Module not found: " + (String)stringArray2);
}
}
stringArray2 = new String[stringArray.length - 1];
System.arraycopy(stringArray, 1, stringArray2, 0, stringArray2.length);
Nre.runClass(nModule, string2, stringArray2);
}
catch (FatalException fatalException) {
}
catch (Throwable throwable) {
Log.getLog("sys").error("Cannot boot", throwable);
}
}
static void runClass(NModule nModule, String string, String[] stringArray) {
Object[] objectArray;
if (nModule != null && (!nModule.getModuleName().equals("workbench") || !string.equals("com.tridium.workbench.shell.WbMain")) || nModule == null) {
licenseManager.checkFeature("Tridium", "nre");
}
Class clazz = null;
try {
clazz = nModule != null ? nModule.loadClass(string) : Class.forName(string);
}
catch (ClassNotFoundException classNotFoundException) {
Nre.fatal("FATAL: Cannot find class: " + string);
}
launchedClass = clazz;
Method method = null;
try {
Class[] classArray = new Class[1];
Class clazz2 = array$Ljava$lang$String;
if (clazz2 == null) {
clazz2 = classArray[0] = (array$Ljava$lang$String = Nre.class("[Ljava.lang.String;", true));
}
if (!(method = clazz.getMethod("main", (Class<?>[])(objectArray = classArray))).getReturnType().equals(Void.TYPE)) {
Nre.fatal("FATAL: Main must return void: " + string);
}
if (!Modifier.isPublic(method.getModifiers())) {
Nre.fatal("FATAL: Main must be public: " + string);
}
if (!Modifier.isStatic(method.getModifiers())) {
Nre.fatal("FATAL: Main must be static: " + string);
}
}
catch (Exception exception) {
Nre.fatal("FATAL: No main: " + string);
}
try {
objectArray = new Object[]{stringArray};
method.invoke(null, objectArray);
}
catch (InvocationTargetException invocationTargetException) {
Log.getLog("sys").error("Cannot boot", invocationTargetException.getTargetException());
}
catch (Throwable throwable) {
Log.getLog("sys").error("Cannot boot", throwable);
}
}
public static void setDefaultLocale(String string) {
try {
StringTokenizer stringTokenizer = new StringTokenizer(string, "_");
String string2 = stringTokenizer.nextToken();
String string3 = "";
if (stringTokenizer.hasMoreTokens()) {
string3 = stringTokenizer.nextToken();
}
String string4 = "";
if (stringTokenizer.hasMoreTokens()) {
string4 = stringTokenizer.nextToken(" \t\n\r\f").substring(1);
}
Nre.setDefaultLocale(new Locale(string2, string3, string4));
}
catch (Exception exception) {
exception.printStackTrace();
}
}
public static void setDefaultLocale(Locale locale) {
Locale.setDefault(locale);
language = Locale.getDefault().getLanguage();
}
public static void setDefaultTimeZone(String string) {
try {
TimeZone timeZone = TimeZone.getTimeZone(string);
if (timeZone != null && timeZone.getID().equalsIgnoreCase(string)) {
TimeZone.setDefault(timeZone);
}
}
catch (Exception exception) {
exception.printStackTrace();
}
}
static void dumpProps() {
Nre.boot();
Class clazz = class$java$lang$String;
if (clazz == null) {
clazz = class$java$lang$String = Nre.class("[Ljava.lang.String;", false);
}
Array array = new Array(clazz);
Enumeration<Object> enumeration = System.getProperties().keys();
while (enumeration.hasMoreElements()) {
String string = enumeration.nextElement().toString();
String string2 = System.getProperty(string);
array.add((Object)(string + " = " + string2));
}
array = array.sort();
int n = 0;
while (n < array.size()) {
System.out.println(array.get(n));
++n;
}
}
public static boolean boot() {
return Nre.boot(null);
}
public static synchronized boolean boot(BootEnv bootEnv) {
String string;
String string2;
String[] stringArray;
if (isBooted) {
return false;
}
isBooted = true;
if (bootEnv == null) {
bootEnv = new DefaultBootEnv();
}
Nre.bootEnv = bootEnv;
isRemote = bootEnv.isRemote();
bajaHome = bootEnv.getBajaHome();
String[] stringArray2 = stringArray = args != null ? Nre.args.parameters : new String[]{};
if (stringArray.length >= 2 && stringArray[0].equals("com.tridium.sys.station.Station")) {
string2 = stringArray[1];
stationHome = userHome = new File(bajaHome, "stations" + File.separator + string2);
isStation = true;
hasBootClass = true;
} else if (stringArray.length >= 1) {
hasBootClass = true;
string2 = System.getProperty("user.name");
if (string2 == null) {
string2 = "user";
}
if (!(userHome = new File(bajaHome, "users" + File.separator + string2)).exists()) {
userHome.mkdirs();
}
Nre.buildCredentialsHome();
} else {
string2 = System.getProperty("user.name");
if (string2 == null) {
string2 = "user";
}
if (!(userHome = new File(bajaHome, "users" + File.separator + string2)).exists()) {
userHome.mkdirs();
}
Nre.buildCredentialsHome();
}
Nre.loadSystemProperties();
Nre.checkSystemTimeWorkaround();
string2 = System.getProperty("niagara.lang", null);
if (string2 != null) {
Nre.setDefaultLocale(string2);
}
if ((string = System.getProperty("niagara.timezone", null)) != null) {
Nre.setDefaultTimeZone(string);
}
mainThreadGroup = Nre.findMainThreadGroup(Thread.currentThread().getThreadGroup());
stdoutManager = new StdoutManager();
registryManager = new NRegistry();
schemaManager = new SchemaManager();
moduleManager = new ModuleManager();
engineManager = new EngineManager();
leaseManager = new LeaseManager();
serviceManager = new ServiceManager();
licenseManager = NLicenseManager.make();
stationManager = new StationManager();
resourceManager = new ResourceManager();
sessionManager = new NSessionManager();
metricsRecount = new Metrics.Recount();
Spy.ROOT.add("sysInfo", new SysInfoSpy());
Spy.ROOT.add("stdout", new StdoutManager.SpyPage(stdoutManager));
Spy.ROOT.add("systemProperties", new SystemPropertiesSpy());
Spy.ROOT.add("logSetup", new LogSetupSpy());
spySysManagers = new SpyDir();
Spy.ROOT.add("sysManagers", spySysManagers);
Spy.ROOT.add("util", new UtilSpy());
Spy.ROOT.add("classLoaders", new ModuleClassLoader.LoaderSpy());
Spy.ROOT.add("metrics", new Metrics.MetricSpy());
stdoutManager.postInit();
registryManager.postInit();
schemaManager.postInit();
moduleManager.postInit();
engineManager.postInit();
leaseManager.postInit();
serviceManager.postInit();
licenseManager.postInit();
stationManager.postInit();
resourceManager.postInit();
sessionManager.postInit();
Spy.ROOT.add("nav", new ObjectSpy(BNavRoot.INSTANCE));
BModuleSpace.INSTANCE.getNavName();
BFileSystem.INSTANCE.getNavName();
BSpySpace.INSTANCE.getNavName();
vmUuid = BUuid.make().toString();
if (hasBootClass || isRemote) {
Nre.loadSecurityProviders();
String string3 = null;
String string4 = null;
if (isStation) {
string3 = System.getProperty("baja.home");
string4 = ".km";
} else {
string3 = isRemote ? bootEnv.getBajaHome().getPath() : System.getProperty("baja.home");
string3 = string3 + "/workbench";
string4 = ".wbkm";
}
string3 = string3 + "/security";
Nre.loadKeyRings(string3, string4, false);
try {
Class clazz = Sys.loadClass("platCrypto", "com.tridium.platcrypto.spy.CryptoPlatformPage");
if (clazz != null) {
Spy.ROOT.add("cryptography info", (Spy)clazz.getConstructor(null).newInstance(null));
}
if (stationHome == null) {
CertManagerFactory.getInstanceEx();
}
}
catch (Exception exception) {}
}
return true;
}
public static ThreadGroup findMainThreadGroup(ThreadGroup threadGroup) {
ThreadGroup threadGroup2 = null;
ThreadGroup threadGroup3 = threadGroup;
while (threadGroup3.getParent() != null) {
if (threadGroup3.getName().equals("main")) {
threadGroup2 = threadGroup3;
break;
}
threadGroup3 = threadGroup3.getParent();
}
if (threadGroup2 == null) {
threadGroup3 = threadGroup2 = threadGroup;
while (threadGroup3.getParent() != null) {
threadGroup2 = threadGroup3;
threadGroup3 = threadGroup3.getParent();
}
}
return threadGroup2;
}
static void buildCredentialsHome() {
if (credentialsHome == null) {
Object object;
Object object2;
String string = "tridium";
try {
object2 = MessageDigest.getInstance("SHA-1");
object = ((MessageDigest)object2).digest(bajaHome.getCanonicalPath().getBytes());
string = ByteArrayUtil.toHexString((byte[])object);
}
catch (Exception exception) {
exception.printStackTrace();
}
credentialsHome = new File(System.getProperty("user.home"), "niagara" + File.separator + "credentials" + File.separator + string);
if (!credentialsHome.exists()) {
File file;
Log.getLog("sys").trace("creating user credentials directory");
credentialsHome.mkdirs();
object2 = System.getProperty("user.name");
if (object2 == null) {
object2 = "user";
}
if (((File)(object = (Object)new File(bajaHome, "users" + File.separator + (String)object2))).exists() && (file = new File((File)object, "credentials.xml")).exists()) {
file.delete();
}
}
}
}
static void loadSystemProperties() {
File file = new File(bajaHome, "lib" + File.separator + "system.properties");
try {
FileInputStream fileInputStream = new FileInputStream(file);
Properties properties = new Properties();
properties.load(fileInputStream);
fileInputStream.close();
Iterator<Object> iterator = properties.keySet().iterator();
while (iterator.hasNext()) {
String string = (String)iterator.next();
if (System.getProperty(string) != null && System.getProperty(NRE_PROP + string) != null) continue;
System.getProperties().setProperty(string, properties.getProperty(string).trim());
}
}
catch (FileNotFoundException fileNotFoundException) {
System.out.println("WARNING: Cannot load " + file + ": File not found");
}
catch (Throwable throwable) {
System.out.println("ERROR: Cannot load " + file + ": " + throwable);
}
}
static void loadSecurityProviders() {
block15: {
EntrustProviderManager entrustProviderManager = new EntrustProviderManager();
boolean bl = false;
try {
Sys.getLicenseManager().checkFeature("tridium", "fips140-2");
if (!entrustProviderManager.verifyProviders()) {
throw new Exception();
}
bl = true;
}
catch (FeatureNotLicensedException featureNotLicensedException) {
if (entrustProviderManager.verifyProviders()) {
Log.getLog("sys").warning("FIPS module is present but FIPS is not licensed.");
}
}
catch (Exception exception) {
Log.getLog("sys").warning("FIPS is licensed but FIPS module is not present.");
}
try {
Provider[] providerArray;
if (System.getProperty("java.vm.name").equalsIgnoreCase("J9")) {
providerArray = new Provider[1];
Class clazz = class$com$tridium$sys$Nre;
if (clazz == null) {
clazz = class$com$tridium$sys$Nre = Nre.class("[Lcom.tridium.sys.Nre;", false);
}
providerArray[0] = (Provider)Class.forName(J9_PROVIDER, false, clazz.getClassLoader()).newInstance();
SecurityInitializer.initialize((Provider[])providerArray, (boolean)false);
break block15;
}
if (bl) {
try {
SecurityInitializer.initialize((Provider[])entrustProviderManager.getProcessedProviders(), (boolean)true);
Log.getLog("sys").message("FIPS providers successfully loaded.");
}
catch (Exception exception) {
Log.getLog("sys").error("Error loading FIPS modules. Falling back to BouncyCastle. Cause is:");
exception.printStackTrace();
Provider[] providerArray2 = Nre.getStandardProviders();
SecurityInitializer.initialize((Provider[])providerArray2, (boolean)false);
}
break block15;
}
try {
providerArray = Nre.getStandardProviders();
SecurityInitializer.initialize((Provider[])providerArray, (boolean)false);
}
catch (ClassNotFoundException classNotFoundException) {
if (!bootEnv.isRemote()) {
throw classNotFoundException;
}
}
}
catch (Exception exception) {
throw new SecurityException("Could not load security providers: " + exception);
}
}
}
private static final Provider[] getStandardProviders() throws Exception {
Class clazz;
Provider provider;
ArrayList<Provider> arrayList = new ArrayList<Provider>();
try {
Class clazz2 = class$com$tridium$sys$Nre;
if (clazz2 == null) {
clazz2 = class$com$tridium$sys$Nre = Nre.class("[Lcom.tridium.sys.Nre;", false);
}
provider = (Provider)Class.forName(NIAGARA_PROVIDER, false, clazz2.getClassLoader()).newInstance();
arrayList.add(provider);
}
catch (Exception exception) {
Log.getLog("sys").warning("Could not load NiagaraBasicProvider. Cause is: " + exception);
}
if ((clazz = class$com$tridium$sys$Nre) == null) {
clazz = class$com$tridium$sys$Nre = Nre.class("[Lcom.tridium.sys.Nre;", false);
}
provider = (Provider)Class.forName(BC_PROVIDER, false, clazz.getClassLoader()).newInstance();
arrayList.add(provider);
return arrayList.toArray(new Provider[arrayList.size()]);
}
static void loadKeyRings(String string, String string2, boolean bl) {
try {
if (secInfProvider == null) {
KeyRing keyRing;
final File file = new File(string);
final String string3 = string2;
if (bl) {
keyRing = new File(string).listFiles();
int n = 0;
while (n < ((KeyRing)keyRing).length) {
keyRing[n].delete();
++n;
}
}
keyRing = KeyRingFactory.getInstance((File)file, (String)".kr", (String)string2).getKeyRing();
secInfProvider = new ISecurityInfoProvider(){
public final KeyRing getKeyRing() {
return keyRing;
}
public final File getSecurityDir() {
return file;
}
public final String getKeyMaterialName() {
return string3;
}
public final String getKeyRingName() {
return ".kr";
}
};
}
}
catch (Exception exception) {
throw new RuntimeException("Unable to initialize key ring", exception);
}
}
public static void checkSystemTimeWorkaround() {
if ("true".equals(System.getProperty("niagara.forceTimeHighResolution", "false"))) {
Log.getLog("sys").message("Forcing time to use 1ms resolution");
new Thread(){
public final void run() {
while (true) {
try {
Thread.sleep(Integer.MAX_VALUE);
continue;
}
catch (InterruptedException interruptedException) {
continue;
}
break;
}
}
private final /* synthetic */ void this() {
this.setDaemon(true);
}
{
this.this();
}
}.start();
}
}
public static ISecurityInfoProvider getSecurityInfoProvider() {
return secInfProvider;
}
public static BIPlatform getPlatform() {
if (platform == null) {
platform = new BNullPlatform();
}
return platform;
}
public static void loadPlatform() {
if (platform != null && !(platform instanceof BNullPlatform)) {
return;
}
try {
TypeInfo[] typeInfoArray = registryManager.getConcreteTypes(BIPlatform.TYPE.getTypeInfo());
if (typeInfoArray.length == 1 || typeInfoArray.length > 1 && !typeInfoArray[0].equals(BNullPlatform.TYPE.getTypeInfo())) {
platform = (BIPlatform)((Object)typeInfoArray[0].getInstance());
} else if (typeInfoArray.length > 1 && typeInfoArray[0].equals(BNullPlatform.TYPE.getTypeInfo())) {
platform = (BIPlatform)((Object)typeInfoArray[1].getInstance());
}
platform.initPlatform();
}
catch (Throwable throwable) {
Log.getLog("sys").error("Cannot load platform", throwable);
platform = new BNullPlatform();
}
}
public static void clearPlatform() {
platform = null;
}
public static SessionManager getSessionManager() {
return sessionManager;
}
public static void version() {
Nre.println("");
Nre.println("Niagara Runtime Environment");
Nre.println(" java.version: " + System.getProperty("java.version"));
Nre.println(" java.vendor: " + System.getProperty("java.vendor"));
Nre.println(" java.vm.name: " + System.getProperty("java.vm.name"));
Nre.println(" java.vm.version: " + System.getProperty("java.vm.version"));
Nre.println(" java.home: " + System.getProperty("java.home"));
Nre.println(" baja.home: " + System.getProperty("baja.home"));
Nre.println(" nre.hostId: " + Nre.getHostId());
Nre.println(" nre.hostModel: " + Nre.getHostModel());
Log.getLog("sys.registry").setSeverity(3);
Nre.boot();
NModule nModule = moduleManager.loadModule("baja");
Nre.println(" nre.bajaVersion: " + nModule.getBajaVersion());
Nre.println(" nre.vendor: " + nModule.getVendor());
Nre.println(" nre.vendorVersion: " + nModule.getVendorVersion());
}
public static void modules(String string) {
ModuleInfo moduleInfo;
Nre.boot();
if (string == null || string.length() == 0) {
string = "*";
}
string = string.toLowerCase();
PatternFilter patternFilter = new PatternFilter(string);
ModuleInfo[] moduleInfoArray = Sys.getRegistry().getModules();
Class clazz = class$javax$baja$registry$ModuleInfo;
if (clazz == null) {
clazz = class$javax$baja$registry$ModuleInfo = Nre.class("[Ljavax.baja.registry.ModuleInfo;", false);
}
Array array = new Array(clazz);
int n = 0;
while (n < moduleInfoArray.length) {
if (patternFilter.accept(moduleInfoArray[n].getModuleName().toLowerCase())) {
array.add((Object)moduleInfoArray[n]);
}
++n;
}
ModuleInfo[] moduleInfoArray2 = (ModuleInfo[])array.trim();
int n2 = 0;
int n3 = 0;
int n4 = 0;
while (n4 < moduleInfoArray2.length) {
moduleInfo = moduleInfoArray2[n4];
n2 = Math.max(moduleInfo.getModuleName().length(), n2);
n3 = Math.max(moduleInfo.getVendor().length(), n3);
++n4;
}
n4 = 0;
while (n4 < moduleInfoArray2.length) {
moduleInfo = moduleInfoArray2[n4];
Nre.println(TextUtil.pad((String)moduleInfo.getModuleName(), (int)n2) + " " + TextUtil.pad((String)moduleInfo.getVendor(), (int)n3) + " " + moduleInfo.getVendorVersion());
++n4;
}
}
public static void hostId() {
Nre.println("HostId: " + Nre.getHostId());
}
public static void licenses() {
String string = System.getProperty("baja.home");
if (string == null) {
System.out.println("ERROR: baja.home not defined");
return;
}
bajaHome = new File(string);
bootEnv = new DefaultBootEnv();
registryManager = new NRegistry();
schemaManager = new SchemaManager();
moduleManager = new ModuleManager();
licenseManager = NLicenseManager.make();
licenseManager.reload();
licenseManager.dump();
}
public static void rebootLicenseManager() {
if (!isBooted) {
return;
}
licenseManager = NLicenseManager.make();
licenseManager.postInit();
}
public static void buildreg() {
NRegistry.forceRebuild = true;
Nre.boot();
}
public static void initKm() throws Exception {
if (Nre.args.parameters.length < 2) {
throw new Exception("invalid parameters for km");
}
Nre.loadSecurityProviders();
try {
Nre.loadKeyRings(Nre.args.parameters[0], Nre.args.parameters[1], false);
}
catch (SecurityException securityException) {
Nre.loadKeyRings(Nre.args.parameters[0], Nre.args.parameters[1], true);
}
}
public static void testheap() {
Nre.println("Test Heap");
Nre.dumpheap("Start");
byte[][] byArrayArray = new byte[1000][];
int n = 0;
while (n < byArrayArray.length) {
byArrayArray[n] = new byte[0x100000];
Nre.dumpheap("Alloc " + n + "MB");
++n;
}
}
public static void dumpheap(String string) {
long l = Runtime.getRuntime().totalMemory();
long l2 = Runtime.getRuntime().freeMemory();
long l3 = l - l2;
System.out.println(string + " [Total=" + Nre.mem(l) + " Used=" + Nre.mem(l3) + ']');
}
public static String mem(long l) {
if (l < 0x100000L) {
return l / 1024L + "KB";
}
return l / 0x100000L + "MB";
}
static void println(String string) {
System.out.println(string);
}
static void print(Throwable throwable) {
Nre.println(" " + throwable);
}
static void fatal(String string) {
System.out.println(string);
throw new FatalException();
}
static void fatal(String string, Throwable throwable) {
Nre.println(string);
if (throwable != null) {
ThrowableUtil.dump(System.out, throwable);
}
throw new FatalException();
}
public static void dumpThreads() {
NreLib.dumpThreads();
}
public static String getHostId() {
return NreLib.getHostId();
}
public static String getHostModel() {
return NreLib.getHostModel();
}
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());
}
}
static {
credentialsHome = null;
stationHome = null;
language = "en";
unitConversion = 0;
isStation = false;
isRemote = false;
hasBootClass = false;
}
static class FatalException
extends RuntimeException {
FatalException() {
}
}
}
@@ -0,0 +1,275 @@
/*
* Decompiled with CFR 0.152.
*
* Could not load the following classes:
* com.tridium.nre.util.PlatformUtil
*/
package com.tridium.sys;
import com.tridium.nre.util.PlatformUtil;
import com.tridium.sys.BootEnv;
import com.tridium.sys.Nre;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.FileWriter;
import java.net.Inet4Address;
import java.net.Inet6Address;
import java.net.InetAddress;
import java.util.ArrayList;
import javax.baja.log.Log;
import javax.baja.sys.BajaRuntimeException;
public class NreLib {
private static InetAddress localHost = null;
private static InetAddress localHost6 = null;
public static boolean nativesLoaded = false;
static boolean niagaraIpv6Enabled = Boolean.getBoolean("niagara.ipv6Enabled");
public static void dumpThreads() {
if (nativesLoaded) {
NreLib.dumpThreads0();
}
}
static native void dumpThreads0();
public static String getHostId() {
return PlatformUtil.getHostId();
}
public static String getHostModel() {
try {
String string = NreLib.getHostModel0();
if (string == null || string.length() == 0) {
return "Workstation";
}
return string;
}
catch (Throwable throwable) {
return "unknown";
}
}
static native String getHostModel0();
public static String getenv(String string) {
try {
return NreLib.getenv0(string);
}
catch (Throwable throwable) {
return null;
}
}
static native String getenv0(String var0);
/*
* WARNING - Removed try catching itself - possible behaviour change.
* WARNING - Removed back jump from a try to a catch block - possible behaviour change.
* Enabled aggressive block sorting
* Enabled unnecessary exception pruning
* Enabled aggressive exception aggregation
*/
public static synchronized boolean setSystemProperty(String string, String string2) {
if (string == null) return false;
if (string2 == null) {
return false;
}
System.getProperties().setProperty(string, string2);
BufferedReader bufferedReader = null;
BufferedWriter bufferedWriter = null;
String string3 = Nre.bajaHome + File.separator + "lib" + File.separator + "system.properties";
File file = new File(string3);
try {
try {
bufferedReader = new BufferedReader(new FileReader(string3));
ArrayList<String> arrayList = new ArrayList<String>();
String string4 = null;
boolean bl = false;
while (true) {
if ((string4 = bufferedReader.readLine()) == null) {
if (!bl) {
arrayList.add(string + '=' + string2);
}
break;
}
if (string4.startsWith(string + '=')) {
bl = true;
string4 = string + '=' + string2;
}
arrayList.add(string4);
}
bufferedReader.close();
bufferedWriter = new BufferedWriter(new FileWriter(file));
int n = 0;
while (true) {
block23: {
if (n < arrayList.size()) break block23;
bufferedWriter.write("\r\n");
bufferedWriter.flush();
break;
}
bufferedWriter.write("" + arrayList.get(n) + '\n');
++n;
}
}
catch (FileNotFoundException fileNotFoundException) {
System.out.println("WARNING: Cannot save " + file + ": File not found");
boolean bl = false;
Object var7_14 = null;
try {
bufferedReader.close();
}
catch (Exception exception) {}
try {
bufferedWriter.close();
return bl;
}
catch (Exception exception) {}
return bl;
}
catch (Throwable throwable) {
System.out.println("ERROR: Cannot save " + file + ": " + throwable);
boolean bl = false;
Object var7_15 = null;
try {}
catch (Exception exception) {}
bufferedReader.close();
try {}
catch (Exception exception) {}
bufferedWriter.close();
return bl;
}
}
catch (Throwable throwable) {
Object var7_16 = null;
try {}
catch (Exception exception) {}
bufferedReader.close();
try {}
catch (Exception exception) {}
bufferedWriter.close();
throw throwable;
throw throwable;
}
{
Object var7_17 = null;
}
try {}
catch (Exception exception) {}
bufferedReader.close();
try {}
catch (Exception exception) {
return true;
}
bufferedWriter.close();
return true;
}
public static InetAddress getLocalHost() {
return NreLib.getLocalHost(niagaraIpv6Enabled);
}
public static InetAddress getLocalHost(boolean bl) {
try {
if (!bl) {
if (localHost == null) {
if (nativesLoaded) {
localHost = NreLib.getLocalHost0();
}
if (localHost == null && (localHost = NreLib.getBestLocalAddress(bl)) == null) {
Log.getLog("sys").warning("No valid IPv4 addresses found, using IPv4 loopback as localhost");
localHost = InetAddress.getByName("127.0.0.1");
}
}
return localHost;
}
if (localHost6 == null) {
if (nativesLoaded) {
localHost6 = NreLib.getLocalHost60();
}
if (localHost6 == null && (localHost6 = NreLib.getBestLocalAddress(bl)) == null) {
Log.getLog("sys").warning("No valid IPv6 addresses found, using IPv6 loopback as localhost");
localHost6 = InetAddress.getByName("::1");
}
}
return localHost6;
}
catch (Throwable throwable) {
throwable.printStackTrace();
throw new BajaRuntimeException("getLocalHost", throwable);
}
}
static native InetAddress getLocalHost0();
static native InetAddress getLocalHost60();
private static final InetAddress getBestLocalAddress(boolean bl) throws Exception {
InetAddress[] inetAddressArray = InetAddress.getAllByName(InetAddress.getLocalHost().getHostName());
InetAddress inetAddress = null;
InetAddress inetAddress2 = null;
InetAddress inetAddress3 = null;
InetAddress inetAddress4 = null;
int n = 0;
while (n < inetAddressArray.length) {
block16: {
block15: {
block14: {
if (!bl || !(inetAddressArray[n] instanceof Inet6Address)) break block14;
inetAddress = inetAddressArray[n];
break block15;
}
if (bl || !(inetAddressArray[n] instanceof Inet4Address)) break block16;
inetAddress = inetAddressArray[n];
}
if (inetAddress2 == null && inetAddress.isLinkLocalAddress()) {
inetAddress2 = inetAddress;
} else if (inetAddress3 == null && inetAddress.isSiteLocalAddress()) {
inetAddress3 = inetAddress;
} else if (!(inetAddress4 != null || inetAddress.isLinkLocalAddress() || inetAddress.isLoopbackAddress() || inetAddress.isMulticastAddress() || inetAddress.isSiteLocalAddress() || inetAddress.isAnyLocalAddress())) {
inetAddress4 = inetAddress;
break;
}
}
++n;
}
inetAddress = null;
if (inetAddress4 != null) {
inetAddress = inetAddress4;
} else if (inetAddress3 != null) {
inetAddress = inetAddress3;
} else if (inetAddress2 != null) {
inetAddress = inetAddress2;
}
return inetAddress;
}
public static void traceEvent(int n) {
if (nativesLoaded) {
NreLib.traceEvent0(n);
}
}
static native void traceEvent0(int var0);
static {
try {
BootEnv bootEnv = Nre.bootEnv;
if (bootEnv == null || !bootEnv.isRemote()) {
System.loadLibrary("nre");
nativesLoaded = true;
} else {
System.out.println("WARNING: Not loading nre native library");
}
}
catch (Throwable throwable) {
System.out.println("ERROR: Cannot load nre native library");
System.out.println(" " + throwable);
}
}
}
@@ -0,0 +1,23 @@
/*
* Decompiled with CFR 0.152.
*/
package com.tridium.sys;
import java.net.URL;
public interface RemoteShellContainer {
public boolean isActive();
public URL getCodeBase();
public URL getDocumentBase();
public String getParameter(String var1);
public void showStatus(String var1);
public void showDocument(URL var1);
public void showDocument(URL var1, String var2);
}
@@ -0,0 +1,99 @@
/*
* Decompiled with CFR 0.152.
*/
package com.tridium.sys.engine;
import com.tridium.sys.schema.NSlot;
import java.util.HashMap;
import java.util.Iterator;
import javax.baja.sys.Action;
import javax.baja.sys.BComponent;
import javax.baja.sys.BValue;
/*
* Illegal identifiers - consider using --renameillegalidents true
*/
public final class ActionQueue {
private Entry temp;
private HashMap map;
private Entry head;
private Entry tail;
private int peak;
public final int size() {
return this.map.size();
}
public final int peak() {
return this.peak;
}
public final void enqueue(BComponent bComponent, Action action, BValue bValue) {
this.temp.init(bComponent, action, bValue);
if (this.map.get(this.temp) != null) {
return;
}
Entry entry = this.temp;
this.temp = new Entry();
this.map.put(entry, this);
if (this.tail == null) {
this.head = this.tail = entry;
} else {
this.tail.next = entry;
this.tail = entry;
}
if (this.map.size() > this.peak) {
this.peak = this.map.size();
}
}
public final Entry reset() {
Entry entry = this.head;
this.map.clear();
this.tail = null;
this.head = null;
return entry;
}
public final Iterator iterator() {
return this.map.keySet().iterator();
}
private final /* synthetic */ void this() {
this.temp = new Entry();
this.map = new HashMap();
}
public ActionQueue() {
this.this();
}
public static final class Entry {
public BComponent component;
public Action action;
public BValue arg;
public int hashCode;
public Entry next;
public final void init(BComponent bComponent, Action action, BValue bValue) {
this.component = bComponent;
this.action = action;
this.arg = bValue;
this.hashCode = bComponent.hashCode() ^ ((NSlot)((Object)action)).index;
}
public final int hashCode() {
return this.hashCode;
}
public final boolean equals(Object object) {
Entry entry = (Entry)object;
boolean bl = false;
if (this.component == entry.component && this.action == entry.action) {
bl = true;
}
return bl;
}
}
}
@@ -0,0 +1,563 @@
/*
* 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 com.tridium.sys.engine.ActionQueue;
import com.tridium.sys.engine.EngineUtil;
import com.tridium.sys.engine.NClockTicket;
import com.tridium.sys.engine.TicketQueue;
import com.tridium.sys.resource.ResourceReport;
import java.text.DecimalFormat;
import java.util.Iterator;
import javax.baja.log.Log;
import javax.baja.nre.util.SortUtil;
import javax.baja.spy.Spy;
import javax.baja.spy.SpyDir;
import javax.baja.spy.SpyWriter;
import javax.baja.sys.Action;
import javax.baja.sys.BAbsTime;
import javax.baja.sys.BComponent;
import javax.baja.sys.BLink;
import javax.baja.sys.BObject;
import javax.baja.sys.BRelTime;
import javax.baja.sys.BStation;
import javax.baja.sys.BValue;
import javax.baja.sys.Clock;
import javax.baja.sys.Flags;
import javax.baja.sys.NotRunningException;
import javax.baja.sys.SlotCursor;
import javax.baja.sys.Sys;
/*
* Illegal identifiers - consider using --renameillegalidents true
*/
public class EngineManager {
static DecimalFormat timeFormat = new DecimalFormat("#.000 ms");
public static final Log log = Log.getLog("sys.engine");
public static long engineSleepPeriod = 20L;
private static final int SYSTEM_CLOCK_CHANGE_TOLERANCE = 1000;
public static long shortTimerThreshold = 2100L;
public static long mediumTimerThreshold = 61000L;
private long startTicks;
private volatile int scanCount;
private int ticketScanCount;
private long totalTicksInsideScan;
private long lastTotalTicksInsideScan;
private long deltaTicksInsideScan;
private long peakTicksInsideScan;
private boolean suspended;
private ActionQueue actionQueue;
private BComponent currentComponent;
private Action currentAction;
private long lastMillisVsTicksDelta;
public TicketQueue shortTimers;
public TicketQueue mediumTimers;
public TicketQueue longTimers;
public void start(BComponent bComponent) {
if (!bComponent.isRunning()) {
throw new IllegalStateException();
}
this.activateLinks(bComponent);
EngineUtil.started(bComponent);
SlotCursor slotCursor = bComponent.getProperties();
while (slotCursor.nextComponent()) {
if (Flags.isNoRun(bComponent, slotCursor.property())) continue;
slotCursor.get().asComponent().start();
}
EngineUtil.descendantsStarted(bComponent);
}
private final void activateLinks(BComponent bComponent) {
SlotCursor slotCursor = bComponent.getProperties();
while (slotCursor.nextObject()) {
BObject bObject = slotCursor.get();
if (!(bObject instanceof BLink)) continue;
EngineUtil.activate((BLink)bObject);
}
}
public void stop(BComponent bComponent) {
if (bComponent.isRunning()) {
throw new IllegalStateException();
}
this.deactivateLinks(bComponent);
EngineUtil.stopped(bComponent);
SlotCursor slotCursor = bComponent.getProperties();
while (slotCursor.nextComponent()) {
slotCursor.get().asComponent().stop();
}
EngineUtil.descendantsStopped(bComponent);
}
private final void deactivateLinks(BComponent bComponent) {
SlotCursor slotCursor = bComponent.getProperties();
while (slotCursor.nextObject()) {
BObject bObject = slotCursor.get();
if (!(bObject instanceof BLink)) continue;
EngineUtil.deactivate((BLink)bObject);
}
}
public void stationStarted(BComponent bComponent) {
EngineUtil.stationStarted(bComponent);
SlotCursor slotCursor = bComponent.getProperties();
while (slotCursor.nextComponent()) {
this.stationStarted(slotCursor.get().asComponent());
}
}
public void atSteadyState(BComponent bComponent) {
if (!bComponent.isRunning()) {
log.warning("Not running: " + bComponent);
return;
}
EngineUtil.atSteadyState(bComponent);
SlotCursor slotCursor = bComponent.getProperties();
while (slotCursor.nextComponent()) {
this.atSteadyState(slotCursor.get().asComponent());
}
}
void execute() {
long l = Clock.ticks();
this.checkIfSystemClockChanged();
this.shortTimers.check();
this.mediumTimers.check();
this.longTimers.check();
this.checkAsyncActions();
long l2 = Clock.ticks();
long l3 = l2 - l;
if (l3 > this.peakTicksInsideScan) {
this.peakTicksInsideScan = l3;
}
this.totalTicksInsideScan += l3;
++this.scanCount;
if (this.scanCount % 10 == 0) {
this.deltaTicksInsideScan = this.totalTicksInsideScan - this.lastTotalTicksInsideScan;
this.lastTotalTicksInsideScan = this.totalTicksInsideScan;
}
}
private final void checkIfSystemClockChanged() {
long l = this.getSystemClockWarp();
if (l != 0L) {
log.warning("System clock modified: " + l + "ms");
this.clockChanged(Sys.getStation(), BRelTime.make(l));
}
}
private final long getMillisVsTicksDelta() {
long l = Clock.ticks();
long l2 = Clock.millis();
long l3 = Clock.ticks();
if (l3 - l > 1000L) {
return 0L;
}
long l4 = l3 - l2;
return l4 >= 0L ? l4 : -l4;
}
private final long getSystemClockWarp() {
long l = this.getMillisVsTicksDelta();
if (l == 0L) {
return 0L;
}
long l2 = l - this.lastMillisVsTicksDelta;
if (Math.abs(l2) < 1000L) {
return 0L;
}
this.lastMillisVsTicksDelta = l;
return l2;
}
public void clockChanged(BComponent bComponent, BRelTime bRelTime) {
try {
if (bComponent == null) {
return;
}
EngineUtil.clockChanged(bComponent, bRelTime);
SlotCursor slotCursor = bComponent.getProperties();
while (slotCursor.nextComponent()) {
this.clockChanged(slotCursor.get().asComponent(), bRelTime);
}
}
catch (Throwable throwable) {
throwable.printStackTrace();
}
}
/*
* WARNING - Removed try catching itself - possible behaviour change.
* Enabled aggressive block sorting
* Enabled unnecessary exception pruning
* Enabled aggressive exception aggregation
*/
public void enqueueAction(BComponent bComponent, Action action, BValue bValue) {
ActionQueue actionQueue = this.actionQueue;
synchronized (actionQueue) {
if (bComponent == this.currentComponent && action == this.currentAction) {
return;
}
this.actionQueue.enqueue(bComponent, action, bValue);
return;
}
}
/*
* 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
*/
void checkAsyncActions() {
var1_1 = null;
var2_2 = this.actionQueue;
synchronized (var2_2) {
var1_1 = this.actionQueue.reset();
// MONITOREXIT @DISABLED, blocks:[0, 1] lbl6 : MonitorExitStatement: MONITOREXIT : var2_2
if (true) ** GOTO lbl17
}
do {
this.currentComponent = var1_1.component;
this.currentAction = var1_1.action;
EngineUtil.doInvoke(var1_1.component, var1_1.action, var1_1.arg, null);
var4_3 = var1_1;
var1_1 = var1_1.next;
var4_3.next = null;
lbl17:
// 2 sources
} while (var1_1 != null);
this.currentComponent = null;
this.currentAction = null;
}
public NClockTicket schedule(BComponent bComponent, BRelTime bRelTime, Action action, BValue bValue) {
if (!bComponent.isRunning()) {
throw new NotRunningException();
}
if (action == null) {
throw new NullPointerException("Null action");
}
long l = bRelTime.getMillis();
if (l <= 0L) {
throw new IllegalArgumentException("time <= 0");
}
NClockTicket nClockTicket = new NClockTicket(bComponent, action, bValue);
nClockTicket.nextUpdate = -(Clock.ticks() + l);
nClockTicket.period = 0L;
this.enqueueTicket(nClockTicket);
return nClockTicket;
}
public NClockTicket schedule(BComponent bComponent, BAbsTime bAbsTime, Action action, BValue bValue) {
if (!bComponent.isRunning()) {
throw new NotRunningException();
}
if (action == null) {
throw new NullPointerException("Null action");
}
long l = bAbsTime.getMillis();
if (l <= 0L) {
throw new IllegalArgumentException("time <= 0");
}
NClockTicket nClockTicket = new NClockTicket(bComponent, action, bValue);
nClockTicket.nextUpdate = l;
nClockTicket.period = 0L;
this.enqueueTicket(nClockTicket);
return nClockTicket;
}
public NClockTicket schedulePeriodically(BComponent bComponent, BRelTime bRelTime, Action action, BValue bValue) {
if (!bComponent.isRunning()) {
throw new NotRunningException();
}
if (action == null) {
throw new NullPointerException("Null action");
}
long l = bRelTime.getMillis();
if (l <= 0L) {
throw new IllegalArgumentException("period <= 0");
}
NClockTicket nClockTicket = new NClockTicket(bComponent, action, bValue);
nClockTicket.nextUpdate = -(Clock.ticks() + l);
nClockTicket.period = l;
this.enqueueTicket(nClockTicket);
return nClockTicket;
}
public NClockTicket schedulePeriodically(BComponent bComponent, BAbsTime bAbsTime, BRelTime bRelTime, Action action, BValue bValue) {
if (!bComponent.isRunning()) {
throw new NotRunningException();
}
if (action == null) {
throw new NullPointerException("Null action");
}
long l = bAbsTime.getMillis();
long l2 = bRelTime.getMillis();
if (l <= 0L) {
throw new IllegalArgumentException("start <= 0");
}
if (l2 <= 0L) {
throw new IllegalArgumentException("period <= 0");
}
NClockTicket nClockTicket = new NClockTicket(bComponent, action, bValue);
nClockTicket.nextUpdate = l;
nClockTicket.period = l2;
this.enqueueTicket(nClockTicket);
return nClockTicket;
}
void enqueueTicket(NClockTicket nClockTicket) {
long l = nClockTicket.period;
if (l <= 0L) {
l = nClockTicket.millisLeft();
}
if (l < shortTimerThreshold) {
this.shortTimers.enqueue(nClockTicket);
} else if (l < mediumTimerThreshold) {
this.mediumTimers.enqueue(nClockTicket);
} else {
this.longTimers.enqueue(nClockTicket);
}
}
public void reportResources(ResourceReport resourceReport) {
double d = (double)this.totalTicksInsideScan / (double)this.scanCount;
double d2 = (double)this.deltaTicksInsideScan / 10.0;
double d3 = Clock.ticks() - this.startTicks;
double d4 = (double)this.totalTicksInsideScan / d3 * 100.0;
resourceReport.put("engine.scan.lifetime", timeFormat.format(d));
resourceReport.put("engine.scan.peak", timeFormat.format(this.peakTicksInsideScan));
resourceReport.put("engine.scan.recent", timeFormat.format(d2));
resourceReport.put("engine.scan.usage", "" + (int)d4 + '%');
resourceReport.put("engine.queue.shortTimers", this.shortTimers.size + " (Peak " + this.shortTimers.peak + ')');
resourceReport.put("engine.queue.mediumTimers", this.mediumTimers.size + " (Peak " + this.mediumTimers.peak + ')');
resourceReport.put("engine.queue.longTimers", this.longTimers.size + " (Peak " + this.longTimers.peak + ')');
resourceReport.put("engine.queue.actions", this.actionQueue.size() + " (Peak " + this.actionQueue.peak() + ')');
}
public void postInit() {
SummaryPage summaryPage = new SummaryPage();
Nre.spySysManagers.add("engineManager", summaryPage);
summaryPage.add("shortTimers", new TicketQueuePage(this.shortTimers));
summaryPage.add("mediumTimers", new TicketQueuePage(this.mediumTimers));
summaryPage.add("longTimers", new TicketQueuePage(this.longTimers));
summaryPage.add("asyncQueue", new AsyncQueuePage());
summaryPage.add("hogs", new HogsPage());
}
static String timeStr(long l) {
return l + "ms [" + BRelTime.toString(l) + ']';
}
public void suspend() {
this.suspended = true;
}
public void resume() {
this.suspended = false;
}
public int getCycles() {
return this.scanCount;
}
public long getTotalTicksInsideCycle() {
return this.totalTicksInsideScan;
}
public float getAvgerageTicks() {
double d = (double)this.deltaTicksInsideScan / 10.0;
return (float)d;
}
private final /* synthetic */ void this() {
this.lastTotalTicksInsideScan = 0L;
this.deltaTicksInsideScan = 0L;
this.peakTicksInsideScan = 0L;
this.suspended = false;
this.actionQueue = new ActionQueue();
this.shortTimers = new TicketQueue(100, 1000);
this.mediumTimers = new TicketQueue(1000, 10000);
this.longTimers = new TicketQueue(1000, 30000);
}
public EngineManager() {
this.this();
this.startTicks = Clock.ticks();
this.lastMillisVsTicksDelta = this.getMillisVsTicksDelta();
new EngineThread().start();
}
/*
* Illegal identifiers - consider using --renameillegalidents true
*/
public class SummaryPage
extends SpyDir {
public void write(SpyWriter spyWriter) throws Exception {
double d = (double)EngineManager.this.totalTicksInsideScan / (double)EngineManager.this.scanCount;
double d2 = (double)EngineManager.this.deltaTicksInsideScan / 10.0;
BComponent bComponent = EngineManager.this.currentComponent;
Action action = EngineManager.this.currentAction;
spyWriter.startProps();
spyWriter.prop((Object)"atSteadyState", Sys.atSteadyState());
spyWriter.prop((Object)"suspended", "" + EngineManager.this.suspended);
spyWriter.prop((Object)"scanCount", "" + EngineManager.this.scanCount);
spyWriter.prop((Object)"runtime", EngineManager.timeStr(Clock.ticks() - EngineManager.this.startTicks));
spyWriter.prop((Object)"totalTicksInsideScan", EngineManager.timeStr(EngineManager.this.totalTicksInsideScan));
spyWriter.prop((Object)"averageTime/scan", d + "ms");
spyWriter.prop((Object)"averageTimeLast10Scan", d2 + "ms");
spyWriter.prop((Object)"peakScanTime", EngineManager.this.peakTicksInsideScan + "ms");
spyWriter.trTitle("Actions", 2);
spyWriter.prop((Object)"currentComponent", bComponent == null ? "null" : bComponent.toDebugString());
spyWriter.prop((Object)"currentAction", action);
spyWriter.prop((Object)("<a href='" + spyWriter.href("asyncQueue") + "'>Async Action Queue</a>"), EngineManager.this.actionQueue.size() + " (Peak " + EngineManager.this.actionQueue.peak() + ')');
spyWriter.prop((Object)("<a href='" + spyWriter.href("hogs") + "'>Engine Hogs</a>"), "");
spyWriter.trTitle("Short Timers (" + shortTimerThreshold + "ms or less)", 2);
EngineManager.this.shortTimers.writeSummary(spyWriter, "shortTimers");
spyWriter.trTitle("Medium Timers (" + shortTimerThreshold + "ms to " + mediumTimerThreshold + "ms)", 2);
EngineManager.this.mediumTimers.writeSummary(spyWriter, "mediumTimers");
spyWriter.trTitle("Long Timers (" + mediumTimerThreshold + "ms or greater)", 2);
EngineManager.this.longTimers.writeSummary(spyWriter, "longTimers");
spyWriter.endProps();
}
}
/*
* Illegal identifiers - consider using --renameillegalidents true
*/
public class TicketQueuePage
extends Spy {
TicketQueue q;
public void write(SpyWriter spyWriter) throws Exception {
long l = Clock.millis();
long l2 = Clock.ticks();
spyWriter.startTable(true);
spyWriter.trTitle("Timer Clock.Ticket Queue: " + BAbsTime.make(), 6);
spyWriter.w("<tr>").th("Mode").th("Next Update").th("Period").th("Component").th("Action").th("ActionArg").w("</tr>\n");
int n = 0;
NClockTicket nClockTicket = this.q.head;
while (nClockTicket != null) {
long l3 = nClockTicket.millisLeft();
if (++n > 1000) {
spyWriter.tr("more...", "", "", "", "", "");
break;
}
spyWriter.tr(nClockTicket.nextUpdate < 0L ? "ticks" : "millis", EngineManager.timeStr(l3), "" + nClockTicket.period, nClockTicket.component.toDebugString(), nClockTicket.action, nClockTicket.arg);
nClockTicket = nClockTicket.next;
}
spyWriter.endTable();
}
TicketQueuePage(TicketQueue ticketQueue) {
this.q = ticketQueue;
}
}
/*
* Illegal identifiers - consider using --renameillegalidents true
*/
public class AsyncQueuePage
extends Spy {
/*
* WARNING - Removed try catching itself - possible behaviour change.
* Enabled aggressive block sorting
* Enabled unnecessary exception pruning
* Enabled aggressive exception aggregation
*/
public void write(SpyWriter spyWriter) throws Exception {
spyWriter.startTable(true);
spyWriter.trTitle("Async Action Queue", 2);
spyWriter.w("<tr>").th("Component").th("Action").w("</tr>\n");
ActionQueue actionQueue = EngineManager.this.actionQueue;
synchronized (actionQueue) {
int n = 0;
Iterator iterator = EngineManager.this.actionQueue.iterator();
while (iterator.hasNext()) {
if (++n > 1000) {
spyWriter.tr("more...", "");
break;
}
ActionQueue.Entry entry = (ActionQueue.Entry)iterator.next();
spyWriter.tr(entry.component.toDebugString(), entry.action);
}
}
spyWriter.endTable();
}
}
/*
* Illegal identifiers - consider using --renameillegalidents true
*/
public class HogsPage
extends Spy {
public void write(SpyWriter spyWriter) throws Exception {
BStation bStation = Sys.getStation();
if (bStation == null) {
spyWriter.w("Not station VM");
return;
}
Object[] objectArray = bStation.getComponentSpace().getAllComponents();
Object[] objectArray2 = new Long[objectArray.length];
Long l = new Long(0L);
int n = 0;
while (n < objectArray.length) {
objectArray2[n] = (Long)((BObject)objectArray[n]).fw(22);
if (objectArray2[n] == null) {
objectArray2[n] = l;
}
++n;
}
SortUtil.sort((Object[])objectArray2, (Object[])objectArray, (boolean)false);
spyWriter.startTable(true);
spyWriter.trTitle("Engine Hogs", 4);
spyWriter.w("<tr>").th("Rank").th("Component").th("Type").th("Total Time").w("</tr>\n");
n = 0;
while (n < 100 && n < objectArray.length) {
Object object = objectArray[n];
if (objectArray2[n] == l) break;
long l2 = (Long)objectArray2[n];
spyWriter.tr("" + n, ((BComponent)object).toPathString(), ((BComponent)object).getType(), EngineManager.timeStr(l2 / 1000000L));
++n;
}
spyWriter.endTable();
}
}
/*
* Illegal identifiers - consider using --renameillegalidents true
*/
class EngineThread
extends Thread {
public void run() {
while (true) {
try {
Thread.sleep(engineSleepPeriod);
if (EngineManager.this.suspended) continue;
EngineManager.this.execute();
continue;
}
catch (Throwable throwable) {
log.error("Error in run", throwable);
continue;
}
break;
}
}
public EngineThread() {
super(Nre.mainThreadGroup, "Nre:Engine");
this.setDaemon(true);
}
}
}
@@ -0,0 +1,194 @@
/*
* Decompiled with CFR 0.152.
*/
package com.tridium.sys.engine;
import com.tridium.sys.engine.EngineManager;
import com.tridium.sys.schema.ComponentSlotMap;
import javax.baja.log.Log;
import javax.baja.naming.UnresolvedException;
import javax.baja.sys.Action;
import javax.baja.sys.ActionInvokeException;
import javax.baja.sys.BComponent;
import javax.baja.sys.BLink;
import javax.baja.sys.BObject;
import javax.baja.sys.BRelTime;
import javax.baja.sys.BValue;
import javax.baja.sys.Context;
import javax.baja.sys.SlotCursor;
import javax.baja.sys.Topic;
public final class EngineUtil {
public static final Log log = EngineManager.log;
public static final void invoke(BComponent bComponent, Action action, BValue bValue, Context context) {
try {
bComponent.invoke(action, bValue, context);
}
catch (ActionInvokeException actionInvokeException) {
log.error("Action failed: " + action, actionInvokeException.getCause());
}
catch (Throwable throwable) {
log.error("Action failed: " + action, throwable);
}
}
public static final void doInvoke(BComponent bComponent, Action action, BValue bValue, Context context) {
try {
((ComponentSlotMap)bComponent.fw(1)).invoke(action, bValue, context, true);
}
catch (ActionInvokeException actionInvokeException) {
log.error("Action failed: " + action, actionInvokeException.getCause());
}
catch (Throwable throwable) {
log.error("Action failed: " + action, throwable);
}
}
public static final void fire(BComponent bComponent, Topic topic, BValue bValue) {
try {
bComponent.fire(topic, bValue);
}
catch (Throwable throwable) {
log.error("Topic failed: " + topic, throwable);
}
}
public static final void activate(BLink bLink) {
try {
if (bLink.isEnabled()) {
bLink.activate();
}
}
catch (UnresolvedException unresolvedException) {
log.error("Cannot activate link \"" + EngineUtil.toString(bLink) + "\": " + unresolvedException.getMessage());
}
catch (Throwable throwable) {
log.error("Cannot activate link \"" + EngineUtil.toString(bLink) + '\"', throwable);
}
}
public static final void deactivate(BLink bLink) {
try {
if (bLink.isActive()) {
bLink.deactivate();
}
}
catch (Throwable throwable) {
log.error("Cannot deactivate link \"" + EngineUtil.toString(bLink) + '\"', throwable);
}
}
public static final void started(BComponent bComponent) {
try {
bComponent.fw(11, null, null, null, null);
bComponent.started();
}
catch (Throwable throwable) {
log.error("Cannot start component: " + EngineUtil.toString(bComponent), throwable);
}
}
public static final void stopped(BComponent bComponent) {
try {
bComponent.fw(12, null, null, null, null);
bComponent.stopped();
}
catch (Throwable throwable) {
log.error("Cannot stop component: " + EngineUtil.toString(bComponent), throwable);
}
}
public static final void descendantsStarted(BComponent bComponent) {
try {
bComponent.fw(13, null, null, null, null);
bComponent.descendantsStarted();
}
catch (Throwable throwable) {
log.error("Cannot start component: " + EngineUtil.toString(bComponent), throwable);
}
}
public static final void descendantsStopped(BComponent bComponent) {
try {
bComponent.fw(14, null, null, null, null);
bComponent.descendantsStopped();
}
catch (Throwable throwable) {
log.error("Cannot stop component: " + EngineUtil.toString(bComponent), throwable);
}
}
public static final void stationStarted(BComponent bComponent) {
try {
bComponent.fw(23, null, null, null, null);
bComponent.stationStarted();
}
catch (Throwable throwable) {
log.error("Failed stationStarted: " + EngineUtil.toString(bComponent), throwable);
}
}
public static final void atSteadyState(BComponent bComponent) {
try {
bComponent.fw(20, null, null, null, null);
bComponent.atSteadyState();
}
catch (Throwable throwable) {
log.error("Failed atSteadyState: " + EngineUtil.toString(bComponent), throwable);
}
}
public static final void clockChanged(BComponent bComponent, BRelTime bRelTime) {
try {
bComponent.clockChanged(bRelTime);
}
catch (Throwable throwable) {
log.error("Failed clockChanged: " + EngineUtil.toString(bComponent), throwable);
}
}
public static final String toString(Object object) {
try {
return String.valueOf(object);
}
catch (Throwable throwable) {
return object.getClass().getName() + "???";
}
}
public static final void activateLinks(BComponent bComponent) {
try {
SlotCursor slotCursor = bComponent.getProperties();
while (slotCursor.nextObject()) {
BObject bObject = slotCursor.get();
if (bObject instanceof BLink) {
EngineUtil.activate((BLink)bObject);
}
if (!(bObject instanceof BComponent)) continue;
EngineUtil.activateLinks((BComponent)bObject);
}
}
catch (Exception exception) {
exception.printStackTrace();
}
}
public static final void deactivateLinks(BComponent bComponent) {
try {
SlotCursor slotCursor = bComponent.getProperties();
while (slotCursor.nextObject()) {
BObject bObject = slotCursor.get();
if (bObject instanceof BLink) {
EngineUtil.deactivate((BLink)bObject);
}
if (!(bObject instanceof BComponent)) continue;
EngineUtil.deactivateLinks((BComponent)bObject);
}
}
catch (Exception exception) {
exception.printStackTrace();
}
}
}
@@ -0,0 +1,229 @@
/*
* 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("<tr>").th("Component").th("Type").th("Time Left").w("</tr>");
n = 0;
while (n < objectArray.length) {
Object object = objectArray[n];
BComponent bComponent = ((Entry)object).component;
String string = ((Entry)object).expiration - Clock.ticks() + "ms";
spyWriter.tr(objectArray2[n], bComponent.getType(), string);
++n;
}
spyWriter.endTable();
}
}
/*
* Illegal identifiers - consider using --renameillegalidents true
*/
class LeaseSubscriber
extends Subscriber {
public void event(BComponentEvent bComponentEvent) {
}
public boolean doesHandleEvent(int n) {
return false;
}
public void subscribed(BComponent bComponent, Context context) {
LeaseManager.this.checkLease(bComponent, (LeaseContext)context);
}
LeaseSubscriber() {
}
}
/*
* Illegal identifiers - consider using --renameillegalidents true
*/
class LeaseThread
extends Thread {
/*
* 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 run() {
var1_1 = new ArrayList<BComponent>();
while (true) {
try {
Thread.sleep(5000L);
var1_1.clear();
var2_2 = Clock.ticks();
var4_4 = LeaseManager.this.map;
synchronized (var4_4) {
var6_6 = LeaseManager.this.map.values().toArray(new Entry[LeaseManager.this.map.size()]);
var7_7 = 0;
while (true) {
block12: {
if (var7_7 < var6_6.length) break block12;
// MONITOREXIT @DISABLED, blocks:[0, 3, 7, 8] lbl18 : MonitorExitStatement: MONITOREXIT : var4_4
var6_5 = 0;
if (true) ** GOTO lbl42
}
var8_9 = var6_6[var7_7];
if (var8_9.expiration < var2_2) {
var1_1.add(var8_9.component);
LeaseManager.this.map.remove(var8_9.component);
if (LeaseManager.log.isTraceOn()) {
LeaseManager.log.trace("Expired: " + var8_9.component.toPathString());
}
}
++var7_7;
}
}
}
catch (Throwable var2_3) {
LeaseManager.log.error("Error in run", var2_3);
continue;
}
do {
var7_8 = (BComponent)var1_1.get(var6_5);
try {
LeaseManager.this.subscriber.unsubscribe(var7_8);
}
catch (Throwable var8_10) {
LeaseManager.log.error("Cannot unsubscribe: " + var7_8);
}
++var6_5;
lbl42:
// 2 sources
} while (var6_5 < var1_1.size());
}
}
public LeaseThread() {
super(Nre.mainThreadGroup, "Nre:Lease");
this.setDaemon(true);
}
}
}
@@ -0,0 +1,70 @@
/*
* Decompiled with CFR 0.152.
*/
package com.tridium.sys.engine;
import com.tridium.sys.engine.NKnob;
import javax.baja.naming.BOrd;
import javax.baja.sys.BComponent;
import javax.baja.sys.BLink;
import javax.baja.sys.Slot;
public final class LocalKnob
extends NKnob {
private static int idCounter = 0;
public final BLink link;
public final boolean isLocal() {
return true;
}
public final boolean isProxy() {
return false;
}
public final void copyFrom(NKnob nKnob) {
Thread.dumpStack();
}
public final BLink getLink() {
return this.link;
}
public final BOrd getTargetOrd() {
return this.link.getTargetComponent().getOrdInSpace();
}
public final BComponent getTargetComponent() {
return this.link.getTargetComponent();
}
public final String getTargetSlotName() {
return this.link.getTargetSlotName();
}
public final Slot getTargetSlot() {
return this.link.getTargetSlot();
}
public final BOrd getSourceOrd() {
return this.link.getSourceOrd();
}
public final BComponent getSourceComponent() {
return this.link.getSourceComponent();
}
public final String getSourceSlotName() {
return this.link.getSourceSlotName();
}
public final Slot getSourceSlot() {
return this.link.getSourceSlot();
}
public LocalKnob(BLink bLink) {
super(idCounter++);
this.link = bLink;
}
}
@@ -0,0 +1,119 @@
/*
* Decompiled with CFR 0.152.
*/
package com.tridium.sys.engine;
import com.tridium.sys.engine.EngineUtil;
import javax.baja.sys.Action;
import javax.baja.sys.BAbsTime;
import javax.baja.sys.BBoolean;
import javax.baja.sys.BComponent;
import javax.baja.sys.BFacets;
import javax.baja.sys.BValue;
import javax.baja.sys.Clock;
import javax.baja.sys.ExpiredTicketException;
public final class NClockTicket
implements Clock.Ticket {
long nextUpdate;
long period;
BComponent component;
Action action;
BValue arg;
NClockTicket next;
public final void cancel() {
this.nextUpdate = 0L;
this.period = -1;
this.component = null;
this.action = null;
this.arg = null;
}
public final boolean isExpired() {
boolean bl = false;
if (this.component == null) {
bl = true;
}
return bl;
}
public final BComponent getComponent() {
if (this.isExpired()) {
throw new ExpiredTicketException();
}
return this.component;
}
public final Action getAction() {
if (this.isExpired()) {
throw new ExpiredTicketException();
}
return this.action;
}
public final BValue getActionArgument() {
if (this.isExpired()) {
throw new ExpiredTicketException();
}
return this.arg;
}
public final String toString() {
if (this.isExpired()) {
return "Ticket: expired";
}
BFacets bFacets = BFacets.make("showMilliseconds", BBoolean.TRUE);
return "Ticket nextUpdate=" + BAbsTime.make(Clock.millis() + this.millisLeft()).toString(bFacets) + " period=" + this.period;
}
public final long millisLeft() {
if (this.nextUpdate < 0L) {
return -this.nextUpdate - Clock.ticks();
}
return this.nextUpdate - Clock.millis();
}
final long process(long l, long l2) {
BComponent bComponent = this.component;
Action action = this.action;
BValue bValue = this.arg;
if (bComponent == null) {
return Long.MIN_VALUE;
}
if (!bComponent.isRunning()) {
return Long.MIN_VALUE;
}
if (this.nextUpdate < 0L) {
if (l >= -this.nextUpdate) {
if (this.period == 0L) {
this.cancel();
} else {
this.nextUpdate = -(l + this.period);
}
EngineUtil.invoke(bComponent, action, bValue, null);
}
} else if (l2 >= this.nextUpdate) {
if (this.period == 0L) {
this.cancel();
} else {
this.nextUpdate += this.period;
}
EngineUtil.invoke(bComponent, action, bValue, null);
}
if (this.component == null || this.nextUpdate == 0L) {
return Long.MIN_VALUE;
}
if (this.nextUpdate < 0L) {
return -this.nextUpdate - l;
}
return this.nextUpdate - l2;
}
public NClockTicket(BComponent bComponent, Action action, BValue bValue) {
this.component = bComponent;
this.action = action;
this.arg = bValue;
}
}
@@ -0,0 +1,33 @@
/*
* Decompiled with CFR 0.152.
*/
package com.tridium.sys.engine;
import javax.baja.sys.Knob;
public abstract class NKnob
implements Knob {
public final int id;
public abstract boolean isLocal();
public abstract boolean isProxy();
public abstract void copyFrom(NKnob var1);
public String toString() {
String string = "???";
try {
string = String.valueOf(this.getTargetOrd());
}
catch (Exception exception) {}
StringBuffer stringBuffer = new StringBuffer();
stringBuffer.append(this.getSourceSlotName()).append("->").append(string).append('.').append(this.getTargetSlotName());
return stringBuffer.toString();
}
NKnob(int n) {
this.id = n;
}
}
@@ -0,0 +1,82 @@
/*
* Decompiled with CFR 0.152.
*/
package com.tridium.sys.engine;
import com.tridium.sys.engine.NKnob;
import javax.baja.naming.BOrd;
import javax.baja.sys.BComponent;
import javax.baja.sys.BLink;
import javax.baja.sys.Slot;
public final class ProxyKnob
extends NKnob {
BComponent source;
Slot sourceSlot;
BOrd targetOrd;
String targetSlot;
public final boolean isLocal() {
return false;
}
public final boolean isProxy() {
return true;
}
public final BLink getLink() {
return null;
}
public final BOrd getTargetOrd() {
return this.targetOrd;
}
public final BComponent getTargetComponent() {
return null;
}
public final String getTargetSlotName() {
return this.targetSlot;
}
public final Slot getTargetSlot() {
return null;
}
public final BOrd getSourceOrd() {
return this.source.getOrdInSpace();
}
public final BComponent getSourceComponent() {
return this.source;
}
public final String getSourceSlotName() {
return this.sourceSlot.getName();
}
public final Slot getSourceSlot() {
return this.sourceSlot;
}
public final void copyFrom(NKnob nKnob) {
try {
ProxyKnob proxyKnob = (ProxyKnob)nKnob;
this.targetOrd = proxyKnob.targetOrd;
this.targetSlot = proxyKnob.targetSlot;
}
catch (Exception exception) {
exception.printStackTrace();
}
}
public ProxyKnob(int n, BComponent bComponent, Slot slot, BOrd bOrd, String string) {
super(n);
this.source = bComponent;
this.sourceSlot = slot;
this.targetOrd = bOrd;
this.targetSlot = string;
}
}
@@ -0,0 +1,103 @@
/*
* Decompiled with CFR 0.152.
*/
package com.tridium.sys.engine;
import com.tridium.sys.engine.EngineManager;
import com.tridium.sys.engine.NKnob;
import com.tridium.sys.schema.NSlot;
import java.util.ArrayList;
import javax.baja.sys.ActionInvokeException;
import javax.baja.sys.BComponent;
import javax.baja.sys.BLink;
import javax.baja.sys.BValue;
public final class SlotKnobs {
private static final NKnob[] noKnobs = new NKnob[0];
public final BComponent sourceComponent;
public final NSlot sourceSlot;
public NKnob[] knobs;
public int size;
public final void propagate(BValue bValue) {
int n = 0;
while (n < this.size) {
BLink bLink = null;
try {
bLink = this.knobs[n].getLink();
if (bLink != null && bLink.isEnabled()) {
bLink.propagate(bValue);
}
}
catch (ActionInvokeException actionInvokeException) {
EngineManager.log.error("Link propogate: " + bLink, actionInvokeException.getCause());
}
catch (Throwable throwable) {
EngineManager.log.error("Link propogate: " + bLink, throwable);
}
++n;
}
}
public final NKnob get(int n) {
int n2 = 0;
while (n2 < this.size) {
if (this.knobs[n2].id == n) {
return this.knobs[n2];
}
++n2;
}
return null;
}
public final NKnob[] list() {
NKnob[] nKnobArray = new NKnob[this.size];
System.arraycopy(this.knobs, 0, nKnobArray, 0, this.size);
return nKnobArray;
}
public final void appendTo(ArrayList arrayList) {
int n = 0;
while (n < this.size) {
arrayList.add(this.knobs[n]);
++n;
}
}
public final void add(NKnob nKnob) {
if (this.size >= this.knobs.length) {
NKnob[] nKnobArray = new NKnob[Math.max(this.size * 2, 4)];
System.arraycopy(this.knobs, 0, nKnobArray, 0, this.knobs.length);
this.knobs = nKnobArray;
}
this.knobs[this.size++] = nKnob;
}
public final void remove(NKnob nKnob) {
int n = 0;
while (n < this.size) {
if (this.knobs[n] == nKnob) {
if (n < this.knobs.length) {
System.arraycopy(this.knobs, n + 1, this.knobs, n, this.knobs.length - n - 1);
}
this.knobs[this.size - 1] = null;
--this.size;
return;
}
++n;
}
}
public SlotKnobs(BComponent bComponent, NSlot nSlot, NKnob nKnob) {
this(bComponent, nSlot);
this.knobs = new NKnob[]{nKnob};
this.size = 1;
}
public SlotKnobs(BComponent bComponent, NSlot nSlot) {
this.sourceComponent = bComponent;
this.sourceSlot = nSlot;
this.knobs = noKnobs;
}
}
@@ -0,0 +1,155 @@
/*
* Decompiled with CFR 0.152.
*/
package com.tridium.sys.engine;
import com.tridium.sys.engine.EngineManager;
import com.tridium.sys.engine.NClockTicket;
import javax.baja.spy.SpyWriter;
import javax.baja.sys.Clock;
/*
* Illegal identifiers - consider using --renameillegalidents true
*/
public class TicketQueue {
public int minScan;
public int maxScan;
int scanCount;
long totalTicksInsideScan;
int size;
int peak;
NClockTicket head;
NClockTicket tail;
long nextScan;
final Object lock;
public void check() {
long l = Clock.ticks();
if (this.nextScan >= l) {
return;
}
long l2 = this.scan();
long l3 = Clock.ticks();
if (l2 < (long)this.minScan) {
l2 = this.minScan;
}
if (l2 > (long)this.maxScan) {
l2 = this.maxScan;
}
this.nextScan = l + l2;
this.totalTicksInsideScan += l3 - l;
++this.scanCount;
}
/*
* WARNING - Removed try catching itself - possible behaviour change.
* Enabled aggressive block sorting
* Enabled unnecessary exception pruning
* Enabled aggressive exception aggregation
*/
public void enqueue(NClockTicket nClockTicket) {
Object object = this.lock;
synchronized (object) {
block5: {
block4: {
if (this.tail != null) break block4;
this.head = this.tail = nClockTicket;
break block5;
}
this.tail.next = nClockTicket;
this.tail = nClockTicket;
}
++this.size;
if (this.size > this.peak) {
this.peak = this.size;
}
this.nextScan = 0L;
return;
}
}
/*
* WARNING - Removed try catching itself - possible behaviour change.
* Enabled aggressive block sorting
* Enabled unnecessary exception pruning
* Enabled aggressive exception aggregation
*/
private final long scan() {
long l;
NClockTicket nClockTicket;
NClockTicket nClockTicket2;
NClockTicket nClockTicket3 = null;
Object object = this.lock;
synchronized (object) {
nClockTicket3 = this.head;
this.tail = null;
this.head = null;
this.size = 0;
// MONITOREXIT @DISABLED, blocks:[0, 2] lbl9 : MonitorExitStatement: MONITOREXIT : var2_2
nClockTicket2 = null;
nClockTicket = null;
l = Long.MAX_VALUE;
}
long l2 = Clock.ticks();
long l3 = Clock.millis();
int n = 0;
while (nClockTicket3 != null) {
NClockTicket nClockTicket4 = nClockTicket3.next;
nClockTicket3.next = null;
long l4 = nClockTicket3.process(l2, l3);
if (l4 != Long.MIN_VALUE) {
l = Math.min(l, l4);
if (nClockTicket == null) {
nClockTicket2 = nClockTicket = nClockTicket3;
} else {
nClockTicket.next = nClockTicket3;
nClockTicket = nClockTicket3;
}
++n;
}
nClockTicket3 = nClockTicket4;
}
object = this.lock;
synchronized (object) {
block11: {
block13: {
block12: {
if (nClockTicket2 == null) break block11;
if (this.head != null) break block12;
this.head = nClockTicket2;
this.tail = nClockTicket;
break block13;
}
nClockTicket.next = this.head;
this.head = nClockTicket2;
}
this.size += n;
if (this.size > this.peak) {
this.peak = this.size;
}
}
return l;
}
}
public void writeSummary(SpyWriter spyWriter, String string) throws Exception {
long l = Clock.ticks();
String string2 = this.nextScan < l ? "next cycle" : EngineManager.timeStr(this.nextScan - l);
spyWriter.prop((Object)"scanCount", "" + this.scanCount);
spyWriter.prop((Object)"totalTicksInsideScan", EngineManager.timeStr(this.totalTicksInsideScan));
spyWriter.prop((Object)("<a href='" + spyWriter.href(string) + "'>Queue</a>"), this.size + " (Peak " + this.peak + ')');
spyWriter.prop((Object)"nextScan", string2);
spyWriter.prop((Object)"scanBounds", this.minScan + "ms - " + this.maxScan + "ms");
}
private final /* synthetic */ void this() {
this.lock = new Object();
}
public TicketQueue(int n, int n2) {
this.this();
this.minScan = n;
this.maxScan = n2;
}
}
@@ -0,0 +1,127 @@
/*
* Decompiled with CFR 0.152.
*/
package com.tridium.sys.license;
import javax.baja.license.Feature;
import javax.baja.license.LicenseException;
import javax.baja.log.Log;
import javax.baja.sys.Sys;
import javax.baja.util.PatternFilter;
public class Brand {
static final Log log = Log.getLog("sys.brand");
private static boolean init;
private static String brandId;
private static AcceptList acceptStationIn;
private static AcceptList acceptStationOut;
private static AcceptList acceptWbIn;
private static AcceptList acceptWbOut;
public static String getBrandId() {
Brand.init();
return brandId;
}
public static String getAcceptStationInString() {
Brand.init();
return Brand.acceptStationIn.patternString;
}
public static String getAcceptStationOutString() {
Brand.init();
return Brand.acceptStationOut.patternString;
}
public static String getAcceptWbInString() {
Brand.init();
return Brand.acceptWbIn.patternString;
}
public static String getAcceptWbOutString() {
Brand.init();
return Brand.acceptWbOut.patternString;
}
public static void checkStationIn(String string) {
Brand.init();
acceptStationIn.check(string);
}
public static void checkStationOut(String string) {
Brand.init();
acceptStationOut.check(string);
}
public static void checkWbIn(String string) {
Brand.init();
acceptWbIn.check(string);
}
public static void checkWbOut(String string) {
Brand.init();
acceptWbOut.check(string);
}
private static final void init() {
if (init) {
return;
}
Feature feature = Sys.getLicenseManager().checkFeature("tridium", "brand");
brandId = feature.get("brandId");
if (brandId == null) {
throw new LicenseException("Missing brandId in brand feature");
}
acceptStationIn = new AcceptList(feature, "accept.station.in");
acceptStationOut = new AcceptList(feature, "accept.station.out");
acceptWbIn = new AcceptList(feature, "accept.wb.in");
acceptWbOut = new AcceptList(feature, "accept.wb.out");
init = true;
}
public static class AcceptList {
String id;
PatternFilter[] patterns;
String patternString;
public void check(String string) {
if (!this.accept(string)) {
throw new LicenseException("Brand incompatibility [" + this.id + "] " + string + " != " + this.patternString);
}
}
public boolean accept(String string) {
if (log.isTraceOn()) {
log.trace("check " + this.id + ": " + string + " against " + this.patternString);
}
if (string == null) {
return true;
}
int n = 0;
while (n < this.patterns.length) {
if (this.patterns[n].accept(string)) {
return true;
}
++n;
}
return false;
}
public String toString() {
return this.id + '=' + this.patternString;
}
public AcceptList(Feature feature, String string) {
this.id = string;
this.patternString = feature.get(string, "*");
this.patterns = PatternFilter.parseList(this.patternString, ";");
}
public AcceptList(String string, String string2) {
this.id = string;
this.patternString = string2;
this.patterns = PatternFilter.parseList(string2, ";");
}
}
}
@@ -0,0 +1,86 @@
/*
* Decompiled with CFR 0.152.
*
* Could not load the following classes:
* javax.baja.nre.util.Base64
* javax.baja.xml.XContent
* javax.baja.xml.XElem
* javax.baja.xml.XException
* javax.baja.xml.XParser
*/
package com.tridium.sys.license;
import com.tridium.sys.license.LicenseUtil;
import com.tridium.sys.license.NLicenseManager;
import java.io.File;
import java.security.PublicKey;
import javax.baja.nre.util.Base64;
import javax.baja.xml.XContent;
import javax.baja.xml.XElem;
import javax.baja.xml.XException;
import javax.baja.xml.XParser;
public class CertificateFile {
File file;
String error;
String vendor;
long expiration;
PublicKey publicKey;
public void load(NLicenseManager nLicenseManager) {
try {
XElem xElem = XParser.make((File)this.file).parse();
if (!xElem.qname().equals("certificate")) {
throw new XException("Root name must be certificate", xElem);
}
this.vendor = xElem.get("vendor");
XElem xElem2 = xElem.elem("publicKey");
byte[] byArray = Base64.decode((String)xElem2.string());
this.publicKey = LicenseUtil.toPublicKey(byArray);
long l = System.currentTimeMillis();
this.expiration = LicenseUtil.parseDate(xElem.get("expiration"));
if (l > this.expiration) {
this.error = "Expired";
return;
}
XElem xElem3 = xElem.elem("signature");
byte[] byArray2 = Base64.decode((String)xElem3.string());
xElem.removeContent((XContent)xElem3);
byte[] byArray3 = LicenseUtil.encode(xElem);
if (!LicenseUtil.verify(byArray3, byArray2, LicenseUtil.getMasterPublicKey())) {
this.error = "Invalid signature";
return;
}
}
catch (XException xException) {
this.error = "Invalid XML: " + xException.getMessage();
}
catch (Throwable throwable) {
this.error = throwable.toString();
}
}
public boolean isValid() {
boolean bl = false;
if (this.error == null) {
bl = true;
}
return bl;
}
public PublicKey getPublicKey() {
return this.publicKey;
}
public String toString() {
if (this.isValid()) {
return this.file.getName() + " <" + this.vendor + "> [expires: " + LicenseUtil.formatDate(this.expiration) + "] {valid}";
}
return this.file.getName() + " {invalid: " + this.error + '}';
}
CertificateFile(File file) {
this.file = file;
}
}
@@ -0,0 +1,441 @@
/*
* Decompiled with CFR 0.152.
*
* Could not load the following classes:
* javax.baja.xml.XElem
*/
package com.tridium.sys.license;
import com.tridium.sys.license.FlrConfig;
import com.tridium.sys.license.FlrException;
import com.tridium.sys.license.LicenseFile;
import com.tridium.sys.license.NLicenseManager;
import com.tridium.sys.license.XFlrMsg;
import java.math.BigInteger;
import java.net.HttpURLConnection;
import java.net.URL;
import java.security.DigestException;
import java.security.MessageDigest;
import java.util.Random;
import java.util.StringTokenizer;
import javax.baja.license.LicenseDatabaseException;
import javax.baja.sys.BAbsTime;
import javax.baja.sys.BFacets;
import javax.baja.sys.BLong;
import javax.baja.sys.BRelTime;
import javax.baja.sys.Sys;
import javax.baja.util.Version;
import javax.baja.xml.XElem;
public class FloatingLicenseManager
extends NLicenseManager {
static final int MIN_HB_FREQ = 5;
static final int MAX_HB_FREQ;
static final int HB_MISS_LIMIT;
FlrClient client;
private Heartbeat heartbeat;
private ReleaseLicenseHook releaseHook;
private FlrConfig flrConfig;
private String licPack;
protected LicenseFile[] loadLicenses() {
try {
Runtime.getRuntime().removeShutdownHook(this.releaseHook);
LicenseFile[] licenseFileArray = this.client.getLicenses();
int n = 0;
while (n < licenseFileArray.length) {
licenseFileArray[n].load(this);
++n;
}
Runtime.getRuntime().addShutdownHook(this.releaseHook);
if (this.heartbeat == null) {
this.heartbeat = new Heartbeat(this);
this.heartbeat.start();
}
return licenseFileArray;
}
catch (LicenseDatabaseException licenseDatabaseException) {
this.setFatalLicenseFault(licenseDatabaseException.getMessage());
return new FloatingLicense[0];
}
}
public FlrConfig getConfig() {
return this.flrConfig;
}
public String getPack() {
return this.licPack;
}
boolean failover() {
log.error(this.lex.getText("flm.failover.notify", new Object[]{this.client.getBoundUrl()}));
this.reload();
if (this.isFatalLicenseFault()) {
log.error(this.lex.getText("flm.failover.fail"));
return false;
}
log.message(this.lex.getText("flm.failover.success", new Object[]{this.client.getBoundUrl()}));
return true;
}
public FloatingLicenseManager(FlrConfig flrConfig, String string) {
this.flrConfig = flrConfig;
this.licPack = string;
this.client = new FlrClient(this);
this.releaseHook = new ReleaseLicenseHook(this);
}
static {
int n = 3600;
try {
n = Integer.parseInt(System.getProperty("niagara.flm.hb.freq"));
if (n > 3600) {
n = 3600;
}
}
catch (Exception exception) {}
MAX_HB_FREQ = Math.max(5, n);
int n2 = 24;
try {
n2 = Integer.parseInt(System.getProperty("niagara.flm.hb.maxMiss"));
if (n2 > 24) {
n2 = 24;
}
}
catch (Exception exception) {}
HB_MISS_LIMIT = Math.max(1, n2);
}
/*
* Illegal identifiers - consider using --renameillegalidents true
*/
private static class FlrClient {
private static final String XML_CONTENT = "text/xml; charset=\"utf-8\"";
XFlrMsg reqMsg;
private FloatingLicenseManager mgr;
private FlrCksum flrCksum;
private int boundFlr;
public boolean isBound() {
boolean bl = false;
if (this.boundFlr >= 0) {
bl = true;
}
return bl;
}
public URL getBoundUrl() {
if (!this.isBound()) {
throw new IllegalStateException("FLR is not bound");
}
return this.mgr.flrConfig.flrs()[this.boundFlr].getURL();
}
public FloatingLicense[] getLicenses() throws LicenseDatabaseException {
FlrConfig.FlrDef[] flrDefArray = this.mgr.getConfig().flrs();
int n = this.isBound() ? this.boundFlr : (this.boundFlr = 0);
while (true) {
XElem[] xElemArray;
Object object;
try {
XFlrMsg xFlrMsg = new XFlrMsg("lease");
xFlrMsg.setPayload(new XElem("lease").addAttr("pack", this.mgr.getPack()));
xFlrMsg.setMetadata("autofree", BLong.make(this.calcAutoFree()));
object = this.post(flrDefArray[this.boundFlr].getURL(), xFlrMsg);
xElemArray = ((XFlrMsg)object).getPayload().elems("license");
FloatingLicense[] floatingLicenseArray = new FloatingLicense[xElemArray.length];
int n2 = 0;
while (n2 < xElemArray.length) {
floatingLicenseArray[n2] = new FloatingLicense(xElemArray[n2]);
++n2;
}
this.reqMsg = xFlrMsg;
log.message(this.mgr.lex.getText("flm.lease.success", new Object[]{this.mgr.getPack(), flrDefArray[this.boundFlr].getURL()}));
return floatingLicenseArray;
}
catch (Exception exception) {
object = log.isTraceOn() ? "" : " -- " + exception.getMessage();
xElemArray = this.mgr.lex.getText("flm.lease.fail", new Object[]{this.mgr.getPack(), flrDefArray[this.boundFlr].getURL(), object});
if (log.isTraceOn()) {
log.trace((String)xElemArray, exception);
} else {
log.error((String)xElemArray);
}
if (flrDefArray.length != 1) {
++this.boundFlr;
this.boundFlr %= flrDefArray.length;
if (n != this.boundFlr) continue;
}
throw new LicenseDatabaseException(this.mgr.lex.getText("flm.lease.fatal", new Object[]{this.mgr.getPack()}));
}
break;
}
}
public XFlrMsg post(XFlrMsg xFlrMsg) {
return this.post(this.getBoundUrl(), xFlrMsg);
}
public XFlrMsg post(URL uRL, XFlrMsg xFlrMsg) {
try {
xFlrMsg.getChallenge().setCksum(this.flrCksum.calcCksum(xFlrMsg, true));
HttpURLConnection httpURLConnection = (HttpURLConnection)uRL.openConnection();
httpURLConnection.setDoOutput(true);
httpURLConnection.setRequestProperty("Content-Type", XML_CONTENT);
xFlrMsg.write(httpURLConnection.getOutputStream(), true);
XFlrMsg xFlrMsg2 = XFlrMsg.make(httpURLConnection.getInputStream());
xFlrMsg2.throwIfError();
try {
this.flrCksum.validate(xFlrMsg, xFlrMsg2);
}
catch (DigestException digestException) {
throw new SecurityException(digestException.getMessage());
}
return xFlrMsg2;
}
catch (FlrException flrException) {
throw flrException;
}
catch (Exception exception) {
throw new FlrException("Message to FLR failed: " + exception);
}
}
private final long calcAutoFree() {
return BRelTime.makeSeconds(MAX_HB_FREQ).getMillis() * (long)HB_MISS_LIMIT;
}
private final /* synthetic */ void this() {
this.flrCksum = new CksumMagic();
}
public FlrClient(FloatingLicenseManager floatingLicenseManager) {
this.this();
this.mgr = floatingLicenseManager;
this.boundFlr = -1;
}
}
private static class Heartbeat
extends Thread {
private FloatingLicenseManager mgr;
private FlrClient client;
private int missedHeartbeats;
public boolean isFlatlined() {
boolean bl = false;
if (this.missedHeartbeats >= HB_MISS_LIMIT) {
bl = true;
}
return bl;
}
private final void forceFlatline() {
this.missedHeartbeats = HB_MISS_LIMIT;
}
private final long nextHbTime() {
return BRelTime.makeSeconds((int)(Math.random() * (double)(MAX_HB_FREQ - 5 + 1)) + 5).getMillis();
}
public void run() {
while (true) {
block11: {
try {
Object object;
long l = this.nextHbTime();
if (log.isTraceOn()) {
object = BAbsTime.now().add(BRelTime.make(l)).toString(BFacets.make("showSeconds", true));
log.trace(this.mgr.lex.getText("flm.hb.next", new Object[]{object}));
}
Thread.sleep(l);
object = new XFlrMsg("heartbeat");
((XFlrMsg)object).setPayload(this.client.reqMsg.asXML());
XFlrMsg xFlrMsg = this.client.post((XFlrMsg)object);
XElem xElem = xFlrMsg.getPayload();
if (xElem.name().equals("reject")) {
log.error(this.mgr.lex.getText("flm.hb.rejected"));
this.forceFlatline();
break block11;
}
if (xElem.name().equals("licenses")) break block11;
if (xElem.name().equals("success")) {
if (this.missedHeartbeats > 0) {
log.message(this.mgr.lex.getText("flm.hb.alive"));
}
this.missedHeartbeats = 0;
break block11;
}
throw new IllegalStateException("Invalid heartbeat response: " + xElem.name());
}
catch (InterruptedException interruptedException) {
}
catch (Exception exception) {
++this.missedHeartbeats;
Integer n = new Integer(HB_MISS_LIMIT - this.missedHeartbeats);
if (log.isTraceOn()) {
log.trace(this.mgr.lex.getText("flm.hb.missed", new Object[]{n, ""}), exception);
}
log.warning(this.mgr.lex.getText("flm.hb.missed", new Object[]{n, " -- " + exception.getMessage()}));
}
}
if (!this.isFlatlined()) continue;
if (!this.mgr.failover()) break;
this.missedHeartbeats = 0;
}
if (this.isFlatlined()) {
log.error(this.mgr.lex.getText("flm.exit"));
if (Sys.getStation() != null) {
Sys.getStation().save();
}
System.exit(1);
}
}
public Heartbeat(FloatingLicenseManager floatingLicenseManager) {
super(BAbsTime.now().toString());
this.mgr = floatingLicenseManager;
this.client = floatingLicenseManager.client;
this.missedHeartbeats = 0;
}
}
private static class FloatingLicense
extends LicenseFile {
XElem license;
protected String getLicenseName() {
return "Floating License";
}
protected XElem getRoot() throws Exception {
return this.license;
}
protected boolean isLicenseHostIdValid() {
return this.hostId.equals("FLOATING");
}
public FloatingLicense(XElem xElem) {
this.license = xElem;
}
}
private static final class ReleaseLicenseHook
extends Thread {
private FloatingLicenseManager mgr;
public final void run() {
try {
XFlrMsg xFlrMsg = new XFlrMsg("checkin");
xFlrMsg.setPayload(this.mgr.client.reqMsg.asXML());
log.message(this.mgr.lex.getText("flm.checkin.begin"));
this.mgr.client.post(xFlrMsg);
log.message(this.mgr.lex.getText("flm.checkin.end"));
}
catch (Exception exception) {
log.error(this.mgr.lex.getText("flm.checkin.failed", new Object[]{" -- " + exception.getMessage()}));
log.error("Failed to check-in leased license.", exception);
}
}
public ReleaseLicenseHook(FloatingLicenseManager floatingLicenseManager) {
this.mgr = floatingLicenseManager;
}
}
public static interface FlrCksum {
public Version version();
public String calcCksum(XFlrMsg var1, boolean var2) throws DigestException;
public void validate(XFlrMsg var1, XFlrMsg var2) throws DigestException;
public void validate(XFlrMsg var1, BRelTime var2) throws DigestException;
}
private static class CksumMagic
implements FlrCksum {
private Version version = new Version("1.0");
public Version version() {
return this.version;
}
public String calcCksum(XFlrMsg xFlrMsg, boolean bl) throws DigestException {
try {
MessageDigest messageDigest = MessageDigest.getInstance("md5");
XFlrMsg.XChallenge xChallenge = xFlrMsg.getChallenge();
xChallenge.setVersion(this.version);
long l = xChallenge.getTimestamp();
String string = xChallenge.getHostid();
int[] nArray = xChallenge.parseNonce();
Random random = new Random(l >>> 2 ^ -1L);
StringTokenizer stringTokenizer = new StringTokenizer(string, "-");
String[] stringArray = new String[stringTokenizer.countTokens()];
int n = 0;
while (n < stringArray.length) {
stringArray[n] = stringTokenizer.nextToken();
++n;
}
n = 0;
StringBuffer stringBuffer = new StringBuffer();
if (bl) {
stringBuffer.append(xFlrMsg.getType()).append(this.version.toString());
}
int n2 = 0;
while (n2 < 4) {
int n3 = 0;
while (n3 < nArray.length) {
boolean bl2 = random.nextBoolean();
if (bl && bl2) {
stringBuffer.append(nArray[n3]);
} else if (!bl && !bl2) {
stringBuffer.append(nArray[n3]);
} else {
stringBuffer.append(stringArray[n++ % stringArray.length]);
}
++n3;
}
++n2;
}
if (!bl) {
stringBuffer.append(xFlrMsg.getType()).append(this.version.toString());
}
return new BigInteger(1, messageDigest.digest(stringBuffer.toString().getBytes("UTF-16LE"))).toString(16);
}
catch (Exception exception) {
throw new DigestException(exception.getMessage());
}
}
public void validate(XFlrMsg xFlrMsg, XFlrMsg xFlrMsg2) throws DigestException {
XFlrMsg.XChallenge xChallenge = xFlrMsg2.getChallenge();
this.throwIfVersionMismatch(xChallenge);
String string = this.calcCksum(xFlrMsg, false);
String string2 = xChallenge.getCksum();
if (!string.equals(string2)) {
throw new DigestException("Invalid FLR cksum");
}
}
public void validate(XFlrMsg xFlrMsg, BRelTime bRelTime) throws DigestException {
XFlrMsg.XChallenge xChallenge = xFlrMsg.getChallenge();
this.throwIfVersionMismatch(xChallenge);
xChallenge.throwIfTooOld(bRelTime);
String string = xChallenge.getCksum();
String string2 = this.calcCksum(xFlrMsg, true);
if (!string.equals(string2)) {
throw new DigestException("Cksum mismatch");
}
}
private final void throwIfVersionMismatch(XFlrMsg.XChallenge xChallenge) throws DigestException {
if (!xChallenge.getVersion().equals(this.version)) {
throw new DigestException("FLR and client have different cksum methods.");
}
}
}
}
@@ -0,0 +1,231 @@
/*
* Decompiled with CFR 0.152.
*
* Could not load the following classes:
* javax.baja.xml.XContent
* javax.baja.xml.XElem
* javax.baja.xml.XException
* javax.baja.xml.XParser
*/
package com.tridium.sys.license;
import java.io.File;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import javax.baja.sys.Sys;
import javax.baja.xml.XContent;
import javax.baja.xml.XElem;
import javax.baja.xml.XException;
import javax.baja.xml.XParser;
public class FlrConfig {
public static final String filename = "flrclient.xml";
private File configFile;
private String err;
private FlrDef[] flrs;
private HashMap appToPack;
public static String aliasApp(String string) {
if (string.equals("workbench:com.tridium.workbench.shell.WbMain")) {
return "wb";
}
if (string.equals("com.tridium.sys.station.Station")) {
return "station";
}
return string;
}
public static String unaliasApp(String string) {
if (string.equals("station")) {
return "com.tridium.sys.station.Station";
}
if (string.equals("wb")) {
return "workbench:com.tridium.workbench.shell.WbMain";
}
return string;
}
public boolean exists() {
return this.configFile.exists();
}
public boolean isValid() {
boolean bl = false;
if (this.err == null) {
bl = true;
}
return bl;
}
public FlrDef[] flrs() {
return this.flrs;
}
public void addFlrDef(FlrDef flrDef) {
ArrayList<FlrDef> arrayList = new ArrayList<FlrDef>(Arrays.asList(this.flrs));
if (arrayList.contains(flrDef)) {
return;
}
arrayList.add(flrDef);
this.flrs = arrayList.toArray(new FlrDef[arrayList.size()]);
}
public void removeFlr(FlrDef flrDef) {
ArrayList<FlrDef> arrayList = new ArrayList<FlrDef>(Arrays.asList(this.flrs));
if (arrayList.remove(flrDef)) {
this.flrs = arrayList.toArray(new FlrDef[arrayList.size()]);
}
}
public String[] apps() {
return this.appToPack.keySet().toArray(new String[this.appToPack.size()]);
}
public void addPackmap(String string, String string2) {
if (string == null || string2 == null) {
return;
}
this.appToPack.put(FlrConfig.unaliasApp(string), string2);
}
public void removePackmap(String string) {
this.appToPack.remove(FlrConfig.unaliasApp(string));
}
public String getPackName(String string) {
return (String)this.appToPack.get(FlrConfig.unaliasApp(string));
}
public String toString() {
return this.err == null ? filename : this.err;
}
private final void load() {
this.configFile = new File(new File(Sys.getBajaHome(), "licenses"), filename);
if (!this.exists()) {
return;
}
try {
XElem xElem = XParser.make((File)this.configFile).parse();
if (!xElem.name().equals("flrclient")) {
throw new XException("root element must be <flrclient>");
}
this.flrs = this.parseFlrs(xElem.elems("flr"));
if (this.flrs.length == 0) {
throw new XException("No FLRs are defined");
}
this.appToPack = this.parsePacks(xElem);
}
catch (XException xException) {
this.err = "Invalid flrclient.xml XML: " + xException.getMessage();
}
catch (Exception exception) {
this.err = exception.toString();
}
}
private final FlrDef[] parseFlrs(XElem[] xElemArray) {
FlrDef[] flrDefArray = new FlrDef[xElemArray.length];
int n = 0;
while (n < xElemArray.length) {
flrDefArray[n] = new FlrDef(xElemArray[n].get("host"), xElemArray[n].geti("port"));
++n;
}
return flrDefArray;
}
private final HashMap parsePacks(XElem xElem) {
HashMap<String, String> hashMap = new HashMap<String, String>(2);
XElem[] xElemArray = xElem.elems("packmap");
int n = 0;
while (n < xElemArray.length) {
String string = FlrConfig.unaliasApp(xElemArray[n].get("app"));
String string2 = xElemArray[n].get("pack");
if (hashMap.containsKey(string)) {
throw new XException("Duplicate app defined '" + FlrConfig.aliasApp(string) + '\'', xElemArray[n]);
}
hashMap.put(FlrConfig.unaliasApp(xElemArray[n].get("app")), xElemArray[n].get("pack"));
++n;
}
return hashMap;
}
public void write() throws Exception {
XElem xElem = new XElem("flrclient");
int n = 0;
while (n < this.flrs.length) {
xElem.addContent((XContent)new XElem("flr").addAttr("host", this.flrs[n].ip).addAttr("port", Integer.toString(this.flrs[n].port)));
++n;
}
String[] stringArray = this.apps();
int n2 = 0;
while (n2 < stringArray.length) {
xElem.addContent((XContent)new XElem("packmap").addAttr("app", FlrConfig.aliasApp(stringArray[n2])).addAttr("pack", this.getPackName(stringArray[n2])));
++n2;
}
xElem.write(this.configFile);
}
public FlrConfig(FlrDef[] flrDefArray, HashMap hashMap) {
this.flrs = flrDefArray;
this.appToPack = hashMap;
}
public FlrConfig() {
this.flrs = new FlrDef[0];
this.appToPack = new HashMap();
this.load();
}
public static class FlrDef {
public final String ip;
public final int port;
public URL getURL() {
try {
return new URL("http", this.ip, this.port, "/flr/");
}
catch (MalformedURLException malformedURLException) {
malformedURLException.printStackTrace();
return null;
}
}
public int hashCode() {
int n = 1;
int n2 = 0;
if (this.ip != null) {
n2 = this.ip.hashCode();
}
n = 31 * n + n2;
n = 31 * n + this.port;
return n;
}
public boolean equals(Object object) {
if (this == object) {
return true;
}
if (object == null) {
return false;
}
if (this.getClass() != object.getClass()) {
return false;
}
FlrDef flrDef = (FlrDef)object;
if (this.ip == null ? flrDef.ip != null : !this.ip.equals(flrDef.ip)) {
return false;
}
return this.port == flrDef.port;
}
public FlrDef(String string, int n) {
this.ip = string;
this.port = n;
}
}
}
@@ -0,0 +1,23 @@
/*
* Decompiled with CFR 0.152.
*/
package com.tridium.sys.license;
public class FlrException
extends RuntimeException {
public FlrException() {
}
public FlrException(String string) {
super(string);
}
public FlrException(Throwable throwable) {
super(throwable);
}
public FlrException(String string, Throwable throwable) {
super(string, throwable);
}
}
@@ -0,0 +1,175 @@
/*
* Decompiled with CFR 0.152.
*
* Could not load the following classes:
* javax.baja.nre.util.Base64
* javax.baja.xml.XContent
* javax.baja.xml.XElem
* javax.baja.xml.XException
*/
package com.tridium.sys.license;
import com.tridium.sys.Nre;
import com.tridium.sys.license.CertificateFile;
import com.tridium.sys.license.LicenseUtil;
import com.tridium.sys.license.NFeature;
import com.tridium.sys.license.NLicenseManager;
import java.security.PublicKey;
import java.util.Properties;
import javax.baja.license.LicenseDatabaseException;
import javax.baja.nre.util.Base64;
import javax.baja.util.Version;
import javax.baja.xml.XContent;
import javax.baja.xml.XElem;
import javax.baja.xml.XException;
public abstract class LicenseFile {
protected String error;
protected String hostId;
protected String vendor;
protected long generated;
protected long expiration;
protected abstract XElem getRoot() throws Exception;
protected abstract boolean isLicenseHostIdValid();
public void load(NLicenseManager nLicenseManager) {
try {
XElem[] xElemArray;
if (Nre.getHostId() == null) {
this.error = "HostId not supported";
return;
}
XElem xElem = this.getRoot();
if (xElem.qname().equals("license")) {
this.load(nLicenseManager, xElem);
return;
}
if (xElem.qname().equals("licenses") && (xElemArray = xElem.elems("license")).length > 0) {
int n = 0;
while (n < xElemArray.length) {
this.load(nLicenseManager, xElemArray[n]);
++n;
}
return;
}
throw new XException("Missing <license> element", xElem);
}
catch (XException xException) {
this.error = "Invalid XML: " + xException.getMessage();
}
catch (Throwable throwable) {
this.error = throwable.toString();
}
}
private final void load(NLicenseManager nLicenseManager, XElem xElem) throws Exception {
Object object;
Object object2;
this.vendor = xElem.get("vendor");
CertificateFile certificateFile = nLicenseManager.getCertificate(this.vendor);
PublicKey publicKey = certificateFile.publicKey;
XElem xElem2 = xElem.elem("signature");
if (xElem2 == null) {
throw new XException("Missing signature element", xElem);
}
byte[] byArray = Base64.decode((String)xElem2.string());
this.hostId = xElem.get("hostId");
if (!this.isLicenseHostIdValid()) {
if (this.error == null) {
this.error = "HostId does not match";
}
return;
}
long l = System.currentTimeMillis();
this.generated = LicenseUtil.parseDate(xElem.get("generated"));
if (l < this.generated - 86400000L) {
this.error = "Current date is earlier than license generated date";
return;
}
this.expiration = LicenseUtil.parseDate(xElem.get("expiration"));
if (l > this.expiration) {
this.error = "License file is expired";
return;
}
String string = xElem.get("vendor");
if (string != null && string.equalsIgnoreCase("Tridium")) {
object2 = new Version(xElem.get("version"));
object = new Version("3.8");
if (((Version)object2).major() != ((Version)object).major() || ((Version)object2).minor() < ((Version)object).minor()) {
this.error = "License for older version: " + object2 + " < " + object;
return;
}
}
xElem.removeContent((XContent)xElem2);
object2 = LicenseUtil.encode(xElem);
if (!LicenseUtil.verify((byte[])object2, byArray, publicKey)) {
this.error = "Invalid signature";
return;
}
object = xElem.elems("feature");
int n = 0;
while (n < ((Object)object).length) {
try {
this.loadFeature(nLicenseManager, (XElem)object[n]);
}
catch (LicenseDatabaseException licenseDatabaseException) {
this.error = licenseDatabaseException.getMessage();
throw licenseDatabaseException;
}
catch (Throwable throwable) {
System.out.println("Invalid feature in " + this.getLicenseName() + " [line " + object[n].line() + ']');
System.out.println(" " + throwable);
}
++n;
}
}
private final void loadFeature(NLicenseManager nLicenseManager, XElem xElem) throws Exception {
String string = xElem.get("name");
long l = Long.MAX_VALUE;
String string2 = xElem.get("expiration", null);
if (string2 != null) {
l = LicenseUtil.parseDate(string2);
}
if (this.expiration < l) {
l = this.expiration;
}
NFeature nFeature = new NFeature(this.vendor, string, l);
int n = 0;
while (n < xElem.attrSize()) {
String string3 = xElem.attrName(n);
String string4 = xElem.attrValue(n);
if (!string3.equals("name") && !string3.equals("expiration")) {
if (nFeature.props == NFeature.noProps) {
nFeature.props = new Properties();
}
nFeature.props.put(string3, string4);
}
++n;
}
nLicenseManager.addFeature(nFeature);
}
protected abstract String getLicenseName();
public boolean isValid() {
boolean bl = false;
if (this.error == null) {
bl = true;
}
return bl;
}
public String toString() {
if (this.isValid()) {
return this.getLicenseName() + " <" + this.vendor + "> [expires: " + LicenseUtil.formatDate(this.expiration) + "] {valid}";
}
return this.getLicenseName() + " {invalid: " + this.error + '}';
}
LicenseFile() {
}
}
@@ -0,0 +1,592 @@
/*
* Decompiled with CFR 0.152.
*
* Could not load the following classes:
* javax.baja.nre.util.TextUtil
* javax.baja.xml.XContent
* javax.baja.xml.XElem
* javax.baja.xml.XText
*/
package com.tridium.sys.license;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.security.KeyFactory;
import java.security.PublicKey;
import java.security.Signature;
import java.security.spec.X509EncodedKeySpec;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.StringTokenizer;
import javax.baja.license.LicenseException;
import javax.baja.nre.util.TextUtil;
import javax.baja.xml.XContent;
import javax.baja.xml.XElem;
import javax.baja.xml.XText;
public class LicenseUtil {
private static PublicKey masterPublicKey;
private static byte[] masterPublicKeyData;
public static String toKey(String string, String string2) {
StringBuffer stringBuffer = new StringBuffer();
stringBuffer.append(TextUtil.toLowerCase((String)string)).append(':').append(TextUtil.toLowerCase((String)string2));
return stringBuffer.toString();
}
public static String[] parseList(String string) throws LicenseException {
ArrayList<String> arrayList = new ArrayList<String>();
StringTokenizer stringTokenizer = new StringTokenizer(string, ";");
while (stringTokenizer.hasMoreTokens()) {
arrayList.add(stringTokenizer.nextToken().trim());
}
return arrayList.toArray(new String[arrayList.size()]);
}
public static String formatDate(long l) {
if (l == Long.MAX_VALUE) {
return "never";
}
return new SimpleDateFormat("yyyy-MM-dd").format(new Date(l));
}
public static long parseDate(String string) throws LicenseException {
if (string.equalsIgnoreCase("never")) {
return Long.MAX_VALUE;
}
try {
StringTokenizer stringTokenizer = new StringTokenizer(string, "- ");
int n = Integer.parseInt(stringTokenizer.nextToken()) - 1900;
int n2 = Integer.parseInt(stringTokenizer.nextToken()) - 1;
int n3 = Integer.parseInt(stringTokenizer.nextToken());
Date date = new GregorianCalendar(n + 1900, n2, n3, 23, 59).getTime();
return date.getTime();
}
catch (Exception exception) {
throw new LicenseException("Invalid expiration format YYYY-MM-DD: " + string);
}
}
public static byte[] encode(XElem xElem) {
try {
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
LicenseUtil.encode((OutputStream)byteArrayOutputStream, xElem);
byteArrayOutputStream.flush();
return byteArrayOutputStream.toByteArray();
}
catch (Exception exception) {
throw new IllegalStateException();
}
}
private static final void encode(OutputStream outputStream, XElem xElem) throws IOException {
LicenseUtil.encode(outputStream, "<");
LicenseUtil.encode(outputStream, xElem.qname());
int n = 0;
while (n < xElem.attrSize()) {
LicenseUtil.encode(outputStream, " ");
LicenseUtil.encode(outputStream, xElem.attrName(n));
LicenseUtil.encode(outputStream, "=\"");
LicenseUtil.encode(outputStream, xElem.attrValue(n));
LicenseUtil.encode(outputStream, "\"");
++n;
}
LicenseUtil.encode(outputStream, ">\n");
n = 0;
while (n < xElem.contentSize()) {
XContent xContent = xElem.content(n);
if (xContent instanceof XElem) {
LicenseUtil.encode(outputStream, (XElem)xContent);
} else {
LicenseUtil.encode(outputStream, ((XText)xContent).string());
LicenseUtil.encode(outputStream, "\n");
}
++n;
}
LicenseUtil.encode(outputStream, "</");
LicenseUtil.encode(outputStream, xElem.qname());
LicenseUtil.encode(outputStream, ">\n");
}
private static final void encode(OutputStream outputStream, String string) throws IOException {
int n = 0;
while (n < string.length()) {
outputStream.write(string.charAt(n));
++n;
}
}
public static boolean verify(byte[] byArray, byte[] byArray2, byte[] byArray3) throws Exception {
X509EncodedKeySpec x509EncodedKeySpec = new X509EncodedKeySpec(byArray3);
KeyFactory keyFactory = KeyFactory.getInstance("DSA");
PublicKey publicKey = keyFactory.generatePublic(x509EncodedKeySpec);
return LicenseUtil.verify(byArray, byArray2, publicKey);
}
public static boolean verify(byte[] byArray, byte[] byArray2, PublicKey publicKey) throws Exception {
Signature signature = Signature.getInstance("DSA");
signature.initVerify(publicKey);
signature.update(byArray);
return signature.verify(byArray2);
}
static PublicKey toPublicKey(byte[] byArray) throws Exception {
X509EncodedKeySpec x509EncodedKeySpec = new X509EncodedKeySpec(byArray);
KeyFactory keyFactory = KeyFactory.getInstance("DSA");
return keyFactory.generatePublic(x509EncodedKeySpec);
}
static PublicKey getMasterPublicKey() throws Exception {
if (masterPublicKey == null) {
masterPublicKey = LicenseUtil.toPublicKey(masterPublicKeyData);
}
return masterPublicKey;
}
static {
byte[] byArray = new byte[444];
byArray[0] = 48;
byArray[1] = -126;
byArray[2] = 1;
byArray[3] = -72;
byArray[4] = 48;
byArray[5] = -126;
byArray[6] = 1;
byArray[7] = 44;
byArray[8] = 6;
byArray[9] = 7;
byArray[10] = 42;
byArray[11] = -122;
byArray[12] = 72;
byArray[13] = -50;
byArray[14] = 56;
byArray[15] = 4;
byArray[16] = 1;
byArray[17] = 48;
byArray[18] = -126;
byArray[19] = 1;
byArray[20] = 31;
byArray[21] = 2;
byArray[22] = -127;
byArray[23] = -127;
byArray[25] = -3;
byArray[26] = 127;
byArray[27] = 83;
byArray[28] = -127;
byArray[29] = 29;
byArray[30] = 117;
byArray[31] = 18;
byArray[32] = 41;
byArray[33] = 82;
byArray[34] = -33;
byArray[35] = 74;
byArray[36] = -100;
byArray[37] = 46;
byArray[38] = -20;
byArray[39] = -28;
byArray[40] = -25;
byArray[41] = -10;
byArray[42] = 17;
byArray[43] = -73;
byArray[44] = 82;
byArray[45] = 60;
byArray[46] = -17;
byArray[47] = 68;
byArray[49] = -61;
byArray[50] = 30;
byArray[51] = 63;
byArray[52] = -128;
byArray[53] = -74;
byArray[54] = 81;
byArray[55] = 38;
byArray[56] = 105;
byArray[57] = 69;
byArray[58] = 93;
byArray[59] = 64;
byArray[60] = 34;
byArray[61] = 81;
byArray[62] = -5;
byArray[63] = 89;
byArray[64] = 61;
byArray[65] = -115;
byArray[66] = 88;
byArray[67] = -6;
byArray[68] = -65;
byArray[69] = -59;
byArray[70] = -11;
byArray[71] = -70;
byArray[72] = 48;
byArray[73] = -10;
byArray[74] = -53;
byArray[75] = -101;
byArray[76] = 85;
byArray[77] = 108;
byArray[78] = -41;
byArray[79] = -127;
byArray[80] = 59;
byArray[81] = -128;
byArray[82] = 29;
byArray[83] = 52;
byArray[84] = 111;
byArray[85] = -14;
byArray[86] = 102;
byArray[87] = 96;
byArray[88] = -73;
byArray[89] = 107;
byArray[90] = -103;
byArray[91] = 80;
byArray[92] = -91;
byArray[93] = -92;
byArray[94] = -97;
byArray[95] = -97;
byArray[96] = -24;
byArray[97] = 4;
byArray[98] = 123;
byArray[99] = 16;
byArray[100] = 34;
byArray[101] = -62;
byArray[102] = 79;
byArray[103] = -69;
byArray[104] = -87;
byArray[105] = -41;
byArray[106] = -2;
byArray[107] = -73;
byArray[108] = -58;
byArray[109] = 27;
byArray[110] = -8;
byArray[111] = 59;
byArray[112] = 87;
byArray[113] = -25;
byArray[114] = -58;
byArray[115] = -88;
byArray[116] = -90;
byArray[117] = 21;
byArray[118] = 15;
byArray[119] = 4;
byArray[120] = -5;
byArray[121] = -125;
byArray[122] = -10;
byArray[123] = -45;
byArray[124] = -59;
byArray[125] = 30;
byArray[126] = -61;
byArray[127] = 2;
byArray[128] = 53;
byArray[129] = 84;
byArray[130] = 19;
byArray[131] = 90;
byArray[132] = 22;
byArray[133] = -111;
byArray[134] = 50;
byArray[135] = -10;
byArray[136] = 117;
byArray[137] = -13;
byArray[138] = -82;
byArray[139] = 43;
byArray[140] = 97;
byArray[141] = -41;
byArray[142] = 42;
byArray[143] = -17;
byArray[144] = -14;
byArray[145] = 34;
byArray[146] = 3;
byArray[147] = 25;
byArray[148] = -99;
byArray[149] = -47;
byArray[150] = 72;
byArray[151] = 1;
byArray[152] = -57;
byArray[153] = 2;
byArray[154] = 21;
byArray[156] = -105;
byArray[157] = 96;
byArray[158] = 80;
byArray[159] = -113;
byArray[160] = 21;
byArray[161] = 35;
byArray[162] = 11;
byArray[163] = -52;
byArray[164] = -78;
byArray[165] = -110;
byArray[166] = -71;
byArray[167] = -126;
byArray[168] = -94;
byArray[169] = -21;
byArray[170] = -124;
byArray[171] = 11;
byArray[172] = -16;
byArray[173] = 88;
byArray[174] = 28;
byArray[175] = -11;
byArray[176] = 2;
byArray[177] = -127;
byArray[178] = -127;
byArray[180] = -9;
byArray[181] = -31;
byArray[182] = -96;
byArray[183] = -123;
byArray[184] = -42;
byArray[185] = -101;
byArray[186] = 61;
byArray[187] = -34;
byArray[188] = -53;
byArray[189] = -68;
byArray[190] = -85;
byArray[191] = 92;
byArray[192] = 54;
byArray[193] = -72;
byArray[194] = 87;
byArray[195] = -71;
byArray[196] = 121;
byArray[197] = -108;
byArray[198] = -81;
byArray[199] = -69;
byArray[200] = -6;
byArray[201] = 58;
byArray[202] = -22;
byArray[203] = -126;
byArray[204] = -7;
byArray[205] = 87;
byArray[206] = 76;
byArray[207] = 11;
byArray[208] = 61;
byArray[209] = 7;
byArray[210] = -126;
byArray[211] = 103;
byArray[212] = 81;
byArray[213] = 89;
byArray[214] = 87;
byArray[215] = -114;
byArray[216] = -70;
byArray[217] = -44;
byArray[218] = 89;
byArray[219] = 79;
byArray[220] = -26;
byArray[221] = 113;
byArray[222] = 7;
byArray[223] = 16;
byArray[224] = -127;
byArray[225] = -128;
byArray[226] = -76;
byArray[227] = 73;
byArray[228] = 22;
byArray[229] = 113;
byArray[230] = 35;
byArray[231] = -24;
byArray[232] = 76;
byArray[233] = 40;
byArray[234] = 22;
byArray[235] = 19;
byArray[236] = -73;
byArray[237] = -49;
byArray[238] = 9;
byArray[239] = 50;
byArray[240] = -116;
byArray[241] = -56;
byArray[242] = -90;
byArray[243] = -31;
byArray[244] = 60;
byArray[245] = 22;
byArray[246] = 122;
byArray[247] = -117;
byArray[248] = 84;
byArray[249] = 124;
byArray[250] = -115;
byArray[251] = 40;
byArray[252] = -32;
byArray[253] = -93;
byArray[254] = -82;
byArray[255] = 30;
byArray[256] = 43;
byArray[257] = -77;
byArray[258] = -90;
byArray[259] = 117;
byArray[260] = -111;
byArray[261] = 110;
byArray[262] = -93;
byArray[263] = 127;
byArray[264] = 11;
byArray[265] = -6;
byArray[266] = 33;
byArray[267] = 53;
byArray[268] = 98;
byArray[269] = -15;
byArray[270] = -5;
byArray[271] = 98;
byArray[272] = 122;
byArray[273] = 1;
byArray[274] = 36;
byArray[275] = 59;
byArray[276] = -52;
byArray[277] = -92;
byArray[278] = -15;
byArray[279] = -66;
byArray[280] = -88;
byArray[281] = 81;
byArray[282] = -112;
byArray[283] = -119;
byArray[284] = -88;
byArray[285] = -125;
byArray[286] = -33;
byArray[287] = -31;
byArray[288] = 90;
byArray[289] = -27;
byArray[290] = -97;
byArray[291] = 6;
byArray[292] = -110;
byArray[293] = -117;
byArray[294] = 102;
byArray[295] = 94;
byArray[296] = -128;
byArray[297] = 123;
byArray[298] = 85;
byArray[299] = 37;
byArray[300] = 100;
byArray[301] = 1;
byArray[302] = 76;
byArray[303] = 59;
byArray[304] = -2;
byArray[305] = -49;
byArray[306] = 73;
byArray[307] = 42;
byArray[308] = 3;
byArray[309] = -127;
byArray[310] = -123;
byArray[312] = 2;
byArray[313] = -127;
byArray[314] = -127;
byArray[316] = -117;
byArray[317] = -24;
byArray[318] = 19;
byArray[319] = 70;
byArray[320] = 80;
byArray[321] = -13;
byArray[322] = -91;
byArray[323] = 91;
byArray[324] = 33;
byArray[325] = -33;
byArray[326] = 99;
byArray[327] = -67;
byArray[328] = 97;
byArray[329] = -80;
byArray[330] = 1;
byArray[331] = -34;
byArray[332] = -33;
byArray[333] = 25;
byArray[334] = -80;
byArray[335] = 27;
byArray[336] = 121;
byArray[337] = -11;
byArray[338] = 71;
byArray[339] = 26;
byArray[340] = -70;
byArray[341] = -126;
byArray[342] = -85;
byArray[343] = -95;
byArray[344] = -106;
byArray[345] = -84;
byArray[346] = 45;
byArray[347] = -73;
byArray[348] = -9;
byArray[349] = 71;
byArray[350] = -87;
byArray[351] = -43;
byArray[352] = 113;
byArray[353] = 70;
byArray[354] = -59;
byArray[355] = -24;
byArray[356] = -122;
byArray[357] = 31;
byArray[358] = 58;
byArray[359] = 100;
byArray[360] = 3;
byArray[361] = -95;
byArray[362] = 91;
byArray[363] = -27;
byArray[364] = -104;
byArray[365] = -99;
byArray[366] = -119;
byArray[367] = 16;
byArray[368] = -42;
byArray[369] = 85;
byArray[370] = -36;
byArray[371] = -67;
byArray[372] = -102;
byArray[373] = -52;
byArray[374] = 78;
byArray[375] = -93;
byArray[376] = -95;
byArray[377] = 94;
byArray[378] = 67;
byArray[379] = 53;
byArray[380] = -34;
byArray[381] = 13;
byArray[382] = -13;
byArray[383] = 72;
byArray[384] = -57;
byArray[385] = -115;
byArray[386] = 82;
byArray[387] = 56;
byArray[388] = 82;
byArray[389] = 60;
byArray[390] = -23;
byArray[391] = 98;
byArray[392] = 113;
byArray[393] = -128;
byArray[394] = -56;
byArray[395] = -105;
byArray[396] = 81;
byArray[397] = -4;
byArray[398] = 63;
byArray[399] = -75;
byArray[400] = 81;
byArray[401] = 3;
byArray[402] = 38;
byArray[403] = 38;
byArray[404] = 103;
byArray[405] = -48;
byArray[406] = -33;
byArray[407] = -108;
byArray[408] = -128;
byArray[409] = -1;
byArray[410] = 25;
byArray[411] = 83;
byArray[412] = -112;
byArray[413] = -61;
byArray[414] = 57;
byArray[415] = 84;
byArray[416] = 68;
byArray[417] = -94;
byArray[418] = -24;
byArray[419] = 15;
byArray[420] = -80;
byArray[421] = -44;
byArray[422] = -106;
byArray[423] = -19;
byArray[424] = 55;
byArray[425] = 5;
byArray[426] = 14;
byArray[427] = 40;
byArray[428] = 75;
byArray[429] = 35;
byArray[430] = 42;
byArray[431] = -17;
byArray[432] = 47;
byArray[433] = 53;
byArray[434] = -15;
byArray[435] = 77;
byArray[436] = 56;
byArray[437] = -106;
byArray[438] = -63;
byArray[439] = 100;
byArray[440] = -11;
byArray[441] = -96;
byArray[442] = -114;
byArray[443] = -106;
masterPublicKeyData = byArray;
}
}
@@ -0,0 +1,113 @@
/*
* Decompiled with CFR 0.152.
*
* Could not load the following classes:
* javax.baja.nre.util.TextUtil
*/
package com.tridium.sys.license;
import com.tridium.sys.license.LicenseUtil;
import java.util.Properties;
import javax.baja.license.Feature;
import javax.baja.license.FeatureLicenseExpiredException;
import javax.baja.license.FeatureNotLicensedException;
import javax.baja.nre.util.TextUtil;
import javax.baja.sys.Clock;
/*
* Illegal identifiers - consider using --renameillegalidents true
*/
public class NFeature
implements Feature {
static Properties noProps = new Properties();
final String key;
final String vendorName;
final String featureName;
long expiration;
Properties props;
public String getVendorName() {
return this.vendorName;
}
public String getFeatureName() {
return this.featureName;
}
public boolean isExpired() {
boolean bl = false;
if (this.expiration < Clock.millis()) {
bl = true;
}
return bl;
}
public void check() throws FeatureNotLicensedException {
if (this.isExpired()) {
throw new FeatureLicenseExpiredException(this.toString());
}
}
public long getExpiration() {
return this.expiration;
}
public String[] list() {
return this.props.keySet().toArray(new String[this.props.size()]);
}
public String get(String string) {
return this.props.getProperty(string);
}
public String get(String string, String string2) {
return this.props.getProperty(string, string2);
}
public boolean getb(String string, boolean bl) {
String string2 = this.props.getProperty(string);
if (string2 == null) {
return bl;
}
if ((string2 = TextUtil.toLowerCase((String)string2)).equals("true")) {
return true;
}
if (string2.equals("false")) {
return false;
}
throw new IllegalStateException("Invalid boolean " + string2);
}
public int geti(String string, int n) {
String string2 = this.props.getProperty(string);
if (string2 == null) {
return n;
}
return Integer.parseInt(string2);
}
public String toString() {
String string = this.expiration == Long.MAX_VALUE ? "never" : LicenseUtil.formatDate(this.expiration);
if (this.isExpired()) {
return this.key + " [EXPIRED: " + string + ']';
}
return this.key + " [expires: " + string + ']';
}
void merge(NFeature nFeature) {
this.expiration = Math.max(this.expiration, nFeature.expiration);
}
private final /* synthetic */ void this() {
this.props = noProps;
}
NFeature(String string, String string2, long l) {
this.this();
this.key = LicenseUtil.toKey(string, string2);
this.vendorName = string;
this.featureName = string2;
this.expiration = l;
}
}
@@ -0,0 +1,286 @@
/*
* Decompiled with CFR 0.152.
*
* Could not load the following classes:
* javax.baja.nre.util.SortUtil
*/
package com.tridium.sys.license;
import com.tridium.sys.Nre;
import com.tridium.sys.license.Brand;
import com.tridium.sys.license.CertificateFile;
import com.tridium.sys.license.FloatingLicenseManager;
import com.tridium.sys.license.FlrConfig;
import com.tridium.sys.license.LicenseFile;
import com.tridium.sys.license.LicenseUtil;
import com.tridium.sys.license.NFeature;
import com.tridium.sys.license.NodeLockedLicenseManager;
import java.io.File;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.HashMap;
import javax.baja.license.Feature;
import javax.baja.license.FeatureNotLicensedException;
import javax.baja.license.LicenseDatabaseException;
import javax.baja.license.LicenseManager;
import javax.baja.log.Log;
import javax.baja.nre.util.SortUtil;
import javax.baja.spy.Spy;
import javax.baja.spy.SpyWriter;
import javax.baja.sys.Sys;
import javax.baja.util.Lexicon;
/*
* Illegal identifiers - consider using --renameillegalidents true
*/
public abstract class NLicenseManager
implements LicenseManager {
protected static final Log log = Log.getLog("sys.license");
final String TRIDIUM_BRAND_KEY;
protected Lexicon lex;
private HashMap features;
private CertificateFile[] certificates;
private LicenseFile[] licenses;
private String fatalLicenseFault;
public static NLicenseManager make() {
NLicenseManager nLicenseManager = new NodeLockedLicenseManager();
if (Nre.args == null || Nre.args.parameters.length == 0) {
return nLicenseManager;
}
FlrConfig flrConfig = new FlrConfig();
if (flrConfig.exists()) {
if (flrConfig.isValid()) {
String string = Nre.args.getOption("pack");
if (string == null && (string = flrConfig.getPackName(Nre.args.parameters[0])) == null) {
log.warning("No license pack is mapped for app '" + FlrConfig.aliasApp(Nre.args.parameters[0]) + "'. Looking for a node-locked license.");
} else {
nLicenseManager = new FloatingLicenseManager(flrConfig, string);
}
} else {
log.error("flrclient.xml file exists, but is not valid: { " + flrConfig + " }. Looking for a node-locked license.");
}
}
return nLicenseManager;
}
public Feature getFeature(String string, String string2) throws FeatureNotLicensedException, LicenseDatabaseException {
if (this.fatalLicenseFault != null) {
throw new LicenseDatabaseException(this.fatalLicenseFault);
}
String string3 = LicenseUtil.toKey(string, string2);
Feature feature = (Feature)this.features.get(string3);
if (feature == null) {
throw new FeatureNotLicensedException(string3);
}
return feature;
}
public Feature checkFeature(String string, String string2) throws FeatureNotLicensedException, LicenseDatabaseException {
if (this.fatalLicenseFault != null) {
throw new LicenseDatabaseException(this.fatalLicenseFault);
}
String string3 = LicenseUtil.toKey(string, string2);
Feature feature = (Feature)this.features.get(string3);
if (feature == null) {
throw new FeatureNotLicensedException(string3);
}
feature.check();
return feature;
}
public Feature[] getFeatures() throws LicenseDatabaseException {
if (this.fatalLicenseFault != null) {
throw new LicenseDatabaseException(this.fatalLicenseFault);
}
Object[] objectArray = this.features.values().toArray(new NFeature[this.features.size()]);
Object[] objectArray2 = new String[objectArray.length];
int n = 0;
while (n < objectArray2.length) {
objectArray2[n] = ((NFeature)objectArray[n]).key;
++n;
}
SortUtil.sort((Object[])objectArray2, (Object[])objectArray, (boolean)true);
return objectArray;
}
public final CertificateFile getCertificate(String string) throws LicenseDatabaseException {
int n = 0;
while (n < this.certificates.length) {
CertificateFile certificateFile = this.certificates[n];
if (string.equals(certificateFile.vendor)) {
if (!certificateFile.isValid()) {
throw new LicenseDatabaseException("Invalid certificate for vendor: " + string);
}
return certificateFile;
}
++n;
}
throw new LicenseDatabaseException("No certificate for vendor: " + string);
}
protected final void setFatalLicenseFault(String string) {
this.fatalLicenseFault = string;
}
protected final boolean isFatalLicenseFault() {
boolean bl = false;
if (this.fatalLicenseFault != null) {
bl = true;
}
return bl;
}
protected final CertificateFile[] getCertificates() {
return this.certificates;
}
protected final void setCertificates(CertificateFile[] certificateFileArray) {
this.certificates = certificateFileArray;
}
protected final LicenseFile[] getLicenses() {
return this.licenses;
}
protected final void setLicenses(LicenseFile[] licenseFileArray) {
this.licenses = licenseFileArray;
}
public void reload() {
this.load();
}
protected final void load() {
this.features = new HashMap();
this.setCertificates(this.loadCertificates());
this.setLicenses(this.loadLicenses());
}
protected CertificateFile[] loadCertificates() {
ArrayList<CertificateFile> arrayList = new ArrayList<CertificateFile>();
File file = new File(Sys.getBajaHome(), "certificates");
File[] fileArray = file.listFiles();
int n = 0;
while (fileArray != null && n < fileArray.length) {
if (fileArray[n].getName().toLowerCase().endsWith(".certificate")) {
CertificateFile certificateFile = new CertificateFile(fileArray[n]);
certificateFile.load(this);
arrayList.add(certificateFile);
}
++n;
}
return arrayList.toArray(new CertificateFile[arrayList.size()]);
}
protected abstract LicenseFile[] loadLicenses();
protected void addFeature(NFeature nFeature) throws LicenseDatabaseException {
String string = nFeature.key;
NFeature nFeature2 = (NFeature)this.features.get(string);
if (nFeature2 != null) {
if (this.TRIDIUM_BRAND_KEY.equals(string)) {
this.fatalLicenseFault = "Cannot have multiple branded licenses";
throw new LicenseDatabaseException(this.fatalLicenseFault);
}
nFeature2.merge(nFeature);
} else {
this.features.put(nFeature.key, nFeature);
}
}
public void dump() {
PrintWriter printWriter = new PrintWriter(System.out);
this.dump(printWriter);
printWriter.flush();
}
public void dump(PrintWriter printWriter) {
printWriter.println("");
printWriter.println("Niagara Licensing");
printWriter.println("HostId=" + Nre.getHostId());
printWriter.println("");
printWriter.println("Certificates");
if (this.certificates.length == 0) {
printWriter.println(" none");
}
int n = 0;
while (n < this.certificates.length) {
printWriter.println(" " + this.certificates[n]);
++n;
}
printWriter.println("");
printWriter.print("Licenses ");
printWriter.println(this instanceof NodeLockedLicenseManager ? "(node-locked)" : "(floating)");
if (this.licenses.length == 0) {
printWriter.println(" none");
}
n = 0;
while (n < this.licenses.length) {
printWriter.println(" " + this.licenses[n]);
++n;
}
if (this.fatalLicenseFault != null) {
return;
}
printWriter.println("");
printWriter.println("Features");
Feature[] featureArray = this.getFeatures();
if (featureArray.length == 0) {
printWriter.println(" none");
}
int n2 = 0;
while (n2 < featureArray.length) {
NFeature nFeature = (NFeature)featureArray[n2];
printWriter.println(" " + nFeature);
String[] stringArray = nFeature.list();
int n3 = 0;
while (n3 < stringArray.length) {
printWriter.println(" " + stringArray[n3] + '=' + nFeature.get(stringArray[n3]));
++n3;
}
++n2;
}
try {
printWriter.println("");
printWriter.println("Brand");
printWriter.println(" brandId = " + Brand.getBrandId());
printWriter.println(" accept.station.in = " + Brand.getAcceptStationInString());
printWriter.println(" accept.station.out = " + Brand.getAcceptStationOutString());
printWriter.println(" accept.wb.in = " + Brand.getAcceptWbInString());
printWriter.println(" accept.wb.out = " + Brand.getAcceptWbOutString());
}
catch (Exception exception) {}
}
public void postInit() {
this.lex = Lexicon.make("baja");
this.load();
if (Nre.spySysManagers.find("licenseManager") != null) {
Nre.spySysManagers.remove("licenseManager");
}
Nre.spySysManagers.add("licenseManager", new Page());
}
private final /* synthetic */ void this() {
this.TRIDIUM_BRAND_KEY = LicenseUtil.toKey("tridium", "brand");
this.fatalLicenseFault = null;
}
protected NLicenseManager() {
this.this();
}
/*
* Illegal identifiers - consider using --renameillegalidents true
*/
public class Page
extends Spy {
public void write(SpyWriter spyWriter) throws Exception {
spyWriter.print("<pre>");
NLicenseManager.this.dump(spyWriter);
spyWriter.print("</pre>");
}
}
}
@@ -0,0 +1,64 @@
/*
* Decompiled with CFR 0.152.
*
* Could not load the following classes:
* javax.baja.xml.XElem
* javax.baja.xml.XParser
*/
package com.tridium.sys.license;
import com.tridium.sys.Nre;
import com.tridium.sys.license.LicenseFile;
import com.tridium.sys.license.NLicenseManager;
import com.tridium.sys.license.dom.LicenseDatabase;
import java.io.File;
import java.util.ArrayList;
import javax.baja.sys.Sys;
import javax.baja.xml.XElem;
import javax.baja.xml.XParser;
public class NodeLockedLicenseManager
extends NLicenseManager {
protected LicenseFile[] loadLicenses() {
LicenseDatabase.LOCAL_INSTANCE.getHostIds();
ArrayList<NodeLockedLicense> arrayList = new ArrayList<NodeLockedLicense>();
File file = new File(Sys.getBajaHome(), "licenses");
File[] fileArray = file.listFiles();
int n = 0;
while (fileArray != null && n < fileArray.length) {
if (fileArray[n].getName().toLowerCase().endsWith(".license")) {
NodeLockedLicense nodeLockedLicense = new NodeLockedLicense(fileArray[n]);
nodeLockedLicense.load(this);
arrayList.add(nodeLockedLicense);
}
++n;
}
return arrayList.toArray(new LicenseFile[arrayList.size()]);
}
private static class NodeLockedLicense
extends LicenseFile {
File file;
protected String getLicenseName() {
return this.file.getName();
}
protected XElem getRoot() throws Exception {
return XParser.make((File)this.file).parse();
}
protected boolean isLicenseHostIdValid() {
boolean bl = false;
if (this.hostId.equals(Nre.getHostId()) || this.hostId.equals("*")) {
bl = true;
}
return bl;
}
public NodeLockedLicense(File file) {
this.file = file;
}
}
}
@@ -0,0 +1,248 @@
/*
* Decompiled with CFR 0.152.
*
* Could not load the following classes:
* javax.baja.xml.XContent
* javax.baja.xml.XElem
* javax.baja.xml.XParser
* javax.baja.xml.XWriter
*/
package com.tridium.sys.license;
import com.tridium.sys.Nre;
import com.tridium.sys.license.FlrException;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.math.BigInteger;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.Random;
import java.util.StringTokenizer;
import javax.baja.data.BIDataValue;
import javax.baja.sys.BFacets;
import javax.baja.sys.BRelTime;
import javax.baja.sys.Clock;
import javax.baja.util.Lexicon;
import javax.baja.util.Version;
import javax.baja.xml.XContent;
import javax.baja.xml.XElem;
import javax.baja.xml.XParser;
import javax.baja.xml.XWriter;
public class XFlrMsg {
private static final Lexicon lex = Lexicon.make("baja");
private String type;
private XChallenge challenge;
private XElem payload;
private BFacets metadata;
public static XFlrMsg make(InputStream inputStream) throws Exception {
return new XFlrMsg(XParser.make((InputStream)inputStream).parse());
}
public static XFlrMsg error(Exception exception) {
XFlrMsg xFlrMsg = new XFlrMsg("error");
XElem xElem = new XElem("error").addContent((XContent)new XElem("exception").addText(exception == null ? "?" : exception.toString()));
if (exception != null && exception.getCause() != null) {
xElem.addContent((XContent)new XElem("cause").addText(exception.getCause().toString()));
}
xFlrMsg.setPayload(xElem);
return xFlrMsg;
}
public String getType() {
return this.type;
}
public void setType(String string) {
this.type = string;
}
public XChallenge getChallenge() {
return this.challenge;
}
public void setChallenge(XChallenge xChallenge) {
this.challenge = xChallenge;
}
public BFacets getMetadata() {
return this.metadata;
}
public XFlrMsg setMetadata(String string, BIDataValue bIDataValue) {
this.metadata = BFacets.make(this.metadata, BFacets.make(string, bIDataValue));
return this;
}
public XElem getPayload() {
return this.payload;
}
public void setPayload(XElem xElem) {
this.payload = xElem;
}
public void throwIfError() throws FlrException {
XElem xElem = this.getPayload();
if (xElem == null) {
throw new FlrException("Null payload.");
}
if (!xElem.name().equals("error")) {
return;
}
StringBuffer stringBuffer = new StringBuffer().append(xElem.elem("exception").text());
XElem xElem2 = xElem.elem("cause");
if (xElem2 != null) {
stringBuffer.append(" -- ").append(xElem2.text());
}
throw new FlrException(stringBuffer.toString());
}
public boolean isError() {
XElem xElem = this.getPayload();
boolean bl = false;
if (xElem == null || xElem.name().equals("error")) {
bl = true;
}
return bl;
}
public void write(OutputStream outputStream) throws IOException {
this.write(outputStream, false);
}
public void write(OutputStream outputStream, boolean bl) throws IOException {
XWriter xWriter = new XWriter(outputStream);
this.asXML().write(xWriter);
outputStream.flush();
if (bl) {
xWriter.close();
}
}
public XElem asXML() {
String string = "";
try {
string = this.metadata.encodeToString();
}
catch (Exception exception) {}
return new XElem("msg").addAttr("type", this.type).addAttr("metadata", string).addContent((XContent)this.challenge.asXML()).addContent((XContent)new XElem("payload").addContent((XContent)this.payload.copy()));
}
public void dump() {
this.asXML().dump();
}
public XFlrMsg(String string) {
this.type = string;
this.challenge = new XChallenge();
this.payload = new XElem("empty");
}
public XFlrMsg(XElem xElem) {
this.type = xElem.get("type", "");
this.challenge = new XChallenge(xElem.elem("challenge"));
this.metadata = BFacets.DEFAULT;
try {
this.metadata = BFacets.make(xElem.get("metadata"));
}
catch (Exception exception) {}
this.payload = xElem.elem("payload").elem(0);
}
public static final class XChallenge {
private Version version;
private String hostid;
private long timestamp;
private String nonce;
private String cksum;
public final String getHostid() {
return this.hostid;
}
public final long getTimestamp() {
return this.timestamp;
}
public final String getCksum() {
return this.cksum;
}
public final void setCksum(String string) {
this.cksum = string;
}
public final Version getVersion() {
return this.version;
}
public final void setVersion(Version version) {
this.version = version;
}
public final int[] parseNonce() {
try {
StringTokenizer stringTokenizer = new StringTokenizer(this.nonce, ":");
int[] nArray = new int[stringTokenizer.countTokens()];
int n = 0;
while (n < nArray.length) {
nArray[n] = Integer.parseInt(stringTokenizer.nextToken());
++n;
}
return nArray;
}
catch (Exception exception) {
return new int[]{1, 2, 3, 4, 5};
}
}
public final XElem asXML() {
return new XElem("challenge").addAttr("version", this.version.toString()).addAttr("hostid", this.hostid).addAttr("timestamp", Long.toString(this.timestamp)).addAttr("nonce", this.nonce).addAttr("cksum", this.cksum);
}
public final void throwIfTooOld(BRelTime bRelTime) throws FlrException {
long l = Clock.millis();
long l2 = bRelTime.getMillis();
if (this.getTimestamp() < l - l2 || this.getTimestamp() > l + l2) {
throw new FlrException(lex.getText("flm.msg.errGracePeriod"));
}
}
public XChallenge() {
this.version = Version.ZERO;
this.hostid = Nre.getHostId();
this.timestamp = Clock.millis();
Random random = new Random();
int n = random.nextInt(20) + 5;
StringBuffer stringBuffer = new StringBuffer();
int n2 = 0;
while (n2 < n) {
if (n2 > 0) {
stringBuffer.append(":");
}
stringBuffer.append(random.nextInt());
++n2;
}
this.nonce = stringBuffer.toString();
try {
MessageDigest messageDigest = MessageDigest.getInstance("md5");
this.cksum = new BigInteger(messageDigest.digest(this.nonce.getBytes())).toString(16);
}
catch (NoSuchAlgorithmException noSuchAlgorithmException) {
this.cksum = "F00BA5";
}
}
XChallenge(XElem xElem) {
this.version = new Version(xElem.get("version", Version.ZERO.toString()));
this.hostid = xElem.get("hostid", "");
this.timestamp = xElem.getl("timestamp", 0L);
this.nonce = xElem.get("nonce", "1:2:3:4:5");
this.cksum = xElem.get("cksum");
}
}
}
@@ -0,0 +1,273 @@
/*
* Decompiled with CFR 0.152.
*
* Could not load the following classes:
* javax.baja.nre.util.Array
* javax.baja.nre.util.TextUtil
* javax.baja.xml.XWriter
*/
package com.tridium.sys.license.dom;
import com.tridium.sys.license.dom.CertificateSet;
import com.tridium.sys.license.dom.VendorCertificate;
import java.io.InputStream;
import java.io.OutputStream;
import javax.baja.file.BDirectory;
import javax.baja.file.BFileSpace;
import javax.baja.file.BFileSystem;
import javax.baja.file.BIFile;
import javax.baja.file.FilePath;
import javax.baja.nre.util.Array;
import javax.baja.nre.util.TextUtil;
import javax.baja.sys.BajaRuntimeException;
import javax.baja.xml.XWriter;
/*
* Illegal identifiers - consider using --renameillegalidents true
*/
public class CertificateDatabase
extends CertificateSet {
public static final CertificateDatabase LOCAL_INSTANCE = new LocalCertificateDatabase();
protected BDirectory certDbRoot;
static /* synthetic */ Class class$com$tridium$sys$license$dom$VendorCertificate;
static /* synthetic */ Class class$java$lang$String;
public VendorCertificate[] getCertificates() throws Exception {
Class clazz = class$com$tridium$sys$license$dom$VendorCertificate;
if (clazz == null) {
clazz = class$com$tridium$sys$license$dom$VendorCertificate = CertificateDatabase.class("[Lcom.tridium.sys.license.dom.VendorCertificate;", false);
}
Array array = new Array(clazz);
BDirectory bDirectory = (BDirectory)this.getSpace().findFile(this.getRootPath());
if (bDirectory != null) {
BIFile[] bIFileArray = bDirectory.listFiles();
int n = 0;
while (n < bIFileArray.length) {
if ("certificate".equals(bIFileArray[n].getExtension())) {
array.add((Object)VendorCertificate.make(bIFileArray[n]));
break;
}
++n;
}
}
return (VendorCertificate[])array.trim();
}
public boolean add(VendorCertificate vendorCertificate) throws Exception {
VendorCertificate vendorCertificate2 = this.getCertificate(vendorCertificate.getVendor());
if (vendorCertificate2 == null || vendorCertificate.getGenerated() >= vendorCertificate2.getGenerated()) {
BIFile bIFile = this.getSpace().makeFile(this.getFilePath(vendorCertificate.getVendor()));
OutputStream outputStream = bIFile.getOutputStream();
this.writeCertificate(vendorCertificate, outputStream);
try {
outputStream.close();
}
catch (Exception exception) {}
boolean bl = false;
if (vendorCertificate2 != null) {
bl = true;
}
return bl;
}
return false;
}
public boolean remove(VendorCertificate vendorCertificate) throws Exception {
return this.removeCertificate(vendorCertificate.getVendor());
}
public void clear() throws Exception {
BDirectory bDirectory = this.getSpace().makeDir(this.getRootPath(), null);
BIFile[] bIFileArray = bDirectory.listFiles();
int n = 0;
while (n < bIFileArray.length) {
if ("certificate".equals(bIFileArray[n].getExtension())) {
bIFileArray[n].delete();
}
++n;
}
}
public String[] getVendors() {
this.init();
Class clazz = class$java$lang$String;
if (clazz == null) {
clazz = class$java$lang$String = CertificateDatabase.class("[Ljava.lang.String;", false);
}
Array array = new Array(clazz);
BDirectory bDirectory = (BDirectory)this.getSpace().findFile(this.getRootPath());
if (bDirectory != null) {
BIFile[] bIFileArray = bDirectory.listFiles();
int n = 0;
while (n < bIFileArray.length) {
if ("certificate".equals(bIFileArray[n].getExtension())) {
array.add((Object)bIFileArray[n].getFileName());
break;
}
++n;
}
}
return (String[])array.trim();
}
public VendorCertificate getCertificate(String string) throws Exception {
this.init();
BIFile bIFile = this.getSpace().findFile(this.getFilePath(string));
return bIFile == null ? null : VendorCertificate.make(bIFile);
}
public boolean removeCertificate(String string) throws Exception {
this.init();
BIFile bIFile = this.getSpace().findFile(this.getFilePath(string));
if (bIFile == null) {
return false;
}
bIFile.delete();
return true;
}
public void importFile(BIFile bIFile) throws Exception {
if ("lar".equals(bIFile.getExtension())) {
this.importCertificates(bIFile);
} else if ("certificate".equals(bIFile.getExtension())) {
this.add(VendorCertificate.make(bIFile));
} else {
throw new IllegalArgumentException("importFile argument must be a certificate file or license archive");
}
}
/*
* WARNING - Removed back jump from a try to a catch block - possible behaviour change.
* Enabled aggressive block sorting
* Enabled unnecessary exception pruning
* Enabled aggressive exception aggregation
*/
public void importCertificates(BIFile bIFile) throws Exception {
InputStream inputStream = bIFile.getInputStream();
try {
this.importLicenses(inputStream);
}
catch (Throwable throwable) {
Object var4_4 = null;
try {
inputStream.close();
throw throwable;
}
catch (Exception exception) {}
throw throwable;
}
{
Object var4_5 = null;
}
try {}
catch (Exception exception) {
return;
}
inputStream.close();
}
/*
* Exception decompiling
*/
public void importLicenses(InputStream var1_1) throws Exception {
/*
* This method has failed to decompile. When submitting a bug report, please provide this stack trace, and (if you hold appropriate legal rights) the relevant class file.
*
* org.benf.cfr.reader.util.ConfusedCFRException: Back jump on a try block [egrp 2[TRYBLOCK] [2 : 101->105)] java.lang.Throwable
* at org.benf.cfr.reader.bytecode.analysis.opgraph.Op02WithProcessedDataAndRefs.insertExceptionBlocks(Op02WithProcessedDataAndRefs.java:2283)
* at org.benf.cfr.reader.bytecode.CodeAnalyser.getAnalysisInner(CodeAnalyser.java:415)
* at org.benf.cfr.reader.bytecode.CodeAnalyser.getAnalysisOrWrapFail(CodeAnalyser.java:278)
* at org.benf.cfr.reader.bytecode.CodeAnalyser.getAnalysis(CodeAnalyser.java:201)
* at org.benf.cfr.reader.entities.attributes.AttributeCode.analyse(AttributeCode.java:94)
* at org.benf.cfr.reader.entities.Method.analyse(Method.java:531)
* at org.benf.cfr.reader.entities.ClassFile.analyseMid(ClassFile.java:1055)
* at org.benf.cfr.reader.entities.ClassFile.analyseTop(ClassFile.java:942)
* at org.benf.cfr.reader.Driver.doJarVersionTypes(Driver.java:257)
* at org.benf.cfr.reader.Driver.doJar(Driver.java:139)
* at org.benf.cfr.reader.CfrDriverImpl.analyse(CfrDriverImpl.java:76)
* at org.benf.cfr.reader.Main.main(Main.java:54)
*/
throw new IllegalStateException("Decompilation failed");
}
/*
* Exception decompiling
*/
public void exportLicenses(OutputStream var1_1) throws Exception {
/*
* This method has failed to decompile. When submitting a bug report, please provide this stack trace, and (if you hold appropriate legal rights) the relevant class file.
*
* org.benf.cfr.reader.util.ConfusedCFRException: Back jump on a try block [egrp 2[TRYBLOCK] [3 : 187->191)] java.lang.Throwable
* at org.benf.cfr.reader.bytecode.analysis.opgraph.Op02WithProcessedDataAndRefs.insertExceptionBlocks(Op02WithProcessedDataAndRefs.java:2283)
* at org.benf.cfr.reader.bytecode.CodeAnalyser.getAnalysisInner(CodeAnalyser.java:415)
* at org.benf.cfr.reader.bytecode.CodeAnalyser.getAnalysisOrWrapFail(CodeAnalyser.java:278)
* at org.benf.cfr.reader.bytecode.CodeAnalyser.getAnalysis(CodeAnalyser.java:201)
* at org.benf.cfr.reader.entities.attributes.AttributeCode.analyse(AttributeCode.java:94)
* at org.benf.cfr.reader.entities.Method.analyse(Method.java:531)
* at org.benf.cfr.reader.entities.ClassFile.analyseMid(ClassFile.java:1055)
* at org.benf.cfr.reader.entities.ClassFile.analyseTop(ClassFile.java:942)
* at org.benf.cfr.reader.Driver.doJarVersionTypes(Driver.java:257)
* at org.benf.cfr.reader.Driver.doJar(Driver.java:139)
* at org.benf.cfr.reader.CfrDriverImpl.analyse(CfrDriverImpl.java:76)
* at org.benf.cfr.reader.Main.main(Main.java:54)
*/
throw new IllegalStateException("Decompilation failed");
}
protected BFileSpace getSpace() {
return this.certDbRoot.getFileSpace();
}
protected FilePath getRootPath() {
return this.certDbRoot.getFilePath();
}
protected FilePath getFilePath(String string) {
return this.getRootPath().merge(TextUtil.capitalize((String)string) + ".certificate");
}
protected void init() {
}
protected void writeCertificate(VendorCertificate vendorCertificate, OutputStream outputStream) throws Exception {
XWriter xWriter = new XWriter(outputStream);
vendorCertificate.save(xWriter);
xWriter.flush();
}
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());
}
}
public CertificateDatabase(BDirectory bDirectory) {
this.certDbRoot = bDirectory;
}
protected CertificateDatabase() {
}
private static class LocalCertificateDatabase
extends CertificateDatabase {
public LocalCertificateDatabase() {
try {
this.certDbRoot = BFileSystem.INSTANCE.makeDir(new FilePath("!certificates"));
}
catch (RuntimeException runtimeException) {
throw runtimeException;
}
catch (Exception exception) {
throw new BajaRuntimeException(exception);
}
}
}
}
@@ -0,0 +1,80 @@
/*
* Decompiled with CFR 0.152.
*
* Could not load the following classes:
* javax.baja.nre.util.TextUtil
*/
package com.tridium.sys.license.dom;
import com.tridium.sys.license.dom.VendorCertificate;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Iterator;
import javax.baja.file.BDirectory;
import javax.baja.file.BIFile;
import javax.baja.nre.util.TextUtil;
/*
* Illegal identifiers - consider using --renameillegalidents true
*/
public class CertificateSet {
private ArrayList list;
public VendorCertificate[] getCertificates() throws Exception {
VendorCertificate[] vendorCertificateArray = new VendorCertificate[this.list.size()];
this.list.toArray(vendorCertificateArray);
return vendorCertificateArray;
}
public boolean add(VendorCertificate vendorCertificate) throws Exception {
this.list.add(vendorCertificate);
return false;
}
public boolean remove(VendorCertificate vendorCertificate) throws Exception {
return this.list.remove(vendorCertificate);
}
public void clear() throws Exception {
this.list.clear();
}
public void load(BDirectory bDirectory) {
BIFile[] bIFileArray = bDirectory.listFiles();
int n = 0;
while (bIFileArray != null && n < bIFileArray.length) {
BIFile bIFile = bIFileArray[n];
if (!bIFile.isDirectory() && "certificate".equals(bIFile.getExtension())) {
try {
this.add(VendorCertificate.make(bIFile));
}
catch (Exception exception) {
System.out.println("ERROR: Cannot read \"" + bIFile + '\"');
exception.printStackTrace();
}
}
++n;
}
}
public void dump() throws Exception {
this.dump(new PrintWriter(System.out));
}
public void dump(PrintWriter printWriter) throws Exception {
printWriter.println(TextUtil.getClassName(this.getClass()));
Iterator iterator = this.list.iterator();
while (iterator.hasNext()) {
((VendorCertificate)iterator.next()).dump(printWriter);
}
}
private final /* synthetic */ void this() {
this.list = new ArrayList();
}
public CertificateSet() {
this.this();
}
}
@@ -0,0 +1,215 @@
/*
* Decompiled with CFR 0.152.
*
* Could not load the following classes:
* javax.baja.nre.util.Array
* javax.baja.nre.util.TextUtil
* javax.baja.xml.XElem
* javax.baja.xml.XException
*/
package com.tridium.sys.license.dom;
import com.tridium.sys.license.LicenseUtil;
import com.tridium.sys.license.dom.VendorLicense;
import java.io.PrintWriter;
import javax.baja.nre.util.Array;
import javax.baja.nre.util.TextUtil;
import javax.baja.sys.Clock;
import javax.baja.xml.XElem;
import javax.baja.xml.XException;
/*
* Illegal identifiers - consider using --renameillegalidents true
*/
public class Feature
implements Comparable {
private final VendorLicense parent;
private final String name;
private final String key;
private XElem xml;
static /* synthetic */ Class class$java$lang$String;
static Feature make(VendorLicense vendorLicense, String string) {
if (string.equalsIgnoreCase("brand")) {
return new Brand(vendorLicense);
}
return new Feature(vendorLicense, string);
}
static String toKey(String string) {
return TextUtil.toLowerCase((String)string);
}
public VendorLicense getParent() {
return this.parent;
}
public String getKey() {
return this.key;
}
public String getName() {
return this.name;
}
public boolean isExpired() {
boolean bl = false;
if (Clock.millis() > this.getExpiration() || this.parent.isExpired()) {
bl = true;
}
return bl;
}
public long getExpiration() {
String string = this.xml.get("expiration", null);
return string == null ? Long.MAX_VALUE : LicenseUtil.parseDate(string);
}
public void setExpiration(long l) {
this.modify();
this.xml.setAttr("expiration", LicenseUtil.formatDate(l));
}
public int compareTo(Object object) {
String string = ((Feature)object).name;
if (this.name.equals("about")) {
return -1;
}
if (this.name.equals("brand")) {
return string.equals("about") ? 1 : -1;
}
return this.name.compareTo(string);
}
public String toString() {
return this.parent.getVendor() + ':' + this.getName();
}
public String get(String string) {
return this.xml.get(string, null);
}
public String get(String string, String string2) {
return this.xml.get(string, string2);
}
public boolean getb(String string, boolean bl) {
return this.xml.getb(string, bl);
}
public int geti(String string, int n) {
return this.xml.geti(string, n);
}
public String[] list() {
Class clazz = class$java$lang$String;
if (clazz == null) {
clazz = class$java$lang$String = Feature.class("[Ljava.lang.String;", false);
}
Array array = new Array(clazz, this.xml.attrSize());
int n = 0;
while (n < this.xml.attrSize()) {
String string = this.xml.attrName(n);
if (!string.equals("name") && !string.equals("expiration")) {
array.add((Object)string);
}
++n;
}
return (String[])array.trim();
}
public void set(String string, String string2) {
this.xml.setAttr(string, string2);
}
public final void set(String string, boolean bl) {
this.set(string, String.valueOf(bl));
}
public final void set(String string, int n) {
this.set(string, String.valueOf(n));
}
public final void remove(String string) {
this.xml.removeAttr(string);
}
void load(XElem xElem) throws Exception {
if (!xElem.qname().equals("feature")) {
throw new XException("Root element must be <feature> element", xElem);
}
this.xml = xElem.copy();
}
XElem save() {
return this.xml.copy();
}
public void dump(PrintWriter printWriter) {
printWriter.println(" " + this.name);
printWriter.println(" expiration: " + LicenseUtil.formatDate(this.getExpiration()));
String[] stringArray = this.list();
int n = 0;
while (n < stringArray.length) {
printWriter.println(" " + TextUtil.pad((String)(stringArray[n] + ": "), (int)20) + this.get(stringArray[n]));
++n;
}
printWriter.flush();
}
public void modify() {
this.getParent().modify();
}
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 Feature(VendorLicense vendorLicense, String string) {
if (vendorLicense == null) {
throw new NullPointerException();
}
this.parent = vendorLicense;
this.name = string;
this.key = Feature.toKey(string);
this.xml = new XElem("feature");
this.xml.setAttr("name", string);
}
public static class Brand
extends Feature {
public String getBrandId() {
return this.get("brandId");
}
public String getStationIn() {
return this.get("accept.station.in");
}
public String getStationOut() {
return this.get("accept.station.out");
}
public String getWbIn() {
return this.get("accept.wb.in");
}
public String getWbOut() {
return this.get("accept.wb.out");
}
Brand(VendorLicense vendorLicense) {
super(vendorLicense, "brand");
}
}
}
@@ -0,0 +1,36 @@
/*
* Decompiled with CFR 0.152.
*/
package com.tridium.sys.license.dom;
import com.tridium.sys.license.dom.Feature;
import com.tridium.sys.license.dom.LicenseSet;
import com.tridium.sys.license.dom.VendorLicense;
import java.util.Iterator;
public class HostLicenseSet
extends LicenseSet {
public String getHostId() throws Exception {
Iterator iterator = this.iterator();
return iterator.hasNext() ? ((VendorLicense)iterator.next()).getHostId() : null;
}
public VendorLicense getVendorLicense(String string) throws Exception {
Iterator iterator = this.iterator();
while (iterator.hasNext()) {
VendorLicense vendorLicense = (VendorLicense)iterator.next();
if (!string.equalsIgnoreCase(vendorLicense.getVendor())) continue;
return vendorLicense;
}
return null;
}
public VendorLicense getTridiumLicense() throws Exception {
return this.getVendorLicense("tridium");
}
public Feature.Brand getBrandFeature() throws Exception {
return this.getTridiumLicense().getBrandFeature();
}
}
@@ -0,0 +1,579 @@
/*
* Decompiled with CFR 0.152.
*
* Could not load the following classes:
* javax.baja.nre.util.Array
* javax.baja.xml.XWriter
*/
package com.tridium.sys.license.dom;
import com.tridium.sys.license.dom.HostLicenseSet;
import com.tridium.sys.license.dom.LicenseSet;
import com.tridium.sys.license.dom.VendorLicense;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.Iterator;
import javax.baja.file.BDirectory;
import javax.baja.file.BFileSpace;
import javax.baja.file.BFileSystem;
import javax.baja.file.BIFile;
import javax.baja.file.FilePath;
import javax.baja.log.Log;
import javax.baja.nre.util.Array;
import javax.baja.sys.BajaRuntimeException;
import javax.baja.sys.Sys;
import javax.baja.xml.XWriter;
/*
* Illegal identifiers - consider using --renameillegalidents true
*/
public class LicenseDatabase
extends LicenseSet {
public static final LicenseDatabase LOCAL_INSTANCE = new LocalLicenseDatabase();
protected BDirectory licenseDbRoot;
static /* synthetic */ Class class$java$lang$String;
static /* synthetic */ Class class$com$tridium$sys$license$dom$VendorLicense;
public Iterator iterator() throws Exception {
return new LicenseDatabaseIterator();
}
public boolean add(VendorLicense vendorLicense) throws Exception {
if (vendorLicense.getHostId().equals("*")) {
return false;
}
VendorLicense vendorLicense2 = this.getLicense(vendorLicense.getHostId(), vendorLicense.getVendor(), vendorLicense.getBrandId());
if (vendorLicense2 == null || vendorLicense.getGenerated() >= vendorLicense2.getGenerated()) {
BDirectory bDirectory = this.makeHostDirectory(vendorLicense.getHostId());
BIFile bIFile = this.getSpace().makeFile(bDirectory.getFilePath().merge(vendorLicense.getLicenseName() + ".license"));
OutputStream outputStream = bIFile.getOutputStream();
this.writeLicense(vendorLicense, outputStream);
try {
outputStream.close();
}
catch (Exception exception) {}
return true;
}
return false;
}
public boolean remove(VendorLicense vendorLicense) throws Exception {
return this.removeLicense(vendorLicense.getHostId(), vendorLicense.getVendor(), vendorLicense.getBrandId());
}
public void clear() throws Exception {
BDirectory bDirectory = this.getSpace().makeDir(this.getRootPath(), null);
BIFile[] bIFileArray = bDirectory.listFiles();
int n = 0;
while (n < bIFileArray.length) {
if (bIFileArray[n] instanceof BDirectory) {
BIFile[] bIFileArray2 = ((BDirectory)bIFileArray[n]).listFiles();
boolean bl = true;
int n2 = 0;
while (n2 < bIFileArray2.length) {
if ("license".equals(bIFileArray2[n2].getExtension())) {
bIFileArray2[n2].delete();
} else {
bl = false;
}
++n2;
}
if (bl) {
bIFileArray[n].delete();
}
}
++n;
}
}
public HostLicenseSet toHostLicenseSet(String string, String string2) throws Exception {
HostLicenseSet hostLicenseSet = null;
this.init();
BDirectory bDirectory = this.getHostDirectory(string);
if (bDirectory != null) {
BIFile[] bIFileArray = bDirectory.listFiles();
int n = 0;
while (n < bIFileArray.length) {
if ("license".equals(bIFileArray[n].getExtension())) {
VendorLicense vendorLicense = VendorLicense.make(bIFileArray[n]);
if (string2 == null || vendorLicense.getBrandId() == null || vendorLicense.getBrandId().equals(string2)) {
if (hostLicenseSet == null) {
hostLicenseSet = new HostLicenseSet();
}
if (hostLicenseSet.getVendorLicense(vendorLicense.getVendor()) != null) {
throw new RuntimeException("Duplicate licenses for same hostId and vendor: " + vendorLicense.getVendor());
}
hostLicenseSet.add(vendorLicense);
}
}
++n;
}
}
return hostLicenseSet;
}
public String[] getHostIds() {
this.init();
Class clazz = class$java$lang$String;
if (clazz == null) {
clazz = class$java$lang$String = LicenseDatabase.class("[Ljava.lang.String;", false);
}
Array array = new Array(clazz);
BDirectory bDirectory = (BDirectory)this.getSpace().findFile(this.getRootPath());
if (bDirectory != null) {
BIFile[] bIFileArray = bDirectory.listFiles();
int n = 0;
while (n < bIFileArray.length) {
if (bIFileArray[n] instanceof BDirectory) {
BIFile[] bIFileArray2 = ((BDirectory)bIFileArray[n]).listFiles();
int n2 = 0;
while (n2 < bIFileArray2.length) {
if ("license".equals(bIFileArray2[n2].getExtension())) {
array.add((Object)bIFileArray[n].getFileName());
break;
}
++n2;
}
}
++n;
}
}
return (String[])array.trim();
}
public VendorLicense[] getLicenses(String string) {
return this.getLicenses(string, null);
}
public VendorLicense[] getLicenses(String string, String string2) {
this.init();
String string3 = string2;
Class clazz = class$com$tridium$sys$license$dom$VendorLicense;
if (clazz == null) {
clazz = class$com$tridium$sys$license$dom$VendorLicense = LicenseDatabase.class("[Lcom.tridium.sys.license.dom.VendorLicense;", false);
}
Array array = new Array(clazz);
BDirectory bDirectory = this.getHostDirectory(string);
if (bDirectory != null) {
BIFile[] bIFileArray = bDirectory.listFiles();
int n = 0;
while (n < bIFileArray.length) {
if ("license".equals(bIFileArray[n].getExtension())) {
try {
VendorLicense vendorLicense = VendorLicense.make(bIFileArray[n]);
if (string3 == null || vendorLicense.getBrandId() == null || string3.equals(vendorLicense.getBrandId())) {
array.add((Object)vendorLicense);
string3 = vendorLicense.getBrandId();
}
}
catch (Exception exception) {
exception.printStackTrace();
}
}
++n;
}
}
return (VendorLicense[])array.trim();
}
public VendorLicense getLicense(String string, String string2, String string3) {
this.init();
BDirectory bDirectory = this.getHostDirectory(string);
if (bDirectory != null) {
String string4 = "tridium".equalsIgnoreCase(string2) && string3 != null ? string3 : string2;
BIFile bIFile = (BIFile)bDirectory.getNavChild(string4 + ".license");
try {
return bIFile == null ? null : VendorLicense.make(bIFile);
}
catch (Exception exception) {
exception.printStackTrace();
}
}
return null;
}
public boolean removeLicense(String string, String string2, String string3) throws Exception {
String string4;
BIFile bIFile;
BDirectory bDirectory = this.getHostDirectory(string);
if (bDirectory != null && (bIFile = (BIFile)bDirectory.getNavChild((string4 = "tridium".equalsIgnoreCase(string2) && string3 != null ? string3 : string2) + ".license")) != null) {
bIFile.delete();
if (bDirectory.listFiles().length == 0) {
bDirectory.delete();
}
return true;
}
return false;
}
public void importFile(BIFile bIFile) throws Exception {
if ("lar".equals(bIFile.getExtension())) {
this.importLicenses(bIFile);
} else if ("license".equals(bIFile.getExtension())) {
this.add(VendorLicense.make(bIFile));
} else {
throw new IllegalArgumentException("importFile argument must be a license file or license archive");
}
}
/*
* WARNING - Removed back jump from a try to a catch block - possible behaviour change.
* Enabled aggressive block sorting
* Enabled unnecessary exception pruning
* Enabled aggressive exception aggregation
*/
public void importLicenses(BIFile bIFile) throws Exception {
InputStream inputStream = bIFile.getInputStream();
try {
this.importLicenses(inputStream);
}
catch (Throwable throwable) {
Object var4_4 = null;
try {
inputStream.close();
throw throwable;
}
catch (Exception exception) {}
throw throwable;
}
{
Object var4_5 = null;
}
try {}
catch (Exception exception) {
return;
}
inputStream.close();
}
/*
* Exception decompiling
*/
public void importLicenses(InputStream var1_1) throws Exception {
/*
* This method has failed to decompile. When submitting a bug report, please provide this stack trace, and (if you hold appropriate legal rights) the relevant class file.
*
* org.benf.cfr.reader.util.ConfusedCFRException: Back jump on a try block [egrp 2[TRYBLOCK] [2 : 101->105)] java.lang.Throwable
* at org.benf.cfr.reader.bytecode.analysis.opgraph.Op02WithProcessedDataAndRefs.insertExceptionBlocks(Op02WithProcessedDataAndRefs.java:2283)
* at org.benf.cfr.reader.bytecode.CodeAnalyser.getAnalysisInner(CodeAnalyser.java:415)
* at org.benf.cfr.reader.bytecode.CodeAnalyser.getAnalysisOrWrapFail(CodeAnalyser.java:278)
* at org.benf.cfr.reader.bytecode.CodeAnalyser.getAnalysis(CodeAnalyser.java:201)
* at org.benf.cfr.reader.entities.attributes.AttributeCode.analyse(AttributeCode.java:94)
* at org.benf.cfr.reader.entities.Method.analyse(Method.java:531)
* at org.benf.cfr.reader.entities.ClassFile.analyseMid(ClassFile.java:1055)
* at org.benf.cfr.reader.entities.ClassFile.analyseTop(ClassFile.java:942)
* at org.benf.cfr.reader.Driver.doJarVersionTypes(Driver.java:257)
* at org.benf.cfr.reader.Driver.doJar(Driver.java:139)
* at org.benf.cfr.reader.CfrDriverImpl.analyse(CfrDriverImpl.java:76)
* at org.benf.cfr.reader.Main.main(Main.java:54)
*/
throw new IllegalStateException("Decompilation failed");
}
/*
* Exception decompiling
*/
public void exportLicenses(OutputStream var1_1) throws Exception {
/*
* This method has failed to decompile. When submitting a bug report, please provide this stack trace, and (if you hold appropriate legal rights) the relevant class file.
*
* org.benf.cfr.reader.util.ConfusedCFRException: Back jump on a try block [egrp 2[TRYBLOCK] [3 : 239->243)] java.lang.Throwable
* at org.benf.cfr.reader.bytecode.analysis.opgraph.Op02WithProcessedDataAndRefs.insertExceptionBlocks(Op02WithProcessedDataAndRefs.java:2283)
* at org.benf.cfr.reader.bytecode.CodeAnalyser.getAnalysisInner(CodeAnalyser.java:415)
* at org.benf.cfr.reader.bytecode.CodeAnalyser.getAnalysisOrWrapFail(CodeAnalyser.java:278)
* at org.benf.cfr.reader.bytecode.CodeAnalyser.getAnalysis(CodeAnalyser.java:201)
* at org.benf.cfr.reader.entities.attributes.AttributeCode.analyse(AttributeCode.java:94)
* at org.benf.cfr.reader.entities.Method.analyse(Method.java:531)
* at org.benf.cfr.reader.entities.ClassFile.analyseMid(ClassFile.java:1055)
* at org.benf.cfr.reader.entities.ClassFile.analyseTop(ClassFile.java:942)
* at org.benf.cfr.reader.Driver.doJarVersionTypes(Driver.java:257)
* at org.benf.cfr.reader.Driver.doJar(Driver.java:139)
* at org.benf.cfr.reader.CfrDriverImpl.analyse(CfrDriverImpl.java:76)
* at org.benf.cfr.reader.Main.main(Main.java:54)
*/
throw new IllegalStateException("Decompilation failed");
}
/*
* Exception decompiling
*/
public void exportLicenses(String[] var1_1, OutputStream var2_2) throws Exception {
/*
* This method has failed to decompile. When submitting a bug report, please provide this stack trace, and (if you hold appropriate legal rights) the relevant class file.
*
* org.benf.cfr.reader.util.ConfusedCFRException: Back jump on a try block [egrp 2[TRYBLOCK] [3 : 235->239)] java.lang.Throwable
* at org.benf.cfr.reader.bytecode.analysis.opgraph.Op02WithProcessedDataAndRefs.insertExceptionBlocks(Op02WithProcessedDataAndRefs.java:2283)
* at org.benf.cfr.reader.bytecode.CodeAnalyser.getAnalysisInner(CodeAnalyser.java:415)
* at org.benf.cfr.reader.bytecode.CodeAnalyser.getAnalysisOrWrapFail(CodeAnalyser.java:278)
* at org.benf.cfr.reader.bytecode.CodeAnalyser.getAnalysis(CodeAnalyser.java:201)
* at org.benf.cfr.reader.entities.attributes.AttributeCode.analyse(AttributeCode.java:94)
* at org.benf.cfr.reader.entities.Method.analyse(Method.java:531)
* at org.benf.cfr.reader.entities.ClassFile.analyseMid(ClassFile.java:1055)
* at org.benf.cfr.reader.entities.ClassFile.analyseTop(ClassFile.java:942)
* at org.benf.cfr.reader.Driver.doJarVersionTypes(Driver.java:257)
* at org.benf.cfr.reader.Driver.doJar(Driver.java:139)
* at org.benf.cfr.reader.CfrDriverImpl.analyse(CfrDriverImpl.java:76)
* at org.benf.cfr.reader.Main.main(Main.java:54)
*/
throw new IllegalStateException("Decompilation failed");
}
protected BDirectory getHostDirectory(String string) {
return (BDirectory)this.getSpace().findFile(this.getRootPath().merge(string));
}
protected BDirectory makeHostDirectory(String string) throws Exception {
return this.getSpace().makeDir(this.getRootPath().merge(string));
}
protected BFileSpace getSpace() {
return this.licenseDbRoot.getFileSpace();
}
protected FilePath getRootPath() {
return this.licenseDbRoot.getFilePath();
}
protected void init() {
}
protected void writeLicense(VendorLicense vendorLicense, OutputStream outputStream) throws Exception {
XWriter xWriter = new XWriter(outputStream);
vendorLicense.save(xWriter);
xWriter.flush();
}
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());
}
}
public LicenseDatabase(BDirectory bDirectory) {
this.licenseDbRoot = bDirectory;
}
protected LicenseDatabase() {
}
/*
* Illegal identifiers - consider using --renameillegalidents true
*/
private class LicenseDatabaseIterator
implements Iterator {
private String[] hostIds;
private int hostIdx;
private VendorLicense[] licensesForHost;
private int licenseIdx;
/*
* Unable to fully structure code
* Enabled aggressive block sorting
* Enabled unnecessary exception pruning
* Enabled aggressive exception aggregation
*/
public boolean hasNext() {
try {
while (true) {
if (this.licensesForHost != null) ** GOTO lbl13
if (this.hostIdx + 1 >= this.hostIds.length) {
this.licensesForHost = null;
this.licenseIdx = -1;
return false;
}
++this.hostIdx;
this.licensesForHost = LicenseDatabase.this.getLicenses(this.hostIds[this.hostIdx]);
this.licenseIdx = 0;
continue;
lbl13:
// 1 sources
if (this.licenseIdx < this.licensesForHost.length) {
return true;
}
this.licensesForHost = null;
this.licenseIdx = -1;
continue;
break;
}
}
catch (RuntimeException var1_1) {
throw var1_1;
}
catch (Exception var1_2) {
throw new BajaRuntimeException(var1_2);
}
}
public Object next() {
if (this.hasNext()) {
VendorLicense vendorLicense = this.licensesForHost[this.licenseIdx];
++this.licenseIdx;
return vendorLicense;
}
throw new IllegalStateException("Called next() when hasNext==false");
}
public void remove() {
throw new UnsupportedOperationException();
}
public LicenseDatabaseIterator() throws Exception {
this.hostIds = LicenseDatabase.this.getHostIds();
this.hostIdx = -1;
this.licensesForHost = null;
this.licenseIdx = -1;
}
}
/*
* Illegal identifiers - consider using --renameillegalidents true
*/
private static class LocalLicenseDatabase
extends LicenseDatabase {
private boolean initialized;
private String brandId;
private ArrayList copyList;
protected void init() {
if (this.initialized) {
return;
}
this.initialized = true;
Log log = Log.getLog("sys.license");
try {
this.brandId = this.getBrand();
this.importDir(BFileSystem.INSTANCE.makeDir(new FilePath("!licenses")), false);
this.importDir(BFileSystem.INSTANCE.makeDir(new FilePath("!licenses/inbox")), true);
this.exportNewLicenses();
}
catch (Exception exception) {
log.error("Error initializing local license database", exception);
exception.printStackTrace();
}
}
/*
* Exception decompiling
*/
private final String getBrand() {
/*
* This method has failed to decompile. When submitting a bug report, please provide this stack trace, and (if you hold appropriate legal rights) the relevant class file.
*
* org.benf.cfr.reader.util.ConfusedCFRException: Back jump on a try block [egrp 3[TRYBLOCK] [4 : 96->99)] java.lang.Throwable
* at org.benf.cfr.reader.bytecode.analysis.opgraph.Op02WithProcessedDataAndRefs.insertExceptionBlocks(Op02WithProcessedDataAndRefs.java:2283)
* at org.benf.cfr.reader.bytecode.CodeAnalyser.getAnalysisInner(CodeAnalyser.java:415)
* at org.benf.cfr.reader.bytecode.CodeAnalyser.getAnalysisOrWrapFail(CodeAnalyser.java:278)
* at org.benf.cfr.reader.bytecode.CodeAnalyser.getAnalysis(CodeAnalyser.java:201)
* at org.benf.cfr.reader.entities.attributes.AttributeCode.analyse(AttributeCode.java:94)
* at org.benf.cfr.reader.entities.Method.analyse(Method.java:531)
* at org.benf.cfr.reader.entities.ClassFile.analyseMid(ClassFile.java:1055)
* at org.benf.cfr.reader.entities.ClassFile.analyseInnerClassesPass1(ClassFile.java:923)
* at org.benf.cfr.reader.entities.ClassFile.analyseMid(ClassFile.java:1035)
* at org.benf.cfr.reader.entities.ClassFile.analyseTop(ClassFile.java:942)
* at org.benf.cfr.reader.Driver.doJarVersionTypes(Driver.java:257)
* at org.benf.cfr.reader.Driver.doJar(Driver.java:139)
* at org.benf.cfr.reader.CfrDriverImpl.analyse(CfrDriverImpl.java:76)
* at org.benf.cfr.reader.Main.main(Main.java:54)
*/
throw new IllegalStateException("Decompilation failed");
}
protected void importDir(BDirectory bDirectory, boolean bl) throws Exception {
Log log = Log.getLog("sys.license");
BIFile[] bIFileArray = bDirectory.listFiles();
int n = 0;
while (n < bIFileArray.length) {
if ("license".equals(bIFileArray[n].getExtension())) {
VendorLicense vendorLicense = VendorLicense.make(bIFileArray[n]);
this.add(vendorLicense);
if (bl || !vendorLicense.getHostId().equals(Sys.getHostId()) && !"*".equals(vendorLicense.getHostId())) {
try {
bIFileArray[n].delete();
log.message("moved " + bIFileArray[n]);
}
catch (Exception exception) {
log.warning("error deleting " + bIFileArray[n], exception);
}
}
} else if ("lar".equals(bIFileArray[n].getExtension())) {
this.importFile(bIFileArray[n]);
try {
bIFileArray[n].delete();
log.message("imported and removed license archive " + bIFileArray[n]);
}
catch (Exception exception) {
log.warning("error deleting " + bIFileArray[n], exception);
}
}
++n;
}
}
public boolean add(VendorLicense vendorLicense) throws Exception {
boolean bl = super.add(vendorLicense);
if (!bl) {
return bl;
}
String string = vendorLicense.getSource();
if (Sys.getHostId().equals(vendorLicense.getHostId()) && ("lar".equals(string) || string.indexOf("licenses/inbox/") > 0)) {
this.copyList.add(vendorLicense);
}
if (this.brandId == null && Sys.getHostId().equals(vendorLicense.getHostId()) && vendorLicense.getBrandId() != null) {
this.brandId = vendorLicense.getBrandId();
}
return bl;
}
private final void exportNewLicenses() {
Log log = Log.getLog("sys.license");
if (this.brandId == null) {
log.error("Could not determine brand");
return;
}
Iterator iterator = this.copyList.iterator();
while (iterator.hasNext()) {
VendorLicense vendorLicense = (VendorLicense)iterator.next();
if (vendorLicense.getBrandId() != null && !vendorLicense.getBrandId().equals(this.brandId)) continue;
try {
FilePath filePath = new FilePath("!licenses/" + vendorLicense.getLicenseName() + ".license");
BIFile bIFile = BFileSystem.INSTANCE.makeFile(filePath);
log.message("LicenseDatabase is exporting new license to " + bIFile);
vendorLicense.save(bIFile);
}
catch (IOException iOException) {
log.error("LicenseDatabase could not copy license file to !licenses", iOException);
}
}
this.copyList.clear();
}
private final /* synthetic */ void this() {
this.initialized = false;
this.copyList = new ArrayList();
}
public LocalLicenseDatabase() {
this.this();
try {
this.licenseDbRoot = BFileSystem.INSTANCE.makeDir(new FilePath("!licenses/db"));
}
catch (RuntimeException runtimeException) {
throw runtimeException;
}
catch (Exception exception) {
throw new BajaRuntimeException(exception);
}
}
}
}
@@ -0,0 +1,100 @@
/*
* Decompiled with CFR 0.152.
*
* Could not load the following classes:
* javax.baja.nre.util.TextUtil
*/
package com.tridium.sys.license.dom;
import com.tridium.sys.license.dom.HostLicenseSet;
import com.tridium.sys.license.dom.VendorLicense;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Iterator;
import javax.baja.file.BDirectory;
import javax.baja.file.BIFile;
import javax.baja.nre.util.TextUtil;
/*
* Illegal identifiers - consider using --renameillegalidents true
*/
public class LicenseSet {
private ArrayList list;
public Iterator iterator() throws Exception {
return this.list.iterator();
}
public boolean add(VendorLicense vendorLicense) throws Exception {
this.list.add(vendorLicense);
return false;
}
public boolean remove(VendorLicense vendorLicense) throws Exception {
return this.list.remove(vendorLicense);
}
public void clear() throws Exception {
this.list.clear();
}
public HostLicenseSet toHostLicenseSet(String string) throws Exception {
return this.toHostLicenseSet(string, null);
}
public HostLicenseSet toHostLicenseSet(String string, String string2) throws Exception {
HostLicenseSet hostLicenseSet = null;
Iterator iterator = this.iterator();
while (iterator.hasNext()) {
VendorLicense vendorLicense = (VendorLicense)iterator.next();
if (!string.equals(vendorLicense.getHostId()) || string2 != null && vendorLicense.getBrandId() != null && !vendorLicense.getBrandId().equals(string2)) continue;
if (hostLicenseSet == null) {
hostLicenseSet = new HostLicenseSet();
}
if (hostLicenseSet.getVendorLicense(vendorLicense.getVendor()) != null) {
throw new RuntimeException("Duplicate licenses for same hostId and vendor: " + vendorLicense.getVendor());
}
hostLicenseSet.add(vendorLicense);
}
return hostLicenseSet;
}
public void load(BDirectory bDirectory) {
BIFile[] bIFileArray = bDirectory.listFiles();
int n = 0;
while (bIFileArray != null && n < bIFileArray.length) {
BIFile bIFile = bIFileArray[n];
if (!bIFile.isDirectory() && "license".equals(bIFile.getExtension())) {
try {
this.add(VendorLicense.make(bIFile));
}
catch (Exception exception) {
System.out.println("ERROR: Cannot read \"" + bIFile + '\"');
exception.printStackTrace();
}
}
++n;
}
}
public void dump() throws Exception {
this.dump(new PrintWriter(System.out));
}
public void dump(PrintWriter printWriter) throws Exception {
printWriter.println(TextUtil.getClassName(this.getClass()));
Iterator iterator = this.iterator();
while (iterator.hasNext()) {
((VendorLicense)iterator.next()).dump(printWriter);
}
}
private final /* synthetic */ void this() {
this.list = new ArrayList();
}
public LicenseSet() {
this.this();
}
}
@@ -0,0 +1,326 @@
/*
* Decompiled with CFR 0.152.
*
* Could not load the following classes:
* javax.baja.xml.XWriter
*/
package com.tridium.sys.license.dom;
import com.tridium.sys.NreLib;
import com.tridium.sys.license.dom.Feature;
import com.tridium.sys.license.dom.HostLicenseSet;
import com.tridium.sys.license.dom.LicenseSet;
import com.tridium.sys.license.dom.VendorLicense;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.OutputStream;
import javax.baja.file.BDirectory;
import javax.baja.file.BFileSystem;
import javax.baja.file.BIFile;
import javax.baja.file.FilePath;
import javax.baja.util.Version;
import javax.baja.xml.XWriter;
/*
* Illegal identifiers - consider using --renameillegalidents true
*/
public class LicenseTest {
static final long NEVER = Long.MAX_VALUE;
int verifies;
VendorLicense trid;
public static void main(String[] stringArray) throws Exception {
LicenseTest licenseTest = new LicenseTest();
licenseTest.readTridium();
licenseTest.fromScratch();
licenseTest.licenseSet();
System.out.println("ALL TESTS PASSED [" + licenseTest.verifies + ']');
}
public void readTridium() throws Exception {
BIFile bIFile = BFileSystem.INSTANCE.findFile(new FilePath("!licenses/Tridium.license"));
if (bIFile == null) {
bIFile = BFileSystem.INSTANCE.findFile(new FilePath("!licenses/Vykon.license"));
}
VendorLicense vendorLicense = this.trid = new VendorLicense();
vendorLicense.load(bIFile);
boolean bl = false;
if (vendorLicense.getExpiration() == Long.MAX_VALUE) {
bl = true;
}
this.verify(bl);
this.verify(vendorLicense.getHostId().equals(NreLib.getHostId()));
this.verify(vendorLicense.getVendor().equals("Tridium"));
boolean bl2 = false;
if (vendorLicense.getVersion() != null) {
bl2 = true;
}
this.verify(bl2);
Feature feature = vendorLicense.getFeature("about");
boolean bl3 = false;
if (feature == vendorLicense.getFeature("AbOuT")) {
bl3 = true;
}
this.verify(bl3);
this.verify(feature.getName().equals("about"));
this.verify(feature.getKey().equals("about"));
boolean bl4 = false;
if (feature.getExpiration() == Long.MAX_VALUE) {
bl4 = true;
}
this.verify(bl4);
boolean bl5 = false;
if (feature.get("owner") != null) {
bl5 = true;
}
this.verify(bl5);
boolean bl6 = false;
if (feature.get("project") != null) {
bl6 = true;
}
this.verify(bl6);
boolean bl7 = false;
if (feature.get("foobar") == null) {
bl7 = true;
}
this.verify(bl7);
boolean bl8 = false;
if (feature.get("foobar", "rocking") == "rocking") {
bl8 = true;
}
this.verify(bl8);
Feature.Brand brand = vendorLicense.getBrandFeature();
this.verifyEq(brand.getStationIn(), "*");
this.verifyEq(brand.getStationOut(), "*");
this.verifyEq(brand.getWbIn(), "*");
this.verifyEq(brand.getWbOut(), "*");
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
vendorLicense.save(byteArrayOutputStream);
this.roundRobinIO(this.trid);
}
public void fromScratch() throws Exception {
VendorLicense vendorLicense = new VendorLicense();
vendorLicense.setVendor("brianco");
vendorLicense.setVersion(new Version("3.2"));
vendorLicense.setHostId("win-host-id");
vendorLicense.setSignature("abcdefghijklmnopqrstuvwxyz");
this.roundRobinIO(vendorLicense);
Feature feature = vendorLicense.addFeature("kickIt");
boolean bl = false;
if (vendorLicense.getFeature("KickIt") == feature) {
bl = true;
}
this.verify(bl);
boolean bl2 = false;
if (feature.getParent() == vendorLicense) {
bl2 = true;
}
this.verify(bl2);
this.verify(feature.getName().equals("kickIt"));
boolean bl3 = false;
if (feature.list().length == 0) {
bl3 = true;
}
this.verify(bl3);
this.roundRobinIO(vendorLicense);
feature.set("alpha", "bravo");
feature.set("charlie", "delta");
feature.set("bool", false);
feature.set("int", 77);
boolean bl4 = false;
if (feature.list().length == 4) {
bl4 = true;
}
this.verify(bl4);
this.verifyEq(feature.get("alpha"), "bravo");
this.verifyEq(feature.get("charlie"), "delta");
this.verify(feature.getb("bool", true) ^ true);
boolean bl5 = false;
if (feature.geti("int", 99) == 77) {
bl5 = true;
}
this.verify(bl5);
this.roundRobinIO(vendorLicense);
vendorLicense.removeFeature("kickIt");
boolean bl6 = false;
if (vendorLicense.getFeature("KickIt") == null) {
bl6 = true;
}
this.verify(bl6);
this.roundRobinIO(vendorLicense);
}
public void licenseSet() throws Exception {
BDirectory bDirectory = BFileSystem.INSTANCE.makeDir(new FilePath("!licenses/test"), null);
VendorLicense vendorLicense = this.makeLic(bDirectory, "A", "tridium", "vykon", null);
VendorLicense vendorLicense2 = this.makeLic(bDirectory, "A", "acme", null, null);
VendorLicense vendorLicense3 = this.makeLic(bDirectory, "B", "tridium", "vykon", null);
VendorLicense vendorLicense4 = this.makeLic(bDirectory, "C", "tridium", "vykon", "C-tridium-1.license");
VendorLicense vendorLicense5 = this.makeLic(bDirectory, "C", "tridium", "vykon", "C-tridium-2.license");
VendorLicense vendorLicense6 = this.makeLic(bDirectory, "D", "tridium", "tridium", "D-tridium-1.license");
VendorLicense vendorLicense7 = this.makeLic(bDirectory, "D", "tridium", "vykon", "D-tridium-2.license");
LicenseSet licenseSet = new LicenseSet();
licenseSet.load(bDirectory);
HostLicenseSet hostLicenseSet = licenseSet.toHostLicenseSet("no way", "vykon");
boolean bl = false;
if (hostLicenseSet == null) {
bl = true;
}
this.verify(bl);
hostLicenseSet = licenseSet.toHostLicenseSet("A", "vykon");
this.verifyEq(hostLicenseSet.getHostId(), "A");
this.verifyEq(hostLicenseSet.getVendorLicense("acme"), vendorLicense2);
this.verifyEq(hostLicenseSet.getVendorLicense("tridium"), vendorLicense);
this.verifyEq(hostLicenseSet.getTridiumLicense(), vendorLicense);
this.verifyEq(hostLicenseSet.getBrandFeature().getBrandId(), "vykon");
hostLicenseSet = licenseSet.toHostLicenseSet("B", "vykon");
this.verifyEq(hostLicenseSet.getHostId(), "B");
this.verifyEq(hostLicenseSet.getTridiumLicense(), vendorLicense3);
this.verifyEq(hostLicenseSet.getBrandFeature().getBrandId(), "vykon");
Exception exception = null;
try {
hostLicenseSet = licenseSet.toHostLicenseSet("C", "vykon");
}
catch (Exception exception2) {
exception = exception2;
}
boolean bl2 = false;
if (exception != null) {
bl2 = true;
}
this.verify(bl2);
hostLicenseSet = licenseSet.toHostLicenseSet("D", "tridium");
this.verifyEq(hostLicenseSet.getHostId(), "D");
this.verifyEq(hostLicenseSet.getTridiumLicense(), vendorLicense6);
this.verifyEq(hostLicenseSet.getBrandFeature().getBrandId(), "tridium");
hostLicenseSet = licenseSet.toHostLicenseSet("D", "vykon");
this.verifyEq(hostLicenseSet.getHostId(), "D");
this.verifyEq(hostLicenseSet.getTridiumLicense(), vendorLicense7);
this.verifyEq(hostLicenseSet.getBrandFeature().getBrandId(), "vykon");
}
VendorLicense makeLic(BIFile bIFile, String string, String string2, String string3, String string4) throws Exception {
VendorLicense vendorLicense = new VendorLicense();
vendorLicense.setHostId(string);
vendorLicense.setVendor(string2);
vendorLicense.setVersion(new Version("3.3"));
vendorLicense.setSignature("sig");
if (string2.equals("tridium")) {
Feature feature = vendorLicense.addFeature("brand");
feature.set("brandId", string3 == null ? "vykon" : string3);
}
if (string4 == null) {
string4 = string + '-' + string2 + ".license";
}
vendorLicense.save(BFileSystem.INSTANCE.makeFile(bIFile.getFilePath().merge(string4), null));
return vendorLicense;
}
public void roundRobinIO(VendorLicense vendorLicense) throws Exception {
byte[] byArray = this.saveToBuf(vendorLicense);
ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(byArray);
VendorLicense vendorLicense2 = new VendorLicense();
vendorLicense2.load(vendorLicense.getSource(), byteArrayInputStream);
this.verifyEq(vendorLicense, vendorLicense2);
}
public void verifyEq(VendorLicense vendorLicense, VendorLicense vendorLicense2) throws Exception {
this.verifyEq(vendorLicense.getVendor(), vendorLicense2.getVendor());
this.verifyEq(vendorLicense.getExpiration(), vendorLicense2.getExpiration());
this.verifyEq(vendorLicense.getHostId(), vendorLicense2.getHostId());
Feature[] featureArray = vendorLicense.getFeatures();
Feature[] featureArray2 = vendorLicense2.getFeatures();
boolean bl = false;
if (featureArray.length == featureArray2.length) {
bl = true;
}
this.verify(bl);
int n = 0;
while (n < featureArray.length) {
this.verifyEq(featureArray[n], featureArray2[n]);
++n;
}
this.verifyEq(this.saveToBuf(vendorLicense), this.saveToBuf(vendorLicense2));
}
public void verifyEq(Feature feature, Feature feature2) {
this.verifyEq(feature.getName(), feature2.getName());
this.verifyEq(feature.getExpiration(), feature2.getExpiration());
String[] stringArray = feature.list();
String[] stringArray2 = feature2.list();
boolean bl = false;
if (stringArray.length == stringArray2.length) {
bl = true;
}
this.verify(bl);
int n = 0;
while (n < stringArray.length) {
this.verifyEq(stringArray[n], stringArray2[n]);
this.verifyEq(feature.get(stringArray[n]), feature2.get(stringArray2[n]));
++n;
}
}
public void verifyEq(String string, String string2) {
if (string == null) {
boolean bl = false;
if (string2 == null) {
bl = true;
}
this.verify(bl);
} else {
this.verify(string.equals(string2));
}
}
public void verifyEq(long l, long l2) {
boolean bl = false;
if (l == l2) {
bl = true;
}
this.verify(bl);
}
public void verifyEq(byte[] byArray, byte[] byArray2) {
boolean bl = false;
if (byArray.length == byArray2.length) {
bl = true;
}
this.verify(bl);
boolean bl2 = true;
int n = 0;
while (n < byArray.length) {
if (byArray[n] != byArray2[n]) {
bl2 = false;
break;
}
++n;
}
this.verify(bl2);
}
public void verify(boolean bl) {
if (bl) {
++this.verifies;
} else {
throw new RuntimeException("Test failed");
}
}
public byte[] saveToBuf(VendorLicense vendorLicense) throws Exception {
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
XWriter xWriter = new XWriter((OutputStream)byteArrayOutputStream);
vendorLicense.save(xWriter);
return byteArrayOutputStream.toByteArray();
}
private final /* synthetic */ void this() {
this.verifies = 0;
}
public LicenseTest() {
this.this();
}
}
@@ -0,0 +1,326 @@
/*
* Decompiled with CFR 0.152.
*
* Could not load the following classes:
* javax.baja.xml.XContent
* javax.baja.xml.XElem
* javax.baja.xml.XException
* javax.baja.xml.XParser
* javax.baja.xml.XText
* javax.baja.xml.XWriter
*/
package com.tridium.sys.license.dom;
import com.tridium.sys.license.LicenseUtil;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import javax.baja.file.BIFile;
import javax.baja.sys.Clock;
import javax.baja.util.Version;
import javax.baja.xml.XContent;
import javax.baja.xml.XElem;
import javax.baja.xml.XException;
import javax.baja.xml.XParser;
import javax.baja.xml.XText;
import javax.baja.xml.XWriter;
/*
* Illegal identifiers - consider using --renameillegalidents true
*/
public class VendorCertificate {
private String source;
private XElem xml;
private String signature;
private boolean modified;
public static VendorCertificate make(BIFile bIFile) throws Exception {
VendorCertificate vendorCertificate = new VendorCertificate();
vendorCertificate.load(bIFile);
return vendorCertificate;
}
public static VendorCertificate make(String string, InputStream inputStream) throws Exception {
VendorCertificate vendorCertificate = new VendorCertificate();
vendorCertificate.load(string, inputStream);
return vendorCertificate;
}
public static VendorCertificate make(String string, InputStream inputStream, boolean bl) throws Exception {
VendorCertificate vendorCertificate = new VendorCertificate();
vendorCertificate.load(string, inputStream, bl);
return vendorCertificate;
}
public static VendorCertificate make(String string, XElem xElem) throws Exception {
VendorCertificate vendorCertificate = new VendorCertificate();
vendorCertificate.load(string, xElem);
return vendorCertificate;
}
public String getSource() {
return this.source;
}
public String getVendor() {
return this.xml.get("vendor");
}
public void setVendor(String string) {
this.modify();
this.xml.setAttr("vendor", string);
}
public boolean isExpired() {
boolean bl = false;
if (Clock.millis() > this.getExpiration()) {
bl = true;
}
return bl;
}
public long getExpiration() {
return LicenseUtil.parseDate(this.xml.get("expiration"));
}
public void setExpiration(long l) {
this.modify();
this.xml.setAttr("expiration", LicenseUtil.formatDate(l));
}
public long getGenerated() {
return LicenseUtil.parseDate(this.xml.get("generated"));
}
public Version getVersion() {
return new Version(this.xml.get("version"));
}
public void setVersion(Version version) {
this.modify();
this.xml.setAttr("version", version.toString());
}
public String getSignature() {
return this.signature;
}
public void setSignature(String string) {
this.modify();
this.signature = string;
}
public String getPublicKey() {
XElem xElem = this.xml.elem("publicKey");
return xElem == null ? null : xElem.string();
}
public void setPublicKey(String string) {
this.modify();
XElem xElem = this.xml.elem("publicKey");
if (xElem != null) {
this.xml.removeContent((XContent)xElem);
}
xElem = new XElem("publicKey");
xElem.addContent((XContent)new XText(string));
this.xml.addContent((XContent)xElem);
}
/*
* WARNING - Removed back jump from a try to a catch block - possible behaviour change.
* Enabled aggressive block sorting
* Enabled unnecessary exception pruning
* Enabled aggressive exception aggregation
*/
public void load(BIFile bIFile) throws Exception {
InputStream inputStream = bIFile.getInputStream();
try {
this.load(bIFile.toString(), XParser.make((InputStream)inputStream).parse());
}
catch (Throwable throwable) {
Object var4_4 = null;
try {
inputStream.close();
throw throwable;
}
catch (Exception exception) {}
throw throwable;
}
{
Object var4_5 = null;
}
try {}
catch (Exception exception) {
return;
}
inputStream.close();
}
public void load(String string, InputStream inputStream) throws Exception {
this.load(string, inputStream, true);
}
public void load(String string, InputStream inputStream, boolean bl) throws Exception {
this.load(string, XParser.make((InputStream)inputStream).parse(bl));
}
public void load(String string, XElem xElem) throws Exception {
this.source = string == null ? string : "Unknown";
this.parse(xElem);
}
private final void parse(XElem xElem) throws Exception {
XElem xElem2;
XElem xElem3;
if (!xElem.qname().equals("certificate")) {
throw new XException("Root element must be <certificate> element", xElem);
}
this.modified = false;
this.xml = new XElem("certificate");
int n = 0;
while (n < xElem.attrSize()) {
this.xml.addAttr(xElem.attrName(n), xElem.attrValue(n));
++n;
}
if (xElem.get("generated", null) == null) {
this.xml.addAttr("generated", LicenseUtil.formatDate(Clock.millis()));
}
if ((xElem3 = xElem.elem("signature")) != null) {
this.signature = xElem3.string();
}
if ((xElem2 = xElem.elem("publicKey")) != null) {
this.xml.addContent((XContent)xElem2.copy());
}
}
/*
* WARNING - Removed back jump from a try to a catch block - possible behaviour change.
* Enabled aggressive block sorting
* Enabled unnecessary exception pruning
* Enabled aggressive exception aggregation
*/
public void save(BIFile bIFile) throws IOException {
OutputStream outputStream = bIFile.getOutputStream();
try {
VendorCertificate.format(this.save(), new XWriter(outputStream));
}
catch (Throwable throwable) {
Object var4_4 = null;
try {
outputStream.close();
throw throwable;
}
catch (Exception exception) {}
throw throwable;
}
{
Object var4_5 = null;
}
try {}
catch (Exception exception) {
return;
}
outputStream.close();
}
public void save(OutputStream outputStream) throws IOException {
this.save(outputStream, true);
}
public void save(OutputStream outputStream, boolean bl) throws IOException {
XWriter xWriter = new XWriter(outputStream);
this.save(xWriter);
xWriter.flush();
if (bl) {
xWriter.close();
}
}
public void save(XWriter xWriter) throws IOException {
VendorCertificate.format(this.save(), xWriter);
}
public XElem save() {
if (this.modified) {
this.xml.setAttr("generated", LicenseUtil.formatDate(Clock.millis()));
this.modified = false;
}
XElem xElem = this.xml.copy();
if (this.signature != null) {
XElem xElem2 = new XElem("signature");
xElem2.addContent((XContent)new XText(this.signature));
xElem.addContent((XContent)xElem2);
}
return xElem;
}
public static void format(XElem xElem, XWriter xWriter) {
VendorCertificate.formatr(xElem, xWriter, "");
xWriter.flush();
}
private static final void formatr(XElem xElem, XWriter xWriter, String string) {
xWriter.w((Object)string).w('<').w((Object)xElem.name());
int n = xElem.attrSize();
int n2 = 0;
while (n2 < n) {
xWriter.w((Object)" ").attr(xElem.attrName(n2), xElem.attrValue(n2));
++n2;
}
if (xElem.contentSize() == 0) {
xWriter.w((Object)"/>").nl();
return;
}
xWriter.w('>');
XElem[] xElemArray = xElem.elems();
if (xElemArray.length > 0) {
xWriter.nl();
}
int n3 = 0;
while (n3 < xElemArray.length) {
VendorCertificate.formatr(xElemArray[n3], xWriter, string + ' ');
++n3;
}
if (xElem.text() != null) {
xElem.text().write(xWriter);
}
if (xElemArray.length > 0) {
xWriter.w((Object)string);
}
xWriter.w((Object)"</").w((Object)xElem.name()).w('>').nl();
}
protected void modify() {
this.signature = null;
this.modified = true;
}
public void dump() {
this.dump(new PrintWriter(System.out));
}
public void dump(PrintWriter printWriter) {
printWriter.println(" VendorCertificate");
printWriter.println(" source: " + this.source);
printWriter.println(" vendor: " + this.getVendor());
printWriter.println(" version: " + this.getVersion());
printWriter.println(" expiration: " + LicenseUtil.formatDate(this.getExpiration()));
printWriter.println(" generated: " + LicenseUtil.formatDate(this.getGenerated()));
printWriter.flush();
}
private final /* synthetic */ void this() {
this.source = "Unknown";
this.signature = null;
this.modified = false;
}
public VendorCertificate() {
this.this();
this.xml = new XElem("certificate");
this.xml.setAttr("generated", LicenseUtil.formatDate(Clock.millis()));
this.modified = true;
}
}
@@ -0,0 +1,436 @@
/*
* Decompiled with CFR 0.152.
*
* Could not load the following classes:
* javax.baja.nre.util.Array
* javax.baja.nre.util.TextUtil
* javax.baja.xml.XContent
* javax.baja.xml.XElem
* javax.baja.xml.XException
* javax.baja.xml.XParser
* javax.baja.xml.XText
* javax.baja.xml.XWriter
*/
package com.tridium.sys.license.dom;
import com.tridium.sys.license.LicenseUtil;
import com.tridium.sys.license.dom.Feature;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import javax.baja.file.BIFile;
import javax.baja.nre.util.Array;
import javax.baja.nre.util.TextUtil;
import javax.baja.sys.Clock;
import javax.baja.util.Version;
import javax.baja.xml.XContent;
import javax.baja.xml.XElem;
import javax.baja.xml.XException;
import javax.baja.xml.XParser;
import javax.baja.xml.XText;
import javax.baja.xml.XWriter;
/*
* Illegal identifiers - consider using --renameillegalidents true
*/
public class VendorLicense {
private String source;
private XElem xml;
private Array features;
private String signature;
private boolean modified;
static /* synthetic */ Class class$com$tridium$sys$license$dom$Feature;
public static VendorLicense make(BIFile bIFile) throws Exception {
VendorLicense vendorLicense = new VendorLicense();
vendorLicense.load(bIFile);
return vendorLicense;
}
public static VendorLicense make(String string, InputStream inputStream) throws Exception {
VendorLicense vendorLicense = new VendorLicense();
vendorLicense.load(string, inputStream);
return vendorLicense;
}
public static VendorLicense make(String string, InputStream inputStream, boolean bl) throws Exception {
VendorLicense vendorLicense = new VendorLicense();
vendorLicense.load(string, inputStream, bl);
return vendorLicense;
}
public static VendorLicense make(String string, XElem xElem) throws Exception {
VendorLicense vendorLicense = new VendorLicense();
vendorLicense.load(string, xElem);
return vendorLicense;
}
public String getSource() {
return this.source;
}
public String getHostId() {
return this.xml.get("hostId");
}
public void setHostId(String string) {
this.modify();
this.xml.setAttr("hostId", string);
}
public String getVendor() {
return this.xml.get("vendor");
}
public void setVendor(String string) {
this.modify();
this.xml.setAttr("vendor", string);
}
public boolean isExpired() {
boolean bl = false;
if (Clock.millis() > this.getExpiration()) {
bl = true;
}
return bl;
}
public long getExpiration() {
return LicenseUtil.parseDate(this.xml.get("expiration"));
}
public void setExpiration(long l) {
this.modify();
this.xml.setAttr("expiration", LicenseUtil.formatDate(l));
}
public long getGenerated() {
return LicenseUtil.parseDate(this.xml.get("generated"));
}
public Version getVersion() {
return new Version(this.xml.get("version"));
}
public void setVersion(Version version) {
this.modify();
this.xml.setAttr("version", version.toString());
}
public String getSignature() {
return this.signature;
}
public void setSignature(String string) {
this.modify();
this.signature = string;
}
public Feature getFeature(String string) {
int n = 0;
while (n < this.features.size()) {
Feature feature = (Feature)this.features.get(n);
if (feature.getKey().equals(Feature.toKey(string))) {
return feature;
}
++n;
}
return null;
}
public Feature.Brand getBrandFeature() {
return (Feature.Brand)this.getFeature("brand");
}
public String getBrandId() {
if ("tridium".equalsIgnoreCase(this.getVendor())) {
Feature.Brand brand = this.getBrandFeature();
return brand == null ? null : brand.getBrandId();
}
return null;
}
public String getLicenseName() {
if ("tridium".equalsIgnoreCase(this.getVendor())) {
Feature.Brand brand = this.getBrandFeature();
return brand == null ? "Tridium" : TextUtil.capitalize((String)brand.getBrandId());
}
return TextUtil.capitalize((String)this.getVendor());
}
public Feature[] getFeatures() {
return (Feature[])this.features.trim();
}
public String[] getFeatureNames() {
Feature[] featureArray = this.getFeatures();
String[] stringArray = new String[featureArray.length];
int n = 0;
while (n < stringArray.length) {
stringArray[n] = featureArray[n].getName();
++n;
}
return stringArray;
}
public Feature addFeature(String string) {
if (this.getFeature(string) != null) {
throw new RuntimeException("Feature already exists");
}
Feature feature = Feature.make(this, string);
this.features.add((Object)feature);
return feature;
}
public Feature removeFeature(String string) {
int n = 0;
while (n < this.features.size()) {
Feature feature = (Feature)this.features.get(n);
if (feature.getKey().equals(Feature.toKey(string))) {
this.features.remove(n);
return feature;
}
++n;
}
return null;
}
/*
* WARNING - Removed back jump from a try to a catch block - possible behaviour change.
* Enabled aggressive block sorting
* Enabled unnecessary exception pruning
* Enabled aggressive exception aggregation
*/
public void load(BIFile bIFile) throws Exception {
InputStream inputStream = bIFile.getInputStream();
try {
this.load(bIFile.toString(), XParser.make((InputStream)inputStream).parse());
}
catch (Throwable throwable) {
Object var4_4 = null;
try {
inputStream.close();
throw throwable;
}
catch (Exception exception) {}
throw throwable;
}
{
Object var4_5 = null;
}
try {}
catch (Exception exception) {
return;
}
inputStream.close();
}
public void load(String string, InputStream inputStream) throws Exception {
this.load(string, inputStream, true);
}
public void load(String string, InputStream inputStream, boolean bl) throws Exception {
this.load(string, XParser.make((InputStream)inputStream).parse(bl));
}
public void load(String string, XElem xElem) throws Exception {
this.source = string != null ? string : "Unknown";
this.parse(xElem);
}
private final void parse(XElem xElem) throws Exception {
if (!xElem.qname().equals("license")) {
throw new XException("Root element must be <license> element", xElem);
}
this.modified = false;
this.xml = new XElem("license");
int n = 0;
while (n < xElem.attrSize()) {
this.xml.addAttr(xElem.attrName(n), xElem.attrValue(n));
++n;
}
if (xElem.get("generated", null) == null) {
this.xml.addAttr("generated", LicenseUtil.formatDate(Clock.millis()));
}
XElem[] xElemArray = xElem.elems("feature");
Class clazz = class$com$tridium$sys$license$dom$Feature;
if (clazz == null) {
clazz = class$com$tridium$sys$license$dom$Feature = VendorLicense.class("[Lcom.tridium.sys.license.dom.Feature;", false);
}
this.features = new Array(clazz);
int n2 = 0;
while (n2 < xElemArray.length) {
XElem xElem2 = xElemArray[n2];
Feature feature = Feature.make(this, xElem2.get("name"));
feature.load(xElemArray[n2]);
this.features.add((Object)feature);
++n2;
}
XElem xElem3 = xElem.elem("signature");
if (xElem3 != null) {
this.signature = xElem3.string();
}
}
/*
* WARNING - Removed back jump from a try to a catch block - possible behaviour change.
* Enabled aggressive block sorting
* Enabled unnecessary exception pruning
* Enabled aggressive exception aggregation
*/
public void save(BIFile bIFile) throws IOException {
OutputStream outputStream = bIFile.getOutputStream();
try {
VendorLicense.format(this.save(), new XWriter(outputStream));
}
catch (Throwable throwable) {
Object var4_4 = null;
try {
outputStream.close();
throw throwable;
}
catch (Exception exception) {}
throw throwable;
}
{
Object var4_5 = null;
}
try {}
catch (Exception exception) {
return;
}
outputStream.close();
}
public void save(OutputStream outputStream) throws IOException {
this.save(outputStream, true);
}
public void save(OutputStream outputStream, boolean bl) throws IOException {
XWriter xWriter = new XWriter(outputStream);
this.save(xWriter);
xWriter.flush();
if (bl) {
xWriter.close();
}
}
public void save(XWriter xWriter) throws IOException {
VendorLicense.format(this.save(), xWriter);
}
public XElem save() {
if (this.modified) {
this.xml.setAttr("generated", LicenseUtil.formatDate(Clock.millis()));
this.modified = false;
}
XElem xElem = this.xml.copy();
int n = 0;
while (n < this.features.size()) {
xElem.addContent((XContent)((Feature)this.features.get(n)).save());
++n;
}
if (this.signature != null) {
XElem xElem2 = new XElem("signature");
xElem2.addContent((XContent)new XText(this.signature));
xElem.addContent((XContent)xElem2);
}
return xElem;
}
public static void format(XElem xElem, XWriter xWriter) {
VendorLicense.formatr(xElem, xWriter, "");
xWriter.flush();
}
private static final void formatr(XElem xElem, XWriter xWriter, String string) {
xWriter.w((Object)string).w('<').w((Object)xElem.name());
int n = xElem.attrSize();
int n2 = 0;
while (n2 < n) {
xWriter.w((Object)" ").attr(xElem.attrName(n2), xElem.attrValue(n2));
++n2;
}
if (xElem.contentSize() == 0) {
xWriter.w((Object)"/>").nl();
return;
}
xWriter.w('>');
XElem[] xElemArray = xElem.elems();
if (xElemArray.length > 0) {
xWriter.nl();
}
int n3 = 0;
while (n3 < xElemArray.length) {
VendorLicense.formatr(xElemArray[n3], xWriter, string + ' ');
++n3;
}
if (xElem.text() != null) {
xElem.text().write(xWriter);
}
if (xElemArray.length > 0) {
xWriter.w((Object)string);
}
xWriter.w((Object)"</").w((Object)xElem.name()).w('>').nl();
}
protected void modify() {
this.signature = null;
this.modified = true;
}
public void dump() {
this.dump(new PrintWriter(System.out));
}
public void dump(PrintWriter printWriter) {
printWriter.println(" VendorLicense");
printWriter.println(" source: " + this.source);
printWriter.println(" hostId: " + this.getHostId());
printWriter.println(" vendor: " + this.getVendor());
printWriter.println(" version: " + this.getVersion());
printWriter.println(" expiration: " + LicenseUtil.formatDate(this.getExpiration()));
printWriter.println(" generated: " + LicenseUtil.formatDate(this.getGenerated()));
Feature[] featureArray = this.getFeatures();
int n = 0;
while (n < featureArray.length) {
featureArray[n].dump(printWriter);
++n;
}
printWriter.flush();
}
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.source = "Unknown";
Class clazz = class$com$tridium$sys$license$dom$Feature;
if (clazz == null) {
clazz = class$com$tridium$sys$license$dom$Feature = VendorLicense.class("[Lcom.tridium.sys.license.dom.Feature;", false);
}
this.features = new Array(clazz);
this.signature = null;
this.modified = false;
}
public VendorLicense() {
this.this();
this.xml = new XElem("license");
this.xml.setAttr("generated", LicenseUtil.formatDate(Clock.millis()));
this.xml.setAttr("expiration", "never");
this.modified = true;
}
}
@@ -0,0 +1,88 @@
/*
* Decompiled with CFR 0.152.
*
* Could not load the following classes:
* javax.baja.nre.util.Array
* javax.baja.nre.util.TextUtil
*/
package com.tridium.sys.metrics;
import com.tridium.sys.metrics.Group;
import java.util.StringTokenizer;
import javax.baja.license.Feature;
import javax.baja.license.FeatureNotLicensedException;
import javax.baja.nre.util.Array;
import javax.baja.nre.util.TextUtil;
import javax.baja.sys.Sys;
/*
* Illegal identifiers - consider using --renameillegalidents true
*/
class GlobalGroup
extends Group {
static final String FEATURE_NAME = "globalCapacity";
boolean isGlobalEnabled;
final Group.Count links;
final Group.Count histories;
final Group.Count schedules;
final Array excludedNetworks;
final Array excludedDevices;
final Array excludedPoints;
boolean isGlobal() {
return true;
}
protected static void parseModules(Feature feature, String string, Array array) {
String string2 = feature.get(string);
if (string2 != null && !TextUtil.toLowerCase((String)string2).equals("none")) {
StringTokenizer stringTokenizer = new StringTokenizer(string2, ",;");
while (stringTokenizer.hasMoreTokens()) {
array.add((Object)stringTokenizer.nextToken());
}
}
}
private final /* synthetic */ void this() {
this.isGlobalEnabled = false;
this.links = new Group.Count();
this.histories = new Group.Count();
this.schedules = new Group.Count();
this.excludedNetworks = new Array();
this.excludedDevices = new Array();
this.excludedPoints = new Array();
}
GlobalGroup() {
super(FEATURE_NAME);
this.this();
try {
Feature feature = Sys.getLicenseManager().getFeature("tridium", FEATURE_NAME);
try {
feature.check();
this.networks.limit = GlobalGroup.parseLimit(feature, "network.limit");
this.devices.limit = GlobalGroup.parseLimit(feature, "device.limit");
this.points.limit = GlobalGroup.parseLimit(feature, "point.limit");
this.links.limit = GlobalGroup.parseLimit(feature, "link.limit");
this.histories.limit = GlobalGroup.parseLimit(feature, "history.limit");
this.schedules.limit = GlobalGroup.parseLimit(feature, "schedule.limit");
GlobalGroup.parseModules(feature, "excludedNetworks", this.excludedNetworks);
GlobalGroup.parseModules(feature, "excludedDevices", this.excludedDevices);
GlobalGroup.parseModules(feature, "excludedPoints", this.excludedPoints);
this.isGlobalEnabled = true;
}
catch (FeatureNotLicensedException featureNotLicensedException) {
featureNotLicensedException.printStackTrace();
}
}
catch (FeatureNotLicensedException featureNotLicensedException) {
this.networks.limit = Integer.MAX_VALUE;
this.devices.limit = Integer.MAX_VALUE;
this.points.limit = Integer.MAX_VALUE;
this.links.limit = Integer.MAX_VALUE;
this.histories.limit = Integer.MAX_VALUE;
this.schedules.limit = Integer.MAX_VALUE;
}
}
}
@@ -0,0 +1,82 @@
/*
* Decompiled with CFR 0.152.
*
* Could not load the following classes:
* javax.baja.nre.util.TextUtil
*/
package com.tridium.sys.metrics;
import javax.baja.license.Feature;
import javax.baja.nre.util.TextUtil;
/*
* Illegal identifiers - consider using --renameillegalidents true
*/
abstract class Group
implements Comparable {
final String featureName;
final Count networks;
final Count devices;
final Count points;
protected static int parseLimit(Feature feature, String string) {
String string2 = feature.get(string);
int n = Integer.MAX_VALUE;
if (string2 != null && !TextUtil.toLowerCase((String)string2).equals("none")) {
n = Integer.parseInt(string2);
}
return n;
}
public String toString() {
return "[Group " + this.featureName + ']';
}
public int compareTo(Object object) {
Group group = (Group)object;
return this.featureName.compareTo(group.featureName);
}
public boolean equals(Object object) {
if (object == null || !(object instanceof Group)) {
return false;
}
Group group = (Group)object;
return this.featureName.equals(group.featureName);
}
public int hashCode() {
return this.featureName.hashCode();
}
abstract boolean isGlobal();
private final /* synthetic */ void this() {
this.networks = new Count();
this.devices = new Count();
this.points = new Count();
}
Group(String string) {
this.this();
this.featureName = string;
}
/*
* Illegal identifiers - consider using --renameillegalidents true
*/
static class Count {
int limit;
int used;
private final /* synthetic */ void this() {
this.limit = 0;
this.used = 0;
}
Count() {
this.this();
}
}
}
@@ -0,0 +1,8 @@
/*
* Decompiled with CFR 0.152.
*/
package com.tridium.sys.metrics;
public interface IMetricResource {
}
@@ -0,0 +1,592 @@
/*
* Decompiled with CFR 0.152.
*/
package com.tridium.sys.metrics;
import com.tridium.sys.metrics.GlobalGroup;
import com.tridium.sys.metrics.Group;
import com.tridium.sys.metrics.IMetricResource;
import com.tridium.sys.metrics.SubGroup;
import com.tridium.sys.resource.ResourceReport;
import java.text.DecimalFormat;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
import java.util.Stack;
import java.util.TreeSet;
import javax.baja.collection.BIList;
import javax.baja.license.Feature;
import javax.baja.naming.BOrd;
import javax.baja.security.BICredentials;
import javax.baja.security.BPassword;
import javax.baja.spy.Spy;
import javax.baja.spy.SpyWriter;
import javax.baja.sys.BAbsTime;
import javax.baja.sys.BComplex;
import javax.baja.sys.BLink;
import javax.baja.sys.BObject;
import javax.baja.sys.BString;
import javax.baja.sys.Property;
import javax.baja.sys.SlotCursor;
import javax.baja.sys.Sys;
import javax.baja.sys.Type;
import javax.baja.util.BNotification;
import javax.baja.util.BTypeSpec;
public final class Metrics {
private static final DecimalFormat DF = new DecimalFormat("###,###,###");
private static Object lock = new Object();
private static Type scheduleType;
private static String recountLastRun;
private static String recountLastFail;
private static String recountLastFailReason;
private static GlobalGroup global;
private static Set subGroups;
private static Map moduleGroups;
private static int historyExtCount;
public static final String HISTORY_FAULT_CAUSE = "Exceeded Global Capacity history limit.";
/*
* WARNING - Removed try catching itself - possible behaviour change.
* Enabled aggressive block sorting
* Enabled unnecessary exception pruning
* Enabled aggressive exception aggregation
*/
public static final String incrementNetwork(BComplex bComplex) {
Object object = lock;
synchronized (object) {
return Metrics.incrementNetwork(bComplex, global, moduleGroups);
}
}
private static final String incrementNetwork(BComplex bComplex, GlobalGroup globalGroup, Map map) {
boolean bl = false;
if (globalGroup.excludedNetworks.contains((Object)bComplex.getType().getModule().getModuleName())) {
bl = true;
} else {
++globalGroup.networks.used;
}
Group group = Metrics.findSubGroup(bComplex, map);
if (group == null) {
return !bl && globalGroup.networks.used > globalGroup.networks.limit ? globalGroup.featureName : null;
}
++group.networks.used;
if (globalGroup.networks.used > globalGroup.networks.limit) {
return group.networks.used > group.networks.limit ? globalGroup.featureName + ',' + group.featureName : globalGroup.featureName;
}
return group.networks.used > group.networks.limit ? group.featureName : null;
}
/*
* WARNING - Removed try catching itself - possible behaviour change.
* Enabled aggressive block sorting
* Enabled unnecessary exception pruning
* Enabled aggressive exception aggregation
*/
public static final String incrementDevice(BComplex bComplex) {
Object object = lock;
synchronized (object) {
return Metrics.incrementDevice(bComplex, global, moduleGroups);
}
}
private static final String incrementDevice(BComplex bComplex, GlobalGroup globalGroup, Map map) {
boolean bl = false;
if (globalGroup.excludedDevices.contains((Object)bComplex.getType().getModule().getModuleName())) {
bl = true;
} else {
++globalGroup.devices.used;
}
Group group = Metrics.findSubGroup(bComplex, map);
if (group == null) {
return !bl && globalGroup.devices.used > globalGroup.devices.limit ? globalGroup.featureName : null;
}
++group.devices.used;
if (globalGroup.devices.used > globalGroup.devices.limit) {
return group.devices.used > group.devices.limit ? globalGroup.featureName + ',' + group.featureName : globalGroup.featureName;
}
return group.devices.used > group.devices.limit ? group.featureName : null;
}
/*
* WARNING - Removed try catching itself - possible behaviour change.
* Enabled aggressive block sorting
* Enabled unnecessary exception pruning
* Enabled aggressive exception aggregation
*/
public static final String incrementPoint(BComplex bComplex) {
Object object = lock;
synchronized (object) {
return Metrics.incrementPoint(bComplex, global, moduleGroups);
}
}
private static final String incrementPoint(BComplex bComplex, GlobalGroup globalGroup, Map map) {
boolean bl = false;
if (globalGroup.excludedPoints.contains((Object)bComplex.getType().getModule().getModuleName())) {
bl = true;
} else {
++globalGroup.points.used;
}
Group group = Metrics.findSubGroup(bComplex, map);
if (group == null) {
return !bl && globalGroup.points.used > globalGroup.points.limit ? globalGroup.featureName : null;
}
++group.points.used;
if (globalGroup.points.used > globalGroup.points.limit) {
return group.points.used > group.points.limit ? globalGroup.featureName + ',' + group.featureName : globalGroup.featureName;
}
return group.points.used > group.points.limit ? group.featureName : null;
}
/*
* WARNING - Removed try catching itself - possible behaviour change.
* Enabled aggressive block sorting
* Enabled unnecessary exception pruning
* Enabled aggressive exception aggregation
*/
public static final boolean incrementLink() {
Object object = lock;
synchronized (object) {
++Metrics.global.links.used;
if (Metrics.global.links.used == Metrics.global.links.limit + 1 && Sys.getStation() != null) {
BNotification bNotification = new BNotification();
bNotification.add("title", BString.make("Capacity Licensing"));
bNotification.add("message", BString.make("Exceeded Link Limit"));
bNotification.raise(true);
}
boolean bl = false;
if (Metrics.global.links.used > Metrics.global.links.limit) return bl;
return true;
}
}
/*
* WARNING - Removed try catching itself - possible behaviour change.
* Enabled aggressive block sorting
* Enabled unnecessary exception pruning
* Enabled aggressive exception aggregation
*/
public static final boolean incrementHistory() {
Object object = lock;
synchronized (object) {
if (Metrics.global.histories.used < Metrics.global.histories.limit) {
++Metrics.global.histories.used;
return true;
}
return false;
}
}
public static final boolean incrementSchedule(BComplex bComplex) {
return Metrics.incrementSchedule(bComplex, global);
}
/*
* WARNING - Removed try catching itself - possible behaviour change.
* Enabled aggressive block sorting
* Enabled unnecessary exception pruning
* Enabled aggressive exception aggregation
*/
private static final boolean incrementSchedule(BComplex bComplex, GlobalGroup globalGroup) {
Property property = bComplex.getPropertyInParent();
Metrics.ensureScheduleTypeLoaded();
if (!(bComplex instanceof IMetricResource)) {
return true;
}
if (bComplex.getParent() != null && bComplex.getParent().getType().is(scheduleType) && property.isFrozen()) {
return true;
}
Object object = lock;
synchronized (object) {
++globalGroup.schedules.used;
boolean bl = false;
if (globalGroup.schedules.used > globalGroup.schedules.limit) return bl;
return true;
}
}
private static final void ensureScheduleTypeLoaded() {
if (scheduleType == null) {
try {
scheduleType = BTypeSpec.make("schedule", "CompositeSchedule").getResolvedType();
}
catch (Exception exception) {}
}
}
/*
* WARNING - Removed try catching itself - possible behaviour change.
* Enabled aggressive block sorting
* Enabled unnecessary exception pruning
* Enabled aggressive exception aggregation
*/
public static final boolean isUsingCapacityLicensing() {
Object object = lock;
synchronized (object) {
boolean bl = false;
if (Metrics.global.isGlobalEnabled) return true;
if (moduleGroups.size() <= 0) return bl;
return true;
}
}
public static final void writeToResourceReport(ResourceReport resourceReport) {
boolean bl = false;
if (Metrics.global.isGlobalEnabled) {
bl = true;
resourceReport.put("globalCapacity.networks", Metrics.getDisplayUsed(Metrics.global.networks) + " (Limit: " + Metrics.getDisplayLimit(Metrics.global.networks) + ')');
resourceReport.put("globalCapacity.devices", Metrics.getDisplayUsed(Metrics.global.devices) + " (Limit: " + Metrics.getDisplayLimit(Metrics.global.devices) + ')');
resourceReport.put("globalCapacity.points", Metrics.getDisplayUsed(Metrics.global.points) + " (Limit: " + Metrics.getDisplayLimit(Metrics.global.points) + ')');
resourceReport.put("globalCapacity.links", Metrics.getDisplayUsed(Metrics.global.links) + " (Limit: " + Metrics.getDisplayLimit(Metrics.global.links) + ')');
if (Metrics.global.histories.used > historyExtCount) {
resourceReport.put("globalCapacity.histories", Metrics.getDisplayUsed(Metrics.global.histories) + " (Limit: " + Metrics.getDisplayLimit(Metrics.global.histories) + ')');
} else {
resourceReport.put("globalCapacity.histories", DF.format(historyExtCount) + " (Limit: " + Metrics.getDisplayLimit(Metrics.global.histories) + ')');
}
resourceReport.put("globalCapacity.schedules", Metrics.getDisplayUsed(Metrics.global.schedules) + " (Limit: " + Metrics.getDisplayLimit(Metrics.global.schedules) + ')');
}
if (moduleGroups.size() > 0) {
bl = true;
Iterator iterator = subGroups.iterator();
while (iterator.hasNext()) {
SubGroup subGroup = (SubGroup)iterator.next();
resourceReport.put(subGroup.featureName + ".networks", Metrics.getDisplayUsed(subGroup.networks) + " (Limit: " + Metrics.getDisplayLimit(subGroup.networks) + ')');
resourceReport.put(subGroup.featureName + ".devices", Metrics.getDisplayUsed(subGroup.devices) + " (Limit: " + Metrics.getDisplayLimit(subGroup.devices) + ')');
resourceReport.put(subGroup.featureName + ".points", Metrics.getDisplayUsed(subGroup.points) + " (Limit: " + Metrics.getDisplayLimit(subGroup.points) + ')');
}
}
if (bl) {
resourceReport.put("capacityLicensing.recountLastRun", recountLastRun);
resourceReport.put("capacityLicensing.recountLastFail", recountLastFail);
resourceReport.put("capacityLicensing.recountLastFailReason", recountLastFailReason);
}
}
private static final Group findSubGroup(BComplex bComplex, Map map) {
Type type = bComplex.getType();
return (Group)map.get(type.getModule().getModuleName());
}
private static final String getDisplayUsed(Group.Count count) {
return DF.format(count.used);
}
private static final String getDisplayLimit(Group.Count count) {
return count.limit == Integer.MAX_VALUE ? "none" : DF.format(count.limit);
}
private static final void loadSubGroups(Set set, Map map) {
Feature[] featureArray = Sys.getLicenseManager().getFeatures();
int n = 0;
while (n < featureArray.length) {
Feature feature = featureArray[n];
if (feature.getVendorName().toLowerCase().equals("tridium") && feature.getFeatureName().toLowerCase().startsWith("driverCapacity".toLowerCase())) {
SubGroup subGroup = new SubGroup(feature);
set.add(subGroup);
int n2 = 0;
while (n2 < subGroup.modules.length) {
map.put(subGroup.modules[n2], subGroup);
++n2;
}
}
++n;
}
}
static {
recountLastRun = "never";
recountLastFail = "never";
recountLastFailReason = "";
global = new GlobalGroup();
subGroups = new TreeSet();
moduleGroups = new HashMap();
historyExtCount = 0;
Metrics.loadSubGroups(subGroups, moduleGroups);
}
public static final class Recount
extends Thread {
private static final int INTERVAL = 30000;
private static Type NETWORK_TYPE = null;
private static Type DEVICE_TYPE = null;
private static Type POINT_TYPE = null;
private static Set subGroupsBucket = new TreeSet();
private static Map moduleGroupsBucket = new HashMap();
private SlotCursor current;
private BComplex root;
private boolean componentOnly;
private Stack nodeStack;
private GlobalGroup globalBucket;
public final void run() {
if (Metrics.isUsingCapacityLicensing()) {
try {
DEVICE_TYPE = BTypeSpec.make("driver", "Device").getResolvedType();
}
catch (Exception exception) {}
try {
NETWORK_TYPE = BTypeSpec.make("driver", "DeviceNetwork").getResolvedType();
}
catch (Exception exception) {}
try {
POINT_TYPE = BTypeSpec.make("driver", "ProxyExt").getResolvedType();
}
catch (Exception exception) {}
Metrics.ensureScheduleTypeLoaded();
this.globalBucket = new GlobalGroup();
Metrics.loadSubGroups(Recount.subGroupsBucket, Recount.moduleGroupsBucket);
boolean bl = false;
if (this.globalBucket.links.limit == Integer.MAX_VALUE) {
bl = true;
}
this.componentOnly = bl;
while (true) {
try {
Thread.sleep(30000L);
this.root = Sys.getStation();
this.current = null;
this.globalBucket.networks.used = 0;
this.globalBucket.devices.used = 0;
this.globalBucket.points.used = 0;
this.globalBucket.histories.used = 0;
this.globalBucket.links.used = 0;
this.globalBucket.schedules.used = 0;
Iterator iterator = subGroupsBucket.iterator();
while (iterator.hasNext()) {
SubGroup subGroup = (SubGroup)iterator.next();
subGroup.networks.used = 0;
subGroup.devices.used = 0;
subGroup.points.used = 0;
}
this.count();
recountLastRun = BAbsTime.make().toString();
}
catch (Exception exception) {
recountLastFail = BAbsTime.make().toString();
recountLastFailReason = exception.toString();
}
}
}
}
/*
* WARNING - Removed try catching itself - possible behaviour change.
* Enabled aggressive block sorting
* Enabled unnecessary exception pruning
* Enabled aggressive exception aggregation
*/
private final void count() {
BObject bObject;
while (this.nextImpl()) {
bObject = this.get();
if (bObject instanceof BPassword || bObject instanceof BICredentials) continue;
this.checkMatch(bObject);
}
bObject = BOrd.make("history:|bql:select * from sys.histories");
BIList bIList = (BIList)((Object)((BOrd)bObject).resolve().get());
BOrd bOrd = BOrd.make("station:|slot:/|bql:select * from history:HistoryExt where status.isFault AND faultCause like '%Exceeded Global Capacity history limit.%'");
BIList bIList2 = (BIList)((Object)bOrd.resolve().get());
BOrd bOrd2 = BOrd.make("station:|slot:/|bql:select * from driver:HistoryImport where status.isFault and faultCause like '%Exceeded Global Capacity history limit.%'");
BIList bIList3 = (BIList)((Object)bOrd2.resolve().get());
this.globalBucket.histories.used = bIList.size();
historyExtCount = bIList.size() + bIList2.size() + bIList3.size();
Object object = lock;
synchronized (object) {
global.networks.used = this.globalBucket.networks.used;
global.devices.used = this.globalBucket.devices.used;
global.points.used = this.globalBucket.points.used;
if (!this.componentOnly) {
global.links.used = this.globalBucket.links.used;
}
global.schedules.used = this.globalBucket.schedules.used;
global.histories.used = this.globalBucket.histories.used;
Iterator iterator = subGroupsBucket.iterator();
while (iterator.hasNext()) {
SubGroup subGroup = (SubGroup)iterator.next();
Group group = (Group)moduleGroups.get(subGroup.modules[0]);
group.networks.used = subGroup.networks.used;
group.devices.used = subGroup.devices.used;
group.points.used = subGroup.points.used;
}
return;
}
}
private final void checkMatch(BObject bObject) {
if (bObject.getType().is(NETWORK_TYPE)) {
Metrics.incrementNetwork((BComplex)bObject, this.globalBucket, Recount.moduleGroupsBucket);
} else if (bObject.getType().is(DEVICE_TYPE)) {
Metrics.incrementDevice((BComplex)bObject, this.globalBucket, Recount.moduleGroupsBucket);
} else if (bObject.getType().is(POINT_TYPE)) {
Metrics.incrementPoint((BComplex)bObject, this.globalBucket, Recount.moduleGroupsBucket);
} else if (bObject.getType().is(scheduleType)) {
Metrics.incrementSchedule((BComplex)bObject, this.globalBucket);
} else if (bObject instanceof BLink) {
++this.globalBucket.links.used;
}
}
/*
* Unable to fully structure code
*/
private final boolean nextImpl() {
if (this.current == null) {
if (!this.root.isComplex()) {
return false;
}
this.current = this.root.asComplex().getProperties();
if (this.componentOnly) {
return this.current.nextComponent();
}
return this.current.next();
}
var1_1 = null;
var2_2 = null;
var3_3 = false;
if (this.componentOnly != false ? this.current.get().isComponent() != false : this.current.get().isComplex() != false) {
var1_1 = (BComplex)this.current.get();
var2_2 = var1_1.getProperties();
if (this.componentOnly) {
if (var2_2.nextComponent()) {
var3_3 = true;
}
} else if (var2_2.next()) {
var3_3 = true;
}
}
if (!var3_3) ** GOTO lbl30
if (this.nodeStack == null) {
this.nodeStack = new Stack<E>();
}
this.nodeStack.push(this.current);
this.current = var2_2;
return true;
lbl-1000:
// 1 sources
{
if (this.nodeStack == null || this.nodeStack.empty()) {
return false;
}
this.current = (SlotCursor)this.nodeStack.pop();
lbl30:
// 2 sources
** while (!(this.componentOnly != false ? this.current.nextComponent() != false : this.current.next() != false))
}
lbl31:
// 1 sources
return true;
}
private final BObject get() {
return this.current.get();
}
public Recount() {
super("Nre:Metrics.Recount");
this.setDaemon(true);
}
}
public static class MetricSpy
extends Spy {
/*
* WARNING - Removed try catching itself - possible behaviour change.
* Enabled aggressive block sorting
* Enabled unnecessary exception pruning
* Enabled aggressive exception aggregation
*/
public void write(SpyWriter spyWriter) {
Object object = lock;
synchronized (object) {
this.writeRecountTable(spyWriter);
this.writeGroup(spyWriter, global);
Iterator iterator = subGroups.iterator();
while (iterator.hasNext()) {
this.writeGroup(spyWriter, (SubGroup)iterator.next());
}
return;
}
}
private final void writeRecountTable(SpyWriter spyWriter) {
spyWriter.startTable(true);
spyWriter.trTitle("Recount", 3);
spyWriter.w("<tr>");
spyWriter.w("<td>recountLastRun</td>");
spyWriter.w("<td>").w(recountLastRun).w("</td>");
spyWriter.w("</tr>\n");
spyWriter.w("<tr>");
spyWriter.w("<td>recountLastFail</td>");
spyWriter.w("<td>").w(recountLastFail).w("</td>");
spyWriter.w("</tr>\n");
spyWriter.w("<tr>");
spyWriter.w("<td>recountLastFailReason</td>");
spyWriter.w("<td>").w(recountLastFailReason).w("</td>");
spyWriter.w("</tr>\n");
spyWriter.endTable();
spyWriter.w("<p/><p/>");
}
private final void writeGroup(SpyWriter spyWriter, Group group) {
spyWriter.startTable(true);
if (group.isGlobal()) {
spyWriter.trTitle("Global Capacity", 3);
if (((GlobalGroup)group).excludedNetworks.size() > 0) {
spyWriter.trTitle("Excluded Networks: " + ((GlobalGroup)group).excludedNetworks.toString(), 3);
}
if (((GlobalGroup)group).excludedDevices.size() > 0) {
spyWriter.trTitle("Excluded Devices: " + ((GlobalGroup)group).excludedDevices.toString(), 3);
}
if (((GlobalGroup)group).excludedPoints.size() > 0) {
spyWriter.trTitle("Excluded Points: " + ((GlobalGroup)group).excludedPoints.toString(), 3);
}
} else {
String string = group.featureName.substring("driverCapacity".length());
spyWriter.trTitle("Driver Capacity: " + string, 3);
SubGroup subGroup = (SubGroup)group;
String string2 = Arrays.asList(subGroup.modules).toString();
string2 = string2.substring(1, string2.length() - 1);
spyWriter.trTitle("Modules: " + string2, 3);
}
spyWriter.w("<tr>");
spyWriter.w("<th>Type</th>");
spyWriter.w("<th>Limit</th>");
spyWriter.w("<th>Used</th>");
spyWriter.w("</tr>\n");
this.writeRow(spyWriter, "Networks", group.networks);
this.writeRow(spyWriter, "Devices", group.devices);
this.writeRow(spyWriter, "Points", group.points);
if (group.isGlobal()) {
this.writeRow(spyWriter, "Links", ((GlobalGroup)group).links);
if (global.histories.used > historyExtCount) {
this.writeRow(spyWriter, "Histories", ((GlobalGroup)group).histories);
} else {
MetricSpy.writeRow(spyWriter, "Histories", Metrics.getDisplayLimit(((GlobalGroup)group).histories), DF.format(historyExtCount));
}
this.writeRow(spyWriter, "Schedules", ((GlobalGroup)group).schedules);
}
spyWriter.endTable();
spyWriter.w("<p/><p/>");
}
private final void writeRow(SpyWriter spyWriter, String string, Group.Count count) {
String string2 = Metrics.getDisplayLimit(count);
MetricSpy.writeRow(spyWriter, string, string2, Metrics.getDisplayUsed(count));
}
private static final void writeRow(SpyWriter spyWriter, String string, String string2, String string3) {
spyWriter.w("<tr>");
spyWriter.w("<td align='left' nowrap='true'>").w(string).w("</td>");
spyWriter.w("<td align='right' nowrap='true'>").w(string2).w("</td>");
spyWriter.w("<td align='right' nowrap='true'>").w(string3).w("</td>");
spyWriter.w("</tr>\n");
}
}
}
@@ -0,0 +1,49 @@
/*
* Decompiled with CFR 0.152.
*/
package com.tridium.sys.metrics;
import com.tridium.sys.metrics.Group;
import java.util.ArrayList;
import java.util.StringTokenizer;
import javax.baja.license.Feature;
import javax.baja.license.FeatureNotLicensedException;
import javax.baja.sys.BajaRuntimeException;
class SubGroup
extends Group {
static final String PREFIX = "driverCapacity";
String[] modules;
private static final String[] extractModules(String string) {
ArrayList<String> arrayList = new ArrayList<String>();
StringTokenizer stringTokenizer = new StringTokenizer(string, ",;");
while (stringTokenizer.hasMoreTokens()) {
arrayList.add(stringTokenizer.nextToken());
}
return arrayList.toArray(new String[arrayList.size()]);
}
boolean isGlobal() {
return false;
}
SubGroup(Feature feature) {
super(feature.getFeatureName());
try {
feature.check();
this.networks.limit = SubGroup.parseLimit(feature, "network.limit");
this.devices.limit = SubGroup.parseLimit(feature, "device.limit");
this.points.limit = SubGroup.parseLimit(feature, "point.limit");
String string = feature.get("modules");
if (string == null) {
throw new BajaRuntimeException("Feature '" + feature.getFeatureName() + "' does not define the key 'modules'.");
}
this.modules = SubGroup.extractModules(string);
}
catch (FeatureNotLicensedException featureNotLicensedException) {
featureNotLicensedException.printStackTrace();
}
}
}
@@ -0,0 +1,70 @@
/*
* Decompiled with CFR 0.152.
*/
package com.tridium.sys.module;
import com.tridium.asm.Buffer;
import com.tridium.sys.module.ModuleClassLoader;
public class AutoClassLoader {
public static final SysClassLoader sysClassLoader = new SysClassLoader();
public static Class load(Class clazz, String string, Buffer buffer) throws ClassNotFoundException {
if (!string.startsWith("auto.")) {
throw new IllegalStateException("class name must begin with auto");
}
ClassLoader classLoader = clazz.getClassLoader();
if (classLoader instanceof ModuleClassLoader) {
return ((ModuleClassLoader)classLoader).loadAutoClass(string, buffer);
}
return sysClassLoader.loadAutoClass(string, buffer);
}
/*
* Illegal identifiers - consider using --renameillegalidents true
*/
static class SysClassLoader
extends ClassLoader {
private Buffer buffer;
static /* synthetic */ Class class$com$tridium$sys$module$AutoClassLoader$SysClassLoader;
Class loadAutoClass(String string, Buffer buffer) throws ClassNotFoundException {
this.buffer = buffer;
return this.loadClass(string);
}
public Class loadClass(String string, boolean bl) throws ClassNotFoundException {
if (!string.startsWith("auto.")) {
return super.loadClass(string, bl);
}
Class<?> clazz = this.defineClass(string, this.buffer.bytes, 0, this.buffer.count);
if (bl) {
this.resolveClass(clazz);
}
this.buffer = null;
return clazz;
}
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());
}
}
SysClassLoader() {
Class clazz = class$com$tridium$sys$module$AutoClassLoader$SysClassLoader;
if (clazz == null) {
clazz = class$com$tridium$sys$module$AutoClassLoader$SysClassLoader = SysClassLoader.class("[Lcom.tridium.sys.module.AutoClassLoader$SysClassLoader;", false);
}
super(clazz.getClassLoader());
}
}
}
@@ -0,0 +1,50 @@
/*
* Decompiled with CFR 0.152.
*/
package com.tridium.sys.module;
import javax.baja.file.zip.BZipFile;
import javax.baja.sys.BIcon;
import javax.baja.sys.Sys;
import javax.baja.sys.Type;
/*
* Illegal identifiers - consider using --renameillegalidents true
*/
public class BModuleFile
extends BZipFile {
public static final Type TYPE;
private static final BIcon icon;
static /* synthetic */ Class class$com$tridium$sys$module$BModuleFile;
public Type getType() {
return TYPE;
}
public BIcon getIcon() {
return icon;
}
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());
}
}
static {
Class clazz = class$com$tridium$sys$module$BModuleFile;
if (clazz == null) {
clazz = class$com$tridium$sys$module$BModuleFile = BModuleFile.class("[Lcom.tridium.sys.module.BModuleFile;", false);
}
TYPE = Sys.loadType(clazz);
icon = BIcon.std("module.png");
}
}
@@ -0,0 +1,86 @@
/*
* Decompiled with CFR 0.152.
*/
package com.tridium.sys.module;
import com.tridium.sys.registry.NModuleInfo;
import javax.baja.naming.BOrd;
import javax.baja.nav.BINavNode;
import javax.baja.nav.BNavContainer;
import javax.baja.registry.ModuleInfo;
import javax.baja.sys.BIcon;
import javax.baja.sys.BModule;
import javax.baja.sys.Sys;
import javax.baja.sys.Type;
/*
* Illegal identifiers - consider using --renameillegalidents true
*/
public class BModuleNavNode
extends BNavContainer {
public static final Type TYPE;
public final NModuleInfo info;
public final BOrd ord;
private BModule module;
static /* synthetic */ Class class$com$tridium$sys$module$BModuleNavNode;
public boolean hasNavChildren() {
return true;
}
public BINavNode getNavChild(String string) {
return this.load().getNavChild(string);
}
public BINavNode[] getNavChildren() {
return this.load().getNavChildren();
}
public BOrd getNavOrd() {
return this.ord;
}
public BModule load() {
if (this.module == null) {
this.module = Sys.loadModule(this.info.getModuleName());
}
return this.module;
}
public BIcon getIcon() {
this.load();
return this.module.getIcon();
}
public Type getType() {
return TYPE;
}
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());
}
}
public BModuleNavNode(ModuleInfo moduleInfo) {
super(moduleInfo.getModuleName());
this.info = (NModuleInfo)moduleInfo;
this.ord = BOrd.make("local:|module://" + moduleInfo.getModuleName());
}
static {
Class clazz = class$com$tridium$sys$module$BModuleNavNode;
if (clazz == null) {
clazz = class$com$tridium$sys$module$BModuleNavNode = BModuleNavNode.class("[Lcom.tridium.sys.module.BModuleNavNode;", false);
}
TYPE = Sys.loadType(clazz);
}
}
@@ -0,0 +1,158 @@
/*
* Decompiled with CFR 0.152.
*
* Could not load the following classes:
* javax.baja.nre.util.SortUtil
*/
package com.tridium.sys.module;
import com.tridium.sys.module.BTypeNavNode;
import com.tridium.sys.module.NModule;
import java.util.Comparator;
import java.util.HashMap;
import javax.baja.naming.BOrd;
import javax.baja.naming.UnresolvedException;
import javax.baja.nav.BINavNode;
import javax.baja.nav.BNavContainer;
import javax.baja.nre.util.SortUtil;
import javax.baja.sys.BIcon;
import javax.baja.sys.BModule;
import javax.baja.sys.Context;
import javax.baja.sys.Sys;
import javax.baja.sys.Type;
import javax.baja.util.BTypeSpec;
/*
* Illegal identifiers - consider using --renameillegalidents true
*/
public class BModuleTypesContainer
extends BNavContainer {
public static final Type TYPE;
static HashMap moduleTypeNodes;
HashMap types;
BModule module;
static /* synthetic */ Class class$com$tridium$sys$module$BModuleTypesContainer;
public Type getType() {
return TYPE;
}
public static BModuleTypesContainer get(BModule bModule) {
if (moduleTypeNodes.containsKey(bModule.getModuleName())) {
return (BModuleTypesContainer)moduleTypeNodes.get(bModule.getModuleName());
}
BModuleTypesContainer bModuleTypesContainer = new BModuleTypesContainer(bModule);
moduleTypeNodes.put(bModule.getModuleName(), bModuleTypesContainer);
return bModuleTypesContainer;
}
private final void load() {
if (this.types != null) {
return;
}
this.types = new HashMap();
NModule nModule = (NModule)this.module.fw(405);
String[] stringArray = nModule.getTypeList();
int n = 0;
while (n < stringArray.length) {
BTypeNavNode bTypeNavNode = new BTypeNavNode(this, BTypeSpec.make(nModule.getModuleName(), stringArray[n]));
this.types.put(stringArray[n], bTypeNavNode);
++n;
}
}
public String getNavDescription(Context context) {
return "types";
}
public String getNavDisplayName(Context context) {
return "types";
}
public BIcon getNavIcon() {
return BIcon.std("folder.png");
}
public String getNavName() {
return "types";
}
public BOrd getNavOrd() {
return BOrd.make(this.module.getNavOrd().toString() + "/types");
}
public BINavNode getNavParent() {
return this.module;
}
public boolean hasNavChildren() {
this.load();
boolean bl = false;
if (this.types.size() != 0) {
bl = true;
}
return bl;
}
public BINavNode resolveNavChild(String string) {
this.load();
BTypeNavNode bTypeNavNode = (BTypeNavNode)this.types.get(string);
if (bTypeNavNode == null) {
throw new UnresolvedException();
}
return bTypeNavNode;
}
public BINavNode getNavChild(String string) {
this.load();
return (BTypeNavNode)this.types.get(string);
}
public BINavNode[] getNavChildren() {
this.load();
Object[] objectArray = this.types.values().toArray(new BINavNode[this.types.size()]);
SortUtil.sort((Object[])objectArray, (Object[])objectArray, (Comparator)new Comparator(){
public final int compare(Object object, Object object2) {
if (object == null || object2 == null) {
return 0;
}
return ((BINavNode)object).getNavName().compareTo(((BINavNode)object2).getNavName());
}
});
return objectArray;
}
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.types = null;
}
private BModuleTypesContainer(BModule bModule) {
super("types");
this.this();
this.module = bModule;
}
static {
Class clazz = class$com$tridium$sys$module$BModuleTypesContainer;
if (clazz == null) {
clazz = class$com$tridium$sys$module$BModuleTypesContainer = BModuleTypesContainer.class("[Lcom.tridium.sys.module.BModuleTypesContainer;", false);
}
TYPE = Sys.loadType(clazz);
moduleTypeNodes = new HashMap();
}
}
@@ -0,0 +1,55 @@
/*
* Decompiled with CFR 0.152.
*/
package com.tridium.sys.module;
import com.tridium.sys.module.BModuleFile;
import javax.baja.naming.BOrd;
import javax.baja.sys.BIcon;
import javax.baja.sys.Sys;
import javax.baja.sys.Type;
/*
* Illegal identifiers - consider using --renameillegalidents true
*/
public class BSyntheticModuleFile
extends BModuleFile {
public static final Type TYPE;
private static final BIcon icon;
static /* synthetic */ Class class$com$tridium$sys$module$BSyntheticModuleFile;
public Type getType() {
return TYPE;
}
public BIcon getIcon() {
return icon;
}
public BOrd getNavOrd() {
return this.getAbsoluteOrd();
}
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());
}
}
static {
Class clazz = class$com$tridium$sys$module$BSyntheticModuleFile;
if (clazz == null) {
clazz = class$com$tridium$sys$module$BSyntheticModuleFile = BSyntheticModuleFile.class("[Lcom.tridium.sys.module.BSyntheticModuleFile;", false);
}
TYPE = Sys.loadType(clazz);
icon = BIcon.make(BIcon.std("syntheticModule.png"), BIcon.std("badges/beaker.png"));
}
}
@@ -0,0 +1,120 @@
/*
* Decompiled with CFR 0.152.
*/
package com.tridium.sys.module;
import com.tridium.sys.module.BModuleTypesContainer;
import com.tridium.sys.schema.ComplexType;
import com.tridium.sys.schema.NSlot;
import javax.baja.naming.BOrd;
import javax.baja.naming.UnresolvedException;
import javax.baja.nav.BINavNode;
import javax.baja.sys.BIcon;
import javax.baja.sys.BObject;
import javax.baja.sys.Context;
import javax.baja.sys.Slot;
import javax.baja.sys.Sys;
import javax.baja.sys.Type;
import javax.baja.util.BTypeSpec;
/*
* Illegal identifiers - consider using --renameillegalidents true
*/
public class BTypeNavNode
extends BObject
implements BINavNode {
public static final Type TYPE;
NSlot[] slots;
BModuleTypesContainer typesNode;
BTypeSpec type;
static /* synthetic */ Class class$com$tridium$sys$module$BTypeNavNode;
public Type getType() {
return TYPE;
}
public String getNavDescription(Context context) {
return this.type.toString();
}
public String getNavDisplayName(Context context) {
return this.type.getTypeName();
}
public BIcon getNavIcon() {
if (this.type.getTypeInfo().isInterface()) {
return BIcon.std("shapes/rectGray.png");
}
if (this.type.getTypeInfo().isAbstract()) {
return BIcon.std("shapes/diamondGray.png");
}
return BIcon.std("shapes/squareGray.png");
}
public String getNavName() {
return this.type.getTypeName();
}
public BOrd getNavOrd() {
return BOrd.make(this.typesNode.getNavOrd().toString() + '/' + this.type.getTypeName());
}
public BINavNode getNavParent() {
return this.typesNode;
}
public boolean hasNavChildren() {
return false;
}
public BINavNode resolveNavChild(String string) {
throw new UnresolvedException();
}
public BINavNode getNavChild(String string) {
return null;
}
public BINavNode[] getNavChildren() {
return new BINavNode[0];
}
public Slot[] getSlots() {
if (this.type.getResolvedType() instanceof ComplexType) {
return ((ComplexType)this.type.getResolvedType()).getFrozenSlots();
}
return new NSlot[0];
}
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.slots = null;
}
public BTypeNavNode(BModuleTypesContainer bModuleTypesContainer, BTypeSpec bTypeSpec) {
this.this();
this.typesNode = bModuleTypesContainer;
this.type = bTypeSpec;
}
static {
Class clazz = class$com$tridium$sys$module$BTypeNavNode;
if (clazz == null) {
clazz = class$com$tridium$sys$module$BTypeNavNode = BTypeNavNode.class("[Lcom.tridium.sys.module.BTypeNavNode;", false);
}
TYPE = Sys.loadType(clazz);
}
}
@@ -0,0 +1,45 @@
/*
* Decompiled with CFR 0.152.
*/
package com.tridium.sys.module;
import com.tridium.sys.module.NModule;
import javax.baja.util.Version;
public class Dependency {
public final String name;
public final Version bajaVersion;
public final String vendor;
public final Version vendorVersion;
NModule resolution;
public String toString() {
StringBuffer stringBuffer = new StringBuffer(this.name);
if (this.bajaVersion != null) {
stringBuffer.append('-').append(this.bajaVersion);
}
if (this.vendor != null) {
stringBuffer.append('-').append(this.vendor);
if (this.vendorVersion != null) {
stringBuffer.append('-').append(this.vendorVersion);
}
}
if (this.resolution != null) {
stringBuffer.append(" -> ").append(this.resolution);
}
return stringBuffer.toString();
}
public Dependency(String string, Version version, String string2, Version version2) {
this.name = string;
this.bajaVersion = version;
this.vendor = string2;
this.vendorVersion = version2;
}
public Dependency(String string, Version version, String string2, Version version2, NModule nModule) {
this(string, version, string2, version2);
this.resolution = nModule;
}
}
@@ -0,0 +1,399 @@
/*
* Decompiled with CFR 0.152.
*/
package com.tridium.sys.module;
import com.tridium.asm.Buffer;
import com.tridium.sys.module.ModuleExtClassLoader;
import com.tridium.sys.module.NModule;
import com.tridium.util.jar.JarEntry;
import java.io.IOException;
import java.io.InputStream;
import java.lang.reflect.Method;
import java.net.URL;
import java.net.URLConnection;
import java.security.AllPermission;
import java.security.CodeSource;
import java.security.PermissionCollection;
import java.security.Permissions;
import java.security.SecureClassLoader;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.Hashtable;
import java.util.Iterator;
import java.util.Map;
import java.util.Vector;
import javax.baja.spy.Spy;
import javax.baja.spy.SpyWriter;
/*
* Illegal identifiers - consider using --renameillegalidents true
*/
public class ModuleClassLoader
extends SecureClassLoader {
private static final DecimalFormat DF = new DecimalFormat("###,###,###");
static final boolean legacyExtClassLoader = Boolean.getBoolean("niagara.classLoader.ext");
static final boolean parallelCapableClassLoader = Boolean.getBoolean("niagara.classLoader.parallelCapable");
static final Object NOT_FOUND;
private static final Map spyMap;
public final NModule module;
private Hashtable cache;
private Buffer buffer;
protected CodeSource codeSource;
private Permissions permissions;
private Hashtable extClassLoadersByResourcePath;
static /* synthetic */ Class class$java$lang$String;
static /* synthetic */ Class class$java$lang$ClassLoader;
public Class loadClass(String string, boolean bl) throws ClassNotFoundException {
Class clazz = this.nload(string, bl);
if (clazz == null) {
String string2 = string;
if (this.module != null) {
string2 = this.module.name + ':' + string;
}
throw new ClassNotFoundException(string2);
}
return clazz;
}
/*
* WARNING - Removed try catching itself - possible behaviour change.
* Enabled aggressive block sorting
* Enabled unnecessary exception pruning
* Enabled aggressive exception aggregation
*/
public Class nload(String string, boolean bl) {
Object object = ModuleClassLoader.getLoadClassLock(this, string);
Object object2 = object;
synchronized (object2) {
Object v = this.cache.get(string);
if (v == NOT_FOUND) {
return null;
}
Class clazz = (Class)v;
if (clazz == null) {
clazz = this.nfind(string, bl);
if (clazz == null) {
this.cache.put(string, NOT_FOUND);
return null;
}
this.cache.put(string, clazz);
}
if (bl) {
this.resolveClass(clazz);
}
return clazz;
}
}
static final Object getLoadClassLock(ClassLoader classLoader, String string) {
Object object = classLoader;
try {
Method method;
Class clazz = class$java$lang$ClassLoader;
if (clazz == null) {
clazz = class$java$lang$ClassLoader = ModuleClassLoader.class("[Ljava.lang.ClassLoader;", false);
}
Class[] classArray = new Class[1];
Class clazz2 = class$java$lang$String;
if (clazz2 == null) {
clazz2 = classArray[0] = (class$java$lang$String = ModuleClassLoader.class("[Ljava.lang.String;", false));
}
if ((method = clazz.getDeclaredMethod("getClassLoadingLock", classArray)) != null) {
object = method.invoke((Object)classLoader, string);
}
}
catch (Throwable throwable) {}
return object;
}
Class defineExtClass(String string, byte[] byArray, int n, int n2, CodeSource codeSource) {
return this.defineClass(string, byArray, 0, byArray.length, codeSource);
}
protected Class nfind(String string, boolean bl) {
block18: {
block17: {
if (string.startsWith("auto.")) {
ModuleClassLoader.addClassToSpy(this.module.name, string, this.buffer.count);
return this.defineClass(string, this.buffer.bytes, 0, this.buffer.count, this.codeSource);
}
try {
return this.getParent().loadClass(string);
}
catch (ClassNotFoundException classNotFoundException) {
String string2 = string.replace('.', '/') + ".class";
ArrayList arrayList = (ArrayList)this.extClassLoadersByResourcePath.get(string2);
if (arrayList != null) {
return ((ModuleExtClassLoader)arrayList.get(0)).nfind(string, bl, false);
}
if (this.module.isSynthetic()) break block17;
JarEntry jarEntry = this.module.jarFile.getJarEntry(string2);
if (jarEntry != null) {
byte[] byArray = null;
try {
int n = (int)jarEntry.getSize();
InputStream inputStream = jarEntry.getInputStream();
byArray = new byte[n];
int n2 = 0;
while (n2 < n) {
int n3 = inputStream.read(byArray, n2, n - n2);
if (n3 < 0) {
throw new IOException("Unexpected EOF");
}
n2 += n3;
}
inputStream.close();
ModuleClassLoader.addClassToSpy(this.module.name, string, byArray.length);
return this.defineClass(string, byArray, 0, byArray.length, this.codeSource);
}
catch (IOException iOException) {
iOException.printStackTrace();
return null;
}
}
break block18;
}
}
if (this.module.getTypeClassName(string.substring(string.lastIndexOf(46) + 2)) != null) {
ModuleClassLoader.addClassToSpy(this.module.name, string, this.buffer.count);
Class<?> clazz = this.defineClass(string, this.buffer.bytes, 0, this.buffer.count, this.codeSource);
try {
Class.forName(clazz.getName(), true, clazz.getClassLoader());
}
catch (ClassNotFoundException classNotFoundException) {}
return clazz;
}
}
if (this.module.depends != null) {
Class clazz;
NModule nModule;
int n = string.lastIndexOf(46);
String string3 = n == -1 ? "" : string.substring(0, n);
int n4 = 0;
while (n4 < this.module.depends.length) {
nModule = this.module.depends[n4].resolution;
if (!nModule.isSystemJar && nModule.containsPackage(string3) && (clazz = nModule.classLoader.nload(string, bl)) != null) {
return clazz;
}
++n4;
}
n4 = 0;
while (n4 < this.module.depends.length) {
nModule = this.module.depends[n4].resolution;
if (!nModule.isSystemJar && (clazz = nModule.classLoader.nload(string, bl)) != null) {
return clazz;
}
++n4;
}
}
return null;
}
public URL getResource(String string) {
URL uRL = this.getResourceImpl(string);
if (uRL != null) {
return uRL;
}
return ModuleClassLoader.getSystemResource(string);
}
private final URL getResourceImpl(String string) {
ArrayList arrayList = (ArrayList)this.extClassLoadersByResourcePath.get(string);
if (arrayList != null) {
return ((ModuleExtClassLoader)arrayList.get(0)).getResourceImpl(string);
}
JarEntry jarEntry = this.module.jarFile.getJarEntry(string);
if (jarEntry != null) {
return jarEntry.getURL();
}
if (this.module.depends != null) {
int n = 0;
while (n < this.module.depends.length) {
URL uRL;
NModule nModule = this.module.depends[n].resolution;
if (!nModule.isSystemJar && (uRL = nModule.classLoader.getResourceImpl(string)) != null) {
return uRL;
}
++n;
}
}
return null;
}
public InputStream getResourceAsStream(String string) {
try {
URL uRL = this.getResource(string);
if (uRL != null) {
URLConnection uRLConnection = uRL.openConnection();
uRLConnection.connect();
return uRLConnection.getInputStream();
}
}
catch (IOException iOException) {
iOException.printStackTrace();
}
return null;
}
protected Enumeration findResources(String string) throws IOException {
ArrayList arrayList = (ArrayList)this.extClassLoadersByResourcePath.get(string);
Vector<URL> vector = new Vector<URL>();
if (arrayList != null) {
Iterator iterator = arrayList.iterator();
while (iterator.hasNext()) {
vector.add(((ModuleExtClassLoader)iterator.next()).getResourceImpl(string));
}
return vector.elements();
}
URL uRL = this.getResourceImpl(string);
if (uRL != null) {
vector.add(uRL);
}
return vector.elements();
}
public PermissionCollection getPermissions(CodeSource codeSource) {
return this.permissions;
}
Class loadAutoClass(String string, Buffer buffer) throws ClassNotFoundException {
this.buffer = buffer;
Class<?> clazz = this.loadClass(string);
this.buffer = null;
return clazz;
}
protected static void addClassToSpy(String string, String string2, int n) {
int[] nArray = (int[])spyMap.get(string);
if (nArray == null) {
nArray = new int[2];
spyMap.put(string, nArray);
}
nArray[0] = nArray[0] + 1;
nArray[1] = nArray[1] + n;
}
public String toString() {
return this.getClass().getName() + " for " + this.module + " [" + Integer.toString(System.identityHashCode(this), 36) + ']';
}
public static void registerAsParallelCapableFix() {
try {
Method method;
Class clazz = class$java$lang$ClassLoader;
if (clazz == null) {
clazz = class$java$lang$ClassLoader = ModuleClassLoader.class("[Ljava.lang.ClassLoader;", false);
}
if ((method = clazz.getDeclaredMethod("registerAsParallelCapable", null)) != null) {
method.setAccessible(true);
Object object = method.invoke(null, null);
}
}
catch (Throwable throwable) {}
}
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.cache = new Hashtable();
this.extClassLoadersByResourcePath = new Hashtable();
}
ModuleClassLoader(NModule nModule) {
super(nModule.getClass().getClassLoader());
this.this();
this.module = nModule;
URL uRL = null;
if (nModule.jarFile != null) {
uRL = nModule.jarFile.getFileURL();
}
this.codeSource = new CodeSource(uRL, null);
this.permissions = new Permissions();
this.permissions.add(new AllPermission());
if (nModule.extJars != null) {
int n = 0;
while (n < nModule.extJars.length) {
ModuleExtClassLoader moduleExtClassLoader = new ModuleExtClassLoader(this, nModule.extJars[n], this.codeSource);
Iterator iterator = nModule.extJars[n].resourcePaths.iterator();
while (iterator.hasNext()) {
String string = (String)iterator.next();
ArrayList<ModuleExtClassLoader> arrayList = (ArrayList<ModuleExtClassLoader>)this.extClassLoadersByResourcePath.get(string);
if (arrayList == null) {
arrayList = new ArrayList<ModuleExtClassLoader>();
this.extClassLoadersByResourcePath.put(string, arrayList);
}
arrayList.add(moduleExtClassLoader);
}
++n;
}
}
}
static {
if (parallelCapableClassLoader) {
ModuleClassLoader.registerAsParallelCapableFix();
}
NOT_FOUND = new Object();
spyMap = new HashMap();
}
public static class LoaderSpy
extends Spy {
private final void row(SpyWriter spyWriter, String string, int n, int n2) {
spyWriter.w("<tr>");
spyWriter.w("<td align='left' nowrap='true'>").w(string).w("</td>");
spyWriter.w("<td align='right' nowrap='true'>").w(DF.format(n)).w("</td>");
spyWriter.w("<td align='right' nowrap='true'>").w(DF.format(n2)).w("</td>");
spyWriter.w("</tr>\n");
}
private final void summary(SpyWriter spyWriter, String string, int n) {
spyWriter.w("<tr>");
spyWriter.w("<td align='left' nowrap='true'>").w(string).w("</td>");
spyWriter.w("<td align='right' nowrap='true'>").w(DF.format(n)).w("</td>");
spyWriter.w("</tr>\n");
}
public void write(SpyWriter spyWriter) throws Exception {
int n = 0;
int n2 = 0;
spyWriter.startTable(true);
spyWriter.w("<tr>");
spyWriter.thTitle("Class Loader");
spyWriter.thTitle("Classes");
spyWriter.thTitle("Bytes Loaded");
spyWriter.w("</tr>");
Iterator iterator = spyMap.keySet().iterator();
while (iterator.hasNext()) {
String string = (String)iterator.next();
int[] nArray = (int[])spyMap.get(string);
this.row(spyWriter, string, nArray[0], nArray[1]);
n += nArray[0];
n2 += nArray[1];
}
spyWriter.endTable();
spyWriter.w("<p/>");
spyWriter.startTable(true);
spyWriter.trTitle("Summary", 2);
this.summary(spyWriter, "Total Classes", n);
this.summary(spyWriter, "Total Bytes Loaded", n2);
spyWriter.endTable();
}
}
}
@@ -0,0 +1,190 @@
/*
* Decompiled with CFR 0.152.
*/
package com.tridium.sys.module;
import com.tridium.sys.module.ModuleClassLoader;
import com.tridium.sys.module.ModuleExtJar;
import com.tridium.sys.module.NModule;
import com.tridium.util.jar.JarEntry;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.net.URLConnection;
import java.security.CodeSource;
import java.security.PermissionCollection;
import java.security.SecureClassLoader;
import java.util.Enumeration;
import java.util.Hashtable;
import java.util.Vector;
import javax.baja.log.Log;
import javax.baja.sys.BModule;
import javax.baja.sys.Sys;
/*
* Illegal identifiers - consider using --renameillegalidents true
*/
public class ModuleExtClassLoader
extends SecureClassLoader {
static final Object NOT_FOUND = new Object();
static final Log log = Log.getLog("loader");
protected ModuleExtJar extJar;
private Hashtable cache;
private CodeSource codeSource;
public Class loadClass(String string, boolean bl) throws ClassNotFoundException {
Class clazz = this.nload(string, bl);
if (clazz == null) {
String string2 = string;
if (this.module() != null) {
string2 = this.module().name + ':' + string;
}
throw new ClassNotFoundException(string2);
}
return clazz;
}
/*
* WARNING - Removed try catching itself - possible behaviour change.
* Enabled aggressive block sorting
* Enabled unnecessary exception pruning
* Enabled aggressive exception aggregation
*/
public Class nload(String string, boolean bl) {
Object object = ModuleClassLoader.getLoadClassLock(this.moduleClassLoader(), string);
if (ModuleClassLoader.legacyExtClassLoader) {
object = ModuleClassLoader.getLoadClassLock(this, string);
}
Object object2 = object;
synchronized (object2) {
Object v = this.cache.get(string);
if (v == NOT_FOUND) {
return null;
}
Class clazz = (Class)v;
if (clazz == null) {
clazz = this.nfind(string, bl, true);
if (log.isTraceOn()) {
String string2 = "NOT FOUND";
if (clazz != null) {
BModule bModule = Sys.getModuleForClass(clazz);
string2 = bModule != null ? bModule.getModuleName() : "{system}";
}
log.trace(this.module().name + ':' + string + " -> " + string2);
}
if (clazz == null) {
this.cache.put(string, NOT_FOUND);
return null;
}
this.cache.put(string, clazz);
}
if (bl) {
this.resolveClass(clazz);
}
return clazz;
}
}
public URL getResource(String string) {
URL uRL = this.getResourceImpl(string);
if (uRL != null) {
return uRL;
}
return ModuleExtClassLoader.getSystemResource(string);
}
URL getResourceImpl(String string) {
JarEntry jarEntry = this.module().jarFile.getJarEntry(this.extJar.getEntryPath(string));
if (jarEntry != null) {
return jarEntry.getURL();
}
return null;
}
public InputStream getResourceAsStream(String string) {
try {
URL uRL = this.getResource(string);
if (uRL != null) {
URLConnection uRLConnection = uRL.openConnection();
uRLConnection.connect();
return uRLConnection.getInputStream();
}
}
catch (IOException iOException) {
iOException.printStackTrace();
}
return null;
}
protected Enumeration findResources(String string) throws IOException {
Vector<URL> vector = new Vector<URL>();
URL uRL = this.getResourceImpl(string);
if (uRL != null) {
vector.add(uRL);
}
return vector.elements();
}
public PermissionCollection getPermissions(CodeSource codeSource) {
return this.moduleClassLoader().getPermissions(codeSource);
}
Class nfind(String string, boolean bl, boolean bl2) {
Object object;
if (bl2 && (object = this.moduleClassLoader().nload(string, bl)) != null) {
return object;
}
object = this.extJar.getEntryPath(string.replace('.', '/') + ".class");
JarEntry jarEntry = this.module().jarFile.getJarEntry((String)object);
if (jarEntry != null) {
byte[] byArray = null;
try {
int n = (int)jarEntry.getSize();
InputStream inputStream = jarEntry.getInputStream();
byArray = new byte[n];
int n2 = 0;
while (n2 < n) {
int n3 = inputStream.read(byArray, n2, n - n2);
if (n3 < 0) {
throw new IOException("Unexpected EOF");
}
n2 += n3;
}
inputStream.close();
if (ModuleClassLoader.legacyExtClassLoader) {
return this.defineClass(string, byArray, 0, byArray.length, this.codeSource);
}
return this.moduleClassLoader().defineExtClass(string, byArray, 0, byArray.length, this.codeSource);
}
catch (IOException iOException) {
iOException.printStackTrace();
return null;
}
}
return null;
}
protected ClassLoader topClassLoader() {
return this.getParent().getParent();
}
protected ModuleClassLoader moduleClassLoader() {
return (ModuleClassLoader)this.getParent();
}
protected NModule module() {
return this.moduleClassLoader().module;
}
private final /* synthetic */ void this() {
this.cache = new Hashtable();
}
ModuleExtClassLoader(ModuleClassLoader moduleClassLoader, ModuleExtJar moduleExtJar, CodeSource codeSource) {
super(moduleClassLoader);
this.this();
this.extJar = moduleExtJar;
this.codeSource = codeSource;
}
}
@@ -0,0 +1,42 @@
/*
* Decompiled with CFR 0.152.
*
* Could not load the following classes:
* javax.baja.xml.XElem
*/
package com.tridium.sys.module;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import javax.baja.xml.XElem;
public class ModuleExtJar {
public String extFilename;
public Map entryPathsByResourcePath;
public Set resourcePaths;
public String getEntryPath(String string) {
String string2 = (String)this.entryPathsByResourcePath.get(string);
return string2 == null ? string : string2;
}
public ModuleExtJar(XElem xElem) {
this.extFilename = xElem.get("name");
this.entryPathsByResourcePath = new HashMap();
this.resourcePaths = new HashSet();
XElem[] xElemArray = xElem.elems("entry");
int n = 0;
while (n < xElemArray.length) {
String string = xElemArray[n].get("moduleEntryPath", null);
String string2 = xElemArray[n].get("resourcePath");
if (string != null) {
this.entryPathsByResourcePath.put(string2, string);
}
this.resourcePaths.add(string2);
++n;
}
}
}
@@ -0,0 +1,404 @@
/*
* Decompiled with CFR 0.152.
*
* Could not load the following classes:
* javax.baja.nre.util.SortUtil
* javax.baja.xml.XParser
*/
package com.tridium.sys.module;
import com.tridium.asm.Buffer;
import com.tridium.sys.Nre;
import com.tridium.sys.module.Dependency;
import com.tridium.sys.module.ModuleClassLoader;
import com.tridium.sys.module.NModule;
import com.tridium.sys.module.SyntheticModuleClassLoader;
import com.tridium.sys.registry.NModuleInfo;
import com.tridium.sys.schema.SyntheticCompiler;
import com.tridium.util.ArrayUtil;
import com.tridium.util.jar.JarEntry;
import com.tridium.util.jar.JarFile;
import java.io.BufferedInputStream;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.security.AccessController;
import java.security.PrivilegedActionException;
import java.security.PrivilegedExceptionAction;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.HashMap;
import java.util.Hashtable;
import javax.baja.log.Log;
import javax.baja.nre.util.SortUtil;
import javax.baja.registry.TypeInfo;
import javax.baja.spy.Spy;
import javax.baja.spy.SpyDir;
import javax.baja.spy.SpyWriter;
import javax.baja.sys.BajaRuntimeException;
import javax.baja.sys.ModuleException;
import javax.baja.sys.ModuleNotFoundException;
import javax.baja.util.BTypeSpec;
import javax.baja.xml.XParser;
/*
* Illegal identifiers - consider using --renameillegalidents true
*/
public class ModuleManager {
public static ModuleManager instance;
public static final Log log;
private NModule baja;
private NModule[] moduleArray;
private Hashtable moduleTable;
private ArrayList resolving;
private boolean postInit;
public synchronized NModule[] getModules() {
NModule[] nModuleArray = new NModule[this.moduleArray.length];
System.arraycopy(this.moduleArray, 0, nModuleArray, 0, nModuleArray.length);
return nModuleArray;
}
public NModule getModuleForClass(Class clazz) {
ClassLoader classLoader = clazz.getClassLoader();
if (classLoader instanceof ModuleClassLoader) {
return ((ModuleClassLoader)classLoader).module;
}
if (clazz.isPrimitive()) {
return null;
}
String string = clazz.getName();
if (clazz.isArray()) {
int n = string.indexOf(76);
string = string.substring(n + 1);
}
if (string.startsWith("javax.baja.") || string.startsWith("com.tridium.asm.") || string.startsWith("com.tridium.collection.") || string.startsWith("com.tridium.data.") || string.startsWith("com.tridium.sys.") || string.startsWith("com.tridium.timezone.") || string.startsWith("com.tridium.util.")) {
return this.baja;
}
return null;
}
public synchronized NModule loadModule(String string) throws ModuleNotFoundException, ModuleException {
NModule nModule = (NModule)this.moduleTable.get(string);
if (nModule != null) {
return nModule;
}
try {
if (Nre.bootEnv.isRemote()) {
Nre.bootEnv.findModule(string);
}
}
catch (Exception exception) {
throw new BajaRuntimeException("Missing module: " + string, exception);
}
return new PrivilegedLoader().load(string);
}
public synchronized void unloadModule(String string) throws ModuleException {
NModule nModule = (NModule)this.moduleTable.get(string);
if (nModule == null) {
return;
}
try {
nModule.jarFile.close();
}
catch (IOException iOException) {
throw new ModuleException("Cannot close " + nModule.jarFile, iOException);
}
this.moduleArray = (NModule[])ArrayUtil.removeOne((Object[])this.moduleArray, nModule);
this.moduleTable.remove(nModule.name);
}
NModule doLoad(String string) throws ModuleException {
NModule nModule = this.find(string);
if (!nModule.name.equals(string)) {
throw new ModuleException("Invalid case \"" + string + "\" != \"" + nModule.name + '\"');
}
this.resolve(nModule);
if (!nModule.isSystemJar) {
nModule.classLoader = !nModule.isSynthetic() ? new ModuleClassLoader(nModule) : new SyntheticModuleClassLoader(nModule);
}
this.add(nModule);
return nModule;
}
private final NModule loadSystemModule(String string) {
Object object;
File file = null;
try {
file = Nre.bootEnv.findModule(string);
}
catch (Exception exception) {
throw new BajaRuntimeException("Missing system module: " + string, exception);
}
if (file == null || !file.exists()) {
object = File.separator;
String string2 = Nre.bajaHome + (String)object + "lib" + (String)object + string + ".jar";
file = new File(string2);
}
if (!file.exists()) {
throw new IllegalStateException("Missing system module: " + file);
}
try {
object = this.makeModule(file);
((NModule)object).isSystemJar = true;
this.add((NModule)object);
return object;
}
catch (Exception exception) {
log.error("Cannot load system jar file: " + file, exception);
return null;
}
}
private final NModule find(String string) throws ModuleException {
File file;
String[] stringArray = Nre.registryManager.getInvalidModules();
if (stringArray != null) {
int n = stringArray.length;
int n2 = 0;
while (n2 < n) {
if (string.equals(stringArray[n2])) {
throw new ModuleException("Unsupported " + string + " module");
}
++n2;
}
}
try {
file = Nre.bootEnv.findModule(string);
}
catch (Exception exception) {
throw new ModuleNotFoundException(string, exception);
}
if (file == null || !file.exists()) {
throw new ModuleNotFoundException(string);
}
return this.makeModule(file);
}
public NModule makeModule(File file) throws ModuleException {
NModule nModule;
try {
nModule = new NModule();
nModule.jarFile = new JarFile(file);
}
catch (IOException iOException) {
throw new ModuleException("Cannot open jar: " + file, iOException);
}
JarFile jarFile = nModule.jarFile;
JarEntry jarEntry = jarFile.getJarEntry("META-INF/module.xml");
if (jarEntry == null) {
jarEntry = jarFile.getJarEntry("meta-inf/module.xml");
}
if (jarEntry == null) {
throw new ModuleException("Module missing META-INF/module.xml: " + file);
}
try {
nModule.readXml(XParser.make((InputStream)new BufferedInputStream(jarEntry.getInputStream())).parse());
}
catch (Exception exception) {
log.error("Cannot parse XML: " + file, exception);
throw new ModuleException("Cannot parse XML: " + file, exception);
}
if (this.postInit) {
nModule.init();
}
return nModule;
}
/*
* Enabled aggressive block sorting
* Enabled unnecessary exception pruning
* Enabled aggressive exception aggregation
*/
private final void resolve(NModule nModule) throws ModuleException {
NModule nModule2;
if (nModule.depends == null) {
return;
}
int n = 0;
while (n < this.resolving.size()) {
nModule2 = (NModule)this.resolving.get(n);
if (nModule2.name.equals(nModule.name)) {
throw new ModuleException("Circular dependency: " + nModule);
}
++n;
}
this.resolving.add(nModule);
try {
int n2 = 0;
while (n2 < nModule.depends.length) {
Dependency dependency = nModule.depends[n2];
if (dependency != null) {
log.trace("Resolve: " + nModule + " -> " + dependency);
try {
dependency.resolution = this.loadModule(dependency.name);
dependency.resolution.checkBajaVersion(dependency.bajaVersion);
dependency.resolution.checkVendor(dependency.vendor, dependency.vendorVersion);
}
catch (Exception exception) {
throw new ModuleException("Cannot resolve dependency " + dependency + " for " + nModule, exception);
}
}
++n2;
}
nModule2 = null;
this.resolving.remove(nModule);
return;
}
catch (Throwable throwable) {
nModule2 = null;
this.resolving.remove(nModule);
throw throwable;
}
}
public NModule synthesizeModule(NModuleInfo nModuleInfo) {
NModule nModule = new NModule();
nModule.name = nModuleInfo.getModuleName();
nModule.bajaVersion = nModuleInfo.getBajaVersion();
nModule.vendorVersion = nModuleInfo.getVendorVersion();
nModule.description = nModuleInfo.getDescription();
nModule.vendor = nModuleInfo.getVendor();
nModule.preferredSymbol = nModuleInfo.getModuleName();
nModule.isSystemJar = false;
nModule.depends = new Dependency[0];
nModule.typeList = new String[0];
nModule.types = new HashMap();
nModule.jarFile = null;
nModule.classLoader = new ModuleClassLoader(nModule);
if (this.postInit) {
nModule.init();
}
this.add(nModule);
return nModule;
}
public void synthesizeType(BTypeSpec bTypeSpec, String string, TypeInfo typeInfo, TypeInfo[] typeInfoArray, boolean bl, boolean bl2) {
NModule nModule = Nre.moduleManager.loadModule(bTypeSpec.getModuleName());
Buffer buffer = SyntheticCompiler.compile(bTypeSpec, typeInfo, typeInfoArray, bl, bl2, true);
nModule.typeList = (String[])ArrayUtil.addOne(nModule.typeList, bTypeSpec.getTypeName());
nModule.types.put(bTypeSpec.getTypeName(), string);
try {
nModule.getClassLoader().loadAutoClass(string, buffer);
}
catch (ClassNotFoundException classNotFoundException) {
throw new BajaRuntimeException(classNotFoundException);
}
}
private final synchronized void add(NModule nModule) {
log.trace("Loaded: " + nModule);
NModule[] nModuleArray = new NModule[this.moduleArray.length + 1];
System.arraycopy(this.moduleArray, 0, nModuleArray, 0, this.moduleArray.length);
nModuleArray[this.moduleArray.length] = nModule;
this.moduleArray = nModuleArray;
this.moduleTable.put(nModule.name, nModule);
}
public void postInit() {
Nre.spySysManagers.add("moduleManager", new Page());
this.postInit = true;
NModule[] nModuleArray = this.getModules();
int n = 0;
while (n < nModuleArray.length) {
nModuleArray[n].init();
++n;
}
}
private final /* synthetic */ void this() {
this.moduleArray = new NModule[0];
this.moduleTable = new Hashtable();
this.resolving = new ArrayList();
this.postInit = false;
}
public ModuleManager() {
this.this();
instance = this;
this.baja = this.loadSystemModule("baja");
}
static {
log = Log.getLog("sys.module");
}
/*
* Illegal identifiers - consider using --renameillegalidents true
*/
class PrivilegedLoader
implements PrivilegedExceptionAction {
String name;
NModule load(String string) throws ModuleException {
this.name = string;
try {
return (NModule)AccessController.doPrivileged(this);
}
catch (PrivilegedActionException privilegedActionException) {
Exception exception = privilegedActionException.getException();
if (exception instanceof ModuleException) {
throw (ModuleException)exception;
}
throw new BajaRuntimeException(exception);
}
}
public Object run() throws Exception {
return ModuleManager.this.doLoad(this.name);
}
PrivilegedLoader() {
}
}
/*
* Illegal identifiers - consider using --renameillegalidents true
*/
public class Page
extends SpyDir {
public Spy find(String string) {
return new ModulePage(ModuleManager.this.loadModule(string));
}
public void write(SpyWriter spyWriter) throws Exception {
Object[] objectArray = ModuleManager.this.getModules();
SortUtil.sort((Object[])objectArray, (Object[])objectArray, (Comparator)new Comparator(){
public final int compare(Object object, Object object2) {
if (!(object instanceof NModule) || !(object2 instanceof NModule)) {
return 0;
}
return ((NModule)object).getModuleName().compareTo(((NModule)object2).getModuleName());
}
});
spyWriter.startTable(true);
int n = 0;
while (n < objectArray.length) {
Object object = objectArray[n];
String string = ((NModule)object).getModuleName();
spyWriter.tr("<a href='" + string + "'>" + string + "</a>", ((NModule)object).getBajaVersion(), ((NModule)object).getVendor(), ((NModule)object).getVendorVersion(), ((NModule)object).getDescription());
++n;
}
spyWriter.endTable();
}
}
/*
* Illegal identifiers - consider using --renameillegalidents true
*/
public class ModulePage
extends Spy {
NModule m;
public void write(SpyWriter spyWriter) throws Exception {
this.m.bmodule().spy(spyWriter);
}
ModulePage(NModule nModule) {
this.m = nModule;
}
}
}
@@ -0,0 +1,366 @@
/*
* Decompiled with CFR 0.152.
*
* Could not load the following classes:
* javax.baja.nre.util.SortUtil
* javax.baja.xml.XElem
*/
package com.tridium.sys.module;
import com.tridium.sys.Nre;
import com.tridium.sys.module.Dependency;
import com.tridium.sys.module.ModuleClassLoader;
import com.tridium.sys.module.ModuleExtJar;
import com.tridium.sys.module.ModuleManager;
import com.tridium.util.jar.JarFile;
import java.io.File;
import java.io.IOException;
import java.net.URL;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.zip.ZipFile;
import javax.baja.nre.util.SortUtil;
import javax.baja.sys.BModule;
import javax.baja.sys.ModuleException;
import javax.baja.sys.ModuleIncompatibleException;
import javax.baja.sys.Sys;
import javax.baja.sys.Type;
import javax.baja.sys.TypeException;
import javax.baja.sys.TypeNotFoundException;
import javax.baja.util.Lexicon;
import javax.baja.util.Version;
import javax.baja.xml.XElem;
/*
* Illegal identifiers - consider using --renameillegalidents true
*/
public class NModule {
protected String name;
protected Version bajaVersion;
protected Version vendorVersion;
protected String description;
protected String vendor;
protected String preferredSymbol;
boolean isSystemJar;
public JarFile jarFile;
protected Dependency[] depends;
protected ModuleClassLoader classLoader;
String[] typeList;
protected Map types;
protected Map packages;
ModuleExtJar[] extJars;
protected Object bmodule;
Lexicon lexicon;
HashMap lexicons;
void init() {
this.bmodule = new BModule(this);
}
public String getModuleName() {
return this.name;
}
public String getPreferredSymbol() {
return this.preferredSymbol;
}
public Version getBajaVersion() {
return this.bajaVersion;
}
public String getVendor() {
return this.vendor;
}
public Version getVendorVersion() {
return this.vendorVersion;
}
public String getDescription() {
return this.description;
}
public BModule bmodule() {
return (BModule)this.bmodule;
}
public void checkBajaVersion(Version version) throws ModuleIncompatibleException {
if (version != null && version.compareTo(this.getBajaVersion()) > 0) {
throw new ModuleIncompatibleException(this.getModuleName() + '-' + version);
}
}
public void checkVendor(String string, Version version) throws ModuleIncompatibleException {
if (string != null && !string.equalsIgnoreCase(this.getVendor()) || version != null && version.compareTo(this.getVendorVersion()) > 0) {
throw new ModuleIncompatibleException(this.getModuleName() + '-' + string + '-' + version);
}
}
public Class loadClass(String string) throws ClassNotFoundException {
if (this.isSystemJar) {
return Class.forName(string);
}
return Class.forName(string, true, this.classLoader);
}
public URL getResource(String string) {
if (this.isSystemJar) {
return ClassLoader.getSystemResource(string);
}
return this.classLoader.getResource(string);
}
public ModuleClassLoader getClassLoader() {
return this.classLoader;
}
public String[] getTypeList() {
if (this.typeList == null) {
this.typeList = this.types.keySet().toArray(new String[this.types.size()]);
SortUtil.sort((Object[])this.typeList);
}
String[] stringArray = new String[this.typeList.length];
System.arraycopy(this.typeList, 0, stringArray, 0, stringArray.length);
return stringArray;
}
public Type getType(String string) throws TypeException {
Object v = this.types.get(string);
if (v == null) {
throw new TypeNotFoundException(this.name + ':' + string);
}
if (v instanceof Type) {
return (Type)v;
}
String string2 = (String)v;
try {
Class clazz = this.loadClass(string2);
v = this.types.get(string);
if (v == null || !(v instanceof Type)) {
throw new TypeException("Class loaded, but didn't register a type " + this.name + ':' + string + '=' + string2);
}
return (Type)v;
}
catch (TypeException typeException) {
throw typeException;
}
catch (ClassNotFoundException classNotFoundException) {
throw new TypeException("Class not found for type " + this.name + ':' + string + '=' + string2);
}
catch (ExceptionInInitializerError exceptionInInitializerError) {
Throwable throwable = exceptionInInitializerError.getException();
if (throwable == null) {
throwable = exceptionInInitializerError;
}
throw new TypeException(exceptionInInitializerError.toString() + ' ' + this.name + ':' + string + '=' + string2, throwable);
}
catch (Throwable throwable) {
throw new TypeException(throwable.toString() + ' ' + this.name + ':' + string + '=' + string2, throwable);
}
}
public void register(String string, Type type) {
this.types.put(string, type);
}
public void register(String string, String string2) {
this.types.put(string, string2);
}
public ZipFile getZipFile() {
if (this.jarFile instanceof JarFile) {
return this.jarFile.zip;
}
return null;
}
/*
* WARNING - Removed try catching itself - possible behaviour change.
* Enabled aggressive block sorting
* Enabled unnecessary exception pruning
* Enabled aggressive exception aggregation
*/
public final Lexicon getLexicon(String string) {
HashMap hashMap = this.lexicons;
synchronized (hashMap) {
Lexicon lexicon = (Lexicon)this.lexicons.get(string);
if (lexicon == null) {
lexicon = Lexicon.make(this.bmodule(), string);
this.lexicons.put(string, lexicon);
}
return lexicon;
}
}
public final Lexicon getLexicon() {
if (this.lexicon == null || !this.lexicon.language.equals(Sys.getLanguage())) {
this.lexicon = this.getLexicon(Sys.getLanguage());
}
return this.lexicon;
}
public File getFile() {
return this.jarFile.getFile();
}
public String getTypeClassName(String string) {
Object v = this.types.get(string);
if (v == null) {
return null;
}
if (v instanceof String) {
return (String)v;
}
return ((Type)v).getTypeClass().getName();
}
public boolean isSystemJar() {
return this.isSystemJar;
}
public String toString() {
return this.name + '-' + this.vendor + '-' + this.vendorVersion;
}
public void loadAllTypes() {
String[] stringArray = this.getTypeList();
int n = 0;
while (n < stringArray.length) {
try {
this.getType(stringArray[n]);
}
catch (TypeException typeException) {
ModuleManager.log.error("Cannot load type", typeException);
}
++n;
}
}
public boolean isSynthetic() {
if (this.getZipFile() == null) {
return true;
}
return this.getZipFile().getName().endsWith(".sjar");
}
public boolean isTransient() {
boolean bl = false;
if (this.getZipFile() == null) {
bl = true;
}
return bl;
}
public boolean containsPackage(String string) {
return this.packages.containsKey(string);
}
void readXml(XElem xElem) throws IOException {
this.readAttributes(xElem);
this.readDependencies(xElem);
this.readTypes(xElem);
this.readExts(xElem);
this.__postReadXml(xElem);
}
private final void readAttributes(XElem xElem) throws IOException {
this.name = xElem.get("name");
this.bajaVersion = new Version(xElem.get("bajaVersion"));
this.vendorVersion = new Version(xElem.get("vendorVersion"));
this.description = xElem.get("description");
this.vendor = xElem.get("vendor");
this.preferredSymbol = xElem.get("preferredSymbol");
}
private final void readDependencies(XElem xElem) throws IOException {
XElem xElem2 = xElem.elem("dependencies");
if (xElem2 == null) {
return;
}
XElem[] xElemArray = xElem2.elems("dependency");
ArrayList<Dependency> arrayList = new ArrayList<Dependency>(xElemArray.length);
int n = 0;
while (n < xElemArray.length) {
XElem xElem3 = xElemArray[n];
String string = xElem3.get("name");
String string2 = xElem3.get("bajaVersion", null);
String string3 = xElem3.get("vendor", null);
String string4 = xElem3.get("vendorVersion", null);
Version version = string2 == null ? null : new Version(string2);
Version version2 = string4 == null ? null : new Version(string4);
arrayList.add(new Dependency(string, version, string3, version2));
++n;
}
this.depends = arrayList.toArray(new Dependency[arrayList.size()]);
}
private final void readTypes(XElem xElem) throws IOException {
XElem xElem2 = xElem.elem("types");
if (xElem2 == null) {
return;
}
XElem[] xElemArray = xElem2.elems("type");
int n = 0;
while (n < xElemArray.length) {
String string;
XElem xElem3 = xElemArray[n];
String string2 = xElem3.get("name");
String string3 = xElem3.get("class");
this.types.put(string2, string3);
int n2 = string3.lastIndexOf(46);
String string4 = string = n2 == -1 ? "" : string3.substring(0, n2);
if (!this.packages.containsKey(string)) {
this.packages.put(string, string);
}
++n;
}
}
private final void readExts(XElem xElem) throws IOException {
XElem xElem2 = xElem.elem("extFiles");
if (xElem2 == null) {
return;
}
XElem[] xElemArray = xElem2.elems("extFile");
this.extJars = new ModuleExtJar[xElemArray.length];
int n = 0;
while (n < xElemArray.length) {
this.extJars[n] = new ModuleExtJar(xElemArray[n]);
++n;
}
}
private final void __postReadXml(XElem xElem) {
String[] stringArray = Nre.registryManager.getInvalidModules();
if (stringArray == null) {
return;
}
int n = stringArray.length;
int n2 = 0;
while (n2 < n) {
if (this.name.equals(stringArray[n2])) {
this.types.clear();
this.types = Collections.unmodifiableMap(this.types);
this.typeList = null;
throw new ModuleException("Unsupported " + this.name + " module");
}
++n2;
}
}
private final /* synthetic */ void this() {
this.bajaVersion = Version.ZERO;
this.vendorVersion = Version.ZERO;
this.types = new HashMap(63);
this.packages = new HashMap(10);
this.lexicons = new HashMap();
}
public NModule() {
this.this();
}
}
@@ -0,0 +1,95 @@
/*
* Decompiled with CFR 0.152.
*/
package com.tridium.sys.module;
import com.tridium.asm.Buffer;
import com.tridium.sys.module.ModuleClassLoader;
import com.tridium.sys.module.NModule;
import com.tridium.sys.schema.SyntheticCompiler;
import javax.baja.sys.Sys;
import javax.baja.util.BTypeSpec;
public class SyntheticModuleClassLoader
extends ModuleClassLoader {
public Class loadAutoClass(String string, Buffer buffer) throws ClassNotFoundException {
return super.loadAutoClass(string, buffer);
}
public Class ndefineClass(String string, byte[] byArray, int n, int n2) {
return super.defineClass(string, byArray, n, n2, this.codeSource);
}
/*
* Unable to fully structure code
*/
protected Class nfind(String var1_1, boolean var2_2) {
block13: {
if (var1_1.startsWith("auto.")) {
block12: {
try {
return super.nfind(var1_1, var2_2);
}
catch (NoClassDefFoundError var3_3) {
if (this.module.depends == null) break block12;
var4_6 = 0;
** while (var4_6 < this.module.depends.length)
}
lbl-1000:
// 1 sources
{
var5_9 = this.module.depends[var4_6].resolution;
if (var5_9.isSynthetic() && !var5_9.isSystemJar && (var6_12 = var5_9.classLoader.nload(var1_1, var2_2)) != null) {
return var6_12;
}
++var4_6;
continue;
}
}
throw var3_3;
}
try {
return this.getParent().loadClass(var1_1);
}
catch (ClassNotFoundException v0) {
if (this.module.getTypeClassName(var1_1.substring(var1_1.lastIndexOf(46) + 2)) != null) {
var3_4 = BTypeSpec.make(this.module.getModuleName(), var1_1.substring(var1_1.lastIndexOf(46) + 2));
var4_7 = Sys.getRegistry().getType(var3_4.toString());
var5_10 = var4_7.getInterfaces();
var6_13 = var4_7.isAbstract();
var7_14 = var4_7.isFinal();
var8_15 = var4_7.getSuperType();
var9_16 = SyntheticCompiler.compile(var3_4, var8_15, var5_10, var6_13, var7_14, false);
SyntheticModuleClassLoader.addClassToSpy(this.module.name, var1_1, var9_16.count);
var10_17 = this.defineClass(var1_1, var9_16.bytes, 0, var9_16.count, this.codeSource);
try {
Class.forName(var10_17.getName(), true, var10_17.getClassLoader());
}
catch (ClassNotFoundException v1) {}
return var10_17;
}
if (this.module.depends == null) break block13;
var3_5 = 0;
** while (var3_5 < this.module.depends.length)
}
lbl-1000:
// 1 sources
{
var4_8 = this.module.depends[var3_5].resolution;
if (!var4_8.isSystemJar && (var5_11 = var4_8.classLoader.nload(var1_1, var2_2)) != null) {
return var5_11;
}
++var3_5;
continue;
}
}
return null;
}
public SyntheticModuleClassLoader(NModule nModule) {
super(nModule);
}
}
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,160 @@
/*
* Decompiled with CFR 0.152.
*/
package com.tridium.sys.registry;
import java.io.BufferedInputStream;
import java.io.DataInputStream;
import java.io.EOFException;
import java.io.IOException;
import java.io.InputStream;
import javax.baja.io.ByteBuffer;
public class ClassScanner {
private static final String[] noInterfaces = new String[0];
public int modifiers;
public String thisClass;
public String superClass;
public String[] interfaces;
public boolean hasLoadType;
private int[] cpClass;
private byte[][] cpUtf;
/*
* Enabled aggressive block sorting
* Enabled unnecessary exception pruning
* Enabled aggressive exception aggregation
*/
public void scan(InputStream inputStream) throws IOException {
DataInputStream dataInputStream = new DataInputStream(new BufferedInputStream(inputStream));
try {
int n;
int n2 = dataInputStream.readInt();
int n3 = dataInputStream.readUnsignedShort();
int n4 = dataInputStream.readUnsignedShort();
int n5 = dataInputStream.readUnsignedShort();
if (n2 != -889275714) {
throw new IOException("Invalid magic");
}
this.cpClass = new int[n5];
this.cpUtf = new byte[n5][];
int n6 = 1;
while (n6 < n5) {
n = this.readCpInfo(dataInputStream, n6);
if (n != 0) {
++n6;
}
++n6;
}
this.modifiers = dataInputStream.readUnsignedShort();
this.thisClass = this.toClass(dataInputStream.readUnsignedShort());
this.superClass = this.toClass(dataInputStream.readUnsignedShort());
n6 = dataInputStream.readUnsignedShort();
if (n6 == 0) {
this.interfaces = noInterfaces;
} else {
this.interfaces = new String[n6];
n = 0;
while (n < n6) {
this.interfaces[n] = this.toClass(dataInputStream.readUnsignedShort());
++n;
}
}
Object var4_11 = null;
}
catch (Throwable throwable) {
Object var4_10 = null;
dataInputStream.close();
throw throwable;
}
dataInputStream.close();
}
private final boolean readCpInfo(DataInputStream dataInputStream, int n) throws IOException {
int n2 = dataInputStream.readUnsignedByte();
switch (n2) {
case 1: {
int n3 = dataInputStream.readUnsignedShort();
byte[] byArray = new byte[n3];
dataInputStream.readFully(byArray, 0, n3);
this.cpUtf[n] = byArray;
this.checkLoadType(byArray);
return false;
}
case 3: {
ClassScanner.skip(dataInputStream, 4);
return false;
}
case 4: {
ClassScanner.skip(dataInputStream, 4);
return false;
}
case 5: {
ClassScanner.skip(dataInputStream, 8);
return true;
}
case 6: {
ClassScanner.skip(dataInputStream, 8);
return true;
}
case 7: {
this.cpClass[n] = dataInputStream.readUnsignedShort();
return false;
}
case 8: {
ClassScanner.skip(dataInputStream, 2);
return false;
}
case 9: {
ClassScanner.skip(dataInputStream, 4);
return false;
}
case 10: {
ClassScanner.skip(dataInputStream, 4);
return false;
}
case 11: {
ClassScanner.skip(dataInputStream, 4);
return false;
}
case 12: {
ClassScanner.skip(dataInputStream, 4);
return false;
}
}
throw new IOException("Invalid cp tag 0x" + Integer.toHexString(n2));
}
private final String toClass(int n) throws IOException {
byte[] byArray = this.cpUtf[this.cpClass[n]];
ByteBuffer byteBuffer = new ByteBuffer(byArray.length + 4);
byteBuffer.writeShort(byArray.length);
byteBuffer.write(byArray, 0, byArray.length);
return byteBuffer.readUTF().replace('/', '.');
}
private final void checkLoadType(byte[] byArray) {
if (this.hasLoadType) {
return;
}
if (byArray.length != "loadType".length()) {
return;
}
boolean bl = false;
if (byArray[0] == 108 && byArray[1] == 111 && byArray[2] == 97 && byArray[3] == 100 && byArray[4] == 84 && byArray[5] == 121 && byArray[6] == 112 && byArray[7] == 101) {
bl = true;
}
this.hasLoadType = bl;
}
private static final void skip(InputStream inputStream, int n) throws IOException {
int n2 = 0;
while (n2 < n) {
if (n2 < 0) {
throw new EOFException();
}
n2 = (int)((long)n2 + inputStream.skip(n - n2));
}
}
}
@@ -0,0 +1,316 @@
/*
* Decompiled with CFR 0.152.
*
* Could not load the following classes:
* javax.baja.nre.util.Array
* javax.baja.nre.util.SortUtil
*/
package com.tridium.sys.registry;
import com.tridium.sys.Nre;
import com.tridium.sys.registry.NAdapterInfo;
import com.tridium.sys.registry.NModuleInfo;
import com.tridium.sys.registry.NTypeInfo;
import java.io.File;
import java.io.StringWriter;
import javax.baja.agent.AgentInfo;
import javax.baja.io.HtmlWriter;
import javax.baja.log.Log;
import javax.baja.nre.util.Array;
import javax.baja.nre.util.SortUtil;
import javax.baja.registry.ModuleInfo;
import javax.baja.registry.RegistryException;
import javax.baja.registry.TypeInfo;
import javax.baja.spy.Spy;
import javax.baja.spy.SpyDir;
import javax.baja.spy.SpyWriter;
import javax.baja.sys.BAbsTime;
import javax.baja.sys.Sys;
public class Debug {
public static final Log log = Log.getLog("sys.registry");
private File root;
public File modulesFile() {
return new File(this.root, "modules.xml");
}
public File moduleDir(String string) {
return new File(this.root, string);
}
public static class AdaptersPage
extends Spy {
public void write(SpyWriter spyWriter) throws Exception {
String string = "../";
NAdapterInfo[] nAdapterInfoArray = Nre.registryManager.db().adapters;
spyWriter.startTable(true);
spyWriter.trTitle("Installed Adapters", 3);
spyWriter.w("<tr>").th("Type").th("From").th("To").w("</tr>\n");
int n = 0;
while (n < nAdapterInfoArray.length) {
NAdapterInfo nAdapterInfo = nAdapterInfoArray[n];
spyWriter.w("<tr>").td("<a href='" + string + "types/" + nAdapterInfo.type.toString() + "'>" + nAdapterInfo.type + "</a>").td("<a href='" + string + "types/" + nAdapterInfo.from.toString() + "'>" + nAdapterInfo.from + "</a>").td("<a href='" + string + "types/" + nAdapterInfo.to.toString() + "'>" + nAdapterInfo.to + "</a>").w("</tr>\n");
++n;
}
spyWriter.endTable();
}
}
public static class OrdSchemesPage
extends Spy {
public void write(SpyWriter spyWriter) throws Exception {
String string = "../";
String[] stringArray = Sys.getRegistry().getOrdSchemes();
spyWriter.startTable(true);
spyWriter.trTitle("Installed Ord Schemes", 2);
int n = 0;
while (n < stringArray.length) {
TypeInfo typeInfo = Sys.getRegistry().getOrdScheme(stringArray[n]);
spyWriter.w("<tr>").td(stringArray[n]).td("<a href='" + string + "types/" + typeInfo.toString() + "'>" + typeInfo + "</a>").w("</tr>\n");
++n;
}
spyWriter.endTable();
}
}
public static class FileExtsPage
extends Spy {
public void write(SpyWriter spyWriter) throws Exception {
String string = "../";
String[] stringArray = Sys.getRegistry().getFileExtensions();
spyWriter.startTable(true);
spyWriter.trTitle("Installed File Extensions", 2);
int n = 0;
while (n < stringArray.length) {
TypeInfo typeInfo = Sys.getRegistry().getFileTypeForExtension(stringArray[n]);
spyWriter.w("<tr>").td(stringArray[n]).td("<a href='" + string + "types/" + typeInfo.toString() + "'>" + typeInfo + "</a>").w("</tr>\n");
++n;
}
spyWriter.endTable();
}
}
public static class DefsPage
extends Spy {
public void write(SpyWriter spyWriter) throws Exception {
Object[] objectArray = Sys.getRegistry().getDefs();
SortUtil.sort((Object[])objectArray, (Object[])objectArray);
spyWriter.startTable(true);
spyWriter.trTitle("Defs [" + objectArray.length + ']', 2);
int n = 0;
while (n < objectArray.length) {
Object object = objectArray[n];
String string = Sys.getRegistry().getDef((String)object);
spyWriter.tr(object, string);
++n;
}
spyWriter.endTable();
}
}
/*
* Illegal identifiers - consider using --renameillegalidents true
*/
public static class TypePage
extends Spy {
String typeSpec;
static /* synthetic */ Class class$javax$baja$registry$TypeInfo;
public void write(SpyWriter spyWriter) throws Exception {
NTypeInfo[] nTypeInfoArray;
NTypeInfo[] nTypeInfoArray2;
NTypeInfo nTypeInfo = (NTypeInfo)Sys.getRegistry().getType(this.typeSpec);
String string = "../";
spyWriter.startTable(true);
StringWriter stringWriter = new StringWriter();
new HtmlWriter(stringWriter).w("Type ").a("../../modules/" + nTypeInfo.getModuleName(), nTypeInfo.getModuleName()).w(":").w(nTypeInfo.getTypeName());
spyWriter.trTitle(stringWriter, 2);
spyWriter.w("<tr>").td("isAbstract").td("" + nTypeInfo.isAbstract()).w("</tr>\n");
spyWriter.w("<tr>").td("isInterface").td("" + nTypeInfo.isInterface()).w("</tr>\n");
spyWriter.w("<tr>").td("superType").td(this.typeref(string, nTypeInfo.getSuperType())).w("</tr>\n");
TypeInfo[] typeInfoArray = nTypeInfo.getInterfaces();
if (typeInfoArray.length > 0) {
spyWriter.trTitle("Interfaces", 2);
int n = 0;
while (n < typeInfoArray.length) {
spyWriter.w("<tr><td colspan='2'>").w(this.typeref(string, typeInfoArray[n])).w("</td></tr>\n");
++n;
}
}
if ((nTypeInfoArray2 = nTypeInfo.agents).length > 0) {
spyWriter.trTitle("Agents", 2);
int n = 0;
while (n < nTypeInfoArray2.length) {
spyWriter.w("<tr><td colspan='2'>").w(this.typeref(string, nTypeInfoArray2[n])).w("</td></tr>\n");
++n;
}
}
if ((nTypeInfoArray = nTypeInfo.agentOn).length > 0) {
spyWriter.trTitle("Agent On", 2);
int n = 0;
while (n < nTypeInfoArray.length) {
spyWriter.w("<tr><td colspan='2'>").w(this.typeref(string, nTypeInfoArray[n])).w("</td></tr>\n");
++n;
}
}
NTypeInfo[] nTypeInfoArray3 = nTypeInfo.is;
spyWriter.trTitle("Is Types", 2);
int n = 0;
while (n < nTypeInfoArray3.length) {
spyWriter.w("<tr><td colspan='2'>").w(this.typeref(string, nTypeInfoArray3[n])).w("</td></tr>\n");
++n;
}
TypeInfo[] typeInfoArray2 = Sys.getRegistry().getTypes(nTypeInfo);
Class clazz = class$javax$baja$registry$TypeInfo;
if (clazz == null) {
clazz = class$javax$baja$registry$TypeInfo = TypePage.class("[Ljavax.baja.registry.TypeInfo;", false);
}
Array array = new Array(clazz);
int n2 = 0;
while (n2 < typeInfoArray2.length) {
if (nTypeInfo.isInterface()) {
if (new Array((Object[])typeInfoArray2[n2].getInterfaces()).indexOf((Object)nTypeInfo) != -1) {
array.add((Object)typeInfoArray2[n2]);
}
} else {
TypeInfo typeInfo = typeInfoArray2[n2].getSuperType();
if (typeInfo != null && typeInfo.equals(nTypeInfo)) {
array.add((Object)typeInfoArray2[n2]);
}
}
++n2;
}
if (array.size() > 0) {
typeInfoArray2 = (TypeInfo[])array.trim();
spyWriter.trTitle("Sub Types", 2);
n2 = 0;
while (n2 < typeInfoArray2.length) {
spyWriter.w("<tr><td colspan='2'>").w(this.typeref(string, typeInfoArray2[n2])).w("</td></tr>\n");
++n2;
}
}
try {
AgentInfo agentInfo = nTypeInfo.getAgentInfo();
spyWriter.trTitle("AgentInfo", 2);
spyWriter.w("<tr>").td("requiredPermissions").td(agentInfo.getRequiredPermissions()).w("</tr>\n");
spyWriter.w("<tr>").td("appName").td(agentInfo.getAppName()).w("</tr>\n");
}
catch (RegistryException registryException) {}
spyWriter.endTable();
}
private final String typeref(String string, TypeInfo typeInfo) {
if (typeInfo == null) {
return "null";
}
return "<a href='" + string + typeInfo.toString() + "'>" + typeInfo.toString() + "</a>";
}
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());
}
}
TypePage(String string) {
this.typeSpec = string;
}
}
public static class TypesPage
extends SpyDir {
public Spy find(String string) {
return new TypePage(string);
}
public void write(SpyWriter spyWriter) throws Exception {
Object[] objectArray = Sys.getRegistry().getTypes();
SortUtil.sort((Object[])objectArray);
spyWriter.startTable(true);
spyWriter.trTitle("Installed Types", 1);
int n = 0;
while (n < objectArray.length) {
Object object = objectArray[n];
spyWriter.w("<tr>").td("<a href='../types/" + spyWriter.href(object.toString()) + "'>" + object + "</a>").w("</tr>\n");
++n;
}
spyWriter.endTable();
}
}
public static class ModulePage
extends Spy {
String name;
public void write(SpyWriter spyWriter) throws Exception {
Object[] objectArray = Sys.getRegistry().getModule(this.name).getTypes();
SortUtil.sort((Object[])objectArray);
spyWriter.startTable(true);
spyWriter.trTitle("Module \"" + this.name + '\"', 1);
int n = 0;
while (n < objectArray.length) {
NTypeInfo nTypeInfo = (NTypeInfo)objectArray[n];
spyWriter.w("<tr>").td("<a href='" + spyWriter.href("../../types/" + nTypeInfo.toString()) + "'>" + nTypeInfo + "</a>").w("</tr>\n");
++n;
}
spyWriter.endTable();
}
ModulePage(String string) {
this.name = string;
}
}
public static class ModulesPage
extends SpyDir {
public Spy find(String string) {
return new ModulePage(string);
}
public void write(SpyWriter spyWriter) throws Exception {
ModuleInfo[] moduleInfoArray = Sys.getRegistry().getModules();
spyWriter.startTable(true);
spyWriter.trTitle("Installed Modules", 8);
int n = 0;
while (n < moduleInfoArray.length) {
NModuleInfo nModuleInfo = (NModuleInfo)moduleInfoArray[n];
spyWriter.w("<tr>").td("<a href='" + spyWriter.href(nModuleInfo.getModuleName()) + "'>" + nModuleInfo.getModuleName() + "</a>").td(nModuleInfo.getBajaVersion()).td(nModuleInfo.getVendor()).td(nModuleInfo.getVendorVersion()).td(nModuleInfo.getDescription()).td(BAbsTime.make(nModuleInfo.getBuildTime())).td(nModuleInfo.hasPalette() ? "palette" : "no palette").td(nModuleInfo.isAutoload() ? "autoload" : "non-autoload").td(nModuleInfo.isReloadable() ? "reloadable" : "non-reloadable").w("</tr>\n");
++n;
}
spyWriter.endTable();
}
}
public static class SummaryPage
extends SpyDir {
public void write(SpyWriter spyWriter) throws Exception {
spyWriter.startTable(true);
spyWriter.trTitle("Registry", 1);
spyWriter.w("<tr>").td("<a href='" + spyWriter.href("modules") + "'>Installed Modules</a>").w("</tr>");
spyWriter.w("<tr>").td("<a href='" + spyWriter.href("types") + "'>Installed Types</a>").w("</tr>");
spyWriter.w("<tr>").td("<a href='" + spyWriter.href("defs") + "'>Registry Definitions</a>").w("</tr>");
spyWriter.w("<tr>").td("<a href='" + spyWriter.href("fileExts") + "'>Installed File Extensions</a>").w("</tr>");
spyWriter.w("<tr>").td("<a href='" + spyWriter.href("ordSchemes") + "'>Installed Ord Schemes</a>").w("</tr>");
spyWriter.w("<tr>").td("<a href='" + spyWriter.href("adapters") + "'>Installed Adapters</a>").w("</tr>");
spyWriter.endTable();
}
SummaryPage() {
this.add("modules", new ModulesPage());
this.add("types", new TypesPage());
this.add("defs", new DefsPage());
this.add("fileExts", new FileExtsPage());
this.add("ordSchemes", new OrdSchemesPage());
this.add("adapters", new AdaptersPage());
}
}
}
@@ -0,0 +1,46 @@
/*
* Decompiled with CFR 0.152.
*/
package com.tridium.sys.registry;
import com.tridium.sys.registry.NTypeInfo;
import com.tridium.sys.registry.RegistryDatabase;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import javax.baja.registry.TypeInfo;
public class NAdapterInfo {
NTypeInfo type;
NTypeInfo from;
NTypeInfo to;
public boolean isMatch(TypeInfo typeInfo, TypeInfo typeInfo2) {
if (typeInfo == null) {
if (typeInfo2 == null) {
return true;
}
return typeInfo2.is(this.to);
}
if (typeInfo2 == null) {
return typeInfo.is(this.from);
}
boolean bl = false;
if (typeInfo.is(this.from) && typeInfo2.is(this.to)) {
bl = true;
}
return bl;
}
void read(RegistryDatabase registryDatabase, DataInputStream dataInputStream) throws Exception {
this.type = NTypeInfo.readType(registryDatabase, dataInputStream);
this.from = NTypeInfo.readType(registryDatabase, dataInputStream);
this.to = NTypeInfo.readType(registryDatabase, dataInputStream);
}
void write(RegistryDatabase registryDatabase, DataOutputStream dataOutputStream) throws Exception {
NTypeInfo.writeType(registryDatabase, dataOutputStream, this.type);
NTypeInfo.writeType(registryDatabase, dataOutputStream, this.from);
NTypeInfo.writeType(registryDatabase, dataOutputStream, this.to);
}
}
@@ -0,0 +1,118 @@
/*
* Decompiled with CFR 0.152.
*/
package com.tridium.sys.registry;
import com.tridium.sys.registry.NTypeInfo;
import com.tridium.sys.registry.RegistryDatabase;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import javax.baja.agent.AgentInfo;
import javax.baja.registry.TypeInfo;
import javax.baja.security.BPermissions;
import javax.baja.sys.BIcon;
import javax.baja.sys.BObject;
import javax.baja.sys.Context;
/*
* Illegal identifiers - consider using --renameillegalidents true
*/
public class NAgentInfo
implements AgentInfo {
public static final int NO_PREFERRENCE = 0;
public static final int DEFAULT_PREFERRED = 1;
public static final int DEFAULT_NOT_PREFERRED = 2;
final NTypeInfo typeInfo;
BPermissions permissions;
String appName;
int defaultPreferrence;
public final TypeInfo getTypeInfo() {
return this.typeInfo;
}
public final String getAgentId() {
return this.typeInfo.toString();
}
public final BObject getInstance() {
return this.typeInfo.getInstance();
}
public final TypeInfo getAgentType() {
return this.typeInfo;
}
public final String getAppName() {
return this.appName;
}
public TypeInfo[] getAgentOn() {
return this.typeInfo.agentOn;
}
public final String getDisplayName(Context context) {
return this.typeInfo.getDisplayName(context);
}
public final BIcon getIcon(Context context) {
return this.typeInfo.getIcon(context);
}
public final BPermissions getRequiredPermissions() {
return this.permissions;
}
public final String toString() {
return "AgentInfo for " + this.typeInfo;
}
void read(RegistryDatabase registryDatabase, DataInputStream dataInputStream) throws Exception {
this.permissions = BPermissions.make(dataInputStream.readInt());
this.defaultPreferrence = dataInputStream.readShort();
if (dataInputStream.readBoolean()) {
this.appName = dataInputStream.readUTF();
}
}
void write(RegistryDatabase registryDatabase, DataOutputStream dataOutputStream) throws Exception {
dataOutputStream.writeInt(this.permissions.getMask());
dataOutputStream.writeShort(this.defaultPreferrence);
boolean bl = false;
if (this.appName != null) {
bl = true;
}
dataOutputStream.writeBoolean(bl);
if (this.appName != null) {
dataOutputStream.writeUTF(this.appName);
}
}
public static boolean isAdmin(AgentInfo agentInfo) {
int n = agentInfo.getRequiredPermissions().getMask();
int n2 = 112;
boolean bl = false;
if ((n & n2) != 0) {
bl = true;
}
return bl;
}
private final /* synthetic */ void this() {
this.permissions = BPermissions.none;
this.appName = null;
this.defaultPreferrence = 0;
}
public NAgentInfo(NTypeInfo nTypeInfo) {
this.this();
this.typeInfo = nTypeInfo;
}
public NAgentInfo(NTypeInfo nTypeInfo, int n) {
this.this();
this.typeInfo = nTypeInfo;
this.defaultPreferrence = n;
}
}
@@ -0,0 +1,238 @@
/*
* Decompiled with CFR 0.152.
*/
package com.tridium.sys.registry;
import com.tridium.sys.registry.NAgentInfo;
import java.util.ArrayList;
import javax.baja.agent.AgentFilter;
import javax.baja.agent.AgentInfo;
import javax.baja.agent.AgentList;
import javax.baja.agent.NoSuchAgentException;
import javax.baja.sys.Sys;
import javax.baja.sys.TypeNotFoundException;
/*
* Illegal identifiers - consider using --renameillegalidents true
*/
public class NAgentList
implements AgentList {
private ArrayList list;
public int size() {
return this.list.size();
}
public AgentInfo getDefault() {
if (this.list.size() == 0) {
throw new NoSuchAgentException();
}
AgentInfo agentInfo = null;
int n = 0;
while (n < this.list.size()) {
AgentInfo agentInfo2 = (AgentInfo)this.list.get(n);
if (agentInfo2 instanceof NAgentInfo) {
NAgentInfo nAgentInfo = (NAgentInfo)agentInfo2;
if (nAgentInfo.defaultPreferrence == 1) {
return nAgentInfo;
}
if (agentInfo == null && nAgentInfo.defaultPreferrence != 2) {
agentInfo = nAgentInfo;
}
} else if (agentInfo == null) {
agentInfo = agentInfo2;
}
++n;
}
if (agentInfo != null) {
return agentInfo;
}
return (AgentInfo)this.list.get(0);
}
public AgentInfo get(int n) {
return (AgentInfo)this.list.get(n);
}
public AgentInfo get(String string) {
if (string == null) {
return null;
}
int n = 0;
while (n < this.list.size()) {
AgentInfo agentInfo = (AgentInfo)this.list.get(n);
if (agentInfo.getAgentId().equals(string)) {
return agentInfo;
}
++n;
}
return null;
}
public AgentInfo[] list() {
return this.list.toArray(new AgentInfo[this.list.size()]);
}
public int indexOf(String string) {
int n = 0;
while (n < this.list.size()) {
AgentInfo agentInfo = (AgentInfo)this.list.get(n);
if (agentInfo.getAgentId().equals(string)) {
return n;
}
++n;
}
return -1;
}
public int indexOf(AgentInfo agentInfo) {
return this.indexOf(agentInfo.getAgentId());
}
public Object clone() {
NAgentList nAgentList = new NAgentList();
nAgentList.list = (ArrayList)this.list.clone();
return nAgentList;
}
public AgentList filter(AgentFilter agentFilter) {
NAgentList nAgentList = new NAgentList();
ArrayList arrayList = this.list;
int n = arrayList.size();
int n2 = n - 1;
while (n2 >= 0) {
AgentInfo agentInfo = (AgentInfo)arrayList.get(n2);
if (agentFilter.include(agentInfo)) {
nAgentList.add(agentInfo);
}
--n2;
}
return nAgentList;
}
public void add(String string) {
try {
this.add(Sys.getRegistry().getType(string).getAgentInfo());
}
catch (TypeNotFoundException typeNotFoundException) {}
}
public void add(int n, String string) {
try {
this.add(n, Sys.getRegistry().getType(string).getAgentInfo());
}
catch (TypeNotFoundException typeNotFoundException) {}
}
public void add(AgentInfo agentInfo) {
this.add(0, agentInfo);
}
public void add(int n, AgentInfo agentInfo) {
if (agentInfo == null) {
return;
}
int n2 = this.indexOf(agentInfo);
if (n2 >= 0) {
this.list.remove(n2);
if (n > n2) {
--n;
}
}
this.list.add(n, agentInfo);
}
public void remove(String string) {
this.remove(this.indexOf(string));
}
public void remove(AgentInfo agentInfo) {
this.remove(this.indexOf(agentInfo));
}
public void remove(int n) {
if (n < 0 || n >= this.list.size()) {
return;
}
this.list.remove(n);
}
public void remove(AgentList agentList) {
int n = 0;
while (n < agentList.size()) {
this.remove(agentList.get(n));
++n;
}
}
public void toTop(String string) {
this.toTop(this.indexOf(string));
}
public void toTop(AgentInfo agentInfo) {
this.toTop(this.indexOf(agentInfo));
}
public void toTop(int n) {
if (n < 0 || n >= this.list.size()) {
return;
}
AgentInfo agentInfo = (AgentInfo)this.list.remove(n);
this.list.add(0, agentInfo);
}
public void toBottom(String string) {
this.toBottom(this.indexOf(string));
}
public void toBottom(AgentInfo agentInfo) {
this.toBottom(this.indexOf(agentInfo));
}
public void toBottom(int n) {
if (n < 0 || n >= this.list.size()) {
return;
}
AgentInfo agentInfo = (AgentInfo)this.list.remove(n);
this.list.add(agentInfo);
}
public void swap(int n, int n2) {
AgentInfo agentInfo = this.get(n);
AgentInfo agentInfo2 = this.get(n2);
this.list.set(n, agentInfo2);
this.list.set(n2, agentInfo);
}
public String toString() {
StringBuffer stringBuffer = new StringBuffer();
int n = 0;
while (n < this.list.size()) {
if (n > 0) {
stringBuffer.append(';');
}
stringBuffer.append(this.get(n).getAgentId());
++n;
}
return stringBuffer.toString();
}
public void dump() {
System.out.println("AgentList");
int n = 0;
while (n < this.list.size()) {
AgentInfo agentInfo = this.get(n);
System.out.println(" [" + n + "] " + agentInfo.getAgentId() + " (" + agentInfo.getAppName() + ')');
++n;
}
}
private final /* synthetic */ void this() {
this.list = new ArrayList();
}
public NAgentList() {
this.this();
}
}
@@ -0,0 +1,188 @@
/*
* Decompiled with CFR 0.152.
*
* Could not load the following classes:
* javax.baja.xml.XElem
* javax.baja.xml.XParser
*/
package com.tridium.sys.registry;
import java.io.BufferedInputStream;
import java.io.File;
import java.io.InputStream;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
import javax.baja.registry.DependencyInfo;
import javax.baja.registry.ModuleInfo;
import javax.baja.sys.ModuleException;
import javax.baja.sys.Sys;
import javax.baja.util.Version;
import javax.baja.xml.XElem;
import javax.baja.xml.XParser;
public class NDependencyInfo
implements DependencyInfo {
static final NDependencyInfo[] none = new NDependencyInfo[0];
String name;
ModuleInfo module;
Version bajaVersion;
String vendor;
Version vendorVersion;
public String getModuleName() {
return this.name;
}
public ModuleInfo getModuleInfo() {
return this.module;
}
public Version getBajaVersion() {
return this.bajaVersion;
}
public String getVendor() {
return this.vendor;
}
public Version getVendorVersion() {
return this.vendorVersion;
}
/*
* WARNING - Removed try catching itself - possible behaviour change.
* Enabled aggressive block sorting
* Enabled unnecessary exception pruning
* Enabled aggressive exception aggregation
*/
public static DependencyInfo[] load(String string) {
DependencyInfo[] dependencyInfoArray2;
ZipFile zipFile;
block23: {
DependencyInfo[] dependencyInfoArray;
block22: {
DependencyInfo[] dependencyInfoArray3;
block21: {
DependencyInfo[] dependencyInfoArray4;
block20: {
zipFile = null;
try {
try {
ZipEntry zipEntry;
if (string.equals("baja")) {
dependencyInfoArray4 = none;
Object var3_7 = null;
break block20;
}
File file = new File(Sys.getBajaHome(), "modules" + File.separator + string + ".jar");
if (!file.exists()) {
file = new File(Sys.getBajaHome(), "modules" + File.separator + string + ".sjar");
}
if ((zipEntry = (zipFile = new ZipFile(file)).getEntry("META-INF/module.xml")) == null) {
zipEntry = zipFile.getEntry("meta-inf/module.xml");
}
if (zipEntry == null) {
throw new ModuleException("Module missing META-INF/module.xml: " + file);
}
BufferedInputStream bufferedInputStream = new BufferedInputStream(zipFile.getInputStream(zipEntry));
XElem xElem = XParser.make((InputStream)bufferedInputStream).parse().elem("dependencies");
if (xElem == null) {
dependencyInfoArray3 = none;
break block21;
}
XElem[] xElemArray = xElem.elems("dependency");
if (xElemArray.length == 0) {
dependencyInfoArray = none;
break block22;
}
DependencyInfo[] dependencyInfoArray5 = new NDependencyInfo[xElemArray.length];
int n = 0;
while (true) {
if (n >= dependencyInfoArray5.length) {
dependencyInfoArray2 = dependencyInfoArray5;
break block23;
}
dependencyInfoArray5[n] = new NDependencyInfo(xElemArray[n]);
++n;
}
}
catch (Exception exception) {
exception.printStackTrace();
DependencyInfo[] dependencyInfoArray32 = none;
Object var3_11 = null;
try {
if (zipFile == null) return dependencyInfoArray32;
zipFile.close();
return dependencyInfoArray32;
}
catch (Exception exception2) {}
return dependencyInfoArray32;
}
}
catch (Throwable throwable) {
Object var3_12 = null;
try {}
catch (Exception exception) {
throw throwable;
}
if (zipFile == null) throw throwable;
zipFile.close();
throw throwable;
}
}
try {}
catch (Exception exception) {}
if (zipFile == null) return dependencyInfoArray4;
zipFile.close();
return dependencyInfoArray4;
}
Object var3_8 = null;
try {}
catch (Exception exception) {}
if (zipFile == null) return dependencyInfoArray3;
zipFile.close();
return dependencyInfoArray3;
}
Object var3_9 = null;
try {}
catch (Exception exception) {}
if (zipFile == null) return dependencyInfoArray;
zipFile.close();
return dependencyInfoArray;
}
Object var3_10 = null;
try {}
catch (Exception exception) {}
if (zipFile == null) return dependencyInfoArray2;
zipFile.close();
return dependencyInfoArray2;
}
public String toString() {
StringBuffer stringBuffer = new StringBuffer(this.name);
if (this.bajaVersion != null) {
stringBuffer.append('-').append(this.bajaVersion);
}
if (this.vendor != null) {
stringBuffer.append('-').append(this.vendor);
if (this.vendorVersion != null) {
stringBuffer.append('-').append(this.vendorVersion);
}
}
return stringBuffer.toString();
}
public NDependencyInfo(XElem xElem) {
this.name = xElem.get("name");
try {
this.module = Sys.getRegistry().getModule(this.name);
}
catch (Exception exception) {}
String string = xElem.get("bajaVersion", null);
this.bajaVersion = string != null ? new Version(string) : null;
this.vendor = xElem.get("vendor", null);
String string2 = xElem.get("vendorVersion", null);
this.vendorVersion = string2 != null ? new Version(string2) : null;
}
}
@@ -0,0 +1,126 @@
/*
* Decompiled with CFR 0.152.
*
* Could not load the following classes:
* javax.baja.xml.XElem
*/
package com.tridium.sys.registry;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import javax.baja.log.Log;
import javax.baja.registry.LexiconInfo;
import javax.baja.sys.BAbsTime;
import javax.baja.xml.XElem;
/*
* Illegal identifiers - consider using --renameillegalidents true
*/
public class NLexiconInfo
implements LexiconInfo {
private static final Log log = Log.getLog("sys.registry");
private static final NLexiconInfo[] none = new NLexiconInfo[0];
private String brandPattern;
private String moduleName;
private String resourcePath;
private String language;
private String containerModuleName;
private BAbsTime lastModified;
private boolean defaultLexicon;
public String getBrandPattern() {
return this.brandPattern;
}
public String getModuleName() {
return this.moduleName;
}
public String getResourcePath() {
return this.resourcePath;
}
public String getLanguage() {
return this.language;
}
public String getContainerModuleName() {
return this.containerModuleName;
}
public BAbsTime getLastModified() {
return this.lastModified;
}
public boolean isDefault() {
return this.defaultLexicon;
}
public void setLastModified(long l) {
this.lastModified = BAbsTime.make(l);
}
public void setLastModified(BAbsTime bAbsTime) {
this.lastModified = bAbsTime;
}
public void read(DataInputStream dataInputStream) throws Exception {
this.moduleName = dataInputStream.readUTF();
this.brandPattern = dataInputStream.readUTF();
this.resourcePath = dataInputStream.readUTF();
this.language = dataInputStream.readUTF();
this.containerModuleName = dataInputStream.readUTF();
this.defaultLexicon = dataInputStream.readBoolean();
}
public void write(DataOutputStream dataOutputStream) throws Exception {
dataOutputStream.writeUTF(this.moduleName);
dataOutputStream.writeUTF(this.brandPattern);
dataOutputStream.writeUTF(this.resourcePath);
dataOutputStream.writeUTF(this.language);
dataOutputStream.writeUTF(this.containerModuleName);
dataOutputStream.writeBoolean(this.defaultLexicon);
}
public String toString() {
StringBuffer stringBuffer = new StringBuffer(this.moduleName);
if (this.language != null) {
stringBuffer.append('-').append(this.language);
}
if (this.brandPattern != null) {
stringBuffer.append('-').append(this.brandPattern);
}
if (this.containerModuleName != null) {
stringBuffer.append('-').append(this.containerModuleName);
}
if (this.resourcePath != null) {
stringBuffer.append('-').append(this.resourcePath);
}
if (this.defaultLexicon) {
stringBuffer.append('-').append("true");
} else {
stringBuffer.append('-').append("false");
}
return stringBuffer.toString();
}
private final /* synthetic */ void this() {
this.defaultLexicon = false;
}
public NLexiconInfo() {
this.this();
}
public NLexiconInfo(XElem xElem, String string, String string2) {
this.this();
this.moduleName = xElem.get("module");
this.brandPattern = string;
this.resourcePath = xElem.get("resource");
this.language = xElem.get("language", "");
this.containerModuleName = string2;
this.defaultLexicon = xElem.getb("default", false);
this.lastModified = BAbsTime.NULL;
}
}
@@ -0,0 +1,141 @@
/*
* Decompiled with CFR 0.152.
*/
package com.tridium.sys.registry;
import com.tridium.sys.registry.NDependencyInfo;
import com.tridium.sys.registry.NTypeInfo;
import com.tridium.sys.registry.RegistryDatabase;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import javax.baja.registry.DependencyInfo;
import javax.baja.registry.ModuleInfo;
import javax.baja.registry.TypeInfo;
import javax.baja.util.Version;
/*
* Illegal identifiers - consider using --renameillegalidents true
*/
public class NModuleInfo
implements ModuleInfo {
int id;
String moduleName;
Version bajaVersion;
String vendor;
Version vendorVersion;
boolean isTransientModule;
boolean isAutoloadModule;
boolean isReloadableModule;
String description;
String moduleContent;
NTypeInfo[] types;
DependencyInfo[] depends;
boolean hasPalette;
long buildTime;
public String getModuleName() {
return this.moduleName;
}
public Version getBajaVersion() {
return this.bajaVersion;
}
public String getVendor() {
return this.vendor;
}
public Version getVendorVersion() {
return this.vendorVersion;
}
public String getDescription() {
return this.description;
}
public TypeInfo[] getTypes() {
return (TypeInfo[])this.types.clone();
}
public DependencyInfo[] getDependencies() {
if (this.depends == null) {
this.depends = NDependencyInfo.load(this.moduleName);
}
return this.depends;
}
public boolean isTransient() {
return this.isTransientModule;
}
public boolean isAutoload() {
return this.isAutoloadModule;
}
public boolean isReloadable() {
return this.isReloadableModule;
}
public long getBuildTime() {
return this.buildTime;
}
public boolean hasPalette() {
return this.hasPalette;
}
public String getModuleContent() {
return this.moduleContent;
}
void read(RegistryDatabase registryDatabase, DataInputStream dataInputStream) throws Exception {
this.moduleName = dataInputStream.readUTF();
this.bajaVersion = new Version(dataInputStream.readUTF());
this.vendor = dataInputStream.readUTF();
this.vendorVersion = new Version(dataInputStream.readUTF());
this.description = dataInputStream.readUTF();
this.hasPalette = dataInputStream.readBoolean();
this.buildTime = dataInputStream.readLong();
this.types = NTypeInfo.readTypes(registryDatabase, dataInputStream);
this.moduleContent = dataInputStream.readUTF();
try {
this.isAutoloadModule = dataInputStream.readBoolean();
this.isReloadableModule = dataInputStream.readBoolean();
}
catch (Exception exception) {}
}
void write(RegistryDatabase registryDatabase, DataOutputStream dataOutputStream) throws Exception {
dataOutputStream.writeUTF(this.moduleName);
dataOutputStream.writeUTF(this.bajaVersion.toString());
dataOutputStream.writeUTF(this.vendor);
dataOutputStream.writeUTF(this.vendorVersion.toString());
dataOutputStream.writeUTF(this.description);
dataOutputStream.writeBoolean(this.hasPalette);
dataOutputStream.writeLong(this.buildTime);
NTypeInfo.writeTypes(registryDatabase, dataOutputStream, this.types);
dataOutputStream.writeUTF(this.moduleContent);
dataOutputStream.writeBoolean(this.isAutoloadModule);
dataOutputStream.writeBoolean(this.isReloadableModule);
}
public String toString() {
return "NModuleInfo (" + this.moduleName + ')';
}
private final /* synthetic */ void this() {
this.isTransientModule = false;
this.isAutoloadModule = true;
this.isReloadableModule = false;
this.moduleContent = "doc";
this.types = NTypeInfo.noTypes;
this.depends = null;
this.hasPalette = false;
}
protected NModuleInfo(int n) {
this.this();
this.id = n;
}
}
@@ -0,0 +1,415 @@
/*
* Decompiled with CFR 0.152.
*
* Could not load the following classes:
* javax.baja.xml.XException
*/
package com.tridium.sys.registry;
import com.tridium.sys.Nre;
import com.tridium.sys.registry.Builder;
import com.tridium.sys.registry.Debug;
import com.tridium.sys.registry.NTypeInfo;
import com.tridium.sys.registry.RegistryChecksum;
import com.tridium.sys.registry.RegistryDatabase;
import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileWriter;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Date;
import javax.baja.agent.AgentInfo;
import javax.baja.agent.AgentList;
import javax.baja.agent.BIAgent;
import javax.baja.io.ValueDocDecoder;
import javax.baja.log.Log;
import javax.baja.registry.LexiconInfo;
import javax.baja.registry.ModuleInfo;
import javax.baja.registry.Registry;
import javax.baja.registry.RegistryException;
import javax.baja.registry.TypeInfo;
import javax.baja.sys.BAbsTime;
import javax.baja.sys.BComplex;
import javax.baja.sys.BModule;
import javax.baja.sys.BObject;
import javax.baja.sys.ModuleNotFoundException;
import javax.baja.sys.Type;
import javax.baja.sys.TypeNotFoundException;
import javax.baja.util.BTypeSpec;
import javax.baja.util.Version;
import javax.baja.xml.XException;
/*
* Illegal identifiers - consider using --renameillegalidents true
*/
public final class NRegistry
implements Registry {
public static final Log log = Log.getLog("sys.registry");
public static boolean forceRebuild = false;
RegistryDatabase db;
public final ValueDocDecoder.ITypeResolver typeResolver;
private String[] invalidModules;
public final BAbsTime getLastBuildTime() {
return BAbsTime.make(this.dbFile().lastModified());
}
public final ModuleInfo[] getModules() {
return this.db().getModules();
}
public final ModuleInfo getModule(String string) {
return this.db().getModule(string);
}
public final TypeInfo[] getTypes() {
return this.db().getTypes();
}
public final TypeInfo[] getTypes(TypeInfo typeInfo) {
return this.db().getTypes(typeInfo, false);
}
public final TypeInfo[] getConcreteTypes(TypeInfo typeInfo) {
return this.db().getTypes(typeInfo, true);
}
public final TypeInfo getType(String string) {
return this.db().getType(string);
}
public final String[] getDefs() {
return this.db().getDefs();
}
public final String[] getDefs(String string) {
return this.db().getDefs(string);
}
public final String getDef(String string) {
return this.db().getDef(string, null);
}
public final String getDef(String string, String string2) {
return this.db().getDef(string, string2);
}
public final AgentList getAgents(TypeInfo typeInfo) {
return this.db().getAgents(typeInfo);
}
public final AgentList getSpecificAgents(TypeInfo typeInfo) {
return this.db().getSpecificAgents(typeInfo);
}
public final boolean isAgent(TypeInfo typeInfo, TypeInfo typeInfo2) {
return this.db().isAgent(typeInfo, typeInfo2);
}
public final boolean isSpecificAgent(TypeInfo typeInfo, TypeInfo typeInfo2) {
return this.db().isSpecificAgent(typeInfo, typeInfo2);
}
public final TypeInfo[] getAdapters(TypeInfo typeInfo, TypeInfo typeInfo2) {
return this.db().getAdapters(typeInfo, typeInfo2);
}
public final String[] getFileExtensions() {
return this.db().getFileExtensions();
}
public final String[] getFileExtensions(TypeInfo typeInfo) {
return this.db().getFileExtensions(typeInfo);
}
public final TypeInfo getFileTypeForExtension(String string) {
return this.db().getFileTypeForExtension(string);
}
public final String[] getOrdSchemes() {
return this.db().getOrdSchemes();
}
public final TypeInfo getOrdScheme(String string) {
return this.db().getOrdScheme(string);
}
public final boolean isOrdScheme(String string) {
return this.db().isOrdScheme(string);
}
public final LexiconInfo[] getLexicons() {
return this.db().getLexicons();
}
public final LexiconInfo[] getLexicons(String string) {
return this.db().getLexicons(string);
}
public final LexiconInfo[] getLexicons(String string, String string2) {
return this.db().getLexicons(string, string2);
}
public final LexiconInfo getLexicon(String string, String string2, String string3) {
return this.db().getLexicon(string, string2, string3);
}
public final Type synthesizeType(BTypeSpec bTypeSpec, String string, TypeInfo typeInfo, TypeInfo[] typeInfoArray, AgentInfo[] agentInfoArray, boolean bl, boolean bl2) {
return this.db().synthesizeType(bTypeSpec, string, typeInfo, typeInfoArray, agentInfoArray, bl, bl2);
}
public final BModule synthesizeModule(String string, Version version, String string2, Version version2, String string3) {
return this.db().synthesizeModule(string, version, string2, version2, string3);
}
final RegistryDatabase db() {
if (this.db == null) {
try {
long l = System.currentTimeMillis();
this.db = new RegistryDatabase();
InputStream inputStream = Nre.bootEnv.isRemote() ? Nre.bootEnv.read(this.dbRemote()) : new BufferedInputStream(new FileInputStream(this.dbFile()));
this.db.read(inputStream);
long l2 = System.currentTimeMillis();
log.message("Loaded [" + (l2 - l) + "ms]");
}
catch (Throwable throwable) {
throw new RegistryException("Cannot load registry", throwable);
}
}
return this.db;
}
public final boolean isRegistryUpToDate() {
if (Nre.bootEnv.isRemote()) {
return true;
}
if (forceRebuild) {
log.message("Force rebuild");
return false;
}
if (this.dummyFile().exists()) {
log.message("*** No Rebuild ***");
return true;
}
long l = System.currentTimeMillis();
try {
File file = this.chkFile();
if (!file.exists()) {
throw new RegistryException("Missing \"" + file + '\"');
}
RegistryChecksum registryChecksum = new RegistryChecksum();
registryChecksum.read(file);
File file2 = new File(Nre.bajaHome, "modules");
File[] fileArray = file2.listFiles();
int n = 0;
while (n < fileArray.length) {
registryChecksum.checkUpToDate(fileArray[n]);
++n;
}
if (registryChecksum.modules.size() > 0) {
String string = ((RegistryChecksum.ModuleSnapshot)registryChecksum.modules.values().toArray()[0]).name;
throw new RegistryException("Module removed \"" + string + '\"');
}
}
catch (RegistryException registryException) {
log.message("Out-of-date: " + registryException.getMessage());
return false;
}
catch (Throwable throwable) {
log.message("Out-of-date", throwable);
return false;
}
long l2 = System.currentTimeMillis();
log.message("Up-to-date [" + (l2 - l) + "ms]");
return true;
}
public final void rebuild() {
try {
log.message("Rebuilding registry...");
long l = System.currentTimeMillis();
File file = this.dummyFile();
boolean bl = file.exists();
int n = Builder.rebuild(this);
TypeInfo[] typeInfoArray = this.getConcreteTypes(BObject.TYPE.getTypeInfo());
int n2 = 0;
while (n2 < typeInfoArray.length) {
NTypeInfo nTypeInfo = (NTypeInfo)typeInfoArray[n2];
if (nTypeInfo.agentOn.length > 0 && !nTypeInfo.is(BIAgent.TYPE)) {
log.warning(nTypeInfo.getTypeSpec() + " declares itself as an agent, but does not implement BIAgent.");
}
++n2;
}
if (bl) {
PrintWriter printWriter = new PrintWriter(new FileWriter(file));
printWriter.write("no-rebuild.dummy " + new Date());
printWriter.close();
}
long l2 = System.currentTimeMillis();
log.message("Rebuilt: " + n + " types [" + (l2 - l) + "ms]");
}
catch (Throwable throwable) {
log.error("Cannot rebuild", throwable);
}
}
public final void syncModules() {
if (Nre.bootEnv.isRemote()) {
return;
}
if (this.db == null) {
throw new IllegalStateException("Can't syncModules() on uninitialized registry");
}
Builder.syncFiles(this);
}
public final void loadModule(String string) throws Exception {
if (Nre.bootEnv.isRemote()) {
return;
}
if (this.db == null) {
throw new IllegalStateException("Can't loadModule(" + string + ") on uninitialized registry");
}
Builder.loadModule(this, string);
}
public final void unloadModule(String string) throws Exception {
if (Nre.bootEnv.isRemote()) {
return;
}
if (this.db == null) {
throw new IllegalStateException("Can't unloadModule(" + string + ") on uninitialized registry");
}
Builder.unloadModule(this, string);
}
public final void reloadModule(String string) throws Exception {
if (Nre.bootEnv.isRemote()) {
return;
}
if (this.db == null) {
throw new IllegalStateException("Can't reloadModule(" + string + ") on uninitialized registry");
}
Builder.reloadModule(this, string);
}
public final void postInit() {
if (!this.isRegistryUpToDate()) {
this.rebuild();
}
try {
this.checkNSedona();
}
catch (RegistryException registryException) {
((NRegistryTypeResolver)this.typeResolver).registryException = new RegistryException(registryException.getMessage());
this.invalidModules = new String[]{((NRegistryTypeResolver)this.typeResolver).invalidModuleName};
}
Nre.spySysManagers.add("registryManager", new Debug.SummaryPage());
}
public final String[] getInvalidModules() {
return this.invalidModules;
}
private final void checkNSedona() throws RegistryException {
Object object;
try {
((NRegistryTypeResolver)this.typeResolver).invalidModuleName = "nsedona";
object = this.getModule("nsedona");
String string = "nsedona " + object.getVendorVersion() + " not supported: ";
if (object.getVendorVersion().compareTo(new Version("1.1")) < 0) {
throw new RegistryException(string + "baja " + this.getModule("baja").getVendorVersion());
}
try {
this.getType("nsedona:DaspTunnel");
}
catch (TypeNotFoundException typeNotFoundException) {
throw new RegistryException(string + "[0]");
}
try {
this.getType("nsedona:SedonaNetwork");
throw new RegistryException(string + "[1]");
}
catch (TypeNotFoundException typeNotFoundException) {
}
}
catch (ModuleNotFoundException moduleNotFoundException) {}
object = this.getTypes();
int n = 0;
while (n < ((TypeInfo[])object).length) {
String string = object[n].getTypeClassName();
if (string.startsWith("javax.baja.sedona.driver.") || string.startsWith("com.tridium.sedona.")) {
((NRegistryTypeResolver)this.typeResolver).invalidModuleName = object[n].getModuleName();
throw new RegistryException(object[n] + ": [2]");
}
++n;
}
}
public final File dir() {
return new File(Nre.bajaHome, "registry");
}
public final File dbFile() {
return new File(this.dir(), "registry.db");
}
public final String dbRemote() {
return "/registry/registry.db";
}
public final File chkFile() {
return new File(this.dir(), "registry.chk");
}
public final File dummyFile() {
return new File(this.dir(), "no-rebuild.dummy");
}
private final /* synthetic */ void this() {
this.typeResolver = new NRegistryTypeResolver();
this.invalidModules = null;
}
public NRegistry() {
this.this();
}
/*
* Illegal identifiers - consider using --renameillegalidents true
*/
private static class NRegistryTypeResolver
extends ValueDocDecoder.BogTypeResolver {
String invalidModuleName;
RegistryException registryException;
public final BModule loadModule(ValueDocDecoder valueDocDecoder, BComplex bComplex, String string, String string2, String string3) {
if (this.registryException != null && this.invalidModuleName != null) {
String string4 = null;
try {
int n = string2.indexOf(61);
string4 = string2.substring(n + 1).trim();
}
catch (Exception exception) {
super.loadModule(valueDocDecoder, bComplex, string, string2, string3);
throw new XException("Invalid module attribute '" + string2 + '\'', ((ValueDocDecoder.BogDecoderPlugin)valueDocDecoder.getPlugin()).getXmlParser());
}
if (string4.equals(this.invalidModuleName)) {
throw this.registryException;
}
}
return super.loadModule(valueDocDecoder, bComplex, string, string2, string3);
}
private final /* synthetic */ void this() {
this.invalidModuleName = null;
this.registryException = null;
}
private NRegistryTypeResolver() {
this.this();
}
}
}
@@ -0,0 +1,284 @@
/*
* Decompiled with CFR 0.152.
*
* Could not load the following classes:
* javax.baja.nre.util.TextUtil
*/
package com.tridium.sys.registry;
import com.tridium.sys.registry.NAgentInfo;
import com.tridium.sys.registry.NAgentList;
import com.tridium.sys.registry.RegistryDatabase;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.lang.reflect.Modifier;
import javax.baja.agent.AgentInfo;
import javax.baja.agent.AgentList;
import javax.baja.agent.BIAgent;
import javax.baja.nre.util.TextUtil;
import javax.baja.registry.RegistryException;
import javax.baja.registry.TypeInfo;
import javax.baja.sys.BIcon;
import javax.baja.sys.BObject;
import javax.baja.sys.Context;
import javax.baja.sys.Sys;
import javax.baja.sys.Type;
import javax.baja.util.BTypeSpec;
import javax.baja.util.Lexicon;
/*
* Illegal identifiers - consider using --renameillegalidents true
*/
public class NTypeInfo
implements TypeInfo {
static final NTypeInfo[] noTypes = new NTypeInfo[0];
int id;
BTypeSpec typeSpec;
int modifiers;
String className;
boolean isTransientType;
NAgentInfo agentInfo;
NTypeInfo superType;
NTypeInfo[] interfaces;
NTypeInfo[] agents;
NTypeInfo[] is;
NTypeInfo[] agentOn;
Lexicon lexicon;
String friendlyTypeName;
public final String getModuleName() {
return this.typeSpec.getModuleName();
}
public final String getTypeName() {
return this.typeSpec.getTypeName();
}
public final BTypeSpec getTypeSpec() {
return this.typeSpec;
}
public final BObject getInstance() {
return this.typeSpec.getInstance();
}
public final TypeInfo getSuperType() {
return this.superType;
}
public final TypeInfo[] getInterfaces() {
return (TypeInfo[])this.interfaces.clone();
}
public final boolean isAbstract() {
return Modifier.isAbstract(this.modifiers);
}
public final boolean isFinal() {
return Modifier.isFinal(this.modifiers);
}
public final boolean isInterface() {
return Modifier.isInterface(this.modifiers);
}
public final boolean isTransient() {
return this.isTransientType;
}
public final String getTypeClassName() {
return this.className;
}
public final AgentInfo getAgentInfo() {
if (this.agentInfo == null) {
if (this.is(BIAgent.TYPE)) {
this.agentInfo = new NAgentInfo(this);
} else {
throw new RegistryException("Type \"" + this + "\" is not baja:Agent");
}
}
return this.agentInfo;
}
public final AgentList getAgents() {
NAgentList nAgentList = new NAgentList();
int n = this.is.length - 1;
while (n >= 0) {
NTypeInfo nTypeInfo = this.is[n];
NTypeInfo[] nTypeInfoArray = nTypeInfo.agents;
int n2 = 0;
while (n2 < nTypeInfoArray.length) {
nAgentList.add(nTypeInfoArray[n2].getAgentInfo());
++n2;
}
--n;
}
return nAgentList;
}
public final boolean is(TypeInfo typeInfo) {
int n = this.is.length;
int n2 = 0;
while (n2 < n) {
if (typeInfo == this.is[n2]) {
return true;
}
++n2;
}
return false;
}
public final boolean is(Type type) {
return this.is(type.getTypeInfo());
}
public final int hashCode() {
return this.toString().hashCode();
}
public final boolean equals(Object object) {
boolean bl = false;
if (this == object) {
bl = true;
}
return bl;
}
public final String toString() {
return this.typeSpec.toString(null);
}
public Lexicon getLexicon(Context context) {
if (context == null) {
if (this.lexicon == null || !this.lexicon.language.equals(Sys.getLanguage())) {
this.lexicon = Lexicon.make(this.getModuleName());
}
return this.lexicon;
}
return Lexicon.make(this.getModuleName(), context);
}
public String getDisplayName(Context context) {
String string = this.getLexicon(context).get(this.getTypeName() + ".displayName");
if (string != null) {
return string;
}
if (this.friendlyTypeName == null) {
this.friendlyTypeName = TextUtil.toFriendly((String)this.getTypeName());
}
return this.friendlyTypeName;
}
public BIcon getIcon(Context context) {
String string = this.getLexicon(context).get(this.getTypeName() + ".icon");
if (string != null) {
return BIcon.make(string);
}
TypeInfo typeInfo = this.getSuperType();
if (typeInfo != null) {
return typeInfo.getIcon(context);
}
return null;
}
void read(RegistryDatabase registryDatabase, DataInputStream dataInputStream) throws Exception {
this.typeSpec = BTypeSpec.make(dataInputStream.readUTF());
this.modifiers = dataInputStream.readUnsignedShort();
this.className = dataInputStream.readUTF();
this.superType = NTypeInfo.readType(registryDatabase, dataInputStream);
this.interfaces = NTypeInfo.readTypes(registryDatabase, dataInputStream);
this.agents = NTypeInfo.readTypes(registryDatabase, dataInputStream);
this.is = NTypeInfo.readTypes(registryDatabase, dataInputStream);
if (dataInputStream.readBoolean()) {
this.agentInfo = new NAgentInfo(this);
this.agentInfo.read(registryDatabase, dataInputStream);
}
}
void write(RegistryDatabase registryDatabase, DataOutputStream dataOutputStream) throws Exception {
dataOutputStream.writeUTF(this.typeSpec.encodeToString());
dataOutputStream.writeShort(this.modifiers);
dataOutputStream.writeUTF(this.className);
NTypeInfo.writeType(registryDatabase, dataOutputStream, this.superType);
NTypeInfo.writeTypes(registryDatabase, dataOutputStream, this.interfaces);
NTypeInfo.writeTypes(registryDatabase, dataOutputStream, this.agents);
NTypeInfo.writeTypes(registryDatabase, dataOutputStream, this.is);
if (this.agentInfo == null) {
dataOutputStream.writeBoolean(false);
} else {
dataOutputStream.writeBoolean(true);
this.agentInfo.write(registryDatabase, dataOutputStream);
}
}
static NTypeInfo readType(RegistryDatabase registryDatabase, DataInputStream dataInputStream) throws Exception {
short s = dataInputStream.readShort();
if (s < 0) {
return null;
}
return registryDatabase.types[s];
}
static void writeType(RegistryDatabase registryDatabase, DataOutputStream dataOutputStream, NTypeInfo nTypeInfo) throws Exception {
if (nTypeInfo == null) {
dataOutputStream.writeShort(-1);
} else {
dataOutputStream.writeShort(nTypeInfo.id);
}
}
static NTypeInfo[] readTypes(RegistryDatabase registryDatabase, DataInputStream dataInputStream) throws Exception {
int n = dataInputStream.readUnsignedShort();
if (n == 0) {
return noTypes;
}
NTypeInfo[] nTypeInfoArray = new NTypeInfo[n];
int n2 = 0;
while (n2 < n) {
nTypeInfoArray[n2] = registryDatabase.types[dataInputStream.readShort()];
++n2;
}
return nTypeInfoArray;
}
static void writeTypes(RegistryDatabase registryDatabase, DataOutputStream dataOutputStream, NTypeInfo[] nTypeInfoArray) throws Exception {
int n = nTypeInfoArray.length;
dataOutputStream.writeShort(n);
int n2 = 0;
while (n2 < n) {
dataOutputStream.writeShort(nTypeInfoArray[n2].id);
++n2;
}
}
static void writeAgentTypes(RegistryDatabase registryDatabase, DataOutputStream dataOutputStream, NAgentInfo[] nAgentInfoArray) throws Exception {
int n = nAgentInfoArray.length;
dataOutputStream.writeShort(n);
int n2 = 0;
while (n2 < n) {
dataOutputStream.writeShort(nAgentInfoArray[n2].typeInfo.id);
dataOutputStream.writeShort(nAgentInfoArray[n2].defaultPreferrence);
++n2;
}
}
private final /* synthetic */ void this() {
this.modifiers = 0;
this.className = null;
this.isTransientType = false;
this.agentInfo = null;
this.superType = null;
this.interfaces = noTypes;
this.agents = noTypes;
this.is = noTypes;
this.agentOn = noTypes;
}
public NTypeInfo(int n, BTypeSpec bTypeSpec) {
this.this();
this.id = n;
this.typeSpec = bTypeSpec;
}
}
@@ -0,0 +1,49 @@
/*
* Decompiled with CFR 0.152.
*
* Could not load the following classes:
* javax.baja.nre.util.TextUtil
*/
package com.tridium.sys.registry;
import javax.baja.nre.util.TextUtil;
import javax.baja.registry.TypeInfo;
import javax.baja.sys.Sys;
public class RegTool {
public static void main(String[] stringArray) {
if (stringArray.length == 0) {
RegTool.println("RegTool <cmd>:");
RegTool.println(" types <t> List types which extent t");
return;
}
String string = stringArray[0];
if (string.equals("types")) {
RegTool.types(stringArray[1]);
}
}
public static void types(String string) {
TypeInfo typeInfo = Sys.getRegistry().getType(string);
TypeInfo[] typeInfoArray = Sys.getRegistry().getTypes(typeInfo);
System.out.println("Types: " + typeInfo);
int n = 0;
while (n < typeInfoArray.length) {
TypeInfo typeInfo2 = typeInfoArray[n];
if (!typeInfo2.isAbstract()) {
System.out.print(" " + TextUtil.padRight((String)typeInfo2.toString(), (int)50));
try {
System.out.print(" " + typeInfo2.getAgentInfo().getRequiredPermissions());
}
catch (Exception exception) {}
System.out.println();
}
++n;
}
}
public static void println(String string) {
System.out.println(string);
}
}
@@ -0,0 +1,105 @@
/*
* Decompiled with CFR 0.152.
*/
package com.tridium.sys.registry;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.HashMap;
import java.util.Iterator;
import javax.baja.registry.RegistryException;
public class RegistryChecksum {
public static final long magic = 7958534986241635693L;
public static final int version = 3;
HashMap modules;
void checkUpToDate(File file) {
String string = file.getName();
if (string.endsWith(".jar")) {
string = string.substring(0, string.length() - ".jar".length());
} else if (string.endsWith(".sjar")) {
string = string.substring(0, string.length() - ".sjar".length());
} else {
return;
}
ModuleSnapshot moduleSnapshot = (ModuleSnapshot)this.modules.get(string);
if (moduleSnapshot == null) {
throw new RegistryException("Module added \"" + string + '\"');
}
if (moduleSnapshot.size != file.length() || moduleSnapshot.timestamp != file.lastModified()) {
throw new RegistryException("Module changed \"" + string + '\"');
}
this.modules.remove(string);
}
/*
* WARNING - Removed back jump from a try to a catch block - possible behaviour change.
* Enabled aggressive block sorting
* Enabled unnecessary exception pruning
* Enabled aggressive exception aggregation
*/
void read(File file) throws Exception {
DataInputStream dataInputStream = new DataInputStream(new BufferedInputStream(new FileInputStream(file)));
try {
if (dataInputStream.readLong() != 7958534986241635693L) {
throw new IOException("Invalid magic");
}
if (dataInputStream.readInt() != 3) {
throw new IOException("Invalid version");
}
int n = dataInputStream.readInt();
this.modules = new HashMap(n * 3);
int n2 = 0;
while (n2 < n) {
ModuleSnapshot moduleSnapshot = new ModuleSnapshot();
moduleSnapshot.name = dataInputStream.readUTF();
moduleSnapshot.timestamp = dataInputStream.readLong();
moduleSnapshot.size = dataInputStream.readLong();
this.modules.put(moduleSnapshot.name, moduleSnapshot);
++n2;
}
}
catch (Throwable throwable) {
Object var4_7 = null;
dataInputStream.close();
throw throwable;
}
{
Object var4_8 = null;
}
dataInputStream.close();
}
void write(File file) throws Exception {
DataOutputStream dataOutputStream = new DataOutputStream(new BufferedOutputStream(new FileOutputStream(file)));
dataOutputStream.writeLong(7958534986241635693L);
dataOutputStream.writeInt(3);
int n = this.modules.size();
dataOutputStream.writeInt(n);
Iterator iterator = this.modules.values().iterator();
while (iterator.hasNext()) {
ModuleSnapshot moduleSnapshot = (ModuleSnapshot)iterator.next();
dataOutputStream.writeUTF(moduleSnapshot.name);
dataOutputStream.writeLong(moduleSnapshot.timestamp);
dataOutputStream.writeLong(moduleSnapshot.size);
}
dataOutputStream.close();
}
static class ModuleSnapshot {
String name;
long timestamp;
long size;
ModuleSnapshot() {
}
}
}
@@ -0,0 +1,662 @@
/*
* Decompiled with CFR 0.152.
*
* Could not load the following classes:
* javax.baja.nre.util.Array
* javax.baja.nre.util.SortUtil
* javax.baja.nre.util.TextUtil
*/
package com.tridium.sys.registry;
import com.tridium.sys.Nre;
import com.tridium.sys.registry.Builder;
import com.tridium.sys.registry.NAdapterInfo;
import com.tridium.sys.registry.NAgentInfo;
import com.tridium.sys.registry.NAgentList;
import com.tridium.sys.registry.NDependencyInfo;
import com.tridium.sys.registry.NLexiconInfo;
import com.tridium.sys.registry.NModuleInfo;
import com.tridium.sys.registry.NTypeInfo;
import com.tridium.util.ArrayUtil;
import java.io.BufferedOutputStream;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import javax.baja.agent.AgentInfo;
import javax.baja.agent.AgentList;
import javax.baja.agent.BIAgent;
import javax.baja.naming.UnknownSchemeException;
import javax.baja.nre.util.Array;
import javax.baja.nre.util.SortUtil;
import javax.baja.nre.util.TextUtil;
import javax.baja.registry.LexiconInfo;
import javax.baja.registry.ModuleInfo;
import javax.baja.registry.RegistryException;
import javax.baja.registry.TypeInfo;
import javax.baja.sys.BAbsTime;
import javax.baja.sys.BFrozenEnum;
import javax.baja.sys.BModule;
import javax.baja.sys.ModuleNotFoundException;
import javax.baja.sys.Type;
import javax.baja.sys.TypeNotFoundException;
import javax.baja.util.BTypeSpec;
import javax.baja.util.Lexicon;
import javax.baja.util.Version;
/*
* Illegal identifiers - consider using --renameillegalidents true
*/
public class RegistryDatabase {
static String[] noDefs = new String[0];
public static final long magic = 7958534985112118370L;
public static final int version = 3;
NModuleInfo[] modules;
HashMap modulesByName;
NTypeInfo[] types;
HashMap typesBySpec;
HashMap defs;
String[] fileExts;
HashMap typesByFileExt;
String[] ordSchemes;
HashMap lexicons;
HashMap typesByOrdScheme;
NAdapterInfo[] adapters;
static /* synthetic */ Class class$com$tridium$sys$registry$NAgentInfo;
public ModuleInfo[] getModules() {
return (ModuleInfo[])this.modules.clone();
}
public ModuleInfo getModule(String string) {
ModuleInfo moduleInfo = (ModuleInfo)this.modulesByName.get(string);
if (moduleInfo == null) {
throw new ModuleNotFoundException(string);
}
return moduleInfo;
}
public TypeInfo[] getTypes() {
return (TypeInfo[])this.types.clone();
}
public TypeInfo[] getTypes(TypeInfo typeInfo, boolean bl) {
ArrayList<TypeInfo> arrayList = new ArrayList<TypeInfo>();
ModuleInfo[] moduleInfoArray = this.getModules();
int n = 0;
while (n < moduleInfoArray.length) {
TypeInfo[] typeInfoArray = moduleInfoArray[n].getTypes();
int n2 = 0;
while (n2 < typeInfoArray.length) {
TypeInfo typeInfo2 = typeInfoArray[n2];
if (!(bl && typeInfo2.isAbstract() || !typeInfo2.is(typeInfo))) {
arrayList.add(typeInfo2);
}
++n2;
}
++n;
}
return arrayList.toArray(new TypeInfo[arrayList.size()]);
}
public TypeInfo getType(String string) {
NTypeInfo nTypeInfo = (NTypeInfo)this.typesBySpec.get(string);
if (nTypeInfo == null) {
throw new TypeNotFoundException(string);
}
return nTypeInfo;
}
public String[] getDefs() {
return this.defs.keySet().toArray(new String[this.defs.size()]);
}
public String[] getDefs(String string) {
String[] stringArray = (String[])this.defs.get(string);
if (stringArray == null) {
return noDefs;
}
return (String[])stringArray.clone();
}
public String getDef(String string, String string2) {
String[] stringArray = (String[])this.defs.get(string);
if (stringArray == null) {
return string2;
}
return stringArray[0];
}
public AgentList getAgents(TypeInfo typeInfo) {
return typeInfo.getAgents();
}
public AgentList getSpecificAgents(TypeInfo typeInfo) {
NAgentList nAgentList = new NAgentList();
NTypeInfo[] nTypeInfoArray = ((NTypeInfo)typeInfo).agents;
int n = 0;
while (n < nTypeInfoArray.length) {
nAgentList.add(nTypeInfoArray[n].getAgentInfo());
++n;
}
return nAgentList;
}
public boolean isAgent(TypeInfo typeInfo, TypeInfo typeInfo2) {
NTypeInfo[] nTypeInfoArray = ((NTypeInfo)typeInfo2).is;
int n = nTypeInfoArray.length - 1;
while (n >= 0) {
NTypeInfo[] nTypeInfoArray2 = nTypeInfoArray[n].agents;
int n2 = 0;
while (n2 < nTypeInfoArray2.length) {
if (nTypeInfoArray2[n2].getAgentInfo().getAgentType() == typeInfo) {
return true;
}
++n2;
}
--n;
}
return false;
}
public boolean isSpecificAgent(TypeInfo typeInfo, TypeInfo typeInfo2) {
NTypeInfo[] nTypeInfoArray = ((NTypeInfo)typeInfo2).agents;
int n = 0;
while (n < nTypeInfoArray.length) {
if (nTypeInfoArray[n] == typeInfo) {
return true;
}
++n;
}
return false;
}
public TypeInfo[] getAdapters(TypeInfo typeInfo, TypeInfo typeInfo2) {
ArrayList<NTypeInfo> arrayList = new ArrayList<NTypeInfo>();
NAdapterInfo[] nAdapterInfoArray = this.adapters;
int n = nAdapterInfoArray.length;
int n2 = 0;
while (n2 < n) {
if (nAdapterInfoArray[n2].isMatch(typeInfo, typeInfo2)) {
arrayList.add(nAdapterInfoArray[n2].type);
}
++n2;
}
return arrayList.toArray(new TypeInfo[arrayList.size()]);
}
public String[] getFileExtensions() {
return (String[])this.fileExts.clone();
}
public String[] getFileExtensions(TypeInfo typeInfo) {
ArrayList<String> arrayList = new ArrayList<String>();
int n = 0;
while (n < this.fileExts.length) {
TypeInfo typeInfo2 = (TypeInfo)this.typesByFileExt.get(this.fileExts[n]);
if (typeInfo2.is(typeInfo)) {
arrayList.add(this.fileExts[n]);
}
++n;
}
return arrayList.toArray(new String[arrayList.size()]);
}
public TypeInfo getFileTypeForExtension(String string) {
NTypeInfo nTypeInfo = (NTypeInfo)this.typesByFileExt.get(TextUtil.toLowerCase((String)string));
if (nTypeInfo == null) {
return this.getType("baja:DataFile");
}
return nTypeInfo;
}
public String[] getOrdSchemes() {
return (String[])this.ordSchemes.clone();
}
public TypeInfo getOrdScheme(String string) {
NTypeInfo nTypeInfo = (NTypeInfo)this.typesByOrdScheme.get(TextUtil.toLowerCase((String)string));
if (nTypeInfo == null) {
throw new UnknownSchemeException(string);
}
return nTypeInfo;
}
public boolean isOrdScheme(String string) {
NTypeInfo nTypeInfo = (NTypeInfo)this.typesByOrdScheme.get(TextUtil.toLowerCase((String)string));
boolean bl = false;
if (nTypeInfo != null) {
bl = true;
}
return bl;
}
public LexiconInfo[] getLexicons() {
return this.lexicons.values().toArray(new LexiconInfo[this.lexicons.size()]);
}
public LexiconInfo[] getLexicons(String string) {
return this.getLexicons(string, null);
}
public LexiconInfo[] getLexicons(String string, String string2) {
ArrayList<LexiconInfo> arrayList = new ArrayList<LexiconInfo>();
Iterator iterator = this.lexicons.values().iterator();
String string3 = string2;
if (string2 == null) {
string3 = "";
}
while (iterator.hasNext()) {
LexiconInfo lexiconInfo = (LexiconInfo)iterator.next();
if (!lexiconInfo.getModuleName().equalsIgnoreCase(string) || !lexiconInfo.getLanguage().equalsIgnoreCase(string3)) continue;
arrayList.add(lexiconInfo);
}
return arrayList.toArray(new LexiconInfo[arrayList.size()]);
}
public LexiconInfo getLexicon(String string, String string2, String string3) {
LexiconInfo lexiconInfo;
String string4 = string;
if (string2 != null && string2.length() > 0) {
string4 = string + '-' + string2;
}
if ((lexiconInfo = (LexiconInfo)this.lexicons.get(string4 = string4 + '-' + string3)) == null) {
throw new RegistryException("Unknown lexicon" + string4);
}
return lexiconInfo;
}
void read(InputStream inputStream) throws Exception {
DataInputStream dataInputStream = new DataInputStream(inputStream);
this.readHeader(dataInputStream);
this.readModules(dataInputStream);
this.readTypes(dataInputStream);
this.readDefs(dataInputStream);
this.readFileExts(dataInputStream);
this.readOrdSchemes(dataInputStream);
this.readLexicons(dataInputStream);
this.readAdapters(dataInputStream);
dataInputStream.close();
}
void readHeader(DataInputStream dataInputStream) throws Exception {
if (dataInputStream.readLong() != 7958534985112118370L) {
throw new IOException("Invalid magic");
}
if (dataInputStream.readInt() != 3) {
throw new IOException("Invalid version");
}
int n = dataInputStream.readInt();
this.modules = new NModuleInfo[n];
this.modulesByName = new HashMap(n * 3);
int n2 = 0;
while (n2 < n) {
this.modules[n2] = new NModuleInfo(n2);
++n2;
}
n2 = dataInputStream.readInt();
this.types = new NTypeInfo[n2];
this.typesBySpec = new HashMap(n2 * 3);
int n3 = 0;
while (n3 < n2) {
this.types[n3] = new NTypeInfo(n3, null);
++n3;
}
}
void readModules(DataInputStream dataInputStream) throws Exception {
int n = 0;
while (n < this.modules.length) {
NModuleInfo nModuleInfo = this.modules[n];
nModuleInfo.read(this, dataInputStream);
this.modulesByName.put(nModuleInfo.moduleName, nModuleInfo);
++n;
}
}
void readTypes(DataInputStream dataInputStream) throws Exception {
Array array;
NTypeInfo[] nTypeInfoArray;
NTypeInfo nTypeInfo;
int n = 0;
while (n < this.types.length) {
NTypeInfo nTypeInfo2 = this.types[n];
nTypeInfo2.read(this, dataInputStream);
this.typesBySpec.put(nTypeInfo2.toString(), nTypeInfo2);
++n;
}
HashMap<NTypeInfo[], Array> hashMap = new HashMap<NTypeInfo[], Array>();
int n2 = 0;
while (n2 < this.types.length) {
nTypeInfo = this.types[n2];
int n3 = 0;
while (n3 < nTypeInfo.agents.length) {
nTypeInfoArray = nTypeInfo.agents[n3];
array = (Array)hashMap.get(nTypeInfoArray);
if (array == null) {
Class clazz = class$com$tridium$sys$registry$NAgentInfo;
if (clazz == null) {
clazz = RegistryDatabase.class("[Lcom.tridium.sys.registry.NAgentInfo;", false);
}
array = new Array(clazz);
hashMap.put(nTypeInfoArray, array);
}
array.add((Object)new NAgentInfo(nTypeInfo));
++n3;
}
++n2;
}
Iterator iterator = hashMap.keySet().iterator();
while (iterator.hasNext()) {
nTypeInfo = (NTypeInfo)iterator.next();
Array array2 = (Array)hashMap.get(nTypeInfo);
nTypeInfoArray = new NTypeInfo[array2.size()];
array = (Array)array2.trim();
int n4 = 0;
while (n4 < ((NAgentInfo[])array).length) {
nTypeInfoArray[n4] = (NTypeInfo)array[n4].getTypeInfo();
++n4;
}
nTypeInfo.agentOn = nTypeInfoArray;
}
}
void readDefs(DataInputStream dataInputStream) throws Exception {
int n = dataInputStream.readInt();
this.defs = new HashMap(n * 3);
int n2 = 0;
while (n2 < n) {
String string = dataInputStream.readUTF();
int n3 = dataInputStream.readUnsignedByte();
String[] stringArray = new String[n3];
int n4 = 0;
while (n4 < n3) {
stringArray[n4] = dataInputStream.readUTF();
++n4;
}
this.defs.put(string, stringArray);
++n2;
}
}
void readFileExts(DataInputStream dataInputStream) throws Exception {
int n = dataInputStream.readUnsignedShort();
this.fileExts = new String[n];
this.typesByFileExt = new HashMap(n * 3);
int n2 = 0;
while (n2 < n) {
String string;
this.fileExts[n2] = string = dataInputStream.readUTF();
this.typesByFileExt.put(string, this.types[dataInputStream.readUnsignedShort()]);
++n2;
}
}
void readOrdSchemes(DataInputStream dataInputStream) throws Exception {
int n = dataInputStream.readUnsignedShort();
this.ordSchemes = new String[n];
this.typesByOrdScheme = new HashMap(n * 3);
int n2 = 0;
while (n2 < n) {
String string;
this.ordSchemes[n2] = string = dataInputStream.readUTF();
this.typesByOrdScheme.put(string, this.types[dataInputStream.readUnsignedShort()]);
++n2;
}
}
void readLexicons(DataInputStream dataInputStream) throws Exception {
int n = dataInputStream.readInt();
this.lexicons = new HashMap(n * 3);
int n2 = 0;
while (n2 < n) {
NLexiconInfo nLexiconInfo = new NLexiconInfo();
nLexiconInfo.read(dataInputStream);
String string = nLexiconInfo.getModuleName();
String string2 = nLexiconInfo.getLanguage();
String string3 = nLexiconInfo.getContainerModuleName();
if (string2 != null && string2.length() > 0) {
string = string + '-' + string2;
}
string = string + '-' + string3;
this.lexicons.put(string, nLexiconInfo);
++n2;
}
}
void readAdapters(DataInputStream dataInputStream) throws Exception {
int n = dataInputStream.readUnsignedShort();
this.adapters = new NAdapterInfo[n];
int n2 = 0;
while (n2 < n) {
this.adapters[n2] = new NAdapterInfo();
this.adapters[n2].read(this, dataInputStream);
++n2;
}
}
public BModule synthesizeModule(String string, Version version, String string2, Version version2, String string3) {
if (this.modulesByName.containsKey(string)) {
throw new RegistryException("Duplicate module name: " + string);
}
NModuleInfo nModuleInfo = new NModuleInfo(-1);
nModuleInfo.moduleName = string;
nModuleInfo.bajaVersion = version;
nModuleInfo.vendor = string2;
nModuleInfo.vendorVersion = version2;
nModuleInfo.description = string3;
nModuleInfo.hasPalette = false;
nModuleInfo.buildTime = BAbsTime.now().getMillis();
nModuleInfo.types = NTypeInfo.noTypes;
nModuleInfo.moduleContent = "doc";
nModuleInfo.depends = new NDependencyInfo[0];
nModuleInfo.isTransientModule = true;
this.modulesByName.put(nModuleInfo.moduleName, nModuleInfo);
this.modules = (NModuleInfo[])ArrayUtil.addOne(this.modules, nModuleInfo);
SortUtil.sort((Object[])this.modules);
return Nre.moduleManager.synthesizeModule(nModuleInfo).bmodule();
}
public Type synthesizeType(BTypeSpec bTypeSpec, String string, TypeInfo typeInfo, TypeInfo[] typeInfoArray, AgentInfo[] agentInfoArray, boolean bl, boolean bl2) {
if (this.typesBySpec.get(bTypeSpec.toString()) != null) {
throw new RegistryException("Type already exists: " + bTypeSpec);
}
if (!this.modulesByName.containsKey(bTypeSpec.getModuleName())) {
throw new RegistryException("Module does not exist: " + bTypeSpec.getModuleName());
}
if (!string.startsWith("auto.")) {
throw new IllegalArgumentException("Class package must start with 'auto.'.");
}
if (!string.endsWith(".B" + bTypeSpec.getTypeName())) {
throw new IllegalArgumentException("TypeSpec does not match class name.");
}
if (typeInfo.is(BFrozenEnum.TYPE) && !bl2) {
throw new IllegalArgumentException("Frozen enumerations must be declared final.");
}
NTypeInfo nTypeInfo = new NTypeInfo(-1, bTypeSpec);
nTypeInfo.superType = (NTypeInfo)typeInfo;
nTypeInfo.lexicon = Lexicon.make("baja");
nTypeInfo.className = string;
nTypeInfo.isTransientType = true;
boolean bl3 = false;
NTypeInfo[] nTypeInfoArray = new NTypeInfo[typeInfoArray.length];
int n = 0;
while (n < typeInfoArray.length) {
nTypeInfoArray[n] = (NTypeInfo)typeInfoArray[n];
if (typeInfoArray[n].is(BIAgent.TYPE)) {
bl3 = true;
}
++n;
}
nTypeInfo.interfaces = nTypeInfoArray;
if (agentInfoArray.length > 0 && !bl3) {
throw new RegistryException("Type is an agent on other types, but does not implement BIAgent.");
}
NTypeInfo[] nTypeInfoArray2 = new NTypeInfo[agentInfoArray.length];
int n2 = 0;
while (n2 < agentInfoArray.length) {
nTypeInfoArray2[n2] = (NTypeInfo)agentInfoArray[n2].getAgentType();
++n2;
}
nTypeInfo.agentOn = nTypeInfoArray2;
n2 = 0;
while (n2 < nTypeInfo.agentOn.length) {
ArrayUtil.addOne(nTypeInfo.agentOn[n2].agents, nTypeInfo);
++n2;
}
n2 = 1;
if (bl) {
n2 |= 0x400;
}
if (bl2) {
n2 |= 0x10;
}
nTypeInfo.modifiers = n2;
Object object = new Builder.IsMap();
NTypeInfo nTypeInfo2 = nTypeInfo;
while (nTypeInfo2 != null) {
((Builder.IsMap)object).add(nTypeInfo2);
nTypeInfo2 = nTypeInfo2.superType;
}
nTypeInfo2 = nTypeInfo;
while (nTypeInfo2 != null) {
this.mapInterfaces((Builder.IsMap)object, nTypeInfo2);
nTypeInfo2 = nTypeInfo2.superType;
}
nTypeInfo.is = ((Builder.IsMap)object).toArray();
this.types = (NTypeInfo[])ArrayUtil.addOne(this.types, nTypeInfo);
this.typesBySpec.put(nTypeInfo.toString(), nTypeInfo);
object = (NModuleInfo)this.modulesByName.get(bTypeSpec.getModuleName());
((NModuleInfo)object).types = (NTypeInfo[])ArrayUtil.addOne(((NModuleInfo)object).types, nTypeInfo);
Nre.moduleManager.synthesizeType(bTypeSpec, string, typeInfo, typeInfoArray, bl, bl2);
return bTypeSpec.getResolvedType();
}
private final void mapInterfaces(Builder.IsMap isMap, NTypeInfo nTypeInfo) {
if (nTypeInfo.isInterface()) {
isMap.add(nTypeInfo);
}
int n = 0;
while (n < nTypeInfo.interfaces.length) {
this.mapInterfaces(isMap, nTypeInfo.interfaces[n]);
++n;
}
}
void write(File file) throws Exception {
DataOutputStream dataOutputStream = new DataOutputStream(new BufferedOutputStream(new FileOutputStream(file)));
this.writeHeader(dataOutputStream);
this.writeModules(dataOutputStream);
this.writeTypes(dataOutputStream);
this.writeDefs(dataOutputStream);
this.writeFileExts(dataOutputStream);
this.writeOrdSchemes(dataOutputStream);
this.writeLexicons(dataOutputStream);
this.writeAdapters(dataOutputStream);
dataOutputStream.close();
}
void writeHeader(DataOutputStream dataOutputStream) throws Exception {
dataOutputStream.writeLong(7958534985112118370L);
dataOutputStream.writeInt(3);
dataOutputStream.writeInt(this.modules.length);
dataOutputStream.writeInt(this.types.length);
}
void writeModules(DataOutputStream dataOutputStream) throws Exception {
int n = 0;
while (n < this.modules.length) {
this.modules[n].write(this, dataOutputStream);
++n;
}
}
void writeTypes(DataOutputStream dataOutputStream) throws Exception {
int n = 0;
while (n < this.types.length) {
this.types[n].write(this, dataOutputStream);
++n;
}
}
void writeDefs(DataOutputStream dataOutputStream) throws Exception {
dataOutputStream.writeInt(this.defs.size());
Iterator iterator = this.defs.keySet().iterator();
while (iterator.hasNext()) {
String string = (String)iterator.next();
String[] stringArray = (String[])this.defs.get(string);
dataOutputStream.writeUTF(string);
dataOutputStream.write(stringArray.length);
int n = 0;
while (n < stringArray.length) {
dataOutputStream.writeUTF(stringArray[n]);
++n;
}
}
}
void writeFileExts(DataOutputStream dataOutputStream) throws Exception {
int n = this.fileExts.length;
dataOutputStream.writeShort(n);
int n2 = 0;
while (n2 < n) {
String string = this.fileExts[n2];
NTypeInfo nTypeInfo = (NTypeInfo)this.typesByFileExt.get(string);
dataOutputStream.writeUTF(string);
dataOutputStream.writeShort(nTypeInfo.id);
++n2;
}
}
void writeOrdSchemes(DataOutputStream dataOutputStream) throws Exception {
int n = this.ordSchemes.length;
dataOutputStream.writeShort(n);
int n2 = 0;
while (n2 < n) {
String string = this.ordSchemes[n2];
NTypeInfo nTypeInfo = (NTypeInfo)this.typesByOrdScheme.get(string);
dataOutputStream.writeUTF(string);
dataOutputStream.writeShort(nTypeInfo.id);
++n2;
}
}
void writeLexicons(DataOutputStream dataOutputStream) throws Exception {
dataOutputStream.writeInt(this.lexicons.size());
Iterator iterator = this.lexicons.keySet().iterator();
while (iterator.hasNext()) {
String string = (String)iterator.next();
NLexiconInfo nLexiconInfo = (NLexiconInfo)this.lexicons.get(string);
nLexiconInfo.write(dataOutputStream);
}
}
void writeAdapters(DataOutputStream dataOutputStream) throws Exception {
int n = this.adapters.length;
dataOutputStream.writeShort(n);
int n2 = 0;
while (n2 < n) {
this.adapters[n2].write(this, dataOutputStream);
++n2;
}
}
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());
}
}
}
@@ -0,0 +1,228 @@
/*
* Decompiled with CFR 0.152.
*/
package com.tridium.sys.resource;
import com.tridium.sys.BIPlatform;
import com.tridium.sys.Nre;
import com.tridium.sys.metrics.Metrics;
import com.tridium.sys.resource.ResourceReport;
import com.tridium.sys.station.Station;
import com.tridium.util.ArrayUtil;
import javax.baja.license.Feature;
import javax.baja.log.Log;
import javax.baja.spy.Spy;
import javax.baja.spy.SpyWriter;
import javax.baja.sys.BAbsTime;
import javax.baja.sys.BRelTime;
import javax.baja.sys.Clock;
import javax.baja.sys.Sys;
/*
* Illegal identifiers - consider using --renameillegalidents true
*/
public class ResourceManager
extends Thread {
static final Log log = Log.getLog("sys.resource");
static final int NUM_READINGS = 60;
boolean isAlive;
long startTicks;
BAbsTime startTime;
Object lock;
int[] cpu;
int[] mem;
int reading;
ResourceReport snapshot;
long updateTime;
int ruLimit;
/*
* WARNING - Removed try catching itself - possible behaviour change.
* Enabled aggressive block sorting
* Enabled unnecessary exception pruning
* Enabled aggressive exception aggregation
*/
public ResourceReport report() {
Object object = this.lock;
synchronized (object) {
ResourceReport resourceReport = (ResourceReport)this.snapshot.clone();
resourceReport.cpu = ArrayUtil.orderCircular(this.cpu, this.reading);
resourceReport.mem = ArrayUtil.orderCircular(this.mem, this.reading);
resourceReport.put("heap.used", ResourceReport.memstr(resourceReport.mem[59]));
resourceReport.put("cpu.usage", "" + resourceReport.cpu[59] + '%');
Nre.engineManager.reportResources(resourceReport);
long l = Clock.ticks() - this.startTicks;
l -= l % 1000L;
resourceReport.put("time.uptime", BRelTime.toString(l));
resourceReport.put("time.start", this.startTime.toString());
resourceReport.put("time.current", Clock.time().toString());
return resourceReport;
}
}
public BAbsTime getStartTime() {
return this.startTime;
}
public Station.Message report(Station.Message message) throws Exception {
return new Station.Message(message.id, this.report().encode());
}
/*
* WARNING - Removed try catching itself - possible behaviour change.
* Enabled aggressive block sorting
* Enabled unnecessary exception pruning
* Enabled aggressive exception aggregation
*/
public void update() {
long l = Clock.ticks();
ResourceReport resourceReport = new ResourceReport();
resourceReport.generate(this);
Object object = this.lock;
synchronized (object) {
this.snapshot = resourceReport;
}
long l2 = Clock.ticks();
this.updateTime = l2 - l;
String string = this.snapshot.platStationFault();
if (string != null) {
Station.setStationFault(string);
return;
}
if (this.ruLimit >= 0 && this.snapshot.ruTotal() >= this.ruLimit) {
Station.setStationFault("stationFault.resourceLimit");
return;
}
Station.setStationFault(null);
}
public void checkLicense(Feature feature) {
if (Metrics.isUsingCapacityLicensing()) {
return;
}
String string = feature.get("resource.limit", null);
if (string == null || string.equalsIgnoreCase("none")) {
return;
}
this.ruLimit = Integer.parseInt(string) * 1000;
this.update();
int n = this.snapshot.ruTotal();
String string2 = ResourceReport.rustr(n);
String string3 = ResourceReport.rustr(this.ruLimit);
log.message("Resource license used=" + string2 + " limit=" + string3);
if (n > this.ruLimit) {
System.out.println("#####################################################################");
System.out.println("# STATION IS UNLICENSED!!!");
System.out.println("# Licensed resource units exceeded.");
System.out.println("# Used = " + string2 + " > Limit = " + string3);
System.out.println("#####################################################################");
if ((double)n >= (double)this.ruLimit * 1.1) {
System.exit(-3);
}
}
}
public void kill() {
this.isAlive = false;
this.interrupt();
}
/*
* WARNING - Removed try catching itself - possible behaviour change.
* Enabled aggressive block sorting
* Enabled unnecessary exception pruning
* Enabled aggressive exception aggregation
*/
public void run() {
BIPlatform bIPlatform = Nre.getPlatform();
long l = 0L;
while (this.isAlive) {
try {
Thread.sleep(1000L);
bIPlatform.poll();
long l2 = Runtime.getRuntime().totalMemory() / 1024L - Runtime.getRuntime().freeMemory() / 1024L;
Object object = this.lock;
synchronized (object) {
this.cpu[this.reading] = ResourceManager.cap(bIPlatform.getCpuUsage(), 0, 100);
this.mem[this.reading] = ResourceManager.cap((int)l2, 0, Integer.MAX_VALUE);
this.reading = (this.reading + 1) % 60;
}
if (Clock.ticks() - l <= 60000L) continue;
this.update();
l = Clock.ticks();
}
catch (InterruptedException interruptedException) {
}
catch (Throwable throwable) {
throwable.printStackTrace();
}
}
}
public void postInit() {
Nre.spySysManagers.add("resourceManager", new Page());
}
public static int cap(int n, int n2, int n3) {
if (n < n2) {
return n2;
}
if (n > n3) {
return n3;
}
return n;
}
private final /* synthetic */ void this() {
this.isAlive = true;
this.startTicks = Clock.ticks();
this.startTime = Clock.time();
this.lock = new Object();
this.cpu = new int[60];
this.mem = new int[60];
this.reading = 0;
this.ruLimit = -1;
}
public ResourceManager() {
super("Nre:ResourceManager");
this.this();
this.setDaemon(true);
this.setPriority(this.getPriority() - 1);
this.snapshot = new ResourceReport();
}
/*
* Illegal identifiers - consider using --renameillegalidents true
*/
public class Page
extends Spy {
public void write(SpyWriter spyWriter) throws Exception {
if (Sys.getStation() == null) {
spyWriter.print("VM is not a station");
return;
}
if (Metrics.isUsingCapacityLicensing()) {
spyWriter.print("<pre>");
spyWriter.println("Detected Capacity Licensing, ignoring resource limit.");
spyWriter.print("</pre>");
}
spyWriter.startProps("Resource Manager Stats");
spyWriter.prop((Object)"updateTime", BRelTime.toString(ResourceManager.this.updateTime));
spyWriter.prop((Object)"ruLimit", ResourceManager.this.ruLimit);
spyWriter.prop((Object)"snapshot.ruLimit", "" + ResourceManager.this.snapshot.ruLimit());
spyWriter.prop((Object)"snapshot.ruTotal", "" + ResourceManager.this.snapshot.ruTotal());
spyWriter.prop((Object)"snapshot.ruDefault", "" + ResourceManager.this.snapshot.ruDefault());
spyWriter.endProps();
ResourceReport resourceReport = ResourceManager.this.report();
spyWriter.startTable(true);
int n = 0;
while (n < resourceReport.cpu.length) {
spyWriter.tr("" + resourceReport.cpu[n] + '%', resourceReport.mem[n] + "kb");
++n;
}
spyWriter.endTable();
}
}
}
@@ -0,0 +1,291 @@
/*
* Decompiled with CFR 0.152.
*
* Could not load the following classes:
* javax.baja.nre.util.ByteBuffer
*/
package com.tridium.sys.resource;
import com.tridium.sys.BIPlatform;
import com.tridium.sys.Nre;
import com.tridium.sys.metrics.Metrics;
import com.tridium.sys.resource.ResourceManager;
import java.io.IOException;
import java.text.DecimalFormat;
import java.util.HashMap;
import javax.baja.nre.util.ByteBuffer;
import javax.baja.sys.BComplex;
import javax.baja.sys.BComponent;
import javax.baja.sys.BObject;
import javax.baja.sys.Property;
import javax.baja.sys.SlotCursor;
import javax.baja.sys.Sys;
public class ResourceReport
implements Cloneable {
static DecimalFormat ruFormat = new DecimalFormat("#,##0.000 kRU");
int[] cpu;
int[] mem;
private int totalMem;
private int ruLimit;
private int ruTotal;
private int ruDefault;
private HashMap ru = new HashMap();
private HashMap props = new HashMap();
private int numComps;
private String platStationFault;
public int[] cpu() {
return this.cpu;
}
public int[] mem() {
return this.mem;
}
public int totalMem() {
return this.totalMem;
}
public String platStationFault() {
return this.platStationFault;
}
public int ruLimit() {
return this.ruLimit;
}
public int ruTotal() {
return this.ruTotal;
}
public int ruDefault() {
return this.ruDefault;
}
public String[] ruCategories() {
return this.ru.keySet().toArray(new String[this.ru.size()]);
}
public int ru(String string) {
Category category = (Category)this.ru.get(string);
int n = 0;
if (category != null) {
n = category.usage;
}
return n;
}
public String[] props() {
return this.props.keySet().toArray(new String[this.props.size()]);
}
public String prop(String string) {
return (String)this.props.get(string);
}
public final void add(int n) {
this.ruTotal += n;
this.ruDefault += n;
}
public final void add(String string, int n) {
this.ruTotal += n;
Category category = (Category)this.ru.get(string);
if (category == null) {
category = new Category(string);
this.ru.put(string, category);
}
category.usage += n;
}
public final void put(String string, String string2) {
this.props.put(string, string2);
}
void generate(ResourceManager resourceManager) {
BIPlatform bIPlatform = Nre.getPlatform();
this.totalMem = bIPlatform.getTotalMemory();
this.ruLimit = resourceManager.ruLimit;
this.computeResourceUnits(Sys.getStation());
this.put("resources.total", ResourceReport.rustr(this.ruTotal));
this.put("resources.limit", this.ruLimit < 0 ? "none" : ResourceReport.rustr(this.ruLimit));
this.put("resources.category.component", ResourceReport.rustr(this.ruDefault));
String[] stringArray = this.ruCategories();
int n = 0;
while (n < stringArray.length) {
this.put("resources.category." + stringArray[n], ResourceReport.rustr(this.ru(stringArray[n])));
++n;
}
this.put("mem.used", ResourceReport.memstr(bIPlatform.getMemoryUsage()));
this.put("mem.total", ResourceReport.memstr(this.totalMem));
long l = Runtime.getRuntime().totalMemory() / 1024L;
long l2 = Runtime.getRuntime().freeMemory() / 1024L;
this.put("heap.total", ResourceReport.memstr(l));
this.put("heap.free", ResourceReport.memstr(l2));
String string = System.getProperty("platform.maxHeap");
if (string != null) {
long l3 = 0L;
l3 = string.endsWith("M") ? (long)(Integer.parseInt(string.substring(0, string.length() - 1)) * 1024) : (string.endsWith("K") ? (long)Integer.parseInt(string.substring(0, string.length() - 1)) : 0L);
this.put("heap.max", ResourceReport.memstr(l3));
}
this.put("component.count", "" + Sys.getStation().getComponentSpace().getComponentCount());
this.put("version.niagara", "" + Sys.getBajaModule().getVendorVersion());
this.put("version.java", System.getProperty("java.vm.name") + ' ' + System.getProperty("java.vm.version"));
this.put("version.os", System.getProperty("os.arch") + ' ' + System.getProperty("os.name") + ' ' + System.getProperty("os.version"));
if (Metrics.isUsingCapacityLicensing()) {
Metrics.writeToResourceReport(this);
}
this.platStationFault = bIPlatform.checkForStationFault();
bIPlatform.queryResources(this);
}
private final void computeResourceUnits(BObject bObject) {
this.add(1);
try {
bObject.fw(21, this, null, null, null);
}
catch (Exception exception) {
System.out.println("ERROR: ResourceReport on " + bObject.getType() + ": " + exception);
}
if (!(bObject instanceof BComplex)) {
return;
}
BComplex bComplex = (BComplex)bObject;
if (bComplex instanceof BComponent) {
this.add(20);
}
SlotCursor slotCursor = bComplex.getProperties();
while (slotCursor.next()) {
try {
Property property = slotCursor.property();
if (property.getTypeAccess() != 7) {
this.add(1);
continue;
}
this.computeResourceUnits(slotCursor.get());
}
catch (Exception exception) {
System.out.println("ERROR: ResourceReport: " + exception);
}
}
}
public static String memstr(long l) {
if (l < 1024L) {
return l + " KB";
}
return l / 1024L + " MB";
}
public static String rustr(int n) {
return ruFormat.format((double)n / 1000.0);
}
public Object clone() {
try {
return super.clone();
}
catch (Exception exception) {
throw new IllegalStateException();
}
}
public byte[] encode() throws Exception {
ByteBuffer byteBuffer = new ByteBuffer(1024);
int n = this.cpu.length;
byteBuffer.writeUTF("startReport");
byteBuffer.writeInt(1);
byteBuffer.writeUTF("");
byteBuffer.writeInt(this.totalMem);
byteBuffer.writeInt(this.ruLimit);
byteBuffer.writeInt(this.ruTotal);
byteBuffer.writeInt(this.ruDefault);
String[] stringArray = this.ruCategories();
byteBuffer.writeInt(this.ru.size());
int n2 = 0;
while (n2 < stringArray.length) {
byteBuffer.writeUTF(stringArray[n2]);
byteBuffer.writeInt(this.ru(stringArray[n2]));
++n2;
}
byteBuffer.writeInt(n);
n2 = 0;
while (n2 < n) {
byteBuffer.writeByte(this.cpu[n2]);
byteBuffer.writeInt(this.mem[n2]);
++n2;
}
String[] stringArray2 = this.props();
byteBuffer.writeInt(stringArray2.length);
int n3 = 0;
while (n3 < stringArray2.length) {
byteBuffer.writeUTF(stringArray2[n3]);
byteBuffer.writeUTF(this.prop(stringArray2[n3]));
++n3;
}
byteBuffer.writeUTF("endReport");
return byteBuffer.toByteArray();
}
public static ResourceReport decode(byte[] byArray) throws Exception {
int n;
ByteBuffer byteBuffer = new ByteBuffer(byArray);
ResourceReport resourceReport = new ResourceReport();
if (!byteBuffer.readUTF().equals("startReport")) {
throw new IOException();
}
if (byteBuffer.readInt() != 1) {
throw new IOException();
}
byteBuffer.readUTF();
resourceReport.totalMem = byteBuffer.readInt();
resourceReport.ruLimit = byteBuffer.readInt();
resourceReport.ruTotal = byteBuffer.readInt();
resourceReport.ruDefault = byteBuffer.readInt();
int n2 = byteBuffer.readInt();
int n3 = 0;
while (n3 < n2) {
String string = byteBuffer.readUTF();
n = byteBuffer.readInt();
resourceReport.ru.put(string, new Category(string, n));
++n3;
}
n3 = byteBuffer.readInt();
resourceReport.cpu = new int[n3];
resourceReport.mem = new int[n3];
int n4 = 0;
while (n4 < n3) {
resourceReport.cpu[n4] = byteBuffer.readByte();
resourceReport.mem[n4] = byteBuffer.readInt();
++n4;
}
n4 = byteBuffer.readInt();
n = 0;
while (n < n4) {
String string = byteBuffer.readUTF();
String string2 = byteBuffer.readUTF();
resourceReport.props.put(string, string2);
++n;
}
if (!byteBuffer.readUTF().equals("endReport")) {
throw new IOException();
}
return resourceReport;
}
static class Category {
String key;
int usage;
Category(String string) {
this.key = string;
}
Category(String string, int n) {
this.key = string;
this.usage = n;
}
}
}
@@ -0,0 +1,130 @@
/*
* Decompiled with CFR 0.152.
*/
package com.tridium.sys.schema;
import com.tridium.sys.schema.DynamicTable;
import com.tridium.sys.schema.NAction;
import javax.baja.sys.Action;
import javax.baja.sys.BComplex;
import javax.baja.sys.BObject;
import javax.baja.sys.Context;
import javax.baja.sys.CursorException;
import javax.baja.sys.Property;
import javax.baja.sys.Slot;
import javax.baja.sys.SlotCursor;
import javax.baja.sys.Topic;
final class ActionCursor
implements SlotCursor {
private int index = -1;
private BComplex object;
private NAction[] frozen;
private DynamicTable dynamic;
public final BObject target() {
return this.object;
}
public final Context getContext() {
return null;
}
/*
* Unable to fully structure code
*/
public final boolean next() {
if (++this.index < this.frozen.length) {
return true;
}
if (this.dynamic != null) ** GOTO lbl8
return false;
lbl-1000:
// 1 sources
{
if (this.dynamic.slots[this.index - this.frozen.length].isAction()) {
return true;
}
++this.index;
lbl8:
// 2 sources
** while (this.index - this.frozen.length < this.dynamic.count)
}
lbl9:
// 1 sources
return false;
}
public final boolean nextObject() {
throw new CursorException("Only for iterating through properties");
}
public final boolean nextComponent() {
throw new CursorException("Only for iterating through properties");
}
public final boolean next(Class clazz) {
throw new CursorException("Only for iterating through properties");
}
public final Slot slot() {
if (this.index < this.frozen.length) {
return this.frozen[this.index];
}
return this.dynamic.slots[this.index - this.frozen.length];
}
public final Action action() {
return this.slot().asAction();
}
public final Property property() {
throw new CursorException("not property");
}
public final int getTypeAccess() {
throw new CursorException("not property");
}
public final BObject get() {
throw new CursorException("not property");
}
public final boolean getBoolean() {
throw new CursorException("not property");
}
public final int getInt() {
throw new CursorException("not property");
}
public final long getLong() {
throw new CursorException("not property");
}
public final float getFloat() {
throw new CursorException("not property");
}
public final double getDouble() {
throw new CursorException("not property");
}
public final String getString() {
throw new CursorException("not property");
}
public final Topic topic() {
throw new CursorException("not topic");
}
ActionCursor(BComplex bComplex, NAction[] nActionArray, DynamicTable dynamicTable) {
this.object = bComplex;
this.frozen = nActionArray;
this.dynamic = dynamicTable;
}
}
@@ -0,0 +1,762 @@
/*
* Decompiled with CFR 0.152.
*
* Could not load the following classes:
* javax.baja.nre.util.TextUtil
*/
package com.tridium.sys.schema;
import com.tridium.asm.Assembler;
import com.tridium.asm.AttributeInfo;
import com.tridium.asm.Buffer;
import com.tridium.asm.Code;
import com.tridium.asm.ConstantPool;
import com.tridium.asm.FieldInfo;
import com.tridium.asm.Jvm;
import com.tridium.asm.MethodInfo;
import com.tridium.asm.OpCodes;
import com.tridium.sys.schema.NAction;
import com.tridium.sys.schema.NProperty;
import com.tridium.sys.schema.NSlot;
import javax.baja.nre.util.TextUtil;
/*
* Illegal identifiers - consider using --renameillegalidents true
*/
class Compiler
implements OpCodes {
int init;
int exceptionCls;
int exceptionCtor;
int npropCls;
int npropGetDef;
int bbooleanCls;
int bintegerCls;
int blongCls;
int bfloatCls;
int bdoubleCls;
int bstringCls;
int bbooleanMake;
int bintegerMake;
int blongMake;
int bfloatMake;
int bdoubleMake;
int bstringMake;
int getBoolean;
int getInt;
int getLong;
int getFloat;
int getDouble;
int getString;
SwitchCode g;
SwitchCode s;
SwitchCode gb;
SwitchCode sb;
SwitchCode gi;
SwitchCode si;
SwitchCode gj;
SwitchCode sj;
SwitchCode gf;
SwitchCode sf;
SwitchCode gd;
SwitchCode sd;
SwitchCode gs;
SwitchCode ss;
SwitchCode invoke;
Assembler asm;
ConstantPool cp;
int complexClass;
NSlot[] slots;
int[] propFields;
Buffer compile() {
this.genFields();
this.genConstructor();
this.genNewSlotMapInstance();
this.genNewBComplexInstance();
this.genAccessors();
this.addAccessors();
this.asm.addAttribute(new AttributeInfo(this.asm, "SourceFile", "AutoGenerated"));
return this.asm.compile();
}
private final void genFields() {
int n = 2;
this.propFields = new int[this.slots.length];
int n2 = 0;
while (n2 < this.slots.length) {
if (this.slots[n2].isProperty()) {
NProperty nProperty = (NProperty)this.slots[n2];
String string = "p" + n2;
String string2 = null;
switch (nProperty.typeAccess) {
case 0: {
string2 = "Z";
break;
}
case 2: {
string2 = "I";
break;
}
case 3: {
string2 = "J";
break;
}
case 4: {
string2 = "F";
break;
}
case 5: {
string2 = "D";
break;
}
case 6: {
string2 = "Ljava/lang/String;";
break;
}
case 7: {
string2 = "Ljavax/baja/sys/BValue;";
break;
}
default: {
throw new IllegalStateException();
}
}
FieldInfo fieldInfo = new FieldInfo(this.asm, "p" + n2, string2, n);
this.asm.addField(fieldInfo);
this.propFields[n2] = this.cp.field(fieldInfo);
}
++n2;
}
}
private final void genConstructor() {
Code code = new Code(this.asm);
code.add(42);
code.add(183, code.cp.method(this.asm.superClass, this.init(), "()V"));
code.add(177);
this.asm.addMethod(new MethodInfo(this.asm, this.init(), "()V", 1, code));
}
private final void genNewSlotMapInstance() {
int n = this.cp.method(this.asm.thisClass, this.init(), "()V");
Code code = new Code(this.asm);
code.add(187, this.asm.thisClass);
code.add(89);
code.add(183, n);
code.add(176);
this.asm.addMethod(new MethodInfo(this.asm, "newSlotMapInstance", "()Lcom/tridium/sys/schema/ComplexSlotMap;", 1, code));
}
private final void genNewBComplexInstance() {
int n = this.cp.method(this.complexClass, this.init(), "()V");
Code code = new Code(this.asm);
code.add(187, this.complexClass);
code.add(89);
code.add(183, n);
code.add(176);
this.asm.addMethod(new MethodInfo(this.asm, "newBComplexInstance", "()Ljavax/baja/sys/BComplex;", 1, code));
}
private final void genAccessors() {
int n = 0;
while (n < this.slots.length) {
NSlot nSlot = this.slots[n];
if (!nSlot.isTopic()) {
if (nSlot.isAction()) {
if (this.invoke == null) {
this.invoke = this.beginAccessorMethod();
}
this.genInvoke((NAction)nSlot, this.invoke);
} else {
NProperty nProperty = (NProperty)nSlot;
if (this.g == null) {
this.g = this.beginAccessorMethod();
this.s = this.beginAccessorMethod();
}
switch (nProperty.getTypeAccess()) {
case 0: {
if (this.gb == null) {
this.gb = this.beginAccessorMethod();
this.sb = this.beginAccessorMethod();
}
this.genGetBoolean(nProperty, this.g, this.gb);
this.genSetBoolean(nProperty, this.s, this.sb);
break;
}
case 2: {
if (this.gi == null) {
this.gi = this.beginAccessorMethod();
this.si = this.beginAccessorMethod();
}
this.genGetInt(nProperty, this.g, this.gi);
this.genSetInt(nProperty, this.s, this.si);
break;
}
case 3: {
if (this.gj == null) {
this.gj = this.beginAccessorMethod();
this.sj = this.beginAccessorMethod();
}
this.genGetLong(nProperty, this.g, this.gj);
this.genSetLong(nProperty, this.s, this.sj);
break;
}
case 4: {
if (this.gf == null) {
this.gf = this.beginAccessorMethod();
this.sf = this.beginAccessorMethod();
}
this.genGetFloat(nProperty, this.g, this.gf);
this.genSetFloat(nProperty, this.s, this.sf);
break;
}
case 5: {
if (this.gd == null) {
this.gd = this.beginAccessorMethod();
this.sd = this.beginAccessorMethod();
}
this.genGetDouble(nProperty, this.g, this.gd);
this.genSetDouble(nProperty, this.s, this.sd);
break;
}
case 6: {
if (this.gs == null) {
this.gs = this.beginAccessorMethod();
this.ss = this.beginAccessorMethod();
}
this.genGetString(nProperty, this.g, this.gs);
this.genSetString(nProperty, this.s, this.ss);
break;
}
case 7: {
this.genGetGeneric(nProperty, this.g);
this.genSetGeneric(nProperty, this.s);
break;
}
}
}
}
++n;
}
}
private final void addAccessors() {
if (this.g != null) {
this.asm.addMethod(new MethodInfo(this.asm, "g", "(I)Ljavax/baja/sys/BValue;", 17, this.g.code));
this.asm.addMethod(new MethodInfo(this.asm, "s", "(ILjavax/baja/sys/BValue;)V", 17, this.s.code));
}
if (this.gb != null) {
this.asm.addMethod(new MethodInfo(this.asm, "gb", "(I)Z", 17, this.gb.code));
this.asm.addMethod(new MethodInfo(this.asm, "sb", "(IZ)V", 17, this.sb.code));
}
if (this.gi != null) {
this.asm.addMethod(new MethodInfo(this.asm, "gi", "(I)I", 17, this.gi.code));
this.asm.addMethod(new MethodInfo(this.asm, "si", "(II)V", 17, this.si.code));
}
if (this.gj != null) {
this.asm.addMethod(new MethodInfo(this.asm, "gj", "(I)J", 17, this.gj.code));
this.asm.addMethod(new MethodInfo(this.asm, "sj", "(IJ)V", 17, this.sj.code));
}
if (this.gf != null) {
this.asm.addMethod(new MethodInfo(this.asm, "gf", "(I)F", 17, this.gf.code));
this.asm.addMethod(new MethodInfo(this.asm, "sf", "(IF)V", 17, this.sf.code));
}
if (this.gd != null) {
this.asm.addMethod(new MethodInfo(this.asm, "gd", "(I)D", 17, this.gd.code));
this.asm.addMethod(new MethodInfo(this.asm, "sd", "(ID)V", 17, this.sd.code));
}
if (this.gs != null) {
this.asm.addMethod(new MethodInfo(this.asm, "gs", "(I)Ljava/lang/String;", 17, this.gs.code));
this.asm.addMethod(new MethodInfo(this.asm, "ss", "(ILjava/lang/String;)V", 17, this.ss.code));
}
if (this.invoke != null) {
this.asm.addMethod(new MethodInfo(this.asm, "invoke", "(ILjavax/baja/sys/BComponent;Ljavax/baja/sys/BValue;Ljavax/baja/sys/Context;)Ljavax/baja/sys/BValue;", 17, this.invoke.code));
}
}
private final void genGetGeneric(NProperty nProperty, SwitchCode switchCode) {
Code code = switchCode.code;
int n = this.propFields[nProperty.index];
int n2 = code.add(42);
code.add(180, n);
code.add(176);
this.backpatch(switchCode, nProperty.index, n2);
}
private final void genGetBoolean(NProperty nProperty, SwitchCode switchCode, SwitchCode switchCode2) {
Code code = switchCode.code;
int n = this.propFields[nProperty.index];
int n2 = code.add(42);
code.add(180, n);
code.add(184, this.bbooleanMake());
code.add(176);
this.backpatch(switchCode, nProperty.index, n2);
code = switchCode2.code;
n2 = code.add(42);
code.add(180, n);
code.add(172);
this.backpatch(switchCode2, nProperty.index, n2);
}
private final void genGetInt(NProperty nProperty, SwitchCode switchCode, SwitchCode switchCode2) {
Code code = switchCode.code;
int n = this.propFields[nProperty.index];
int n2 = code.add(42);
code.add(180, n);
code.add(184, this.bintegerMake());
code.add(176);
this.backpatch(switchCode, nProperty.index, n2);
code = switchCode2.code;
n2 = code.add(42);
code.add(180, n);
code.add(172);
this.backpatch(switchCode2, nProperty.index, n2);
}
private final void genGetLong(NProperty nProperty, SwitchCode switchCode, SwitchCode switchCode2) {
Code code = switchCode.code;
int n = this.propFields[nProperty.index];
int n2 = code.add(42);
code.add(180, n);
code.add(184, this.blongMake());
code.add(176);
this.backpatch(switchCode, nProperty.index, n2);
code = switchCode2.code;
n2 = code.add(42);
code.add(180, n);
code.add(173);
this.backpatch(switchCode2, nProperty.index, n2);
}
private final void genGetFloat(NProperty nProperty, SwitchCode switchCode, SwitchCode switchCode2) {
Code code = switchCode.code;
int n = this.propFields[nProperty.index];
int n2 = code.add(42);
code.add(180, n);
code.add(184, this.bfloatMake());
code.add(176);
this.backpatch(switchCode, nProperty.index, n2);
code = switchCode2.code;
n2 = code.add(42);
code.add(180, n);
code.add(174);
this.backpatch(switchCode2, nProperty.index, n2);
}
private final void genGetDouble(NProperty nProperty, SwitchCode switchCode, SwitchCode switchCode2) {
Code code = switchCode.code;
int n = this.propFields[nProperty.index];
int n2 = code.add(42);
code.add(180, n);
code.add(184, this.bdoubleMake());
code.add(176);
this.backpatch(switchCode, nProperty.index, n2);
code = switchCode2.code;
n2 = code.add(42);
code.add(180, n);
code.add(175);
this.backpatch(switchCode2, nProperty.index, n2);
}
private final void genGetString(NProperty nProperty, SwitchCode switchCode, SwitchCode switchCode2) {
Code code = switchCode.code;
int n = this.propFields[nProperty.index];
int n2 = code.add(42);
code.add(180, n);
code.add(184, this.bstringMake());
code.add(176);
this.backpatch(switchCode, nProperty.index, n2);
code = switchCode2.code;
n2 = code.add(42);
code.add(180, n);
code.add(176);
this.backpatch(switchCode2, nProperty.index, n2);
}
private final void genSetGeneric(NProperty nProperty, SwitchCode switchCode) {
Code code = switchCode.code;
int n = this.propFields[nProperty.index];
int n2 = this.cp.cls(nProperty.typeClass);
int n3 = code.add(42);
code.add(44);
code.add(192, n2);
code.add(181, n);
code.add(177);
this.backpatch(switchCode, nProperty.index, n3);
}
private final void genSetBoolean(NProperty nProperty, SwitchCode switchCode, SwitchCode switchCode2) {
Code code = switchCode.code;
int n = this.propFields[nProperty.index];
int n2 = code.add(42);
code.add(44);
code.add(192, this.bbooleanCls());
code.add(182, this.getBoolean());
code.add(181, n);
code.add(177);
this.backpatch(switchCode, nProperty.index, n2);
code = switchCode2.code;
n2 = code.add(42);
code.add(28);
code.add(181, n);
code.add(177);
this.backpatch(switchCode2, nProperty.index, n2);
}
private final void genSetInt(NProperty nProperty, SwitchCode switchCode, SwitchCode switchCode2) {
Code code = switchCode.code;
int n = this.propFields[nProperty.index];
int n2 = code.add(42);
code.add(44);
code.add(192, this.bintegerCls());
code.add(182, this.getInt());
code.add(181, n);
code.add(177);
this.backpatch(switchCode, nProperty.index, n2);
code = switchCode2.code;
n2 = code.add(42);
code.add(28);
code.add(181, n);
code.add(177);
this.backpatch(switchCode2, nProperty.index, n2);
}
private final void genSetLong(NProperty nProperty, SwitchCode switchCode, SwitchCode switchCode2) {
Code code = switchCode.code;
int n = this.propFields[nProperty.index];
int n2 = code.add(42);
code.add(44);
code.add(192, this.blongCls());
code.add(182, this.getLong());
code.add(181, n);
code.add(177);
this.backpatch(switchCode, nProperty.index, n2);
code = switchCode2.code;
n2 = code.add(42);
code.add(32);
code.add(181, n);
code.add(177);
this.backpatch(switchCode2, nProperty.index, n2);
}
private final void genSetFloat(NProperty nProperty, SwitchCode switchCode, SwitchCode switchCode2) {
Code code = switchCode.code;
int n = this.propFields[nProperty.index];
int n2 = code.add(42);
code.add(44);
code.add(192, this.bfloatCls());
code.add(182, this.getFloat());
code.add(181, n);
code.add(177);
this.backpatch(switchCode, nProperty.index, n2);
code = switchCode2.code;
n2 = code.add(42);
code.add(36);
code.add(181, n);
code.add(177);
this.backpatch(switchCode2, nProperty.index, n2);
}
private final void genSetDouble(NProperty nProperty, SwitchCode switchCode, SwitchCode switchCode2) {
Code code = switchCode.code;
int n = this.propFields[nProperty.index];
int n2 = code.add(42);
code.add(44);
code.add(192, this.bdoubleCls());
code.add(182, this.getDouble());
code.add(181, n);
code.add(177);
this.backpatch(switchCode, nProperty.index, n2);
code = switchCode2.code;
n2 = code.add(42);
code.add(40);
code.add(181, n);
code.add(177);
this.backpatch(switchCode2, nProperty.index, n2);
}
private final void genSetString(NProperty nProperty, SwitchCode switchCode, SwitchCode switchCode2) {
Code code = switchCode.code;
int n = this.propFields[nProperty.index];
int n2 = code.add(42);
code.add(44);
code.add(192, this.bstringCls());
code.add(182, this.getString());
code.add(181, n);
code.add(177);
this.backpatch(switchCode, nProperty.index, n2);
code = switchCode2.code;
n2 = code.add(42);
code.add(44);
code.add(181, n);
code.add(177);
this.backpatch(switchCode2, nProperty.index, n2);
}
private final void genInvoke(NAction nAction, SwitchCode switchCode) {
Code code = switchCode.code;
Class clazz = nAction.parameterClass;
Class clazz2 = nAction.returnClass;
int n = code.add(44);
code.add(192, this.complexClass);
if (clazz != null) {
int n2 = this.cp.cls(clazz);
code.add(45);
code.add(192, n2);
}
if (nAction.doTakesContext) {
code.add(25, 4);
}
String string = "do" + TextUtil.capitalize((String)nAction.name);
StringBuffer stringBuffer = new StringBuffer("(");
if (clazz != null) {
stringBuffer.append(Jvm.fieldDescriptor(clazz));
}
if (nAction.doTakesContext) {
stringBuffer.append("Ljavax/baja/sys/Context;");
}
stringBuffer.append(")");
if (clazz2 == null) {
stringBuffer.append("V");
} else {
stringBuffer.append(Jvm.fieldDescriptor(clazz2));
}
int n3 = this.cp.method(this.complexClass, string, stringBuffer.toString());
code.add(182, n3);
if (clazz2 == null) {
code.add(1);
}
code.add(176);
this.backpatch(switchCode, nAction.index, n);
}
private final SwitchCode beginAccessorMethod() {
Code code = new Code(this.asm);
int n = this.slots.length;
code.add(27);
int n2 = code.addPad(170);
int n3 = code.code.u4(0);
int n4 = n3 + 12 + n * 4;
int n5 = n4 - n2;
code.code.u4(n3, n5);
code.code.u4(0);
code.code.u4(n - 1);
int n6 = n3 + 12;
int n7 = 0;
while (n7 < n) {
code.code.u4(n5);
++n7;
}
code.add(187, this.exceptionCls());
code.add(89);
code.add(183, this.exceptionCtor());
code.add(191);
return new SwitchCode(code, n2, n6);
}
private final void backpatch(SwitchCode switchCode, int n, int n2) {
switchCode.code.code.u4(switchCode.firstJumpOffset + n * 4, n2 - switchCode.switchOffset);
}
int init() {
if (this.init == 0) {
this.init = this.cp.utf("<init>");
}
return this.init;
}
int exceptionCls() {
if (this.exceptionCls == 0) {
this.exceptionCls = this.cp.cls("com/tridium/sys/schema/UnhandledSlotException");
}
return this.exceptionCls;
}
int exceptionCtor() {
if (this.exceptionCtor == 0) {
this.exceptionCtor = this.cp.method(this.exceptionCls(), this.init(), "()V");
}
return this.exceptionCtor;
}
int npropCls() {
if (this.npropCls == 0) {
this.npropCls = this.cp.cls("com/tridium/sys/schema/NProperty");
}
return this.npropCls;
}
int npropGetDef() {
if (this.npropGetDef == 0) {
this.npropGetDef = this.cp.method(this.npropCls(), "getDefaultValue", "()Ljavax/baja/sys/BValue;");
}
return this.npropGetDef;
}
int bbooleanCls() {
if (this.bbooleanCls == 0) {
this.bbooleanCls = this.cp.cls("javax/baja/sys/BBoolean");
}
return this.bbooleanCls;
}
int bintegerCls() {
if (this.bintegerCls == 0) {
this.bintegerCls = this.cp.cls("javax/baja/sys/BInteger");
}
return this.bintegerCls;
}
int blongCls() {
if (this.blongCls == 0) {
this.blongCls = this.cp.cls("javax/baja/sys/BLong");
}
return this.blongCls;
}
int bfloatCls() {
if (this.bfloatCls == 0) {
this.bfloatCls = this.cp.cls("javax/baja/sys/BFloat");
}
return this.bfloatCls;
}
int bdoubleCls() {
if (this.bdoubleCls == 0) {
this.bdoubleCls = this.cp.cls("javax/baja/sys/BDouble");
}
return this.bdoubleCls;
}
int bstringCls() {
if (this.bstringCls == 0) {
this.bstringCls = this.cp.cls("javax/baja/sys/BString");
}
return this.bstringCls;
}
int bbooleanMake() {
if (this.bbooleanMake == 0) {
this.bbooleanMake = this.cp.method(this.bbooleanCls(), "make", "(Z)Ljavax/baja/sys/BBoolean;");
}
return this.bbooleanMake;
}
int bintegerMake() {
if (this.bintegerMake == 0) {
this.bintegerMake = this.cp.method(this.bintegerCls(), "make", "(I)Ljavax/baja/sys/BInteger;");
}
return this.bintegerMake;
}
int blongMake() {
if (this.blongMake == 0) {
this.blongMake = this.cp.method(this.blongCls(), "make", "(J)Ljavax/baja/sys/BLong;");
}
return this.blongMake;
}
int bfloatMake() {
if (this.bfloatMake == 0) {
this.bfloatMake = this.cp.method(this.bfloatCls(), "make", "(F)Ljavax/baja/sys/BFloat;");
}
return this.bfloatMake;
}
int bdoubleMake() {
if (this.bdoubleMake == 0) {
this.bdoubleMake = this.cp.method(this.bdoubleCls(), "make", "(D)Ljavax/baja/sys/BDouble;");
}
return this.bdoubleMake;
}
int bstringMake() {
if (this.bstringMake == 0) {
this.bstringMake = this.cp.method(this.bstringCls(), "make", "(Ljava/lang/String;)Ljavax/baja/sys/BString;");
}
return this.bstringMake;
}
int getBoolean() {
if (this.getBoolean == 0) {
this.getBoolean = this.cp.method(this.bbooleanCls(), "getBoolean", "()Z");
}
return this.getBoolean;
}
int getInt() {
if (this.getInt == 0) {
this.getInt = this.cp.method(this.bintegerCls(), "getInt", "()I");
}
return this.getInt;
}
int getLong() {
if (this.getLong == 0) {
this.getLong = this.cp.method(this.blongCls(), "getLong", "()J");
}
return this.getLong;
}
int getFloat() {
if (this.getFloat == 0) {
this.getFloat = this.cp.method(this.bfloatCls(), "getFloat", "()F");
}
return this.getFloat;
}
int getDouble() {
if (this.getDouble == 0) {
this.getDouble = this.cp.method(this.bdoubleCls(), "getDouble", "()D");
}
return this.getDouble;
}
int getString() {
if (this.getString == 0) {
this.getString = this.cp.method(this.bstringCls(), "getString", "()Ljava/lang/String;");
}
return this.getString;
}
private final /* synthetic */ void this() {
this.g = null;
this.s = null;
this.gb = null;
this.sb = null;
this.gi = null;
this.si = null;
this.gj = null;
this.sj = null;
this.gf = null;
this.sf = null;
this.gd = null;
this.sd = null;
this.gs = null;
this.ss = null;
this.invoke = null;
}
Compiler(String string, String string2, Class clazz, NSlot[] nSlotArray) {
this.this();
int n = 33;
this.asm = new Assembler(string2, string, n, null);
this.cp = this.asm.cp;
this.slots = nSlotArray;
this.complexClass = this.cp.cls(clazz);
}
static class SwitchCode {
Code code;
int switchOffset;
int firstJumpOffset;
SwitchCode(Code code, int n, int n2) {
this.code = code;
this.switchOffset = n;
this.firstJumpOffset = n2;
}
}
}
@@ -0,0 +1,547 @@
/*
* Decompiled with CFR 0.152.
*
* Could not load the following classes:
* javax.baja.nre.util.TextUtil
*/
package com.tridium.sys.schema;
import com.tridium.asm.Buffer;
import com.tridium.sys.module.AutoClassLoader;
import com.tridium.sys.schema.Compiler;
import com.tridium.sys.schema.ComplexSlotMap;
import com.tridium.sys.schema.ComplexType;
import com.tridium.sys.schema.Introspector;
import com.tridium.sys.schema.MethodMap;
import com.tridium.sys.schema.NAction;
import com.tridium.sys.schema.NProperty;
import com.tridium.sys.schema.NSlot;
import com.tridium.sys.schema.NTopic;
import com.tridium.sys.schema.Utils;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import javax.baja.nre.util.TextUtil;
import javax.baja.sys.BDouble;
import javax.baja.sys.BFloat;
import javax.baja.sys.BInteger;
import javax.baja.sys.BLong;
import javax.baja.sys.Slot;
import javax.baja.sys.Type;
/*
* Illegal identifiers - consider using --renameillegalidents true
*/
public class ComplexIntrospector
extends Introspector {
MethodMap methods;
NSlot[] slots;
NProperty[] properties;
NAction[] actions;
NTopic[] topics;
ComplexSlotMap slotMap;
boolean isComponent;
HashMap superSlotsToFix;
static /* synthetic */ Class class$javax$baja$sys$BComponent;
static /* synthetic */ Class class$javax$baja$sys$BObject;
static /* synthetic */ Class class$javax$baja$sys$BBoolean;
static /* synthetic */ Class class$javax$baja$sys$BInteger;
static /* synthetic */ Class class$javax$baja$sys$BLong;
static /* synthetic */ Class class$javax$baja$sys$BFloat;
static /* synthetic */ Class class$javax$baja$sys$BDouble;
static /* synthetic */ Class class$javax$baja$sys$BString;
static /* synthetic */ Class class$javax$baja$sys$BValue;
static /* synthetic */ Class class$javax$baja$sys$Context;
Type introspect() throws Exception {
this.mapSlots();
this.generateSlotMapClass();
return this.makeType();
}
protected Type makeType() {
return new ComplexType(this);
}
protected void mapSlots() throws Exception {
ArrayList<NProperty> arrayList = new ArrayList<NProperty>();
ArrayList<NProperty> arrayList2 = new ArrayList<NProperty>();
ArrayList<NProperty> arrayList3 = new ArrayList<NProperty>();
ArrayList<NProperty> arrayList4 = new ArrayList<NProperty>();
Field[] fieldArray = this.resolveFields();
int n = 0;
while (n < fieldArray.length) {
Field field = fieldArray[n];
if (field != null) {
Class<?> clazz = field.getType();
NSlot nSlot = null;
try {
NSlot nSlot2;
if (clazz == propertyClass) {
nSlot2 = this.mapProperty((NProperty)this.getSlotField(field));
arrayList2.add((NProperty)nSlot2);
nSlot = nSlot2;
} else if (clazz == actionClass) {
nSlot2 = this.mapAction((NAction)this.getSlotField(field));
arrayList3.add((NProperty)nSlot2);
nSlot = nSlot2;
} else if (clazz == topicClass) {
nSlot2 = this.mapTopic((NTopic)this.getSlotField(field));
arrayList4.add((NProperty)nSlot2);
nSlot = nSlot2;
}
}
catch (Exception exception) {
this.err("" + field);
throw exception;
}
if (nSlot != null) {
nSlot.index = arrayList.size();
arrayList.add((NProperty)nSlot);
}
}
++n;
}
this.slots = arrayList.toArray(new NSlot[arrayList.size()]);
this.properties = arrayList2.toArray(new NProperty[arrayList2.size()]);
this.actions = arrayList3.toArray(new NAction[arrayList3.size()]);
this.topics = arrayList4.toArray(new NTopic[arrayList4.size()]);
if (this.superSlotsToFix != null) {
this.fixSuperSlots();
}
}
/*
* Unable to fully structure code
*/
protected Field[] resolveFields() {
var1_1 = new ArrayList<Class>();
var2_2 = this.cls;
if (true) ** GOTO lbl8
do {
var1_1.add((Class)var2_2);
var2_2 = var2_2.getSuperclass();
lbl8:
// 2 sources
if ((v0 = ComplexIntrospector.class$javax$baja$sys$BObject) != null) continue;
v0 = ComplexIntrospector.class("[Ljavax.baja.sys.BObject;", false);
} while (var2_2 != v0 && var2_2 != null);
var2_2 = new ArrayList<E>();
var3_3 = new HashMap<String, Integer>();
var4_4 = var1_1.size() - 1;
while (var4_4 >= 0) {
var5_5 = ((Class)var1_1.get(var4_4)).getDeclaredFields();
var6_6 = 0;
while (var6_6 < var5_5.length) {
var7_7 = var5_5[var6_6];
var8_8 = var7_7.getType();
if (this.isPublicStaticFinal(var7_7) && (var8_8 == ComplexIntrospector.propertyClass || var8_8 == ComplexIntrospector.actionClass || var8_8 == ComplexIntrospector.topicClass)) {
var9_9 = (Integer)var3_3.get(var7_7.getName());
if (var9_9 != null) {
var10_10 = var9_9;
this.checkSuperSlotInitialized((Field)var2_2.get(var10_10));
var2_2.set(var10_10, var7_7);
} else {
var3_3.put(var7_7.getName(), new Integer(var2_2.size()));
var2_2.add(var7_7);
}
}
++var6_6;
}
--var4_4;
}
return var2_2.toArray(new Field[var2_2.size()]);
}
protected Slot getSlotField(Field field) throws Exception {
NSlot nSlot = null;
try {
nSlot = (NSlot)field.get(null);
}
catch (Exception exception) {
throw this.err("Cannot access slot field \"" + field + "\": " + exception);
}
if (nSlot == null) {
throw this.err("Slot field is null (insure loadType is last)", field.getName());
}
nSlot.name = field.getName();
nSlot.displayName = TextUtil.toFriendly((String)nSlot.name);
return nSlot;
}
protected NProperty mapProperty(NProperty nProperty) {
String string = nProperty.name;
String string2 = TextUtil.capitalize((String)string);
Method method = this.methods.getMethod("get" + string2, MethodMap.noParams);
if (method == null && (method = this.methods.getMethod("is" + string2, MethodMap.noParams)) != null && method.getReturnType() != Boolean.TYPE) {
throw this.err("Only boolean properties may support 'is' getter", string);
}
if (method == null) {
throw this.err("No getter for property", string);
}
if (method.getParameterTypes().length != 0) {
throw this.err("Parameters not allowed on getter", string);
}
TypeSpec typeSpec = new TypeSpec(method.getReturnType());
if (typeSpec.isError()) {
throw this.err("Unsupported type for property", string);
}
if (!this.isComponent && typeSpec.isPotentialComponent()) {
throw this.err("Structs may not contain potential component types", string);
}
if (typeSpec.isBWrapper()) {
throw this.err("Use primitive, not BObject wrapper for " + string);
}
Method method2 = this.methods.getMethod("set" + string2, typeSpec.cls);
if (method2 == null) {
throw this.err("No setter for property", string);
}
if (method2.getReturnType() != Void.TYPE) {
throw this.err("Setter must have void return type", string);
}
nProperty.typeClass = typeSpec.cls;
nProperty.typeAccess = typeSpec.typeAccess;
Class clazz = null;
switch (nProperty.typeAccess) {
case 0: {
Class clazz2 = class$javax$baja$sys$BBoolean;
if (clazz2 == null) {
clazz2 = class$javax$baja$sys$BBoolean = ComplexIntrospector.class("[Ljavax.baja.sys.BBoolean;", false);
}
clazz = clazz2;
break;
}
case 2: {
Class clazz3 = class$javax$baja$sys$BInteger;
if (clazz3 == null) {
clazz3 = class$javax$baja$sys$BInteger = ComplexIntrospector.class("[Ljavax.baja.sys.BInteger;", false);
}
clazz = clazz3;
break;
}
case 3: {
Class clazz4 = class$javax$baja$sys$BLong;
if (clazz4 == null) {
clazz4 = clazz = (class$javax$baja$sys$BLong = ComplexIntrospector.class("[Ljavax.baja.sys.BLong;", false));
}
if (!(nProperty.value instanceof BInteger)) break;
nProperty.value = BLong.make(((BInteger)nProperty.value).getInt());
break;
}
case 4: {
Class clazz5 = class$javax$baja$sys$BFloat;
if (clazz5 == null) {
clazz5 = clazz = (class$javax$baja$sys$BFloat = ComplexIntrospector.class("[Ljavax.baja.sys.BFloat;", false));
}
if (!(nProperty.value instanceof BInteger)) break;
nProperty.value = BFloat.make(((BInteger)nProperty.value).getInt());
break;
}
case 5: {
Class clazz6 = class$javax$baja$sys$BDouble;
if (clazz6 == null) {
clazz6 = clazz = (class$javax$baja$sys$BDouble = ComplexIntrospector.class("[Ljavax.baja.sys.BDouble;", false));
}
if (!(nProperty.value instanceof BInteger)) break;
nProperty.value = BDouble.make(((BInteger)nProperty.value).getInt());
break;
}
case 6: {
Class clazz7 = class$javax$baja$sys$BString;
if (clazz7 == null) {
clazz7 = class$javax$baja$sys$BString = ComplexIntrospector.class("[Ljavax.baja.sys.BString;", false);
}
clazz = clazz7;
break;
}
case 7: {
clazz = nProperty.typeClass;
break;
}
default: {
throw new IllegalStateException();
}
}
Class<?> clazz8 = nProperty.value.getClass();
if (!clazz.isAssignableFrom(clazz8)) {
throw this.err("Property default value is of wrong type " + clazz8.getName() + " != " + clazz.getName(), string);
}
nProperty.init();
return nProperty;
}
protected NTopic mapTopic(NTopic nTopic) throws Exception {
String string = nTopic.name;
String string2 = TextUtil.capitalize((String)string);
Method method = this.methods.getMethod("fire" + string2, MethodMap.wildcard);
if (method == null) {
throw this.err("Missing fire method: fire" + string2, string);
}
if (method.getReturnType() != Void.TYPE) {
throw this.err("Fire method must have void return type", string);
}
Class<?>[] classArray = method.getParameterTypes();
if (classArray.length != 1) {
throw this.err("Fire method must have exactly one parameter", string);
}
nTopic.eventClass = classArray[0];
return nTopic;
}
protected NAction mapAction(NAction nAction) throws Exception {
Method method;
String string = nAction.name;
String string2 = TextUtil.capitalize((String)string);
Method method2 = this.methods.getMethod(string, MethodMap.noParams);
if (method2 == null) {
method2 = this.methods.getMethod(string, MethodMap.wildcard);
}
if (method2 == null) {
throw this.err("Missing action method", string);
}
if (!this.isPublic(method2)) {
throw this.err("Action method must be public", string);
}
if (this.isStatic(method2)) {
throw this.err("Action method must be not be static", string);
}
Class<?> clazz = method2.getReturnType();
if (clazz == Void.TYPE) {
nAction.returnClass = null;
} else {
Class clazz2 = class$javax$baja$sys$BValue;
if (clazz2 == null) {
clazz2 = class$javax$baja$sys$BValue = ComplexIntrospector.class("[Ljavax.baja.sys.BValue;", false);
}
if (!clazz2.isAssignableFrom(clazz)) {
throw this.err("Action return type must be BValue", string);
}
nAction.returnClass = clazz;
}
Class<?>[] classArray = method2.getParameterTypes();
if (classArray.length > 1) {
throw this.err("Action must specify zero or one parameter", string);
}
if (classArray.length == 0) {
if (nAction.parameterDefault != null) {
throw this.err("Action has parameter default, but no parameter", string);
}
} else {
if (nAction.parameterDefault == null) {
throw this.err("Action has parameter, but no parameter default", string);
}
Class clazz3 = class$javax$baja$sys$BValue;
if (clazz3 == null) {
clazz3 = class$javax$baja$sys$BValue = ComplexIntrospector.class("[Ljavax.baja.sys.BValue;", false);
}
if (!clazz3.isAssignableFrom(classArray[0])) {
throw this.err("Action parameter type must be BValue", string);
}
if (!classArray[0].isAssignableFrom(nAction.parameterDefault.getClass())) {
throw this.err("Action parameter default has invalid type", string);
}
nAction.parameterClass = classArray[0];
}
if ((method = classArray.length == 0 ? this.methods.getMethod("do" + string2, MethodMap.noParams) : this.methods.getMethod("do" + string2, classArray[0])) == null) {
if (classArray.length == 0) {
String string3 = "do" + string2;
Class[] classArray2 = new Class[1];
Class clazz4 = class$javax$baja$sys$Context;
if (clazz4 == null) {
clazz4 = class$javax$baja$sys$Context = ComplexIntrospector.class("[Ljavax.baja.sys.Context;", false);
}
classArray2[0] = clazz4;
method = this.methods.getMethod(string3, classArray2);
} else {
String string4 = "do" + string2;
Class[] classArray3 = new Class[2];
classArray3[0] = classArray[0];
Class clazz5 = class$javax$baja$sys$Context;
if (clazz5 == null) {
clazz5 = class$javax$baja$sys$Context = ComplexIntrospector.class("[Ljavax.baja.sys.Context;", false);
}
classArray3[1] = clazz5;
method = this.methods.getMethod(string4, classArray3);
}
if (method == null) {
throw this.err("Missing action do method", "do" + string2);
}
nAction.doTakesContext = true;
}
if (!this.isPublic(method)) {
throw this.err("Do action method must be public", string2);
}
if (this.isStatic(method)) {
throw this.err("Do action method must be not be static", string2);
}
if (clazz != method.getReturnType()) {
throw this.err("Action method and do method have mismatched signature", nAction.name);
}
return nAction;
}
protected void checkSuperSlotInitialized(Field field) {
try {
NSlot nSlot = (NSlot)field.get(null);
if (nSlot.name == null) {
ArrayList<NSlot> arrayList;
if (this.superSlotsToFix == null) {
this.superSlotsToFix = new HashMap();
}
if ((arrayList = (ArrayList<NSlot>)this.superSlotsToFix.get(field.getName())) == null) {
arrayList = new ArrayList<NSlot>();
this.superSlotsToFix.put(field.getName(), arrayList);
}
arrayList.add(nSlot);
}
}
catch (Throwable throwable) {
throwable.printStackTrace();
}
}
protected void fixSuperSlots() {
Iterator iterator = this.superSlotsToFix.keySet().iterator();
while (iterator.hasNext()) {
String string = (String)iterator.next();
ArrayList arrayList = (ArrayList)this.superSlotsToFix.get(string);
int n = 0;
while (n < arrayList.size()) {
NSlot nSlot = (NSlot)arrayList.get(n);
int n2 = 0;
while (n2 < this.slots.length) {
NSlot nSlot2 = this.slots[n2];
if (nSlot2.name.equals(string)) {
nSlot.copyFrom(nSlot2);
break;
}
++n2;
}
++n;
}
}
}
protected void generateSlotMapClass() throws Exception {
String string = this.cls.getName().replace('.', '_');
String string2 = "auto." + string;
String string3 = "auto/" + string;
String string4 = this.isComponent ? "com/tridium/sys/schema/ComponentSlotMap" : "com/tridium/sys/schema/ComplexSlotMap";
Buffer buffer = new Compiler(string4, string3, this.cls, this.slots).compile();
Class clazz = AutoClassLoader.load(this.cls, string2, buffer);
this.slotMap = (ComplexSlotMap)clazz.newInstance();
}
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());
}
}
public ComplexIntrospector(int n, Class clazz) {
super(n, clazz);
this.methods = new MethodMap(clazz);
Class clazz2 = class$javax$baja$sys$BComponent;
if (clazz2 == null) {
clazz2 = class$javax$baja$sys$BComponent = ComplexIntrospector.class("[Ljavax.baja.sys.BComponent;", false);
}
this.isComponent = clazz2.isAssignableFrom(clazz);
}
/*
* Illegal identifiers - consider using --renameillegalidents true
*/
static class TypeSpec {
final Class cls;
final int typeAccess;
static /* synthetic */ Class class$javax$baja$sys$BComponent;
static /* synthetic */ Class class$javax$baja$sys$BObject;
static /* synthetic */ Class class$javax$baja$sys$BValue;
static /* synthetic */ Class class$javax$baja$sys$BComplex;
boolean isError() {
boolean bl = false;
if (this.typeAccess == -1) {
bl = true;
}
return bl;
}
boolean isBWrapper() {
String string = this.cls.getName();
if (string.startsWith("javax.baja.sys.B")) {
string = string.substring(15);
boolean bl = false;
if (string.equals("BBoolean") || string.equals("BInteger") || string.equals("BLong") || string.equals("BFloat") || string.equals("BDouble") || string.equals("BString")) {
bl = true;
}
return bl;
}
return false;
}
boolean isPotentialComponent() {
boolean bl;
block8: {
block7: {
bl = false;
Class clazz = class$javax$baja$sys$BComponent;
if (clazz == null) {
clazz = class$javax$baja$sys$BComponent = TypeSpec.class("[Ljavax.baja.sys.BComponent;", false);
}
if (clazz.isAssignableFrom(this.cls)) break block7;
Class clazz2 = class$javax$baja$sys$BObject;
if (clazz2 == null) {
clazz2 = class$javax$baja$sys$BObject = TypeSpec.class("[Ljavax.baja.sys.BObject;", false);
}
if (this.cls == clazz2) break block7;
Class clazz3 = class$javax$baja$sys$BValue;
if (clazz3 == null) {
clazz3 = class$javax$baja$sys$BValue = TypeSpec.class("[Ljavax.baja.sys.BValue;", false);
}
if (this.cls == clazz3) break block7;
Class clazz4 = class$javax$baja$sys$BComplex;
if (clazz4 == null) {
clazz4 = class$javax$baja$sys$BComplex = TypeSpec.class("[Ljavax.baja.sys.BComplex;", false);
}
if (this.cls != clazz4) break block8;
}
bl = true;
}
return bl;
}
public String toString() {
return this.cls.getName();
}
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());
}
}
TypeSpec(Class clazz) {
this.cls = clazz;
this.typeAccess = Utils.getTypeAccess(clazz);
}
}
}
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,106 @@
/*
* Decompiled with CFR 0.152.
*/
package com.tridium.sys.schema;
import com.tridium.sys.schema.ComplexIntrospector;
import com.tridium.sys.schema.ComplexSlotMap;
import com.tridium.sys.schema.NAction;
import com.tridium.sys.schema.NProperty;
import com.tridium.sys.schema.NSlot;
import com.tridium.sys.schema.NTopic;
import com.tridium.sys.schema.NType;
import java.util.Hashtable;
import javax.baja.sys.BObject;
import javax.baja.sys.BValue;
import javax.baja.sys.Property;
import javax.baja.sys.Slot;
import javax.baja.sys.TypeIntrospectionException;
public class ComplexType
extends NType {
final ComplexSlotMap slotMap;
protected NSlot[] slots;
NProperty[] properties;
NAction[] actions;
NTopic[] topics;
protected Hashtable byName;
BValue defaultInstance;
int[] defaultFlags;
public BObject getInstance() {
try {
return this.slotMap.newBComplexInstance();
}
catch (NoSuchMethodError noSuchMethodError) {
throw new UnsupportedOperationException("Default constructor not available for " + this);
}
}
public ComplexSlotMap newSlotMap() {
return this.slotMap.newSlotMapInstance();
}
public Slot getSlot(String string) {
return this.slotMap.getSlot(string);
}
public NSlot[] getFrozenSlots() {
return (NSlot[])this.slots.clone();
}
public Property getProperty(String string) {
return (Property)this.slotMap.getSlot(string);
}
public NProperty[] getFrozenProperties() {
return (NProperty[])this.properties.clone();
}
public ComplexType(ComplexIntrospector complexIntrospector) {
super(complexIntrospector);
this.slotMap = complexIntrospector.slotMap;
this.slots = complexIntrospector.slots;
this.properties = complexIntrospector.properties;
this.actions = complexIntrospector.actions;
this.topics = complexIntrospector.topics;
this.byName = new Hashtable(this.slots.length * 2 + 3);
this.defaultFlags = new int[this.slots.length];
int n = 0;
while (n < this.slots.length) {
NSlot nSlot = this.slots[n];
this.defaultFlags[n] = nSlot.flags;
if (nSlot.declaringType == null) {
nSlot.declaringType = this;
}
if (this.byName.put(nSlot.name, nSlot) != null) {
throw new TypeIntrospectionException(this.typeClass, "Duplicate slots: " + nSlot.name);
}
++n;
}
}
public ComplexType(ComplexType complexType) {
super(complexType);
this.slotMap = complexType.slotMap;
this.slots = complexType.slots;
this.properties = complexType.properties;
this.actions = complexType.actions;
this.topics = complexType.topics;
this.byName = new Hashtable(this.slots.length * 2 + 3);
this.defaultFlags = new int[this.slots.length];
int n = 0;
while (n < this.slots.length) {
NSlot nSlot = this.slots[n];
this.defaultFlags[n] = nSlot.flags;
if (nSlot.declaringType == null) {
nSlot.declaringType = this;
}
if (this.byName.put(nSlot.name, nSlot) != null) {
throw new TypeIntrospectionException(this.typeClass, "Duplicate slots: " + nSlot.name);
}
++n;
}
}
}
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,211 @@
/*
* Decompiled with CFR 0.152.
*/
package com.tridium.sys.schema;
import com.tridium.sys.schema.NProperty;
import javax.baja.sys.Property;
/*
* Illegal identifiers - consider using --renameillegalidents true
*/
final class DynamicTable {
static final NProperty[] EMPTY = new NProperty[0];
final int baseIndex;
NProperty[] slots;
NProperty[] alpha;
int count;
final NProperty get(String string) {
NProperty[] nPropertyArray = this.alpha;
int n = -1;
int n2 = this.count;
while (n2 - n > 1) {
int n3 = (n2 + n) / 2;
int n4 = string.compareTo(nPropertyArray[n3].name);
if (n4 < 0) {
n2 = n3;
continue;
}
if (n4 > 0) {
n = n3;
continue;
}
return nPropertyArray[n3];
}
return null;
}
final void put(NProperty nProperty) {
NProperty nProperty2;
if (this.slots.length <= this.count) {
this.ensureCapacity(Math.max(8, this.count * 2));
}
if ((nProperty2 = this.insert(nProperty)) != null) {
int n = nProperty2.index - this.baseIndex;
System.arraycopy(this.slots, n + 1, this.slots, n, this.count - n - 1);
--this.count;
}
this.slots[this.count] = nProperty;
++this.count;
this.updateIndices();
}
private final NProperty insert(NProperty nProperty) {
NProperty[] nPropertyArray = this.alpha;
String string = nProperty.name;
if (this.count == 0) {
nPropertyArray[0] = nProperty;
return null;
}
if (this.count == 1) {
int n = string.compareTo(nPropertyArray[0].name);
if (n == 0) {
NProperty nProperty2 = nPropertyArray[0];
nPropertyArray[0] = nProperty;
return nProperty2;
}
if (n < 0) {
nPropertyArray[1] = nPropertyArray[0];
nPropertyArray[0] = nProperty;
} else {
nPropertyArray[1] = nProperty;
}
return null;
}
int n = 0;
int n2 = this.count - 1;
int n3 = (n2 - n) / 2;
while (n <= n2) {
int n4 = string.compareTo(nPropertyArray[n3].name);
if (n4 == 0) {
NProperty nProperty3 = nPropertyArray[n3];
nPropertyArray[n3] = nProperty;
return nProperty3;
}
if (n4 < 0) {
n4 = string.compareTo(nPropertyArray[n].name);
if (n4 == 0) {
NProperty nProperty4 = nPropertyArray[n];
nPropertyArray[n] = nProperty;
return nProperty4;
}
if (n4 < 0) {
n3 = n;
break;
}
n2 = n3 - 1;
} else {
n4 = string.compareTo(nPropertyArray[n2].name);
if (n4 == 0) {
NProperty nProperty5 = nPropertyArray[n2];
nPropertyArray[n2] = nProperty;
return nProperty5;
}
if (n4 > 0) {
n3 = n2 + 1;
break;
}
n = n3 + 1;
}
n3 = n + (n2 - n) / 2;
}
System.arraycopy(nPropertyArray, n3, nPropertyArray, n3 + 1, this.count - n3);
nPropertyArray[n3] = nProperty;
return null;
}
final void remove(NProperty nProperty) {
this.remove(nProperty.name);
int n = nProperty.index - this.baseIndex;
System.arraycopy(this.slots, n + 1, this.slots, n, this.count - n - 1);
this.slots[this.count - 1] = null;
--this.count;
this.updateIndices();
}
final void reorder(Property[] propertyArray) {
System.arraycopy(propertyArray, 0, this.slots, 0, this.count);
this.updateIndices();
}
private final void remove(String string) {
NProperty[] nPropertyArray = this.alpha;
int n = -1;
int n2 = this.count;
while (n2 - n > 1) {
int n3 = (n2 + n) / 2;
int n4 = string.compareTo(nPropertyArray[n3].name);
if (n4 < 0) {
n2 = n3;
continue;
}
if (n4 > 0) {
n = n3;
continue;
}
System.arraycopy(nPropertyArray, n3 + 1, nPropertyArray, n3, this.count - n3 - 1);
nPropertyArray[this.count - 1] = null;
return;
}
throw new IllegalStateException(string);
}
final void copyInto(Object[] objectArray, int n) {
System.arraycopy(this.slots, 0, objectArray, n, this.count);
}
final void ensureCapacity(int n) {
if (this.alpha.length < n) {
NProperty[] nPropertyArray = new NProperty[n];
System.arraycopy(this.slots, 0, nPropertyArray, 0, this.count);
this.slots = nPropertyArray;
nPropertyArray = new NProperty[n];
System.arraycopy(this.alpha, 0, nPropertyArray, 0, this.count);
this.alpha = nPropertyArray;
}
}
final void clear() {
this.slots = EMPTY;
this.alpha = EMPTY;
this.count = 0;
}
final boolean equivalent(DynamicTable dynamicTable) {
if (dynamicTable == null) {
return false;
}
if (this.count != dynamicTable.count) {
return false;
}
int n = 0;
while (n < this.count) {
if (!this.alpha[n].equivalent(dynamicTable.alpha[n])) {
return false;
}
++n;
}
return true;
}
private final void updateIndices() {
int n = 0;
while (n < this.count) {
this.slots[n].index = this.baseIndex + n;
++n;
}
}
private final /* synthetic */ void this() {
this.slots = EMPTY;
this.alpha = EMPTY;
this.count = 0;
}
DynamicTable(int n) {
this.this();
this.baseIndex = n;
}
}
@@ -0,0 +1,84 @@
/*
* Decompiled with CFR 0.152.
*
* Could not load the following classes:
* javax.baja.nre.util.IntHashMap
*/
package com.tridium.sys.schema;
import com.tridium.sys.schema.EnumType;
import com.tridium.sys.schema.Introspector;
import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
import java.util.HashMap;
import javax.baja.nre.util.IntHashMap;
import javax.baja.sys.BFrozenEnum;
import javax.baja.sys.Type;
/*
* Illegal identifiers - consider using --renameillegalidents true
*/
class EnumIntrospector
extends Introspector {
BFrozenEnum def;
IntHashMap byOrdinal;
HashMap byTag;
int[] ordinals;
int count;
Type introspect() throws Exception {
int n = this.cls.getModifiers();
if (this.cls.getName().equals("javax.baja.sys.BFrozenEnum") || Modifier.isAbstract(n)) {
return new EnumType(this, null, null, null, null);
}
if (!Modifier.isFinal(n)) {
throw this.err("BFrozenEnum's must be final classes");
}
this.mapEnums();
int[] nArray = new int[this.count];
System.arraycopy(this.ordinals, 0, nArray, 0, this.count);
return new EnumType(this, this.def, nArray, this.byOrdinal, this.byTag);
}
protected void mapEnums() throws Exception {
Field[] fieldArray = this.cls.getFields();
int n = 0;
while (n < fieldArray.length) {
Field field = fieldArray[n];
int n2 = field.getModifiers();
if (Modifier.isPublic(n2) && Modifier.isStatic(n2) && Modifier.isFinal(n2) && field.getType() == this.cls && !field.getName().equals("DEFAULT")) {
this.mapEnum(field.getName(), (BFrozenEnum)field.get(null));
}
++n;
}
if (this.byOrdinal.size() == 0) {
throw this.err("Must declare at least one enum");
}
}
private final void mapEnum(String string, BFrozenEnum bFrozenEnum) throws Exception {
int n = bFrozenEnum.getOrdinal();
this.ordinals[this.count++] = n;
if (this.byOrdinal.get(n) != null) {
throw this.err("Duplicate ordinal " + n);
}
if (this.def == null) {
this.def = bFrozenEnum;
}
EnumType.Entry entry = new EnumType.Entry(n, string, bFrozenEnum);
this.byOrdinal.put(n, (Object)entry);
this.byTag.put(string, entry);
}
private final /* synthetic */ void this() {
this.byOrdinal = new IntHashMap();
this.byTag = new HashMap();
this.ordinals = new int[1024];
}
EnumIntrospector(int n, Class clazz) {
super(n, clazz);
this.this();
}
}
@@ -0,0 +1,138 @@
/*
* Decompiled with CFR 0.152.
*
* Could not load the following classes:
* javax.baja.nre.util.IntHashMap
* javax.baja.nre.util.TextUtil
*/
package com.tridium.sys.schema;
import com.tridium.sys.schema.EnumIntrospector;
import com.tridium.sys.schema.SimpleType;
import java.util.HashMap;
import javax.baja.nre.util.IntHashMap;
import javax.baja.nre.util.TextUtil;
import javax.baja.sys.BEnumRange;
import javax.baja.sys.BFrozenEnum;
import javax.baja.sys.Context;
import javax.baja.sys.InvalidEnumException;
import javax.baja.util.Lexicon;
/*
* Illegal identifiers - consider using --renameillegalidents true
*/
public class EnumType
extends SimpleType {
int[] ordinals;
IntHashMap byOrdinal;
HashMap byTag;
BEnumRange range;
public int[] getOrdinals() {
if (this.ordinals == null) {
return null;
}
int[] nArray = new int[this.ordinals.length];
System.arraycopy(this.ordinals, 0, nArray, 0, this.ordinals.length);
return nArray;
}
public boolean isOrdinal(int n) {
boolean bl = false;
if (this.byOrdinal.get(n) != null) {
bl = true;
}
return bl;
}
public String getTag(int n) {
return this.getEntry((int)n).tag;
}
public String getDisplayTag(int n, Context context) {
Entry entry = this.getEntry(n);
try {
String string = this.module.getModuleName();
String string2 = Lexicon.make(string, context).get(entry.tag);
if (string2 != null) {
return string2;
}
}
catch (Throwable throwable) {
throwable.printStackTrace();
}
return entry.displayTag;
}
public BFrozenEnum get(int n) {
return this.getEntry((int)n).frozen;
}
public BFrozenEnum get(String string) {
return this.getEntry((String)string).frozen;
}
public boolean isTag(String string) {
boolean bl = false;
if (this.byTag.get(string) != null) {
bl = true;
}
return bl;
}
public int tagToOrdinal(String string) {
return this.getEntry((String)string).ordinal;
}
public BEnumRange getRange(boolean bl) {
if (this.range == null && bl) {
this.range = BEnumRange.make(this);
}
return this.range;
}
Entry getEntry(int n) {
Entry entry = (Entry)this.byOrdinal.get(n);
if (entry == null) {
throw new InvalidEnumException(n);
}
return entry;
}
Entry getEntry(String string) {
Entry entry = (Entry)this.byTag.get(string);
if (entry == null) {
throw new InvalidEnumException(string);
}
return entry;
}
private final /* synthetic */ void this() {
this.byOrdinal = new IntHashMap();
this.byTag = new HashMap();
}
EnumType(EnumIntrospector enumIntrospector, BFrozenEnum bFrozenEnum, int[] nArray, IntHashMap intHashMap, HashMap hashMap) {
super(enumIntrospector, bFrozenEnum, '\u0000');
this.this();
this.ordinals = nArray;
this.byOrdinal = intHashMap;
this.byTag = hashMap;
this.range = BEnumRange.make(this);
}
static class Entry {
int ordinal;
String tag;
String displayTag;
BFrozenEnum frozen;
Entry(int n, String string, BFrozenEnum bFrozenEnum) {
this.ordinal = n;
this.tag = string;
this.displayTag = TextUtil.toFriendly((String)string);
this.frozen = bFrozenEnum;
}
}
}
@@ -0,0 +1,95 @@
/*
* Decompiled with CFR 0.152.
*/
package com.tridium.sys.schema;
public class Fw {
public static final int SLOT_MAP = 1;
public static final int CHANGED = 2;
public static final int ADDED = 3;
public static final int REMOVED = 4;
public static final int RENAMED = 5;
public static final int REORDERED = 6;
public static final int PARENTED = 7;
public static final int UNPARENTED = 8;
public static final int INVOKED = 9;
public static final int FIRED = 10;
public static final int STARTED = 11;
public static final int STOPPED = 12;
public static final int DESCENDANTS_STARTED = 13;
public static final int DESCENDANTS_STOPPED = 14;
public static final int SERVICE_STARTED = 15;
public static final int SERVICE_STOPPED = 16;
public static final int SUBSCRIBED = 17;
public static final int UNSUBSCRIBED = 18;
public static final int GET_OVERRIDE = 19;
public static final int AT_STEADY_STATE = 20;
public static final int RR = 21;
public static final int TOTAL_EXECUTE_TIME = 22;
public static final int STATION_STARTED = 23;
public static final int SELF_GOVERNED_NAME = 24;
public static final int SELF_GOVERNED_DISPLAY_NAME = 25;
public static final int MOUNT = 101;
public static final int UNMOUNT = 102;
public static final int GENERATE_HANDLES = 103;
public static final int ENSURE_LOADED = 104;
public static final int HOLD_MIX_IN_UPDATES = 105;
public static final int DELETE_PROPS = 106;
public static final int UNDELETE_PROPS = 107;
public static final int SET_SPACE = 108;
public static final int RPC = 109;
public static final int TOUCH = 110;
public static final int GENERATE_UNIQUE_NAME = 111;
public static final int MAKE_DELETE_OP = 112;
public static final int MAKE_INTRA_MOVE = 113;
public static final int MAKE_COMP_TRANSFER = 114;
public static final int MAKE_FILE_COMP_TRANSFER = 115;
public static final int GET_COMPONENT = 116;
public static final int SKIP_INTERN = 116;
public static final int GET_AWT = 201;
public static final int SET_AWT = 202;
public static final int GET_IMAGE = 203;
public static final int SET_IMAGE = 204;
public static final int SET_BASE_ORD = 205;
public static final int GET_PEER = 206;
public static final int IS_WIDGET = 301;
public static final int GET_BINDER = 302;
public static final int UPDATE_BINDING = 303;
public static final int PX_EDITOR = 304;
public static final int SHOW_ACCELERATORS = 305;
public static final int UPDATE_COLORS = 306;
public static final int PX_INCLUDE = 307;
public static final int ACTIVATED = 401;
public static final int DEACTIVATED = 402;
public static final int MAKE_BINDER = 403;
public static final int GET_REMOTE_VERSION = 404;
public static final int GET_MODULE = 405;
public static final int CHECK_LICENSE_LIMIT = 501;
public static final int GET_ALARM_SUPPORT = 502;
public static final int GET_LICENSE_COUNT = 503;
public static final int GET_ALARM_QUEUE = 601;
public static final int GET_ALARM_STORE = 602;
public static final int ORION_TABLE_DEF = 701;
public static final int ORION_INIT_ORIG = 702;
public static final int ORION_GET_ORIG_VALUE = 703;
public static final int FOX_SESSION = 801;
public static final int STATION_FOX_SESSION = 802;
public static final int FOX_SESSION_TYPE = 803;
public static final int FOX_UNAUTHENTICATED_MSG = 804;
public static final int FOXS_SESSION = 805;
public static final int STATION_FOXS_SESSION = 806;
public static final int ADD_UNRESTRICTED_FILE_PATH = 901;
public static final int REMOVE_UNRESTRICTED_FILE_PATH = 902;
public static final int INITIALIZE_PLATFORM = 1001;
public static final int INIT_DATA_RECOVERY_RESTORE = 1002;
public static final int RETRIEVE_TIMEZONE_ERA = 1101;
public static final int CREATE_TIMEZONE_FROM_HISTORICAL = 1102;
public static final int CREATE_RULE_FROM_HISTORICAL = 1103;
public static final int GET_TABLE_HANDLE = 1200;
public static final int USER_DEFINED_0 = 9900;
public static final int USER_DEFINED_1 = 9901;
public static final int USER_DEFINED_2 = 9902;
public static final int USER_DEFINED_3 = 9903;
public static final int USER_DEFINED_4 = 9904;
}
@@ -0,0 +1,20 @@
/*
* Decompiled with CFR 0.152.
*/
package com.tridium.sys.schema;
import com.tridium.sys.schema.InterfaceType;
import com.tridium.sys.schema.Introspector;
import javax.baja.sys.Type;
class InterfaceIntrospector
extends Introspector {
Type introspect() throws Exception {
return new InterfaceType(this);
}
InterfaceIntrospector(int n, Class clazz) {
super(n, clazz);
}
}
@@ -0,0 +1,25 @@
/*
* Decompiled with CFR 0.152.
*/
package com.tridium.sys.schema;
import com.tridium.sys.schema.InterfaceIntrospector;
import com.tridium.sys.schema.NType;
import javax.baja.sys.BObject;
import javax.baja.sys.InterfaceTypeException;
public class InterfaceType
extends NType {
public final BObject getInstance() {
throw new InterfaceTypeException(this.toString());
}
public boolean isInterface() {
return true;
}
InterfaceType(InterfaceIntrospector interfaceIntrospector) {
super(interfaceIntrospector);
}
}
@@ -0,0 +1,291 @@
/*
* Decompiled with CFR 0.152.
*/
package com.tridium.sys.schema;
import com.tridium.sys.Nre;
import com.tridium.sys.module.ModuleClassLoader;
import com.tridium.sys.module.NModule;
import com.tridium.sys.schema.ComplexIntrospector;
import com.tridium.sys.schema.EnumIntrospector;
import com.tridium.sys.schema.InterfaceIntrospector;
import com.tridium.sys.schema.NType;
import com.tridium.sys.schema.ObjectIntrospector;
import com.tridium.sys.schema.SchemaManager;
import com.tridium.sys.schema.SimpleIntrospector;
import com.tridium.sys.schema.SingletonIntrospector;
import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.lang.reflect.Member;
import java.lang.reflect.Modifier;
import javax.baja.sys.BObject;
import javax.baja.sys.Type;
import javax.baja.sys.TypeIntrospectionException;
/*
* Illegal identifiers - consider using --renameillegalidents true
*/
public abstract class Introspector {
static Class propertyClass;
static Class actionClass;
static Class topicClass;
Class cls;
int id;
boolean isAbstract;
boolean isFinal;
NModule module;
String typeName;
String facetsPath;
static /* synthetic */ Class class$javax$baja$sys$Property;
static /* synthetic */ Class class$javax$baja$sys$Action;
static /* synthetic */ Class class$javax$baja$sys$Topic;
static /* synthetic */ Class class$javax$baja$sys$BComplex;
static /* synthetic */ Class class$javax$baja$sys$BFrozenEnum;
static /* synthetic */ Class class$javax$baja$sys$BSimple;
static /* synthetic */ Class class$javax$baja$sys$BSingleton;
static /* synthetic */ Class class$java$lang$Class;
static /* synthetic */ Class class$com$tridium$sys$schema$Introspector;
static /* synthetic */ Class class$javax$baja$sys$BObject;
static Introspector create(int n, Class clazz) {
if (clazz.isInterface()) {
return new InterfaceIntrospector(n, clazz);
}
Introspector introspector = Introspector.getCustomIntrospector(n, clazz);
if (introspector != null) {
return introspector;
}
Class clazz2 = class$javax$baja$sys$BComplex;
if (clazz2 == null) {
clazz2 = class$javax$baja$sys$BComplex = Introspector.class("[Ljavax.baja.sys.BComplex;", false);
}
if (clazz2.isAssignableFrom(clazz)) {
return new ComplexIntrospector(n, clazz);
}
Class clazz3 = class$javax$baja$sys$BFrozenEnum;
if (clazz3 == null) {
clazz3 = class$javax$baja$sys$BFrozenEnum = Introspector.class("[Ljavax.baja.sys.BFrozenEnum;", false);
}
if (clazz3.isAssignableFrom(clazz)) {
return new EnumIntrospector(n, clazz);
}
Class clazz4 = class$javax$baja$sys$BSimple;
if (clazz4 == null) {
clazz4 = class$javax$baja$sys$BSimple = Introspector.class("[Ljavax.baja.sys.BSimple;", false);
}
if (clazz4.isAssignableFrom(clazz)) {
return new SimpleIntrospector(n, clazz);
}
Class clazz5 = class$javax$baja$sys$BSingleton;
if (clazz5 == null) {
clazz5 = class$javax$baja$sys$BSingleton = Introspector.class("[Ljavax.baja.sys.BSingleton;", false);
}
if (clazz5.isAssignableFrom(clazz)) {
return new SingletonIntrospector(n, clazz);
}
return new ObjectIntrospector(n, clazz);
}
static Introspector getCustomIntrospector(int n, Class clazz) {
try {
Field field = Introspector.getField("INTROSPECTOR", clazz);
if (field == null) {
return null;
}
Class clazz2 = class$java$lang$Class;
if (clazz2 == null) {
clazz2 = class$java$lang$Class = Introspector.class("[Ljava.lang.Class;", false);
}
if (!clazz2.isAssignableFrom(field.getType())) {
return null;
}
Class clazz3 = (Class)field.get(null);
Class clazz4 = class$com$tridium$sys$schema$Introspector;
if (clazz4 == null) {
clazz4 = class$com$tridium$sys$schema$Introspector = Introspector.class("[Lcom.tridium.sys.schema.Introspector;", false);
}
if (!clazz4.isAssignableFrom(clazz3)) {
return null;
}
Class[] classArray = new Class[2];
classArray[0] = Integer.TYPE;
Class clazz5 = class$java$lang$Class;
if (clazz5 == null) {
clazz5 = class$java$lang$Class = Introspector.class("[Ljava.lang.Class;", false);
}
classArray[1] = clazz5;
Constructor constructor = clazz3.getConstructor(classArray);
return (Introspector)constructor.newInstance(new Integer(n), clazz);
}
catch (Exception exception) {
exception.printStackTrace();
return null;
}
}
/*
* Unable to fully structure code
*/
static Field getField(String var0, Class var1_1) {
var2_2 = var1_1;
if (true) ** GOTO lbl11
do {
var3_3 = null;
try {
var3_3 = var2_2.getDeclaredField(var0);
var3_3.setAccessible(true);
return var3_3;
}
catch (Exception var4_4) {
var2_2 = var2_2.getSuperclass();
}
lbl11:
// 2 sources
if ((v0 = Introspector.class$javax$baja$sys$BObject) != null) continue;
v0 = Introspector.class("[Ljavax.baja.sys.BObject;", false);
} while (var2_2 != v0);
return null;
}
abstract Type introspect() throws Exception;
BObject getConstantFieldObject(String string) throws Exception {
try {
if (this.isAbstract) {
return null;
}
Field field = this.cls.getField(string);
this.checkPublicStaticFinal(field);
if (field.getType() != this.cls) {
throw this.err(string + " field is wrong type");
}
BObject bObject = (BObject)field.get(null);
if (bObject == null) {
throw this.err(string + " field is null; insure getType() comes last");
}
return bObject;
}
catch (TypeIntrospectionException typeIntrospectionException) {
throw typeIntrospectionException;
}
catch (Exception exception) {
throw this.err("Missing or invalid " + string + " field");
}
}
NModule getModule() {
return Introspector.getModule(this.cls, this.typeName);
}
static NModule getModule(Class clazz, String string) {
ClassLoader classLoader = clazz.getClassLoader();
if (classLoader instanceof ModuleClassLoader) {
NModule nModule = ((ModuleClassLoader)classLoader).module;
String string2 = nModule.getTypeClassName(string);
if (string2 == null) {
throw Introspector.err(clazz, "Module does not declare type '" + string + "' in 'module.xml'");
}
if (!string2.equals(clazz.getName())) {
throw Introspector.err(clazz, "Type '" + string + "' should be '" + string2 + '\'');
}
return nModule;
}
NModule[] nModuleArray = Nre.moduleManager.getModules();
int n = 0;
while (n < nModuleArray.length) {
String string3;
if (nModuleArray[n].isSystemJar() && (string3 = nModuleArray[n].getTypeClassName(string)) != null && string3.equals(clazz.getName())) {
return nModuleArray[n];
}
++n;
}
throw Introspector.err(clazz, "Cannot resolve class to module (check 'module.xml')");
}
boolean isPublic(Member member) {
return Modifier.isPublic(member.getModifiers());
}
boolean isStatic(Member member) {
return Modifier.isStatic(member.getModifiers());
}
boolean isPublicStaticFinal(Field field) {
int n = field.getModifiers();
boolean bl = false;
if (Modifier.isPublic(n) && Modifier.isStatic(n) && Modifier.isFinal(n)) {
bl = true;
}
return bl;
}
void checkPublicStaticFinal(Field field) {
if (!this.isPublicStaticFinal(field)) {
throw this.err("Field must be public static final", field.getName());
}
}
public TypeIntrospectionException err(String string) {
return Introspector.err(this.cls, string);
}
public static TypeIntrospectionException err(Class clazz, String string) {
return Introspector.err(clazz, string, null);
}
public TypeIntrospectionException err(String string, String string2) {
return Introspector.err(this.cls, string, string2);
}
public static TypeIntrospectionException err(Class clazz, String string, String string2) {
String string3 = string2 == null ? string : string + " (" + string2 + ')';
String string4 = clazz.getName();
if (clazz.getClassLoader() instanceof ModuleClassLoader) {
NModule nModule = ((ModuleClassLoader)clazz.getClassLoader()).module;
string4 = nModule.getModuleName() + ':' + string4;
}
SchemaManager.log.error(string4 + ": " + string3);
return new TypeIntrospectionException(clazz, string3);
}
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());
}
}
protected Introspector(int n, Class clazz) {
this.id = n;
this.cls = clazz;
this.typeName = NType.getTypeName(clazz.getName());
this.module = this.getModule();
this.facetsPath = "/" + clazz.getName().replace('.', '/') + ".facets";
this.isAbstract = Modifier.isAbstract(clazz.getModifiers());
this.isFinal = Modifier.isFinal(clazz.getModifiers());
}
static {
Class clazz;
Class clazz2;
Class clazz3 = class$javax$baja$sys$Property;
if (clazz3 == null) {
clazz3 = propertyClass = (class$javax$baja$sys$Property = Introspector.class("[Ljavax.baja.sys.Property;", false));
}
if ((clazz2 = class$javax$baja$sys$Action) == null) {
clazz2 = actionClass = (class$javax$baja$sys$Action = Introspector.class("[Ljavax.baja.sys.Action;", false));
}
if ((clazz = class$javax$baja$sys$Topic) == null) {
clazz = class$javax$baja$sys$Topic = Introspector.class("[Ljavax.baja.sys.Topic;", false);
}
topicClass = clazz;
}
}
@@ -0,0 +1,132 @@
/*
* Decompiled with CFR 0.152.
*
* Could not load the following classes:
* javax.baja.nre.util.TextUtil
*/
package com.tridium.sys.schema;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.HashMap;
import javax.baja.nre.util.TextUtil;
/*
* Illegal identifiers - consider using --renameillegalidents true
*/
class MethodMap {
static final Class[] noParams = new Class[0];
static final Class wildcard;
private HashMap map;
private Class[] oneParam;
static /* synthetic */ Class class$com$tridium$sys$schema$MethodMap;
Method getMethod(String string, Class clazz) {
this.oneParam[0] = clazz;
return this.getMethod(string, this.oneParam);
}
Method getMethod(String string, Class[] classArray) {
Object v = this.map.get(string);
if (v != null) {
if (v instanceof Method) {
Method method = (Method)v;
if (this.isMatch(method, classArray)) {
return method;
}
} else {
ArrayList arrayList = (ArrayList)v;
int n = 0;
while (n < arrayList.size()) {
Method method = (Method)arrayList.get(n);
if (this.isMatch(method, classArray)) {
return method;
}
++n;
}
}
}
return null;
}
boolean isMatch(Method method, Class[] classArray) {
Class<?>[] classArray2 = method.getParameterTypes();
if (classArray2.length != classArray.length) {
return false;
}
int n = 0;
while (n < classArray2.length) {
Class clazz = classArray[n];
if (clazz != wildcard && clazz != classArray2[n]) {
return false;
}
++n;
}
return true;
}
String toString(Class[] classArray) {
StringBuffer stringBuffer = new StringBuffer();
stringBuffer.append('(');
int n = 0;
while (n < classArray.length) {
if (n > 0) {
stringBuffer.append(',');
}
stringBuffer.append(TextUtil.getClassName((Class)classArray[n]));
++n;
}
stringBuffer.append(')');
return stringBuffer.toString();
}
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.oneParam = new Class[1];
}
MethodMap(Class clazz) {
this.this();
Method[] methodArray = clazz.getMethods();
int n = methodArray.length;
this.map = new HashMap(n * 3);
int n2 = 0;
while (n2 < n) {
Method method = methodArray[n2];
String string = method.getName();
Object v = this.map.get(string);
if (v == null) {
this.map.put(string, method);
} else if (v instanceof Method) {
ArrayList<Object> arrayList = new ArrayList<Object>(5);
arrayList.add(v);
arrayList.add(method);
this.map.put(string, arrayList);
} else {
((ArrayList)v).add(method);
}
++n2;
}
}
static {
Class clazz = class$com$tridium$sys$schema$MethodMap;
if (clazz == null) {
clazz = class$com$tridium$sys$schema$MethodMap = MethodMap.class("[Lcom.tridium.sys.schema.MethodMap;", false);
}
wildcard = clazz;
}
}
@@ -0,0 +1,110 @@
/*
* Decompiled with CFR 0.152.
*/
package com.tridium.sys.schema;
import com.tridium.sys.schema.NSlot;
import javax.baja.sys.Action;
import javax.baja.sys.BFacets;
import javax.baja.sys.BValue;
import javax.baja.sys.Property;
import javax.baja.sys.Sys;
import javax.baja.sys.Topic;
import javax.baja.sys.Type;
public class NAction
extends NSlot
implements Action {
Class parameterClass;
Class returnClass;
Type parameterType;
Type returnType;
BValue parameterDefault;
boolean doTakesContext;
public final boolean isProperty() {
return false;
}
public final boolean isAction() {
return true;
}
public final boolean isTopic() {
return false;
}
public final Property asProperty() {
throw new ClassCastException();
}
public final Action asAction() {
return this;
}
public final Topic asTopic() {
throw new ClassCastException();
}
public final Type getParameterType() {
if (this.parameterClass == null) {
return null;
}
if (this.parameterType == null) {
this.parameterType = Sys.getType(this.parameterClass);
}
return this.parameterType;
}
public final BValue getParameterDefault() {
if (this.parameterDefault == null) {
return null;
}
return this.parameterDefault.newCopy();
}
public final Type getReturnType() {
if (this.returnClass == null) {
return null;
}
if (this.returnType == null) {
this.returnType = Sys.getType(this.returnClass);
}
return this.returnType;
}
public String toString() {
return NAction.toString(this);
}
void copyFrom(NSlot nSlot) {
super.copyFrom(nSlot);
NAction nAction = (NAction)nSlot;
this.parameterClass = nAction.parameterClass;
this.parameterType = nAction.parameterType;
this.returnClass = nAction.returnClass;
this.returnType = nAction.returnType;
}
static String toString(Action action) {
StringBuffer stringBuffer = new StringBuffer();
stringBuffer.append(action.getName());
stringBuffer.append('(');
try {
if (action.getParameterType() != null) {
stringBuffer.append(action.getParameterType());
}
}
catch (Exception exception) {
stringBuffer.append(exception);
}
stringBuffer.append(')');
return stringBuffer.toString();
}
public NAction(int n, BValue bValue, BFacets bFacets) {
super(null, n, bFacets, true);
this.parameterDefault = bValue;
}
}
@@ -0,0 +1,53 @@
/*
* Decompiled with CFR 0.152.
*/
package com.tridium.sys.schema;
import com.tridium.sys.schema.NAction;
import com.tridium.sys.schema.NProperty;
import javax.baja.sys.Action;
import javax.baja.sys.BAction;
import javax.baja.sys.BFacets;
import javax.baja.sys.BValue;
import javax.baja.sys.Type;
public class NActionProperty
extends NProperty
implements Action {
public final boolean isAction() {
return true;
}
public final Action asAction() {
return this;
}
public final Type getParameterType() {
return ((BAction)this.value).getParameterType();
}
public final Type getReturnType() {
return ((BAction)this.value).getReturnType();
}
public final BValue getParameterDefault() {
return ((BAction)this.value).getParameterDefault();
}
public BFacets getFacets() {
BFacets bFacets = ((BAction)this.value).getFacets();
if (bFacets == null || bFacets.isNull()) {
return super.getFacets();
}
return bFacets;
}
public String toString() {
return NAction.toString(this);
}
public NActionProperty(String string, int n, BAction bAction, BFacets bFacets) {
super(string, n, bAction, bFacets);
}
}
@@ -0,0 +1,136 @@
/*
* Decompiled with CFR 0.152.
*/
package com.tridium.sys.schema;
import com.tridium.sys.schema.NSlot;
import com.tridium.sys.schema.Utils;
import java.lang.reflect.Modifier;
import javax.baja.sys.Action;
import javax.baja.sys.BFacets;
import javax.baja.sys.BObject;
import javax.baja.sys.BValue;
import javax.baja.sys.Property;
import javax.baja.sys.Sys;
import javax.baja.sys.Topic;
import javax.baja.sys.Type;
/*
* Illegal identifiers - consider using --renameillegalidents true
*/
public class NProperty
extends NSlot
implements Property {
public static final int TYPE_FINAL = 1;
public BValue value;
Class typeClass;
Type type;
int typeAccess;
int propertyFlags;
void init() {
if (Modifier.isFinal(this.typeClass.getModifiers())) {
this.propertyFlags |= 1;
}
}
public final boolean isProperty() {
return true;
}
public boolean isAction() {
return false;
}
public boolean isTopic() {
return false;
}
public final Property asProperty() {
return this;
}
public Action asAction() {
throw new ClassCastException();
}
public Topic asTopic() {
throw new ClassCastException();
}
public final int getTypeAccess() {
return this.typeAccess;
}
public final BValue getDefaultValue() {
return this.value.newCopy(true);
}
public final boolean isEquivalentToDefaultValue(BValue bValue) {
return this.value.equivalent(bValue);
}
public final Type getType() {
if (this.type == null) {
this.type = Sys.getType(this.typeClass);
}
return this.type;
}
public final Type getType(BObject bObject) {
return this.getType();
}
public final boolean isTypeFinal() {
boolean bl = false;
if ((this.propertyFlags & 1) != 0) {
bl = true;
}
return bl;
}
boolean equivalent(NProperty nProperty) {
if (!super.equivalent(nProperty)) {
return false;
}
return this.value.equivalent(nProperty.value);
}
void copyFrom(NSlot nSlot) {
super.copyFrom(nSlot);
NProperty nProperty = (NProperty)nSlot;
this.type = nProperty.type;
this.typeClass = nProperty.typeClass;
this.typeAccess = nProperty.typeAccess;
this.propertyFlags = nProperty.propertyFlags;
}
public String toString() {
return this.name + ": " + this.getType();
}
private final /* synthetic */ void this() {
this.typeAccess = -1;
}
public NProperty(int n, BValue bValue, BFacets bFacets) {
super(null, n, bFacets, true);
this.this();
this.value = bValue;
}
public NProperty(String string, int n, BValue bValue, BFacets bFacets) {
this(string, n, bValue, bFacets, false);
}
public NProperty(String string, int n, BValue bValue, BFacets bFacets, boolean bl) {
super(string, n, bFacets, bl);
this.this();
this.value = bValue;
this.type = bValue.getType();
this.typeClass = bValue.getClass();
this.typeAccess = Utils.getTypeAccess(this.typeClass);
this.init();
}
}
@@ -0,0 +1,101 @@
/*
* Decompiled with CFR 0.152.
*/
package com.tridium.sys.schema;
import com.tridium.sys.engine.SlotKnobs;
import javax.baja.naming.SlotPath;
import javax.baja.sys.BFacets;
import javax.baja.sys.Context;
import javax.baja.sys.Slot;
import javax.baja.sys.Type;
import javax.baja.util.Lexicon;
public abstract class NSlot
implements Slot {
public int index;
Type declaringType;
String name;
String displayName;
int flags;
boolean isFrozen;
SlotKnobs knobs;
BFacets facets;
public final Type getDeclaringType() {
return this.declaringType;
}
public final String getName() {
return this.name;
}
public final String getDefaultDisplayName(Context context) {
try {
String string = this.declaringType.getModule().getModuleName();
String string2 = Lexicon.make(string, context).get(this.name);
if (string2 != null) {
return string2;
}
}
catch (Throwable throwable) {
throwable.printStackTrace();
}
if (this.displayName == null) {
this.displayName = SlotPath.unescape(this.name);
}
return this.displayName;
}
public final boolean isFrozen() {
return this.isFrozen;
}
public final boolean isDynamic() {
return this.isFrozen ^ true;
}
public final int getDefaultFlags() {
return this.flags;
}
public BFacets getFacets() {
return this.facets;
}
public final boolean equals(Object object) {
NSlot nSlot = (NSlot)object;
if (this == nSlot) {
return true;
}
boolean bl = false;
if (this.index == nSlot.index) {
bl = true;
}
return bl;
}
boolean equivalent(NSlot nSlot) {
boolean bl = false;
if (this.name.equals(nSlot.name) && this.flags == nSlot.flags && this.isFrozen == nSlot.isFrozen && this.facets.equals(nSlot.facets)) {
bl = true;
}
return bl;
}
void copyFrom(NSlot nSlot) {
this.index = nSlot.index;
this.declaringType = nSlot.declaringType;
this.name = nSlot.name;
this.displayName = nSlot.displayName;
this.isFrozen = nSlot.isFrozen;
}
NSlot(String string, int n, BFacets bFacets, boolean bl) {
this.name = string;
this.flags = n;
this.facets = bFacets;
this.isFrozen = bl;
}
}
@@ -0,0 +1,110 @@
/*
* Decompiled with CFR 0.152.
*
* Could not load the following classes:
* javax.baja.nre.util.TextUtil
*/
package com.tridium.sys.schema;
import com.tridium.sys.schema.NAction;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import javax.baja.nre.util.TextUtil;
import javax.baja.sys.ActionInvokeException;
import javax.baja.sys.BComponent;
import javax.baja.sys.BFacets;
import javax.baja.sys.BValue;
import javax.baja.sys.Context;
import javax.baja.sys.Type;
public class NSyntheticAction
extends NAction {
static final SyntheticActionInvocationHandler DEFAULT_HANDLER = new SyntheticActionInvocationHandler();
SyntheticActionInvocationHandler handler;
public BValue invoke(int n, BComponent bComponent, BValue bValue, Context context) {
return this.handler.invoke(this, bComponent, bValue, context);
}
public NSyntheticAction(int n, BValue bValue, BFacets bFacets) {
this(n, bValue, bFacets, DEFAULT_HANDLER);
}
public NSyntheticAction(int n, BValue bValue, BFacets bFacets, SyntheticActionInvocationHandler syntheticActionInvocationHandler) {
super(n, bValue, bFacets);
this.handler = syntheticActionInvocationHandler;
if (bValue != null) {
this.parameterClass = bValue.getClass();
}
}
/*
* Illegal identifiers - consider using --renameillegalidents true
*/
public static class SyntheticActionInvocationHandler {
static /* synthetic */ Class class$javax$baja$sys$Context;
public BValue invoke(NSyntheticAction nSyntheticAction, BComponent bComponent, BValue bValue, Context context) {
Class<?> clazz = bComponent.getClass();
Type type = nSyntheticAction.getParameterType();
try {
if (type == null) {
try {
Method method = clazz.getMethod("do" + TextUtil.capitalize((String)nSyntheticAction.getName()), new Class[0]);
return (BValue)method.invoke((Object)bComponent, new Object[0]);
}
catch (NoSuchMethodException noSuchMethodException) {
String string = "do" + TextUtil.capitalize((String)nSyntheticAction.getName());
Class[] classArray = new Class[1];
Class clazz2 = class$javax$baja$sys$Context;
if (clazz2 == null) {
clazz2 = class$javax$baja$sys$Context = SyntheticActionInvocationHandler.class("[Ljavax.baja.sys.Context;", false);
}
classArray[0] = clazz2;
Method method = clazz.getMethod(string, classArray);
return (BValue)method.invoke((Object)bComponent, bValue, context);
}
}
try {
Method method = clazz.getMethod("do" + TextUtil.capitalize((String)nSyntheticAction.getName()), type.getTypeClass());
return (BValue)method.invoke((Object)bComponent, bValue);
}
catch (NoSuchMethodException noSuchMethodException) {
String string = "do" + TextUtil.capitalize((String)nSyntheticAction.getName());
Class[] classArray = new Class[2];
classArray[0] = type.getTypeClass();
Class clazz3 = class$javax$baja$sys$Context;
if (clazz3 == null) {
clazz3 = class$javax$baja$sys$Context = SyntheticActionInvocationHandler.class("[Ljavax.baja.sys.Context;", false);
}
classArray[1] = clazz3;
Method method = clazz.getMethod(string, classArray);
return (BValue)method.invoke((Object)bComponent, bValue, context);
}
}
catch (IllegalAccessException illegalAccessException) {
throw new ActionInvokeException("Illegal acccess on action invocation callback for '" + nSyntheticAction.getName() + "'.", illegalAccessException);
}
catch (InvocationTargetException invocationTargetException) {
throw new ActionInvokeException("Action invocation callback failed for '" + nSyntheticAction.getName() + "'.", invocationTargetException);
}
catch (NoSuchMethodException noSuchMethodException) {
throw new ActionInvokeException("Action invocation callback undefined for '" + nSyntheticAction.getName() + "'.", noSuchMethodException);
}
}
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());
}
}
}
}
@@ -0,0 +1,69 @@
/*
* Decompiled with CFR 0.152.
*/
package com.tridium.sys.schema;
import com.tridium.sys.schema.NSlot;
import javax.baja.sys.Action;
import javax.baja.sys.BFacets;
import javax.baja.sys.Property;
import javax.baja.sys.Sys;
import javax.baja.sys.Topic;
import javax.baja.sys.Type;
public class NTopic
extends NSlot
implements Topic {
Class eventClass;
Type eventType;
public final boolean isProperty() {
return false;
}
public final boolean isAction() {
return false;
}
public final boolean isTopic() {
return true;
}
public final Property asProperty() {
throw new ClassCastException();
}
public final Action asAction() {
throw new ClassCastException();
}
public final Topic asTopic() {
return this;
}
public Type getEventType() {
if (this.eventClass == null) {
return null;
}
if (this.eventType == null) {
this.eventType = Sys.getType(this.eventClass);
}
return this.eventType;
}
void copyFrom(NSlot nSlot) {
super.copyFrom(nSlot);
NTopic nTopic = (NTopic)nSlot;
this.eventClass = nTopic.eventClass;
this.eventType = nTopic.eventType;
}
public String toString() {
return this.name + "! " + this.getEventType();
}
public NTopic(int n, BFacets bFacets) {
super(null, n, bFacets, true);
}
}
@@ -0,0 +1,48 @@
/*
* Decompiled with CFR 0.152.
*/
package com.tridium.sys.schema;
import com.tridium.sys.schema.NProperty;
import javax.baja.sys.BFacets;
import javax.baja.sys.BTopic;
import javax.baja.sys.BValue;
import javax.baja.sys.Topic;
import javax.baja.sys.Type;
public class NTopicProperty
extends NProperty
implements Topic {
public final boolean isTopic() {
return true;
}
public final Topic asTopic() {
return this;
}
public Type getEventType() {
Type type = ((BTopic)this.value).getEventType();
if (type == null) {
type = BValue.TYPE;
}
return type;
}
public BFacets getFacets() {
BFacets bFacets = ((BTopic)this.value).getFacets();
if (bFacets == null || bFacets.isNull()) {
return super.getFacets();
}
return bFacets;
}
public String toString() {
return this.name + "! " + this.getEventType();
}
public NTopicProperty(String string, int n, BTopic bTopic, BFacets bFacets) {
super(string, n, bTopic, bFacets);
}
}
@@ -0,0 +1,200 @@
/*
* Decompiled with CFR 0.152.
*/
package com.tridium.sys.schema;
import com.tridium.sys.module.NModule;
import com.tridium.sys.schema.Introspector;
import java.util.ArrayList;
import javax.baja.registry.TypeInfo;
import javax.baja.sys.AbstractTypeException;
import javax.baja.sys.BModule;
import javax.baja.sys.Context;
import javax.baja.sys.Sys;
import javax.baja.sys.Type;
import javax.baja.util.BTypeSpec;
/*
* Illegal identifiers - consider using --renameillegalidents true
*/
public abstract class NType
implements Type {
final int id;
final NModule module;
final Class typeClass;
final String typeName;
final boolean isAbstract;
final boolean isFinal;
private Object typeSpec;
private Type[] interfaces;
private Type superType;
private boolean haveSuperType;
protected TypeInfo typeInfo;
private Object fields;
static /* synthetic */ Class class$javax$baja$sys$BInterface;
static /* synthetic */ Class class$java$lang$Object;
public final int getId() {
return this.id;
}
public final BModule getModule() {
return this.module.bmodule();
}
public final Class getTypeClass() {
return this.typeClass;
}
public final String getTypeName() {
return this.typeName;
}
public final String getDisplayName(Context context) {
return this.getTypeInfo().getDisplayName(context);
}
public boolean isInterface() {
return false;
}
public final boolean isAbstract() {
return this.isAbstract;
}
public final boolean isFinal() {
return this.isFinal;
}
public boolean isDataType() {
return false;
}
public char getDataTypeSymbol() {
return '\u0000';
}
public final TypeInfo getTypeInfo() {
if (this.typeInfo == null) {
this.typeInfo = Sys.getRegistry().getType(this.toString());
}
return this.typeInfo;
}
public final boolean is(Type type) {
return this.getTypeInfo().is(type.getTypeInfo());
}
public final boolean is(TypeInfo typeInfo) {
return this.getTypeInfo().is(typeInfo);
}
public boolean isTransient() {
return false;
}
public final Type[] getInterfaces() {
if (this.interfaces == null) {
ArrayList<Type> arrayList = new ArrayList<Type>();
Class<?>[] classArray = this.typeClass.getInterfaces();
int n = 0;
while (n < classArray.length) {
Class<?> clazz = classArray[n];
Class clazz2 = class$javax$baja$sys$BInterface;
if (clazz2 == null) {
clazz2 = NType.class("[Ljavax.baja.sys.BInterface;", false);
}
if (clazz2.isAssignableFrom(clazz)) {
arrayList.add(Sys.getType(clazz));
}
++n;
}
this.interfaces = arrayList.toArray(new Type[arrayList.size()]);
}
return this.interfaces;
}
public final Type getSuperType() {
if (!this.haveSuperType) {
Class clazz = this.typeClass.getSuperclass();
if (clazz != null) {
Class clazz2 = class$java$lang$Object;
if (clazz2 == null) {
clazz2 = class$java$lang$Object = NType.class("[Ljava.lang.Object;", false);
}
if (clazz != clazz2) {
this.superType = Sys.getType(clazz);
}
}
this.haveSuperType = true;
}
return this.superType;
}
public final BTypeSpec getTypeSpec() {
if (this.typeSpec == null) {
this.typeSpec = BTypeSpec.make(this);
}
return (BTypeSpec)this.typeSpec;
}
public final String toString() {
return this.module.getModuleName() + ':' + this.typeName;
}
public Object getFields() {
return this.fields;
}
public void setFields(Object object) {
this.fields = object;
}
final void checkConcrete() {
if (this.isAbstract) {
throw new AbstractTypeException(this.toString());
}
}
static String getTypeName(String string) {
String string2 = string;
int n = string2.lastIndexOf(46);
if (n > 0 && (string2 = string2.substring(n + 1)).length() > 1 && string2.charAt(0) == 'B' && Character.isUpperCase(string2.charAt(1))) {
string2 = string2.substring(1, string2.length());
}
return string2;
}
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());
}
}
NType(Introspector introspector) {
this.id = introspector.id;
this.module = introspector.module;
this.typeClass = introspector.cls;
this.typeName = introspector.typeName;
this.isAbstract = introspector.isAbstract;
this.isFinal = introspector.isFinal;
this.module.register(this.typeName, this);
}
NType(NType nType) {
this.id = nType.id;
this.module = nType.module;
this.typeClass = nType.typeClass;
this.typeName = nType.typeName;
this.isAbstract = nType.isAbstract;
this.isFinal = nType.isFinal;
}
}
@@ -0,0 +1,20 @@
/*
* Decompiled with CFR 0.152.
*/
package com.tridium.sys.schema;
import com.tridium.sys.schema.Introspector;
import com.tridium.sys.schema.ObjectType;
import javax.baja.sys.Type;
class ObjectIntrospector
extends Introspector {
Type introspect() throws Exception {
return new ObjectType(this);
}
ObjectIntrospector(int n, Class clazz) {
super(n, clazz);
}
}
@@ -0,0 +1,33 @@
/*
* Decompiled with CFR 0.152.
*/
package com.tridium.sys.schema;
import com.tridium.sys.schema.Introspector;
import com.tridium.sys.schema.NType;
import javax.baja.sys.BObject;
import javax.baja.sys.BajaRuntimeException;
public class ObjectType
extends NType {
public final BObject getInstance() {
try {
return (BObject)this.getTypeClass().newInstance();
}
catch (RuntimeException runtimeException) {
throw runtimeException;
}
catch (Throwable throwable) {
throw new BajaRuntimeException("Class.newInstance() failed (insure public ctor and not abstract): " + this, throwable);
}
}
public boolean isInterface() {
return false;
}
ObjectType(Introspector introspector) {
super(introspector);
}
}
@@ -0,0 +1,198 @@
/*
* Decompiled with CFR 0.152.
*/
package com.tridium.sys.schema;
import com.tridium.sys.schema.DynamicTable;
import com.tridium.sys.schema.NProperty;
import javax.baja.log.Log;
import javax.baja.sys.Action;
import javax.baja.sys.BComplex;
import javax.baja.sys.BObject;
import javax.baja.sys.Context;
import javax.baja.sys.CursorException;
import javax.baja.sys.Property;
import javax.baja.sys.Slot;
import javax.baja.sys.SlotCursor;
import javax.baja.sys.Topic;
final class PropertyCursor
implements SlotCursor {
private static final Log log = Log.getLog("baja.PropertyCursor");
private int index = -1;
private BComplex object;
private NProperty[] frozen;
private DynamicTable dynamic;
private int count;
public final BObject target() {
return this.object;
}
public final Context getContext() {
return null;
}
public final boolean next() {
boolean bl = false;
if (++this.index < this.count) {
bl = true;
}
return bl;
}
public final boolean nextObject() {
while (++this.index < this.count) {
block4: {
try {
Property property = this.property();
if (property.getTypeAccess() != 7) {
}
break block4;
}
catch (RuntimeException runtimeException) {
if (!log.isTraceOn()) continue;
log.trace(runtimeException.getMessage(), runtimeException);
}
continue;
}
return true;
}
return false;
}
public final boolean nextComponent() {
while (++this.index < this.count) {
block4: {
try {
Property property = this.property();
if (property.getTypeAccess() != 7) continue;
if (!this.object.get(property).isComponent()) {
}
break block4;
}
catch (RuntimeException runtimeException) {
if (!log.isTraceOn()) continue;
log.trace(runtimeException.getMessage(), runtimeException);
}
continue;
}
return true;
}
return false;
}
public final boolean next(Class clazz) {
while (++this.index < this.count) {
block4: {
try {
Property property = this.property();
if (property.getTypeAccess() != 7) continue;
if (!clazz.isInstance(this.object.get(property))) {
}
break block4;
}
catch (RuntimeException runtimeException) {
runtimeException.printStackTrace();
}
continue;
}
return true;
}
return false;
}
public final Slot slot() {
if (this.index < this.frozen.length) {
return this.frozen[this.index];
}
return this.dynamic.slots[this.index - this.frozen.length];
}
public final Property property() {
if (this.index < this.frozen.length) {
return this.frozen[this.index];
}
return this.dynamic.slots[this.index - this.frozen.length];
}
public final int getTypeAccess() {
if (this.index < this.frozen.length) {
return this.frozen[this.index].typeAccess;
}
return this.dynamic.slots[this.index - this.frozen.length].typeAccess;
}
public final BObject get() {
if (this.index < this.frozen.length) {
return this.object.get(this.frozen[this.index]);
}
return this.object.get(this.dynamic.slots[this.index - this.frozen.length]);
}
public final boolean getBoolean() {
if (this.index < this.frozen.length) {
return this.object.getBoolean(this.frozen[this.index]);
}
return this.object.getBoolean(this.dynamic.slots[this.index - this.frozen.length]);
}
public final int getInt() {
if (this.index < this.frozen.length) {
return this.object.getInt(this.frozen[this.index]);
}
return this.object.getInt(this.dynamic.slots[this.index - this.frozen.length]);
}
public final long getLong() {
if (this.index < this.frozen.length) {
return this.object.getLong(this.frozen[this.index]);
}
return this.object.getLong(this.dynamic.slots[this.index - this.frozen.length]);
}
public final float getFloat() {
if (this.index < this.frozen.length) {
return this.object.getFloat(this.frozen[this.index]);
}
return this.object.getFloat(this.dynamic.slots[this.index - this.frozen.length]);
}
public final double getDouble() {
if (this.index < this.frozen.length) {
return this.object.getDouble(this.frozen[this.index]);
}
return this.object.getDouble(this.dynamic.slots[this.index - this.frozen.length]);
}
public final String getString() {
if (this.index < this.frozen.length) {
return this.object.getString(this.frozen[this.index]);
}
return this.object.getString(this.dynamic.slots[this.index - this.frozen.length]);
}
public final Action action() {
Slot slot = this.slot();
if (slot.isAction()) {
return slot.asAction();
}
throw new CursorException("not action");
}
public final Topic topic() {
Slot slot = this.slot();
if (slot.isTopic()) {
return slot.asTopic();
}
throw new CursorException("not topic");
}
PropertyCursor(BComplex bComplex, NProperty[] nPropertyArray, DynamicTable dynamicTable) {
this.object = bComplex;
this.frozen = nPropertyArray;
this.dynamic = dynamicTable;
this.count = dynamicTable == null ? nPropertyArray.length : nPropertyArray.length + dynamicTable.count;
}
}
@@ -0,0 +1,374 @@
/*
* 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 "<a href='" + spyWriter.href(EscUtil.slot.escape(bTypeSpec.encodeToString())) + "'>" + string + "</a>";
}
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 + "<a href='" + var1_1.href("clear") + "'> Clear Intern Cache</a>";
}
var1_1.trTitle(var7_7, var6_6);
if (var5_5 != 0) {
var1_1.w("<tr><th>Reuse Count</th><th>toString()</th></tr>\n");
} else {
var1_1.w("<tr><th>toString()</th></tr>\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;
}
}
}
@@ -0,0 +1,51 @@
/*
* Decompiled with CFR 0.152.
*/
package com.tridium.sys.schema;
import com.tridium.sys.schema.Introspector;
import com.tridium.sys.schema.SimpleType;
import java.lang.reflect.Modifier;
import java.util.HashMap;
import javax.baja.sys.BSimple;
import javax.baja.sys.Type;
class SimpleIntrospector
extends Introspector {
static HashMap dataTypes = new HashMap();
Type introspect() throws Exception {
if (!this.isAbstract && !Modifier.isFinal(this.cls.getModifiers())) {
throw this.err("Concrete BSimples must be declared final");
}
return new SimpleType(this, (BSimple)this.getConstantFieldObject("DEFAULT"), SimpleIntrospector.getDataTypeSymbol(this.cls));
}
static char getDataTypeSymbol(Class clazz) {
Character c = (Character)dataTypes.get(clazz.getName());
if (c == null) {
return '\u0000';
}
return c.charValue();
}
SimpleIntrospector(int n, Class clazz) {
super(n, clazz);
}
static {
dataTypes.put("javax.baja.sys.BBoolean", new Character('b'));
dataTypes.put("javax.baja.sys.BInteger", new Character('i'));
dataTypes.put("javax.baja.sys.BLong", new Character('l'));
dataTypes.put("javax.baja.sys.BFloat", new Character('f'));
dataTypes.put("javax.baja.sys.BDouble", new Character('d'));
dataTypes.put("javax.baja.sys.BString", new Character('s'));
dataTypes.put("javax.baja.sys.BDynamicEnum", new Character('e'));
dataTypes.put("javax.baja.sys.BEnumRange", new Character('E'));
dataTypes.put("javax.baja.sys.BAbsTime", new Character('a'));
dataTypes.put("javax.baja.sys.BRelTime", new Character('r'));
dataTypes.put("javax.baja.timezone.BTimeZone", new Character('z'));
dataTypes.put("javax.baja.units.BUnit", new Character('u'));
}
}
@@ -0,0 +1,156 @@
/*
* Decompiled with CFR 0.152.
*
* Could not load the following classes:
* javax.baja.nre.util.Array
*/
package com.tridium.sys.schema;
import com.tridium.sys.schema.Introspector;
import com.tridium.sys.schema.NType;
import java.lang.ref.WeakReference;
import java.util.StringTokenizer;
import java.util.WeakHashMap;
import javax.baja.nre.util.Array;
import javax.baja.sys.BObject;
import javax.baja.sys.BSimple;
import javax.baja.sys.Clock;
/*
* Illegal identifiers - consider using --renameillegalidents true
*/
public class SimpleType
extends NType {
static final boolean internDisabled;
static final int maxCacheSize;
static final String defaultExcludedTypes = "baja:AbsTime;baja:Double;baja:Float;baja:Integer;baja:Long;baja:Ord;baja:OrdList;baja:Uuid";
static final Array noInternTypes;
static final boolean internDebug;
static volatile long maxInternTicks;
BSimple defaultInstance;
final char dataTypeSymbol;
final WeakHashMap internMap;
long reuseCounter;
final WeakHashMap counterMap;
static /* synthetic */ Class class$java$lang$String;
/*
* WARNING - Removed try catching itself - possible behaviour change.
* Enabled aggressive block sorting
* Enabled unnecessary exception pruning
* Enabled aggressive exception aggregation
*/
public final BSimple intern(BSimple bSimple) {
block10: {
long l;
if (this.internMap == null) {
return bSimple;
}
long l2 = l = internDebug ? Clock.ticks() : 0L;
if (bSimple.fw(116, bSimple, null, null, null) == Boolean.TRUE) {
return bSimple;
}
WeakHashMap weakHashMap = this.internMap;
synchronized (weakHashMap) {
BSimple bSimple2;
WeakReference weakReference = (WeakReference)this.internMap.get(bSimple);
if (weakReference != null && (bSimple2 = (BSimple)weakReference.get()) != null) {
++this.reuseCounter;
if (internDebug) {
Integer n = (Integer)this.counterMap.get(bSimple2);
if (n != null) {
this.counterMap.put(bSimple2, new Integer(n + 1));
} else {
this.counterMap.put(bSimple2, new Integer(1));
}
maxInternTicks = Math.max(maxInternTicks, Clock.ticks() - l);
}
return bSimple2;
}
if (this.internMap.size() < maxCacheSize) {
this.internMap.put(bSimple, new WeakReference<BSimple>(bSimple));
}
// MONITOREXIT @DISABLED, blocks:[0, 1] lbl26 : MonitorExitStatement: MONITOREXIT : var4_3
if (!internDebug) break block10;
}
maxInternTicks = Math.max(maxInternTicks, Clock.ticks() - l);
}
return bSimple;
}
public final boolean interningEnabled() {
boolean bl = false;
if (this.internMap != null) {
bl = true;
}
return bl;
}
public final BObject getInstance() {
this.checkConcrete();
return this.defaultInstance;
}
public final boolean isDataType() {
boolean bl = false;
if (this.dataTypeSymbol != '\u0000') {
bl = true;
}
return bl;
}
public final char getDataTypeSymbol() {
return this.dataTypeSymbol;
}
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.reuseCounter = 0L;
this.counterMap = internDebug ? new WeakHashMap() : null;
}
SimpleType(Introspector introspector, BSimple bSimple, char c) {
super(introspector);
this.this();
this.defaultInstance = bSimple;
this.dataTypeSymbol = c;
this.internMap = internDisabled || noInternTypes.contains((Object)this.toString()) ? null : new WeakHashMap();
}
static {
String string;
internDisabled = Boolean.getBoolean("niagara.intern.disabled");
maxCacheSize = Integer.getInteger("niagara.intern.maxCacheSize", Integer.MAX_VALUE);
Class clazz = class$java$lang$String;
if (clazz == null) {
clazz = class$java$lang$String = SimpleType.class("[Ljava.lang.String;", false);
}
noInternTypes = new Array(clazz);
if (!internDisabled && (string = System.getProperty("niagara.intern.excludeTypes", defaultExcludedTypes)) != null) {
StringTokenizer stringTokenizer = new StringTokenizer(string, ";");
while (stringTokenizer.hasMoreTokens()) {
try {
noInternTypes.add((Object)stringTokenizer.nextToken());
}
catch (Exception exception) {
exception.printStackTrace();
}
}
}
internDebug = Boolean.getBoolean("niagara.intern.debug");
maxInternTicks = 0L;
}
}

Some files were not shown because too many files have changed in this diff Show More