Process the sytemRole properties from the server.xml.

@param props
551059
private void processConfigProps(Map<String, Object> props) {
        if (props == null || props.isEmpty())
            return;
        id = (String) props.get(CFG_KEY_ID);
        if (id == null) {
            Tr.error(tc, "AUTHZ_ROLE_ID_IS_NULL");
            return;
        }
        rolePids = (String[]) props.get(CFG_KEY_ROLE);
//        if (rolePids == null || rolePids.length < 1)
//            return;
        processRolePids();
    }
817424
private static void applySystemProperties(Properties properties)
   {
      if (properties != null)
      {
         for (Map.Entry<Object, Object> entry : properties.entrySet())
         {
            String key = (String)entry.getKey();
            if (key.startsWith("system.property."))
            {
               key = key.substring(16);
               SecurityActions.setSystemProperty(key, (String)entry.getValue());
            }
         }
      }
   }
847008
public static synchronized void setProperties(Properties props) {
        wordLimit = Integer.parseInt(
                props.getProperty(TOKEN_COUNT_LIMIT_PROPERTY, "0"));

        String filterProp = 
            props.getProperty(TOKEN_FILTER_PROPERTY);
        filter = (filterProp != null)
            ? TokenFilter.loadFromSpecification(filterProp, resourceFinder)
            : null;
        
        // NOTE: future implementations may interpret the value of this property
        // to decide which stemmer to use
        String stemmerProp = props.getProperty(STEMMER_PROPERTY);
        if (stemmerProp != null)
            stemmer = ReflectionUtil.<Stemmer>getObjectInstance(stemmerProp);

        String compoundTokensProp = 
            props.getProperty(COMPOUND_TOKENS_FILE_PROPERTY);
        if (compoundTokensProp != null) {
            // Load the tokens from file
            compoundTokens = new LinkedHashSet<String>();
            try {
                BufferedReader br = resourceFinder.open(compoundTokensProp);
                for (String line = null; (line = br.readLine()) != null; ) {
                    compoundTokens.add(line);
                }
                // For any currently processing threads, update their mapped
                // iterator with the new set of tokens
                for (Map.Entry<Thread,CompoundWordIterator> e
                     : compoundIterators.entrySet()) {
                    // Create an empy dummy BufferedReader, which will be
                    // discarded upon the next .reset() call to the iterator
                    BufferedReader dummyBuffer =
                        new BufferedReader(new StringReader(""));
                    e.setValue(new CompoundWordIterator(
                                dummyBuffer, compoundTokens));
                }
            } catch (IOException ioe) {
                // rethrow
                throw new IOError(ioe);
            }
        } else {
            // If the user did not specify a set of compound tokens, null out
            // the set, in the event that there was one previously
            compoundTokens = null;
        }

        String replacementProp = 
            props.getProperty(TOKEN_REPLACEMENT_FILE_PROPERTY);
        if (replacementProp != null) {
            try {
                BufferedReader br = resourceFinder.open(replacementProp);
                replacementMap = new HashMap<String, String>();
                String line = null;
                while ((line = br.readLine()) != null) {
                    String[] termReplacement = line.split("\\s+");
                    replacementMap.put(termReplacement[0], termReplacement[1]);
                }
            } catch (IOException ioe) {
                throw new IOError(ioe);
            }
        } else
            replacementMap = null;
    }
721851
public static void configure(Properties props) {
        Properties defaultProperties = new Properties();

        HashMap<String, Properties> driversProps = new HashMap<>();
        for (Enumeration<?> enumeration = props.propertyNames(); enumeration.hasMoreElements();) {
            String propertyName = (String) enumeration.nextElement();
            String value = props.getProperty(propertyName);
            int idx = propertyName.lastIndexOf('.');
            if (idx < 0) {
                defaultProperties.put(propertyName, value);
            } else {
                String prefix = propertyName.substring(0, idx);
                String name = propertyName.substring(idx + 1);
                Properties driverProperties = driversProps.get(prefix);
                if (driverProperties == null) {
                    driverProperties = new Properties();
                    driversProps.put(prefix, driverProperties);
                }
                driverProperties.put(name, value);
            }
        }

        // Merge with default properties
        Map<String, Driver> newInstances = new HashMap<>();
        for (Entry<String, Properties> entry : driversProps.entrySet()) {
            String name = entry.getKey();
            Properties properties = new Properties();
            properties.putAll(defaultProperties);
            properties.putAll(entry.getValue());
            newInstances.put(name, createDriver(name, properties));
        }
        if (newInstances.get(DEFAULT_INSTANCE_NAME) == null
                && Parameters.REMOTE_URL_BASE.getValue(defaultProperties) != null) {

            newInstances.put(DEFAULT_INSTANCE_NAME, createDriver(DEFAULT_INSTANCE_NAME, defaultProperties));
        }

        instances = new IndexedInstances(newInstances);
    }
1071514
public static void loadProps(Properties props, File file) throws IOException {
        FileInputStream fis = null;
        try {
            fis = new FileInputStream(file);
            props.load(fis);
        } finally {
            if (null != fis) {
                fis.close();
            }
        }
    }
1335816
private String resolvePropertyValue(final String name, PROPERTY_TYPE propType,
			final Properties submittedProperties, final Properties xmlProperties) {


		
		String value = null;

		switch(propType) {
		
			case JOB_PARAMETERS:
				if (submittedProperties != null) {
					value = submittedProperties.getProperty(name);
				}
				if (value != null){
					return value;
				}
				break;
			case JOB_PROPERTIES:
				if (xmlProperties != null){
					value = xmlProperties.getProperty(name);
				}
				if (value != null) {
					return value;
				}
				break;
			case SYSTEM_PROPERTIES:
				value = System.getProperty(name);
				if (value != null) {
					return value;
				}
				break;
			case PARTITION_PROPERTIES: //We are reusing the submitted props to carry the partition props
				if (submittedProperties != null) {
					value = submittedProperties.getProperty(name);
				}
				if (value != null) {
					return value;
				}
				break;
		}
		
		
		return UNRESOLVED_PROP_VALUE;

	}
419753
public void loadProperties(String prefix) {
        List<Property> props = null;
        
        try {
            props = getListByPrefix(prefix);
        } catch (Exception e) {
            log.error("Error retrieving properties with prefix: " + prefix, e);
            return;
        }
        
        for (Property prop : props) {
            if (prop.getName() != null) {
                this.properties.put(prop.getName(), prop);
            }
        }
    }
559879
private void processKeyValue(Map<ConfigurationKey, Object> properties, String stringKey, Object value) {
        processKeyValue(properties, stringKey, value, false);
    }
775307
protected Properties replacePlaceHolders(Properties props){
		if (replacePlaceHolders){
			Properties result = new Properties();
			for (Object keyObj: props.keySet()){
				String key = (String) keyObj;
				String value = props.getProperty(key);
				key = PlaceHolderReplacer.replaceWithProperties(key);
				value = PlaceHolderReplacer.replaceWithProperties(value);
				result.put(key, value);
			}
			return result;
		}else{
			return props;
		}
	}
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 ();
  }
}
704294
public static void loadProp(Props props, Configuration conf, String name) {
    String prop = props.get(name);
    if (prop != null) {
      conf.set(name, prop);
    }
  }
446582
public void setProperties(Properties props) throws Exception {
		// Use reflection to read in all possible properties of int, String or boolean.
		for (Method method: BoneCPConfig.class.getDeclaredMethods()){
			String tmp = null;
			if (method.getName().startsWith("is")){
				tmp = lowerFirst(method.getName().substring(2));
			} else if (method.getName().startsWith("set")){
				tmp = lowerFirst(method.getName().substring(3));
			} else {
				continue;
			}

			if (method.getParameterTypes().length == 1 && method.getParameterTypes()[0].equals(int.class)){
				String val = props.getProperty(tmp);
				if (val == null){
					val = props.getProperty("bonecp."+tmp); // hibernate provider style
				}
				if (val != null) {
					try{
						method.invoke(this, Integer.parseInt(val));
					} catch (NumberFormatException e){
						// do nothing, use the default value
					}
				}
			} else if (method.getParameterTypes().length == 1 && method.getParameterTypes()[0].equals(long.class)){
				String val = props.getProperty(tmp);
				if (val == null){
					val = props.getProperty("bonecp."+tmp); // hibernate provider style
				}
				if (val != null) {
					try{
						method.invoke(this, Long.parseLong(val));
					} catch (NumberFormatException e){
						// do nothing, use the default value
					}
				}
			} else if (method.getParameterTypes().length == 1 && method.getParameterTypes()[0].equals(String.class)){
				String val = props.getProperty(tmp);
				if (val == null){
					val = props.getProperty("bonecp."+tmp); // hibernate provider style
				}
				if (val != null) {
					method.invoke(this, val);
				}
			} if (method.getParameterTypes().length == 1 && method.getParameterTypes()[0].equals(boolean.class)){
				String val = props.getProperty(tmp);
				if (val == null){
					val = props.getProperty("bonecp."+tmp); // hibernate provider style
				}
				if (val != null) {
					method.invoke(this, Boolean.parseBoolean(val));
				}
			}
		}
	}
650522
@Override
	protected void loadProperties(final Properties props) throws IOException {
		if (locations != null) {
			for (int i = 0; i < locations.length; i++) {
				final Resource location = locations[i];
				if (logger.isInfoEnabled()) {
					logger.info("Loading properties file from " + location);
				}
				File file = null;
				InputStream is = null;
				try {
					try {
						file = location.getFile();
						is = new BufferedInputStream(new FileInputStream(file));
					} catch (final IOException ie) {// ignore
					} finally {
						if (file == null) {
							is = location.getInputStream();
						}
					}

					if (location.getFilename().toLowerCase().endsWith(Constants.XML_FILE_EXTENSION)) {
						persister.loadFromXml(props, is);
					} else if (location.getFilename().toLowerCase().endsWith(Constants.JSON_FILE_EXTENSION)) {
						if (fileEncoding != null) {
							persister.loadFromJson(props, new InputStreamReader(is, Charset.forName(fileEncoding)));
						} else {
							persister.loadFromJson(props, is);
						}
					} else if (location.getFilename().toLowerCase().endsWith(Constants.YAML_FILE_EXTENSION)) {
						if (fileEncoding != null) {
							persister.loadFromYAML(props, new InputStreamReader(is, Charset.forName(fileEncoding)));
						} else {
							persister.loadFromYAML(props, is);
						}
					} else {
						if (fileEncoding != null) {
							persister.load(props, new InputStreamReader(is, Charset.forName(fileEncoding)));
						} else {
							persister.load(props, is);
						}
					}
				} catch (final IOException ex) {
					if (ignoreResourceNotFound) {
						if (logger.isWarnEnabled()) {
							logger.warn("Could not load properties from " + location + ": " + ex.getMessage());
						}
					} else {
						throw ex;
					}
				} finally {
					if (is != null) {
						is.close();
					}
				}
			}
		}
	}
393596
public void loadFromYAML(final Properties props, final Reader rd) throws IOException {
		try {
			((PrefixedProperties) props).loadFromYAML(rd);
		} catch (final NoSuchMethodError err) {
			throw new IOException(
					"Cannot load properties JSON file - not using PrefixedProperties: " + err.getMessage());
		}
	}
988120
private void processProps() {
    ElementFilter
        .fieldsIn(component.getEnclosedElements())
        .stream()
        .filter(field -> hasAnnotation(field, Prop.class))
        .forEach(field -> {
          String propName = field.getSimpleName().toString();
          Prop prop = field.getAnnotation(Prop.class);

          collectionFieldsValidator.validateComponentPropField(field);

          fieldsWithNameExposed.add(new ExposedField(propName, field.asType()));

          optionsBuilder.addStatement(
              "options.addJavaProp($S, $T.getFieldName(this, () -> this.$L = $L), $L, $S)",
              propName,
              VueGWTTools.class,
              propName,
              getFieldMarkingValueForType(field.asType()),
              prop.required(),
              prop.checkType() ? getNativeNameForJavaType(field.asType()) : null
          );
        });
  }
400945
public void underride( Properties props ) {
        if ( siblingHost == null ) {
            siblingHost = props.getProperty("starter.shost");
        }
        if ( siblingPort == 0 ) {
            siblingPort = Integer.parseInt(props.getProperty("starter.sport","0"));
        }
        if ( host == null ) {
            host = props.getProperty("starter.host");
            if ( host == null ) {
                try {
                    host = InetAddress.getLocalHost().getHostName();
                } catch (UnknownHostException e) {
                    e.printStackTrace();
                }
            }
        }
        if ( port == 0 ) {
            port = Integer.parseInt(props.getProperty("starter.port","0"));
        }
        if ( name == null ) {
            name = props.getProperty("starter.name");
        }
    }
413950
private void processProjectProperties()
   {
      //
      // Process common attributes
      //
      List<Row> rows = getRows("project", "proj_id", m_projectID);
      m_reader.processProjectProperties(rows, m_projectID);

      //
      // Process XER-specific attributes
      //
      if (m_defaultCurrencyData != null)
      {
         m_reader.processDefaultCurrency(m_defaultCurrencyData);
      }

      processScheduleOptions();
   }