
package tpm;

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 BuyerAlertClientInitializer
extends org.apache.beehive.controls.runtime.bean.ClientInitializer
{
    static final Field _alertField;
    static final Field _sellerControlField;
    static final Field _tpmField;
    static
    {
        try
        {
            _alertField = tpm.BuyerAlert.class.getDeclaredField("alert");
            _alertField.setAccessible(true);
            _sellerControlField = tpm.BuyerAlert.class.getDeclaredField("sellerControl");
            _sellerControlField.setAccessible(true);
            _tpmField = tpm.BuyerAlert.class.getDeclaredField("tpm");
            _tpmField.setAccessible(true);
        }
        catch (NoSuchFieldException __bc_nsfe)
        {
            throw new ExceptionInInitializerError(__bc_nsfe);
        }
    }
    
    public static class SellerControlCallbackEventAdaptor 
    implements tpm.SellerControl.Callback, 
    EventAdaptor, java.io.Serializable
    {
        private static final long serialVersionUID = 1L;
        
        tpm.BuyerAlert __bc_client;
        
        public SellerControlCallbackEventAdaptor(tpm.BuyerAlert client) { __bc_client = client; }
        
        public Object getClient() { return __bc_client; }
        
        public void onAck(weblogic.wsee.jws.wlw.schemas.soap11.EnvelopeDocument ack) 
        {
            __bc_client.sellerControl_onAck(ack);
        }
        public void onError(weblogic.wsee.jws.wlw.schemas.soap11.EnvelopeDocument error) 
        {
        }
        public void response(org.apache.xmlbeans.XmlObject payload) 
        {
        }
        
    }
    
    
    
    private static void initializeFields(ControlBeanContext cbc,
    tpm.BuyerAlert client)
    {
        try
        {
            String __bc_id;
            //
            // Initialize any nested controls used by the client
            //
            __bc_id = "alert";
            tpm.AlertBean _alert = (cbc == null ? null : (tpm.AlertBean)cbc.getBean(__bc_id));
            if (_alert == null)
            _alert = (tpm.AlertBean) Controls.instantiate(tpm.AlertBean.class, getAnnotationMap(cbc, _alertField), cbc, __bc_id );
            
            
            _alertField.set(client, _alert);
            __bc_id = "sellerControl";
            tpm.SellerControlBean _sellerControl = (cbc == null ? null : (tpm.SellerControlBean)cbc.getBean(__bc_id));
            if (_sellerControl == null)
            _sellerControl = (tpm.SellerControlBean) Controls.instantiate(tpm.SellerControlBean.class, getAnnotationMap(cbc, _sellerControlField), cbc, __bc_id );
            _sellerControl.addCallbackListener(new SellerControlCallbackEventAdaptor(client));
            
            
            _sellerControlField.set(client, _sellerControl);
            __bc_id = "tpm";
            com.bea.control.TPMControlBean _tpm = (cbc == null ? null : (com.bea.control.TPMControlBean)cbc.getBean(__bc_id));
            if (_tpm == null)
            _tpm = (com.bea.control.TPMControlBean) Controls.instantiate(com.bea.control.TPMControlBean.class, getAnnotationMap(cbc, _tpmField), cbc, __bc_id );
            
            
            _tpmField.set(client, _tpm);
        }
        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, tpm.BuyerAlert client)
    {
        
        initializeFields( cbc, client );
    }
}
