public
  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) || "appenders".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);
            PaxPropertySetter setter = new PaxPropertySetter(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;
        }
        else if (prop != null
                    && OptionFactory.class.isAssignableFrom(prop.getPropertyType())
                    && prop.getWriteMethod() != null)
        {
            OptionFactory factory = new ObjectFactory(properties, prefix + key);
            try {
                prop.getWriteMethod().invoke(this.obj, new Object[] { factory });
            } 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();
  }
public void setProperties ( Properties properties , String prefix ) { int len = prefix . length ( ) ; for ( Enumeration e = properties . propertyNames ( ) ; e . hasMoreElements ( ) ; ) { String key = ( String ) e . nextElement ( ) ; if ( key . startsWith ( prefix ) ) { if ( key . indexOf ( '.' , len + 1 ) > 0 ) { continue ; } String value = OptionConverter . findAndSubst ( key , properties ) ; key = key . substring ( len ) ; if ( ( "layout" . equals ( key ) || "errorHandler" . equals ( key ) || "appenders" . equals ( key ) ) && obj instanceof Appender ) { continue ; } 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 ) ; PaxPropertySetter setter = new PaxPropertySetter ( 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 ; } else if ( prop != null && OptionFactory . class . isAssignableFrom ( prop . getPropertyType ( ) ) && prop . getWriteMethod ( ) != null ) { OptionFactory factory = new ObjectFactory ( properties , prefix + key ) ; try { prop . getWriteMethod ( ) . invoke ( this . obj , new Object [ ] { factory } ) ; } 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 ( ) ; }
Set the properites for the object that match the
<code>prefix</code> passed as parameter.