I. The client requesting the server to call it back later

Class DemoRequester wants to invoke Responder.revertString(), which demands a String, a CBstring, and a DescIn as its arguments. The latter two can/should be created using the RequesterUtil class. For CBstring to be created, a ResponseReceiver is necessary. A simple but in many cases sufficient example of a ResponseReceiver is shown below. When the Responder implementation calls the client back, the specified ResponseReceiver will be executed.


import alma.acs.callbacks.RequesterUtil;
import alma.acs.callbacks.ResponseReceiver;
import alma.acs.commandcenter.meta.Firestarter;
import alma.acs.container.ContainerServices;

import alma.mysubsystem.Responder;


public class DemoRequester {

    void go () throws Exception {

        // --- connect to component

        Firestarter.configure(null, "te1.hq.eso.org", "3500");
        Firestarter.prepare();
        ContainerServices cs = Firestarter.giveContainerServices();

        Responder responder = ResponderHelper.narrow(cs.getComponent("RESPONDER"));


        // --- activate callback object
        
        ResponseReceiver rere  =  new ResponseReceiver() {
        
              public void incomingResponse(Object x) {
                 System.out.println("Incoming Response: "+x);
              }
              public void incomingException(Exception x) {
                 System.out.println("Responding failed: "+x);}
         
        };
        
        responder.revertString(  "Hallo",
                                 RequesterUtil.giveCBString(cs, rere), 
                                 RequesterUtil.giveDescIn()  );


        // --- do something else until response comes in
        
        System.out.println("--> press exit to enter <--");
        while (System.in.read() != 13)
            ;

        
        // --- clean up and quit
        
        Firestarter.godown();

    }
}