
package processes;

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 TaskCreationSyncClientInitializer
extends org.apache.beehive.controls.runtime.bean.ClientInitializer
{
    static final Field _taskCtrlField;
    static final Field _taskWorkerCtrlField;
    static
    {
        try
        {
            _taskCtrlField = processes.TaskCreationSync.class.getDeclaredField("taskCtrl");
            _taskCtrlField.setAccessible(true);
            _taskWorkerCtrlField = processes.TaskCreationSync.class.getDeclaredField("taskWorkerCtrl");
            _taskWorkerCtrlField.setAccessible(true);
        }
        catch (NoSuchFieldException __bc_nsfe)
        {
            throw new ExceptionInInitializerError(__bc_nsfe);
        }
    }
    
    public static class TaskCtrlCallbackIntfEventAdaptor 
    implements processes.MyTaskCtrl.CallbackIntf, 
    EventAdaptor, java.io.Serializable
    {
        private static final long serialVersionUID = 1L;
        
        processes.TaskCreationSync __bc_client;
        
        public TaskCtrlCallbackIntfEventAdaptor(processes.TaskCreationSync client) { __bc_client = client; }
        
        public Object getClient() { return __bc_client; }
        
        public void onTaskAborted(org.apache.xmlbeans.XmlObject response) 
        {
            __bc_client.taskCtrl_onTaskAborted(response);
        }
        public void onTaskCompleted(org.apache.xmlbeans.XmlObject response) 
        {
            __bc_client.taskCtrl_onTaskCompleted(response);
        }
        public void onTaskOverdue(java.util.Date time) 
        {
            __bc_client.taskCtrl_onTaskOverdue(time);
        }
        
    }
    
    
    
    private static void initializeFields(ControlBeanContext cbc,
    processes.TaskCreationSync client)
    {
        try
        {
            String __bc_id;
            //
            // Initialize any nested controls used by the client
            //
            __bc_id = "taskCtrl";
            processes.MyTaskCtrlBean _taskCtrl = (cbc == null ? null : (processes.MyTaskCtrlBean)cbc.getBean(__bc_id));
            if (_taskCtrl == null)
            _taskCtrl = (processes.MyTaskCtrlBean) Controls.instantiate(processes.MyTaskCtrlBean.class, getAnnotationMap(cbc, _taskCtrlField), cbc, __bc_id );
            _taskCtrl.addCallbackIntfListener(new TaskCtrlCallbackIntfEventAdaptor(client));
            
            
            _taskCtrlField.set(client, _taskCtrl);
            __bc_id = "taskWorkerCtrl";
            processes.MyTaskWorkerCtrlBean _taskWorkerCtrl = (cbc == null ? null : (processes.MyTaskWorkerCtrlBean)cbc.getBean(__bc_id));
            if (_taskWorkerCtrl == null)
            _taskWorkerCtrl = (processes.MyTaskWorkerCtrlBean) Controls.instantiate(processes.MyTaskWorkerCtrlBean.class, getAnnotationMap(cbc, _taskWorkerCtrlField), cbc, __bc_id );
            
            
            _taskWorkerCtrlField.set(client, _taskWorkerCtrl);
        }
        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, processes.TaskCreationSync client)
    {
        
        initializeFields( cbc, client );
    }
}
