Persist properties that are not system env or other system properties, in a thread synchronized manner
197118
public synchronized void persistProperties(Properties properties, File propsFile, String message) {
    Properties toWrite = new Properties();
    for(String key : properties.stringPropertyNames()) {

      if(System.getProperties().containsKey(key) && !properties.getProperty(key).equals(System.getProperty(key))) {

        toWrite.setProperty(key, properties.getProperty(key));
      } 
      else if(System.getenv().containsKey(key) && !properties.getProperty(key).equals(System.getenv(key))) {

        toWrite.setProperty(key, properties.getProperty(key));
      } 
      else if(!System.getProperties().containsKey(key) && !System.getenv().containsKey(key)){

        toWrite.setProperty(key, properties.getProperty(key));
      }
    }
    writer.persistProperties(toWrite, propsFile, message, log);
  }
7465
private ZooPC checkObjectForRefresh(Object pc) {
        if (!(pc instanceof ZooPC)) {
        	throw DBLogger.newUser("The object is not persistent capable: " + pc.getClass());
        }
        
        ZooPC pci = (ZooPC) pc;
        if (!pci.jdoZooIsPersistent()) {
        	return pci;
        }

        if (pci.jdoZooGetContext().getSession() != this) {
        	throw DBLogger.newUser("The object belongs to a different PersistenceManager.");
        }
        return pci;
	}
443190
@Restricted(NoExternalUse.class)
    public synchronized void persistInstallStatus() {
        List<UpdateCenterJob> jobs = getJobs();

        boolean activeInstalls = false;
        for (UpdateCenterJob job : jobs) {
            if (job instanceof InstallationJob) {
                InstallationJob installationJob = (InstallationJob) job;
                if(!installationJob.status.isSuccess()) {
            activeInstalls = true;
                }
            }
        }

        if(activeInstalls) {
        InstallUtil.persistInstallStatus(jobs); // save this info
        }
        else {
        InstallUtil.clearInstallStatus(); // clear this info
        }
    }
716605
public void afterPropertiesSet() throws Exception {
        scheduler = new ScheduledThreadPoolExecutor(DEFAULT_POOL, new NamedThreadFactory("Otter-Statistics-Client"),
                                                    new ThreadPoolExecutor.CallerRunsPolicy());
        scheduler.submit(new Runnable() {

            public void run() {
                doSendDelayCountEvent();
            }
        });
    }
859648
def rewrite_properties(self, properties):
        """"""
        with self.__properties_lock:
            self.__properties = properties
        self.__write_properties(None)
309072
private static Properties load() {
		Properties properties = new Properties();

		String file = System.getProperty(CONFIGURATION_PROPERTY);
		try {
			if (file != null) {
				InputStream stream;
				if (URL_DETECTION_PATTERN.matcher(file).matches()) {
					stream = new URL(file).openStream();
				} else {
					stream = Thread.currentThread().getContextClassLoader().getResourceAsStream(file);
					if (stream == null) {
						stream = new FileInputStream(file);
					}
				}
				load(properties, stream);
			} else {
				InputStream stream = Thread.currentThread().getContextClassLoader().getResourceAsStream(DEFAULT_CONFIGURATION_FILE);
				if (stream != null) {
					load(properties, stream);
				}
			}
		} catch (IOException ex) {
			InternalLogger.log(Level.ERROR, "Failed loading configuration from '" + file + "'");
		}

		for (Object key : new ArrayList<Object>(System.getProperties().keySet())) {
			String name = (String) key;
			if (name.startsWith(PROPERTIES_PREFIX)) {
				properties.put(name.substring(PROPERTIES_PREFIX.length()), System.getProperty(name));
			}
		}

		for (Entry<Object, Object> entry : properties.entrySet()) {
			String value = (String) entry.getValue();
			if (value.indexOf('{') != -1) {
				value = resolve(value, EnvironmentVariableResolver.INSTANCE);
				value = resolve(value, SystemPropertyResolver.INSTANCE);
				properties.put(entry.getKey(), value);
			}
		}

		return properties;
	}
22432
def set_threadlocal(self, **values):
        """"""
        with self._lock:
            self._ensure_threadlocal()
            self._tpayload.context = values
353281
function Persist(cacheFile, keys, log) {
  var pdata = (cacheFile) ? JSON.parse(fs.readFileSync(cacheFile, 'utf8')) : {}
    , guid = makeGuid(keys);

  pdata[guid] = pdata[guid] || {};

  // this is the only member that needs access to the full object and the file
  this.save = function () {
    if (cacheFile) {
      fs.writeFileSync(cacheFile, JSON.stringify(pdata));
    }
  };

  // members need only know their config object
  this.cfg = pdata[guid];
  this.cfg.opts = this.cfg.opts || {};

  // was a logger passed down?
  this.log = (type.isFunction(log)) ? log : noop;
}
1062890
function persist(pErr, pVal) {
          if (pErr) {
            return cb(pErr);
          }

          if (ttl) {
            conn.setex(key, ttl, pVal, handleResponse(conn, cb));
          } else {
            conn.set(key, pVal, handleResponse(conn, cb));
          }
        }
1276594
def _write_property(self, val, *args):
        """"""
        val_wid = val
        # 'finally' would be better here, but not supported in 2.4 :(
        try:
            totype = type(self._get_property(*args))
            if (totype is not type(None) and
                   (self._prop_cast or not self._prop_write)):
                val = self._cast_value(val, totype)

            if self._prop_write:
                val = self._prop_write(val)

            self._itsme = True
            self._set_property(val, *args)

        except ValueError:
            self._itsme = False
            if self._value_error:
                self._value_error(self, self._prop_name, val_wid)
            else:
                raise

        except:
            self._itsme = False
            raise

        self._itsme = False
625942
@Override
     public boolean saveProperties(String servicePid, Dictionary<String, String> properties)
     {
         try {
             if (servicePid != null)
             {
                 ServiceReference caRef = bundleContext.getServiceReference(ConfigurationAdmin.class.getName());
                 if (caRef != null)
                 {
                     ConfigurationAdmin configAdmin = (ConfigurationAdmin)bundleContext.getService(caRef);
                     Configuration config = configAdmin.getConfiguration(servicePid);
    
                     config.update(properties);
                     return true;
                 }
             }
         } catch (IOException e) {
             e.printStackTrace();
         }
         return false;
     }
1344395
def persistent_object_context_changed(self):
        
        super().persistent_object_context_changed()

        def source_registered(source):
            self.__source = source

        def source_unregistered(source=None):
            pass

        def reference_registered(property_name, reference):
            self.__referenced_objects[property_name] = reference

        def reference_unregistered(property_name, reference=None):
            pass

        if self.persistent_object_context:
            self.persistent_object_context.subscribe(self.source_uuid, source_registered, source_unregistered)

            for property_name, value in self.__properties.items():
                if isinstance(value, dict) and value.get("type") in {"data_item", "display_item", "data_source", "graphic", "structure"} and "uuid" in value:
                    self.persistent_object_context.subscribe(uuid.UUID(value["uuid"]), functools.partial(reference_registered, property_name), functools.partial(reference_unregistered, property_name))
        else:
            source_unregistered()

            for property_name, value in self.__properties.items():
                if isinstance(value, dict) and value.get("type") in {"data_item", "display_item", "data_source", "graphic", "structure"} and "uuid" in value:
                    reference_unregistered(property_name)
1010320
def sync(obj, engine):
    """"""
    snapshot = Condition()
    # Only expect values (or lack of a value) for columns that have been explicitly set
    for column in sorted(_obj_tracking[obj]["marked"], key=lambda col: col.dynamo_name):
        value = getattr(obj, column.name, None)
        value = engine._dump(column.typedef, value)
        condition = column == value
        # The renderer shouldn't try to dump the value again.
        # We're dumping immediately in case the value is mutable,
        # such as a set or (many) custom data types.
        condition.dumped = True
        snapshot &= condition
    _obj_tracking[obj]["snapshot"] = snapshot
476998
def persistent_object_context_changed(self):
        
        super().persistent_object_context_changed()

        def register():
            if self.__source is not None and self.__target is not None:
                assert not self.__binding
                self.__binding = Binding.PropertyBinding(self.__source, self.source_property)
                self.__binding.target_setter = self.__set_target_from_source
                # while reading, the data item in the display data channel will not be connected;
                # we still set its value here. when the data item becomes valid, it will update.
                self.__binding.update_target_direct(self.__binding.get_target_value())

        def source_registered(source):
            self.__source = source
            register()

        def target_registered(target):
            self.__target = target

            def property_changed(target, property_name):
                if property_name == self.target_property:
                    self.__set_source_from_target(getattr(target, property_name))

            assert self.__target_property_changed_listener is None
            self.__target_property_changed_listener = target.property_changed_event.listen(functools.partial(property_changed, target))
            register()

        def unregistered(item=None):
            if not item or item == self.__source:
                self.__source = None
            if not item or item == self.__target:
                self.__target = None
            if self.__binding:
                self.__binding.close()
                self.__binding = None
            if self.__target_property_changed_listener:
                self.__target_property_changed_listener.close()
                self.__target_property_changed_listener = None

        def change_registration(registered_object, unregistered_object):
            if registered_object and registered_object.uuid == self.source_uuid:
                source_registered(registered_object)
            if registered_object and registered_object.uuid == self.target_uuid:
                target_registered(registered_object)
            if unregistered_object and unregistered_object in (self._source, self._target):
                unregistered(unregistered_object)

        if self.persistent_object_context:
            self.__registration_listener = self.persistent_object_context.registration_event.listen(change_registration)
            source = self.persistent_object_context.get_registered_object(self.source_uuid)
            target = self.persistent_object_context.get_registered_object(self.target_uuid)
            if source:
                source_registered(source)
            if target:
                target_registered(target)
        else:
            unregistered()
237366
private void saveProperties(Properties prop) throws FileNotFoundException, IOException {
		FileOutputStream fos = new FileOutputStream(getPropertiesFile());
		try {
			prop.store(fos, null);
		} finally {
			fos.close();
		}
	}
541517
private void saveProperties() {
		assert Thread.holdsLock(properties);
		try {
			// Create a properties instance that sorts the output by keys (case-insensitive)
			Properties writer = new Properties() {
				private static final long serialVersionUID = 6953022173340009928L;
				@Override
				public Enumeration<Object> keys() {
					SortedSet<Object> sortedSet = new TreeSet<>(Collator.getInstance(Locale.ROOT));
					Enumeration<Object> e = super.keys();
					while(e.hasMoreElements()) sortedSet.add(e.nextElement());
					return Collections.enumeration(sortedSet);
				}
			};
			writer.putAll(properties);
			File tmpFile = File.createTempFile("ApplicationResources", null, sourceFile.getParentFile());
			OutputStream out = new BufferedOutputStream(new FileOutputStream(tmpFile));
			try {
				// Write any comments from when file was read
				if(sourceFileComments!=null) {
					for(String line : sourceFileComments) {
						out.write(line.getBytes(propertiesCharset));
						out.write(EOL.getBytes(propertiesCharset));
					}
				}
				// Wrap to skip any comments generated by Properties code
				out = new SkipCommentsFilterOutputStream(out);
				writer.store(out, null);
			} finally {
				out.close();
			}
			FileUtils.renameAllowNonAtomic(tmpFile, sourceFile);
		} catch(IOException err) {
			throw new RuntimeException(err);
		}
	}
253874
def set_property(self, key, value):
        
        self.properties[key] = value
        self.sync_properties()