/** sometimes call by sample application, at that time normally set some properties directly */ private Configure() { Properties p = new Properties(); Map args = new HashMap(); args.putAll(System.getenv()); args.putAll(System.getProperties()); p.putAll(args); this.property = p; reload(false); }
public synchronized boolean reload(boolean force) { long now = System.currentTimeMillis(); if (force == false && now < last_check + 3000) return false; last_check = now; File file = getPropertyFile(); if (file.lastModified() == last_load_time) { return false; } last_load_time = file.lastModified(); Properties temp = new Properties(); if (file.canRead()) { FileInputStream in = null; try { in = new FileInputStream(file); temp.load(in); } catch (Exception e) { e.printStackTrace(); } finally { FileUtil.close(in); } } property = ConfigValueUtil.replaceSysProp(temp); apply(); ConfObserver.run(); return true; }
public File getPropertyFile() { if (propertyFile != null) { return propertyFile; } String s = System.getProperty("scouter.config", "./scouter.conf"); propertyFile = new File(s.trim()); return propertyFile; }
public synchronized void resetObjInfo() { String detected = ObjTypeDetector.drivedType != null ? ObjTypeDetector.drivedType : ObjTypeDetector.objType != null ? ObjTypeDetector.objType : CounterConstants.JAVA; this.obj_type = getValue("obj_type", detected); detected = CounterConstants.HOST; if (SystemUtil.IS_LINUX) { detected = CounterConstants.LINUX; } else if (SystemUtil.IS_WINDOWS) { detected = CounterConstants.WINDOWS; } else if (SystemUtil.IS_MAC_OSX) { detected = CounterConstants.OSX; } else if (SystemUtil.IS_AIX) { detected = CounterConstants.AIX; } else if (SystemUtil.IS_HP_UX) { detected = CounterConstants.HPUX; } this.obj_host_type = getValue("obj_host_type", detected); this.obj_host_name = getValue("obj_host_name", SysJMX.getHostName()); this.objHostName = "/" + this.obj_host_name; this.objHostHash = HashUtil.hash(objHostName); this.obj_name_auto_pid_enabled = getBoolean("obj_name_auto_pid_enabled", false); String defaultName; if (this.obj_name_auto_pid_enabled == true) { defaultName = "" + SysJMX.getProcessPID(); } else { defaultName = this.obj_type + "1"; } this.obj_name = getValue("obj_name", System.getProperty("jvmRoute", defaultName)); this.objName = objHostName + "/" + this.obj_name; this.objHash = HashUtil.hash(objName); System.setProperty("scouter.objname", this.objName); System.setProperty("scouter.objtype", this.obj_type); System.setProperty("scouter.dir", new File(".").getAbsolutePath()); }