Hi All,

I am using Axis2 v1.3 and I would like to know if is there a way to implement a service side listener that after a simple client call it notifies the client frequently? Many times until a final event, like a status notifier? For exemple, consider this client code:

//...
OperationServiceImplStub.AddOperationCallback addOperCallback = new OperationServiceImplStub.AddOperationCallback();
addOperCallback.setOperationBean(getOperBean());
addOperCallback.setReqInfoBean(getReqInfo());

//I know that this is invalid! Just to illustrate the idea...
addOperCallback.setCallback(new StatusListener() {
   public void statusChanged(StatusEvent se) {
       //Do something...
   }
}); AddOperationCallbackResponse addOperRespose = operStub.addOperationCallback(addOperCallback);
//...

The service side:

//...
public OperationBean addOperationCallback(OperationBean oper, RequestInfoBean reqInfoBean, StatusListener callback) {
       operation = addOperation(oper, reqInfo);
       if (callback != null) {
           startCallback(oper, callback);
       }
       return oper;
}

//just emulates a state change workflow...
private void startCallback(final Operation oper, final StatusListener callback) { final String[] status = { "new", "activating", "active", "inactivating", "inactive" };
       Thread t = new Thread() {
           public void run() {
               Random r = new Random();
               for (int i = 0; i < status.length; i++) {
                   try {
                       Thread.sleep(r.nextInt(14) + 1);
                       StatusEvent se = new StatusEventImpl();
                       se.setStatus(oper.getId() + ':' + status[i]);
                       callback.statusChanged(se);
                   } catch (InterruptedException e) {
                       e.printStackTrace();
                   }
               }
           }
       };
       t.start();
}
//...

How can I fit this code to work properly?

Thanks a lot.
José Renato.

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to