void setProperties()

in src/main/java/org/apache/log4j/config/PropertySetter.java [115:173]


  void setProperties(Properties properties, String prefix) {
    int len = prefix.length();
    
    for (Enumeration e = properties.propertyNames(); e.hasMoreElements(); ) {
      String key = (String) e.nextElement();
      
      // handle only properties that start with the desired frefix.
      if (key.startsWith(prefix)) {

	
	// ignore key if it contains dots after the prefix
        if (key.indexOf('.', len + 1) > 0) {
	  //System.err.println("----------Ignoring---["+key
	  //	     +"], prefix=["+prefix+"].");
	  continue;
	}
        
	String value = OptionConverter.findAndSubst(key, properties);
        key = key.substring(len);
        if (("layout".equals(key) || "errorhandler".equals(key)) && obj instanceof Appender) {
          continue;
        }
        //
        //   if the property type is an OptionHandler
        //     (for example, triggeringPolicy of org.apache.log4j.rolling.RollingFileAppender)
        PropertyDescriptor prop = getPropertyDescriptor(Introspector.decapitalize(key));
        if (prop != null
                && OptionHandler.class.isAssignableFrom(prop.getPropertyType())
                && prop.getWriteMethod() != null) {
            OptionHandler opt = (OptionHandler)
                    OptionConverter.instantiateByKey(properties, prefix + key,
                                  prop.getPropertyType(),
                                  null);
            PropertySetter setter = new PropertySetter(opt);
            setter.setProperties(properties, prefix + key + ".");
            try {
                prop.getWriteMethod().invoke(this.obj, new Object[] { opt });
            } catch(IllegalAccessException ex) {
                LogLog.warn("Failed to set property [" + key +
                            "] to value \"" + value + "\". ", ex);
            } catch(InvocationTargetException ex) {
                if (ex.getTargetException() instanceof InterruptedException
                        || ex.getTargetException() instanceof InterruptedIOException) {
                    Thread.currentThread().interrupt();
                }
                LogLog.warn("Failed to set property [" + key +
                            "] to value \"" + value + "\". ", ex);
            } catch(RuntimeException ex) {
                LogLog.warn("Failed to set property [" + key +
                            "] to value \"" + value + "\". ", ex);
            }
            continue;
        }

        setProperty(key, value);
      }
    }
    activate();
  }