Add all System properties to the given <code>props</code>. Will override
any properties that already exist in the given <code>props</code>.
179664
@Nonnull
  private NonBlockingProperties _overrideWithSysProps (@Nonnull final NonBlockingProperties props)
  {
    Properties sysProps = null;
    try
    {
      sysProps = System.getProperties ();
    }
    catch (final AccessControlException e)
    {
      LOGGER.warn ("Skipping overriding MiniQuartz properties with System properties " +
                   "during initialization because of an AccessControlException.  " +
                   "This is likely due to not having read/write access for " +
                   "java.util.PropertyPermission as required by java.lang.System.getProperties().  " +
                   "To resolve this warning, either add this permission to your policy file or " +
                   "use a non-default version of initialize().",
                   e);
    }

    if (sysProps != null)
    {
      for (final Map.Entry <?, ?> aEntry : sysProps.entrySet ())
        props.put ((String) aEntry.getKey (), (String) aEntry.getValue ());
    }

    return props;
  }

  /**
   * <p>
   * Initialize the <code>{@link com.helger.quartz.ISchedulerFactory}</code>
   * with the contents of the <code>Properties</code> file with the given name.
   * </p>
   *
   * @return this
   */
  @Nonnull
  public StdSchedulerFactory initialize (final String filename) throws SchedulerException
  {
    // short-circuit if already initialized
    if (m_aCfg != null)
      return this;

    if (m_aInitException != null)
      throw m_aInitException;

    final NonBlockingProperties props = new NonBlockingProperties ();

    InputStream is = ClassPathResource.getInputStream (filename);
    try
    {
      if (is != null)
      {
        is = new NonBlockingBufferedInputStream (is);
        m_sPropSrc = "the specified file : '" + filename + "' from the class resource path.";
      }
      else
      {
        is = new NonBlockingBufferedInputStream (new FileInputStream (filename));
        m_sPropSrc = "the specified file : '" + filename + "'";
      }
      props.load (is);
    }
    catch (final IOException ioe)
    {
      m_aInitException = new SchedulerException ("Properties file: '" + filename + "' could not be read.", ioe);
      throw m_aInitException;
    }
    finally
    {
      StreamHelper.close (is);
    }

    return initialize (props);
  }

  /**
   * <p>
   * Initialize the <code>{@link com.helger.quartz.ISchedulerFactory}</code>
   * with the contents of the <code>Properties</code> file opened with the given
   * <code>InputStream</code>.
   * </p>
   *
   * @return this
   */
  @Nonnull
  public StdSchedulerFactory initialize (@Nonnull @WillNotClose final InputStream propertiesStream) throws SchedulerException
  {
    // short-circuit if already initialized
    if (m_aCfg != null)
      return this;

    if (m_aInitException != null)
      throw m_aInitException;

    final NonBlockingProperties props = new NonBlockingProperties ();
    if (propertiesStream != null)
    {
      try
      {
        props.load (propertiesStream);
        m_sPropSrc = "an externally opened InputStream.";
      }
      catch (final IOException e)
      {
        m_aInitException = new SchedulerException ("Error loading property data from InputStream", e);
        throw m_aInitException;
      }
    }
    else
    {
      m_aInitException = new SchedulerException ("Error loading property data from InputStream - InputStream is null.");
      throw m_aInitException;
    }

    return initialize (props);
  }

  /**
   * Initialize the <code>{@link com.helger.quartz.ISchedulerFactory}</code>
   * with the contents of the given <code>Properties</code> object.
   *
   * @throws SchedulerException
   *         on error
   * @return this
   */
  @Nonnull
  public StdSchedulerFactory initialize (final NonBlockingProperties props) throws SchedulerException
  {
    if (m_sPropSrc == null)
      m_sPropSrc = "an externally provided properties instance.";

    m_aCfg = new PropertiesParser (props);
    return this;
  }

  private IScheduler _instantiate () throws SchedulerException
  {
    if (LOGGER.isDebugEnabled ())
      LOGGER.debug ("StdSchedulerFactory._instantiate");

    if (m_aCfg == null)
    {
      initialize ();
    }

    if (m_aInitException != null)
      throw m_aInitException;

    IJobStore js = null;
    IThreadPool tp = null;
    QuartzScheduler qs = null;
    String instanceIdGeneratorClass = null;
    NonBlockingProperties tProps;
    boolean bAutoId = false;
    long idleWaitTime = -1;
    String classLoadHelperClass;
    String jobFactoryClass;
    IThreadExecutor threadExecutor;

    final SchedulerRepository schedRep = SchedulerRepository.getInstance ();

    // Get Scheduler Properties
    // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    final String schedName = m_aCfg.getStringProperty (PROP_SCHED_INSTANCE_NAME, "MiniQuartzScheduler");

    final String threadName = m_aCfg.getStringProperty (PROP_SCHED_THREAD_NAME,
                                                        schedName + "_MiniQuartzSchedulerThread");

    String schedInstId = m_aCfg.getStringProperty (PROP_SCHED_INSTANCE_ID, DEFAULT_INSTANCE_ID);

    if (schedInstId.equals (AUTO_GENERATE_INSTANCE_ID))
    {
      bAutoId = true;
      instanceIdGeneratorClass = m_aCfg.getStringProperty (PROP_SCHED_INSTANCE_ID_GENERATOR_CLASS,
                                                           SimpleInstanceIdGenerator.class.getName ());
    }
    else
      if (schedInstId.equals (SYSTEM_PROPERTY_AS_INSTANCE_ID))
      {
        bAutoId = true;
        instanceIdGeneratorClass = SystemPropertyInstanceIdGenerator.class.getName ();
      }

    classLoadHelperClass = m_aCfg.getStringProperty (PROP_SCHED_CLASS_LOAD_HELPER_CLASS,
                                                     CascadingClassLoadHelper.class.getName ());

    jobFactoryClass = m_aCfg.getStringProperty (PROP_SCHED_JOB_FACTORY_CLASS, null);

    idleWaitTime = m_aCfg.getLongProperty (PROP_SCHED_IDLE_WAIT_TIME, idleWaitTime);
    if (idleWaitTime > -1 && idleWaitTime < 1000)
    {
      throw new SchedulerException (PROP_SCHED_IDLE_WAIT_TIME + " of less than 1000ms is not legal.");
    }

    final boolean makeSchedulerThreadDaemon = m_aCfg.getBooleanProperty (PROP_SCHED_MAKE_SCHEDULER_THREAD_DAEMON);

    final boolean threadsInheritInitalizersClassLoader = m_aCfg.getBooleanProperty (PROP_SCHED_SCHEDULER_THREADS_INHERIT_CONTEXT_CLASS_LOADER_OF_INITIALIZING_THREAD);

    final long batchTimeWindow = m_aCfg.getLongProperty (PROP_SCHED_BATCH_TIME_WINDOW, 0L);
    final int maxBatchSize = m_aCfg.getIntProperty (PROP_SCHED_MAX_BATCH_SIZE, 1);

    final boolean interruptJobsOnShutdown = m_aCfg.getBooleanProperty (PROP_SCHED_INTERRUPT_JOBS_ON_SHUTDOWN, false);
    final boolean interruptJobsOnShutdownWithWait = m_aCfg.getBooleanProperty (PROP_SCHED_INTERRUPT_JOBS_ON_SHUTDOWN_WITH_WAIT,
                                                                               false);

    final NonBlockingProperties schedCtxtProps = m_aCfg.getPropertyGroup (PROP_SCHED_CONTEXT_PREFIX, true);

    // Create class load helper
    IClassLoadHelper loadHelper = null;
    try
    {
      loadHelper = (IClassLoadHelper) _loadClass (classLoadHelperClass).getDeclaredConstructor ().newInstance ();
    }
    catch (final Exception e)
    {
      throw new SchedulerConfigException ("Unable to instantiate class load helper class: " + e.getMessage (), e);
    }
    loadHelper.initialize ();

    IJobFactory jobFactory = null;
    if (jobFactoryClass != null)
    {
      if (LOGGER.isDebugEnabled ())
        LOGGER.debug ("Creating jobFactoryClass " + jobFactoryClass);

      try
      {
        jobFactory = (IJobFactory) loadHelper.loadClass (jobFactoryClass).getDeclaredConstructor ().newInstance ();
      }
      catch (final Exception e)
      {
        throw new SchedulerConfigException ("Unable to instantiate JobFactory class: " + e.getMessage (), e);
      }

      tProps = m_aCfg.getPropertyGroup (PROP_SCHED_JOB_FACTORY_PREFIX, true);
      try
      {
        _setBeanProps (jobFactory, tProps);
      }
      catch (final Exception e)
      {
        m_aInitException = new SchedulerException ("JobFactory class '" +
                                                   jobFactoryClass +
                                                   "' props could not be configured.",
                                                   e);
        throw m_aInitException;
      }
    }

    IInstanceIdGenerator instanceIdGenerator = null;
    if (instanceIdGeneratorClass != null)
    {
      if (LOGGER.isDebugEnabled ())
        LOGGER.debug ("Creating instanceIdGeneratorClass " + instanceIdGeneratorClass);

      try
      {
        instanceIdGenerator = (IInstanceIdGenerator) loadHelper.loadClass (instanceIdGeneratorClass)
                                                               .getDeclaredConstructor ()
                                                               .newInstance ();
      }
      catch (final Exception e)
      {
        throw new SchedulerConfigException ("Unable to instantiate InstanceIdGenerator class: " + e.getMessage (), e);
      }

      tProps = m_aCfg.getPropertyGroup (PROP_SCHED_INSTANCE_ID_GENERATOR_PREFIX, true);
      try
      {
        _setBeanProps (instanceIdGenerator, tProps);
      }
      catch (final Exception e)
      {
        m_aInitException = new SchedulerException ("InstanceIdGenerator class '" +
                                                   instanceIdGeneratorClass +
                                                   "' props could not be configured.",
                                                   e);
        throw m_aInitException;
      }
    }

    // Get ThreadPool Properties
    // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    final String tpClass = m_aCfg.getStringProperty (PROP_THREAD_POOL_CLASS, SimpleThreadPool.class.getName ());
    if (tpClass == null)
    {
      m_aInitException = new SchedulerException ("ThreadPool class not specified. ");
      throw m_aInitException;
    }

    try
    {
      tp = (IThreadPool) loadHelper.loadClass (tpClass).getDeclaredConstructor ().newInstance ();
    }
    catch (final Exception e)
    {
      m_aInitException = new SchedulerException ("ThreadPool class '" + tpClass + "' could not be instantiated.", e);
      throw m_aInitException;
    }
    tProps = m_aCfg.getPropertyGroup (PROP_THREAD_POOL_PREFIX, true);
    try
    {
      _setBeanProps (tp, tProps);
    }
    catch (final Exception e)
    {
      m_aInitException = new SchedulerException ("ThreadPool class '" + tpClass + "' props could not be configured.",
                                                 e);
      throw m_aInitException;
    }

    // Get JobStore Properties
    // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    final String jsClass = m_aCfg.getStringProperty (PROP_JOB_STORE_CLASS, RAMJobStore.class.getName ());

    if (jsClass == null)
    {
      m_aInitException = new SchedulerException ("JobStore class not specified. ");
      throw m_aInitException;
    }

    try
    {
      js = (IJobStore) loadHelper.loadClass (jsClass).getDeclaredConstructor ().newInstance ();
    }
    catch (final Exception e)
    {
      m_aInitException = new SchedulerException ("JobStore class '" + jsClass + "' could not be instantiated.", e);
      throw m_aInitException;
    }

    js.setInstanceName (schedName);
    js.setInstanceId (schedInstId);

    tProps = m_aCfg.getPropertyGroup (PROP_JOB_STORE_PREFIX,
                                      true,
                                      new String [] { PROP_JOB_STORE_LOCK_HANDLER_PREFIX });
    try
    {
      _setBeanProps (js, tProps);
    }
    catch (final Exception e)
    {
      m_aInitException = new SchedulerException ("JobStore class '" + jsClass + "' props could not be configured.", e);
      throw m_aInitException;
    }

    // Set up any SchedulerPlugins
    // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    final ICommonsList <String> pluginNames = m_aCfg.getPropertyGroups (PROP_PLUGIN_PREFIX);
    final ICommonsList <ISchedulerPlugin> plugins = new CommonsArrayList <> ();
    for (final String pluginName : pluginNames)
    {
      final NonBlockingProperties pp = m_aCfg.getPropertyGroup (PROP_PLUGIN_PREFIX + "." + pluginName, true);

      final String plugInClass = pp.getProperty (PROP_PLUGIN_CLASS, null);
      if (plugInClass == null)
      {
        m_aInitException = new SchedulerException ("SchedulerPlugin class not specified for plugin '" +
                                                   pluginName +
                                                   "'");
        throw m_aInitException;
      }

      ISchedulerPlugin aPlugin = null;
      try
      {
        aPlugin = (ISchedulerPlugin) loadHelper.loadClass (plugInClass).getDeclaredConstructor ().newInstance ();
      }
      catch (final Exception e)
      {
        m_aInitException = new SchedulerException ("SchedulerPlugin class '" +
                                                   plugInClass +
                                                   "' could not be instantiated.",
                                                   e);
        throw m_aInitException;
      }
      try
      {
        _setBeanProps (aPlugin, pp);
      }
      catch (final Exception e)
      {
        m_aInitException = new SchedulerException ("JobStore SchedulerPlugin '" +
                                                   plugInClass +
                                                   "' props could not be configured.",
                                                   e);
        throw m_aInitException;
      }

      plugins.add (aPlugin);
    }

    // Set up any JobListeners
    // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    final Class <?> [] strArg = new Class [] { String.class };
    final ICommonsList <String> jobListenerNames = m_aCfg.getPropertyGroups (PROP_JOB_LISTENER_PREFIX);
    final ICommonsList <IJobListener> jobListeners = new CommonsArrayList <> ();
    for (final String jobListenerName : jobListenerNames)
    {
      final NonBlockingProperties lp = m_aCfg.getPropertyGroup (PROP_JOB_LISTENER_PREFIX + "." + jobListenerName, true);

      final String listenerClass = lp.getProperty (PROP_LISTENER_CLASS, null);

      if (listenerClass == null)
      {
        m_aInitException = new SchedulerException ("JobListener class not specified for listener '" +
                                                   jobListenerName +
                                                   "'");
        throw m_aInitException;
      }
      IJobListener listener = null;
      try
      {
        listener = (IJobListener) loadHelper.loadClass (listenerClass).getDeclaredConstructor ().newInstance ();
      }
      catch (final Exception e)
      {
        m_aInitException = new SchedulerException ("JobListener class '" +
                                                   listenerClass +
                                                   "' could not be instantiated.",
                                                   e);
        throw m_aInitException;
      }
      try
      {
        Method nameSetter = null;
        try
        {
          nameSetter = listener.getClass ().getMethod ("setName", strArg);
        }
        catch (final NoSuchMethodException ignore)
        {
          /* do nothing */
        }
        if (nameSetter != null)
        {
          nameSetter.invoke (listener, new Object [] { jobListenerName });
        }
        _setBeanProps (listener, lp);
      }
      catch (final Exception e)
      {
        m_aInitException = new SchedulerException ("JobListener '" + listenerClass + "' props could not be configured.",
                                                   e);
        throw m_aInitException;
      }
      jobListeners.add (listener);
    }

    // Set up any TriggerListeners
    // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    final ICommonsList <String> triggerListenerNames = m_aCfg.getPropertyGroups (PROP_TRIGGER_LISTENER_PREFIX);
    final ICommonsList <ITriggerListener> triggerListeners = new CommonsArrayList <> ();
    for (final String triggerListenerName : triggerListenerNames)
    {
      final NonBlockingProperties lp = m_aCfg.getPropertyGroup (PROP_TRIGGER_LISTENER_PREFIX +
                                                                "." +
                                                                triggerListenerName,
                                                                true);

      final String listenerClass = lp.getProperty (PROP_LISTENER_CLASS, null);

      if (listenerClass == null)
      {
        m_aInitException = new SchedulerException ("TriggerListener class not specified for listener '" +
                                                   triggerListenerName +
                                                   "'");
        throw m_aInitException;
      }
      ITriggerListener listener = null;
      try
      {
        listener = (ITriggerListener) loadHelper.loadClass (listenerClass).getDeclaredConstructor ().newInstance ();
      }
      catch (final Exception e)
      {
        m_aInitException = new SchedulerException ("TriggerListener class '" +
                                                   listenerClass +
                                                   "' could not be instantiated.",
                                                   e);
        throw m_aInitException;
      }
      try
      {
        Method nameSetter = null;
        try
        {
          nameSetter = listener.getClass ().getMethod ("setName", strArg);
        }
        catch (final NoSuchMethodException ignore)
        {
          /* do nothing */
        }
        if (nameSetter != null)
        {
          nameSetter.invoke (listener, new Object [] { triggerListenerName });
        }
        _setBeanProps (listener, lp);
      }
      catch (final Exception e)
      {
        m_aInitException = new SchedulerException ("TriggerListener '" +
                                                   listenerClass +
                                                   "' props could not be configured.",
                                                   e);
        throw m_aInitException;
      }
      triggerListeners.add (listener);
    }

    boolean tpInited = false;
    boolean qsInited = false;

    // Get ThreadExecutor Properties
    // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    final String threadExecutorClass = m_aCfg.getStringProperty (PROP_THREAD_EXECUTOR_CLASS);
    if (threadExecutorClass != null)
    {
      tProps = m_aCfg.getPropertyGroup (PROP_THREAD_EXECUTOR, true);
      try
      {
        threadExecutor = (IThreadExecutor) loadHelper.loadClass (threadExecutorClass)
                                                     .getDeclaredConstructor ()
                                                     .newInstance ();
        LOGGER.info ("Using custom implementation for ThreadExecutor: " + threadExecutorClass);

        _setBeanProps (threadExecutor, tProps);
      }
      catch (final Exception e)
      {
        m_aInitException = new SchedulerException ("ThreadExecutor class '" +
                                                   threadExecutorClass +
                                                   "' could not be instantiated.",
                                                   e);
        throw m_aInitException;
      }
    }
    else
    {
      LOGGER.info ("Using default implementation for ThreadExecutor");
      threadExecutor = new DefaultThreadExecutor ();
    }

    try
    {
      // Create correct run-shell factory...
      final IJobRunShellFactory jrsf = new StdJobRunShellFactory ();

      if (bAutoId)
      {
        try
        {
          schedInstId = DEFAULT_INSTANCE_ID;
          if (js.isClustered ())
            schedInstId = instanceIdGenerator.generateInstanceId ();
        }
        catch (final Exception e)
        {
          LOGGER.error ("Couldn't generate instance Id!", e);
          throw new IllegalStateException ("Cannot run without an instance id.");
        }
      }

      final QuartzSchedulerResources rsrcs = new QuartzSchedulerResources ();
      rsrcs.setName (schedName);
      rsrcs.setThreadName (threadName);
      rsrcs.setInstanceId (schedInstId);
      rsrcs.setJobRunShellFactory (jrsf);
      rsrcs.setMakeSchedulerThreadDaemon (makeSchedulerThreadDaemon);
      rsrcs.setThreadsInheritInitializersClassLoadContext (threadsInheritInitalizersClassLoader);
      rsrcs.setBatchTimeWindow (batchTimeWindow);
      rsrcs.setMaxBatchSize (maxBatchSize);
      rsrcs.setInterruptJobsOnShutdown (interruptJobsOnShutdown);
      rsrcs.setInterruptJobsOnShutdownWithWait (interruptJobsOnShutdownWithWait);

      tp.setInstanceName (schedName);
      tp.setInstanceId (schedInstId);

      rsrcs.setThreadExecutor (threadExecutor);

      if (LOGGER.isDebugEnabled ())
        LOGGER.debug ("Initializing ThreadExecutor");

      threadExecutor.initialize ();

      rsrcs.setThreadPool (tp);
      if (tp instanceof SimpleThreadPool)
      {
        if (threadsInheritInitalizersClassLoader)
          ((SimpleThreadPool) tp).setThreadsInheritContextClassLoaderOfInitializingThread (threadsInheritInitalizersClassLoader);
      }

      if (LOGGER.isDebugEnabled ())
        LOGGER.debug ("Initializing ThreadPool");

      tp.initialize ();
      tpInited = true;

      rsrcs.setJobStore (js);

      // add plugins
      if (LOGGER.isDebugEnabled ())
        LOGGER.debug ("Adding " + plugins.size () + " scheduler plugins");

      for (final ISchedulerPlugin plugin : plugins)
      {
        rsrcs.addSchedulerPlugin (plugin);
      }

      qs = new QuartzScheduler (rsrcs, idleWaitTime);
      qsInited = true;

      // Create Scheduler ref...
      final IScheduler scheduler = instantiate (rsrcs, qs);

      // set job factory if specified
      if (jobFactory != null)
      {
        qs.setJobFactory (jobFactory);
      }

      // Initialize plugins now that we have a Scheduler instance.
      if (LOGGER.isDebugEnabled ())
        LOGGER.debug ("Initializing scheduler plugins");
      for (int i = 0; i < plugins.size (); i++)
      {
        plugins.getAtIndex (i).initialize (pluginNames.getAtIndex (i), scheduler, loadHelper);
      }

      // add listeners
      for (final IJobListener jobListener : jobListeners)
      {
        qs.getListenerManager ().addJobListener (jobListener, EverythingMatcher.allJobs ());
      }
      for (final ITriggerListener triggerListener : triggerListeners)
      {
        qs.getListenerManager ().addTriggerListener (triggerListener, EverythingMatcher.allTriggers ());
      }

      // set scheduler context data...
      // (don't use entrySet - different semantics!)
      for (final String key : schedCtxtProps.keySet ())
      {
        final String val = schedCtxtProps.getProperty (key);
        scheduler.getContext ().put (key, val);
      }

      // fire up job store, and runshell factory

      js.setInstanceId (schedInstId);
      js.setInstanceName (schedName);
      js.setThreadPoolSize (tp.getPoolSize ());
      js.initialize (loadHelper, qs.getSchedulerSignaler ());

      if (LOGGER.isDebugEnabled ())
        LOGGER.debug ("Initializing JobRunShellFactory");

      jrsf.initialize (scheduler);

      if (LOGGER.isDebugEnabled ())
        LOGGER.debug ("Initializing QuartzScheduler");

      qs.initialize ();

      LOGGER.info ("Quartz scheduler '" + scheduler.getSchedulerName () + "' initialized from " + m_sPropSrc);

      LOGGER.info ("Quartz scheduler version: " + qs.getVersion ());

      // prevents the repository from being garbage collected
      qs.addNoGCObject (schedRep);

      schedRep.bind (scheduler);
      return scheduler;
    }
    catch (final SchedulerException e)
    {
      _shutdownFromInstantiateException (tp, qs, tpInited, qsInited);
      throw e;
    }
    catch (final RuntimeException re)
    {
      _shutdownFromInstantiateException (tp, qs, tpInited, qsInited);
      throw re;
    }
    catch (final Error re)
    {
      _shutdownFromInstantiateException (tp, qs, tpInited, qsInited);
      throw re;
    }
  }

  private void _shutdownFromInstantiateException (final IThreadPool tp,
                                                  final QuartzScheduler qs,
                                                  final boolean tpInited,
                                                  final boolean qsInited)
  {
    try
    {
      if (qsInited)
        qs.shutdown (false);
      else
        if (tpInited)
          tp.shutdown (false);
    }
    catch (final Exception e)
    {
      LOGGER.error ("Got another exception while shutting down after instantiation exception", e);
    }
  }

  /**
   * @param rsrcs
   * @param qs
   * @return Never null
   */
  @Nonnull
  protected IScheduler instantiate (final QuartzSchedulerResources rsrcs, final QuartzScheduler qs)
  {
    final IScheduler scheduler = new StdScheduler (qs);
    return scheduler;
  }

  private void _setBeanProps (final Object obj, final NonBlockingProperties props) throws NoSuchMethodException,
                                                                                   IllegalAccessException,
                                                                                   InvocationTargetException,
                                                                                   IntrospectionException,
                                                                                   SchedulerConfigException
  {
    props.remove ("class");

    final BeanInfo bi = Introspector.getBeanInfo (obj.getClass ());
    final PropertyDescriptor [] propDescs = bi.getPropertyDescriptors ();
    final PropertiesParser pp = new PropertiesParser (props);

    for (final String name : props.keySet ())
    {
      final String c = name.substring (0, 1).toUpperCase (Locale.US);
      final String methName = "set" + c + name.substring (1);

      final java.lang.reflect.Method setMeth = _getSetMethod (methName, propDescs);

      try
      {
        if (setMeth == null)
        {
          throw new NoSuchMethodException ("No setter for property '" + name + "'");
        }

        final Class <?> [] params = setMeth.getParameterTypes ();
        if (params.length != 1)
        {
          throw new NoSuchMethodException ("No 1-argument setter for property '" + name + "'");
        }

        // does the property value reference another property's value? If so,
        // swap to look at its value
        PropertiesParser refProps = pp;
        String refName = pp.getStringProperty (name);
        if (refName != null && refName.startsWith ("$@"))
        {
          refName = refName.substring (2);
          refProps = m_aCfg;
        }
        else
          refName = name;

        if (params[0].equals (int.class))
        {
          setMeth.invoke (obj, new Object [] { Integer.valueOf (refProps.getIntProperty (refName)) });
        }
        else
          if (params[0].equals (long.class))
          {
            setMeth.invoke (obj, new Object [] { Long.valueOf (refProps.getLongProperty (refName)) });
          }
          else
            if (params[0].equals (float.class))
            {
              setMeth.invoke (obj, new Object [] { Float.valueOf (refProps.getFloatProperty (refName)) });
            }
            else
              if (params[0].equals (double.class))
              {
                setMeth.invoke (obj, new Object [] { Double.valueOf (refProps.getDoubleProperty (refName)) });
              }
              else
                if (params[0].equals (boolean.class))
                {
                  setMeth.invoke (obj, new Object [] { Boolean.valueOf (refProps.getBooleanProperty (refName)) });
                }
                else
                  if (params[0].equals (String.class))
                  {
                    setMeth.invoke (obj, new Object [] { refProps.getStringProperty (refName) });
                  }
                  else
                  {
                    throw new NoSuchMethodException ("No primitive-type setter for property '" + name + "'");
                  }
      }
      catch (final NumberFormatException nfe)
      {
        throw new SchedulerConfigException ("Could not parse property '" +
                                            name +
                                            "' into correct data type: " +
                                            nfe.toString ());
      }
    }
  }

  private java.lang.reflect.Method _getSetMethod (final String name, final PropertyDescriptor [] props)
  {
    for (final PropertyDescriptor prop : props)
    {
      final java.lang.reflect.Method wMeth = prop.getWriteMethod ();

      if (wMeth != null && wMeth.getName ().equals (name))
      {
        return wMeth;
      }
    }

    return null;
  }

  private Class <?> _loadClass (final String className) throws ClassNotFoundException, SchedulerConfigException
  {

    try
    {
      final ClassLoader cl = _findClassloader ();
      if (cl != null)
        return cl.loadClass (className);
      throw new SchedulerConfigException ("Unable to find a class loader on the current thread or class.");
    }
    catch (final ClassNotFoundException e)
    {
      if (getClass ().getClassLoader () != null)
        return getClass ().getClassLoader ().loadClass (className);
      throw e;
    }
  }

  private ClassLoader _findClassloader ()
  {
    // work-around set context loader for windows-service started jvms
    // (QUARTZ-748)
    final Thread t = Thread.currentThread ();
    ClassLoader ret = t.getContextClassLoader ();
    if (ret == null)
    {
      ret = getClass ().getClassLoader ();
      t.setContextClassLoader (ret);
    }
    return ret;
  }

  private String _getSchedulerName ()
  {
    return m_aCfg.getStringProperty (PROP_SCHED_INSTANCE_NAME, "MiniQuartzScheduler");
  }

  /**
   * <p>
   * Returns a handle to the Scheduler produced by this factory.
   * </p>
   * <p>
   * If one of the <code>initialize</code> methods has not be previously called,
   * then the default (no-arg) <code>initialize()</code> method will be called
   * by this method.
   * </p>
   */
  public IScheduler getScheduler () throws SchedulerException
  {
    if (m_aCfg == null)
      initialize ();

    if (LOGGER.isDebugEnabled ())
      LOGGER.debug ("Looking up scheduler with name '" + _getSchedulerName () + "'");

    final SchedulerRepository schedRep = SchedulerRepository.getInstance ();

    IScheduler sched = schedRep.lookup (_getSchedulerName ());
    if (sched != null)
    {
      if (LOGGER.isDebugEnabled ())
        LOGGER.debug ("Reusing existing scheduler with name '" + _getSchedulerName () + "'");

      if (sched.isShutdown ())
        schedRep.remove (_getSchedulerName ());
      else
        return sched;
    }

    sched = _instantiate ();
    return sched;
  }

  /**
   * <p>
   * Returns a handle to the default Scheduler, creating it if it does not yet
   * exist.
   * </p>
   *
   * @see #initialize()
   */
  public static IScheduler getDefaultScheduler () throws SchedulerException
  {
    final StdSchedulerFactory fact = new StdSchedulerFactory ();

    return fact.getScheduler ();
  }

  /**
   * <p>
   * Returns a handle to the Scheduler with the given name, if it exists (if it
   * has already been instantiated).
   * </p>
   */
  public IScheduler getScheduler (final String schedName) throws SchedulerException
  {
    return SchedulerRepository.getInstance ().lookup (schedName);
  }

  /**
   * <p>
   * Returns a handle to all known Schedulers (made by any StdSchedulerFactory
   * instance.).
   * </p>
   */
  public ICommonsCollection <IScheduler> getAllSchedulers () throws SchedulerException
  {
    return SchedulerRepository.getInstance ().lookupAll ();
  }
}
594802
public static void fixPropertiesKeys(final Properties prop) {
		final Enumeration<Object> keys = prop.keys();
		while (keys.hasMoreElements()) {
			String currentKey = (String) keys.nextElement();
			String fixedKey = fixPropertyKey(currentKey);
			String value = prop.getProperty(currentKey);
			value = fixPropertyValue(value);
			prop.remove(currentKey);
			prop.setProperty(fixedKey, value);
		}
	}
323796
@Override
	public synchronized void setProperties(Map<Object, Object> properties)
	{
		if(this.properties == null)
			this.properties = new Properties();
		
		
		this.properties.putAll(properties);
	}
753574
public void addProperty(String propertyType) {

        if (m_properties == null) {
            // this list will be used and clean up in the importResource method
            m_properties = new HashMap<String, CmsProperty>();
        }
        try {
            if ((m_propertyName == null) || getIgnoredProperties().contains(m_propertyName)) {
                // continue if the current property (name) should be ignored or is null
                return;
            }
            CmsProperty property = m_properties.get(m_propertyName);
            if (property == null) {
                property = new CmsProperty();
                property.setName(m_propertyName);
                property.setAutoCreatePropertyDefinition(true);
                m_properties.put(m_propertyName, property);
            }

            if (m_propertyValue == null) {
                m_propertyValue = "";
            }

            if ((propertyType != null) && propertyType.equals(PROPERTY_ATTRIB_TYPE_SHARED)) {
                // it is a shared/resource property value
                property.setResourceValue(m_propertyValue);
            } else {
                // it is an individual/structure value
                property.setStructureValue(m_propertyValue);
            }
        } finally {
            m_propertyName = null;
            m_propertyValue = null;
        }
    }
443787
private static void setProperties(GenericApplicationContext newContext, Properties properties) {
        PropertiesPropertySource pps = new PropertiesPropertySource("external-props", properties);
        newContext.getEnvironment().getPropertySources().addFirst(pps);
    }
282539
@Override
	protected Properties mergeProperties() throws IOException {

		final PrefixedProperties myProperties = createProperties();

		if (localOverride) {
			// Load properties from file upfront, to let local properties
			// override.
			loadProperties(myProperties);
		}
		if (localProperties != null) {
			for (int i = 0; i < localProperties.length; i++) {
				final Properties props = localProperties[i];
				if (props != null) {
					for (final Enumeration<Object> en = props.keys(); en.hasMoreElements();) {
						final Object key = en.nextElement();
						myProperties.put(key, props.get(key));
					}
				}
			}
		}
		if (!localOverride) {
			// Load properties from file afterwards, to let those properties
			// override.
			loadProperties(myProperties);
		}

		return myProperties;
	}
1010885
public void applyProperties(Properties props) {
        Iterator<?> iter = props.keySet().iterator();
        while (iter.hasNext()) {
            String fullName = (String) iter.next();
            String value = props.getProperty(fullName).trim();
            if (fullName.indexOf(":") != -1 && value != null
                    && value.length() > 0) {
                String name = fullName.substring(fullName.lastIndexOf(":") + 1);
                if (fullName.startsWith("server:")) {
                    if (name.endsWith(".class")) {
                        m_className = value;
                    } else {
                        setParameterValue(name, value, true);
                    }
                } else if (fullName.startsWith("module.")) {
                    String role =
                            fullName.substring(7, fullName.lastIndexOf(":"));
                    ModuleConfiguration module = getModuleConfiguration(role);
                    if (module == null) {
                        module =
                                new ModuleConfiguration(new ArrayList<Parameter>(),
                                                        role,
                                                        null,
                                                        null);
                        m_moduleConfigurations.add(module);
                    }
                    if (name.endsWith(".class")) {
                        module.setClassName(value);
                    } else {
                        module.setParameterValue(name, value, true);
                    }
                } else if (fullName.startsWith("datastore.")) {
                    String id =
                            fullName.substring(10, fullName.lastIndexOf(":"));
                    DatastoreConfiguration datastore =
                            getDatastoreConfiguration(id);
                    if (datastore == null) {
                        datastore =
                                new DatastoreConfiguration(new ArrayList<Parameter>(),
                                                           id,
                                                           null);
                        m_datastoreConfigurations.add(datastore);
                    }
                    datastore.setParameterValue(name, value, true);
                }
            }
        }
    }
1048158
protected static void loadPropertiesOverrides (
        PropRecord prec, Map<String,PropRecord> records, Map<String,PropRecord> applied,
        ClassLoader loader, Properties target)
        throws IOException
    {
        if (applied.containsKey(prec._package)) {
            return;
        }

        // first load up properties from all of our parent nodes
        if (prec._overrides != null) {
            for (String override : prec._overrides) {
                PropRecord parent = records.get(override);
                loadPropertiesOverrides(parent, records, applied, loader, target);
            }
        }

        // now apply our properties values
        InputStream in = prec.sourceURL.openStream();
        target.load(in);
        in.close();
        applied.put(prec._package, prec);
    }
628249
@Override
    protected S addService(S service, ServiceProperties props) {
        if (reference.compareAndSet(null, service)) {
            return service;
        }
        return null;
    }
97318
public void underride( Properties props ) {
        if ( host == null ) {
            host = props.getProperty("host");
        }
        if ( port == 0 ) {
            port = Integer.parseInt(props.getProperty("port","0"));
        }
        if ( name == null ) {
            name = props.getProperty("name");
        }
        if ( wd == null ) {
            wd = props.getProperty("wd");
        }
    }
467117
def add_property(self, prop, objects=()):
        """"""
        self._properties.add(prop)
        self._objects |= objects
        self._pairs.update((o, prop) for o in objects)
590027
@Override
    public void loadFromProperties(Properties props) {
        String strValue = props.getProperty(container.getSimpleName() + "." + name);
        if (strValue == null)
            return;

        boolean intValue = Boolean.parseBoolean(strValue);
        set(intValue);
    }
527177
public void defineOwnProperties(Context cx, ScriptableObject props) {
        Object[] ids = props.getIds(false, true);
        ScriptableObject[] descs = new ScriptableObject[ids.length];
        for (int i = 0, len = ids.length; i < len; ++i) {
            Object descObj = ScriptRuntime.getObjectElem(props, ids[i], cx);
            ScriptableObject desc = ensureScriptableObject(descObj);
            checkPropertyDefinition(desc);
            descs[i] = desc;
        }
        for (int i = 0, len = ids.length; i < len; ++i) {
            defineOwnProperty(cx, ids[i], descs[i]);
        }
    }
1189392
public void addProperty( String property)
    {
    String candidate = StringUtils.trimToNull( property);
    if( candidate != null)
      {
      properties_.add( property);
      }
    }
1345474
def add_props(self,**kwargs):
        
        for kw,val in kwargs.iteritems():
            self.properties[kw] = val
137609
public KafkaClient setConsumerProperties(Properties props) {
        if (props == null) {
            consumerProperties = null;
        } else {
            consumerProperties = new Properties();
            consumerProperties.putAll(props);
        }
        return this;
    }
346074
public static void loadCustomerProperties(Properties props){
        for(Entry<Object, Object> entry : props.entrySet()){
            setProperty((String)entry.getKey(), entry.getValue());
        }
    }