/*
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 *  http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.
 */

package org.apache.geronimo.gshell.prefs;

import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.util.prefs.Preferences;

/**
 * Processes an object for preference annotations.
 *
 * @version $Rev$ $Date$
 */
public class PreferencesProcessor
{
    private final Object bean;

    public PreferencesProcessor(final Object bean) throws IllegalAnnotationError {
        assert bean != null;

        this.bean = bean;

        discoverDescriptors();
    }

    public Object getBean() {
        return bean;
    }

    //
    // Discovery
    //

    private void discoverDescriptors() {
        // Recursively process all the methods/fields.
        for (Class type=bean.getClass(); type!=null; type=type.getSuperclass()) {
            // Discover methods
            for (Method method : type.getDeclaredMethods()) {
                Preference pref = method.getAnnotation(Preference.class);
                if (pref != null) {
                    // addOption(new MethodSetter(bean, method), option);
                }
            }

            // Discover fields
            for (Field field : type.getDeclaredFields()) {
                Preference pref = field.getAnnotation(Preference.class);
                if (pref != null) {
                    // addOption(createFieldSetter(field), option);
                }
            }
        }
    }

    //
    // Processing
    //

    public void process(final Preferences node) throws ProcessingException {
        assert node != null;
    }
}
@@ -1078,33 +1078,39 @@
    p
-rivate final Object bean;
+ublic PreferencesProcessor() %7B%7D
 %0A%0A  
@@ -1162,125 +1162,30 @@
 an) 
-throws IllegalAnnotationError %7B%0A        assert bean != null;%0A%0A        this.bean = bean;%0A%0A        discoverDescriptors(
+%7B%0A        addBean(bean
 );%0A 
@@ -1205,23 +1205,38 @@
 lic 
+void addBean(final 
 Object 
-getB
+b
 ean
-(
 ) %7B%0A
@@ -1247,20 +1247,46 @@
     
-return bean;
+assert bean != null;%0A%0A        // TODO:
 %0A   
@@ -1317,24 +1317,31 @@
 ery%0A    //%0A%0A
+    /*%0A
     private 
@@ -2128,24 +2128,35 @@
     %7D%0A    %7D%0A
+    */%0A    
 %0A    //%0A    

Make prefs api accept multipule beans