
package processing;

import java.lang.reflect.Field;
import org.apache.beehive.controls.api.ControlException;
import org.apache.beehive.controls.api.bean.Controls;
import org.apache.beehive.controls.api.versioning.VersionRequired;
import org.apache.beehive.controls.api.context.ControlBeanContext;
import org.apache.beehive.controls.runtime.bean.EventAdaptor;
import org.apache.beehive.controls.runtime.bean.AdaptorPersistenceDelegate;

@SuppressWarnings("all")
public class ProcessExternalApplication81ClientInitializer
extends org.apache.beehive.controls.runtime.bean.ClientInitializer
{
    static final Field _applicationInfoField;
    static final Field _appTaskControlIIField;
    static final Field _appFileCtlField;
    static
    {
        try
        {
            _applicationInfoField = processing.ProcessExternalApplication81.class.getDeclaredField("applicationInfo");
            _applicationInfoField.setAccessible(true);
            _appTaskControlIIField = processing.ProcessExternalApplication81.class.getDeclaredField("appTaskControlII");
            _appTaskControlIIField.setAccessible(true);
            _appFileCtlField = processing.ProcessExternalApplication81.class.getDeclaredField("appFileCtl");
            _appFileCtlField.setAccessible(true);
        }
        catch (NoSuchFieldException __bc_nsfe)
        {
            throw new ExceptionInInitializerError(__bc_nsfe);
        }
    }
    
    public static class AppTaskControlIICallbackEventAdaptor 
    implements controls.AppTaskControl.Callback, 
    EventAdaptor, java.io.Serializable
    {
        private static final long serialVersionUID = 1L;
        
        processing.ProcessExternalApplication81 __bc_client;
        
        public AppTaskControlIICallbackEventAdaptor(processing.ProcessExternalApplication81 client) { __bc_client = client; }
        
        public Object getClient() { return __bc_client; }
        
        public void onTaskAborted(org.apache.xmlbeans.XmlObject response) 
        {
        }
        public void onTaskCompleted(org.apache.xmlbeans.XmlObject response) 
        {
            __bc_client.appTaskControlII_onTaskCompleted(response);
        }
        public void onTaskOverdue(java.util.Date time) 
        {
            __bc_client.appTaskControlII_onTaskOverdue(time);
        }
    }
    
    
    private static void initializeFields(ControlBeanContext cbc,
    processing.ProcessExternalApplication81 client)
    {
        try
        {
            String __bc_id;
            //
            // Initialize any nested controls used by the client
            //
            __bc_id = "applicationInfo";
            controls.ApplicationInfoBean _applicationInfo = (cbc == null ? null : (controls.ApplicationInfoBean)cbc.getBean(__bc_id));
            if (_applicationInfo == null)
            _applicationInfo = (controls.ApplicationInfoBean) Controls.instantiate(controls.ApplicationInfoBean.class, getAnnotationMap(cbc, _applicationInfoField), cbc, __bc_id );
            
            
            _applicationInfoField.set(client, _applicationInfo);
            __bc_id = "appTaskControlII";
            controls.AppTaskControlBean _appTaskControlII = (cbc == null ? null : (controls.AppTaskControlBean)cbc.getBean(__bc_id));
            if (_appTaskControlII == null)
            _appTaskControlII = (controls.AppTaskControlBean) Controls.instantiate(controls.AppTaskControlBean.class, getAnnotationMap(cbc, _appTaskControlIIField), cbc, __bc_id );
            _appTaskControlII.addCallbackListener(new AppTaskControlIICallbackEventAdaptor(client));
            
            
            _appTaskControlIIField.set(client, _appTaskControlII);
            __bc_id = "appFileCtl";
            controls.ApplicationFileCtlBean _appFileCtl = (cbc == null ? null : (controls.ApplicationFileCtlBean)cbc.getBean(__bc_id));
            if (_appFileCtl == null)
            _appFileCtl = (controls.ApplicationFileCtlBean) Controls.instantiate(controls.ApplicationFileCtlBean.class, getAnnotationMap(cbc, _appFileCtlField), cbc, __bc_id );
            
            
            _appFileCtlField.set(client, _appFileCtl);
        }
        catch (RuntimeException __bc_re) { throw __bc_re; }
        catch (Exception __bc_e)
        {
            __bc_e.printStackTrace();
            throw new ControlException("Initializer failure", __bc_e);
        }
    }
    
    public static void initialize(ControlBeanContext cbc, processing.ProcessExternalApplication81 client)
    {
        
        initializeFields( cbc, client );
    }
}
