home *** CD-ROM | disk | FTP | other *** search
- import stardiv.tools.SjProtocolWindow;
-
- class SJCondAckMsgStruct extends SJCondMsgStruct implements SJMessageHandlerInterface {
- private boolean bMessageDone = false;
- private boolean bMessageError = false;
- private SJMessageHandlerInterface aAckObject;
-
- private final void SendAck(SJMessage var1) {
- if (this.aAckObject != null) {
- this.aAckObject.HandleMessage(var1);
- }
-
- }
-
- public SJCondAckMsgStruct(SJMessageHandlerInterface var1) {
- super(var1);
- }
-
- public final boolean IsTrue() {
- return this.HasResult();
- }
-
- public final synchronized void DeliverAndAcknowledge(SJMessageHandlerInterface var1) {
- this.aAckObject = var1;
- ((SJCondMsgStruct)this).GetMessage().JOB_SetNotifyObject(this);
- ((SJCondMsgStruct)this).GetDestination().HandleMessage(((SJCondMsgStruct)this).GetMessage());
- }
-
- public final boolean PeekMessageDone() {
- return this.bMessageDone;
- }
-
- public final synchronized void WaitForMessageDone() {
- try {
- while(!this.bMessageDone) {
- SjProtocolWindow.AddWaitEvent(this, "SJJob.WaitForMessageDone()");
- this.wait();
- SjProtocolWindow.AddWaitEventDONE(this, "SJJob.WaitForMessageDone()");
- }
-
- } catch (InterruptedException var1) {
- }
- }
-
- private final synchronized void SetMessageDone() {
- this.bMessageDone = true;
- SjProtocolWindow.AddNotifyEvent(this, "SJJob.SetMessageDone()");
- this.notifyAll();
- SjProtocolWindow.AddNotifyEventDONE(this, "SJJob.SetMessageDone()");
- }
-
- public final boolean PeekMessageError() {
- return this.bMessageError;
- }
-
- private final synchronized void SetMessageError() {
- this.bMessageError = true;
- SjProtocolWindow.AddNotifyEvent(this, "SJJob.SetMessageError()");
- this.notifyAll();
- SjProtocolWindow.AddNotifyEvent(this, "SJJob.SetMessageError()");
- }
-
- private final synchronized boolean HasDoneNothing() {
- return !this.bMessageDone && !this.bMessageError && !((SJCondMsgStruct)this).PeekMessagePending();
- }
-
- private final synchronized void WaitForSomething() {
- try {
- while(this.HasDoneNothing()) {
- SjProtocolWindow.AddWaitEvent(this, "SJJob.WaitForSomething()");
- this.wait();
- SjProtocolWindow.AddWaitEventDONE(this, "SJJob.WaitForSomething()");
- }
-
- } catch (InterruptedException var1) {
- }
- }
-
- public final synchronized boolean HasResult() {
- return this.bMessageDone || this.bMessageError;
- }
-
- private final synchronized void WaitForResult() {
- try {
- while(this.HasResult()) {
- SjProtocolWindow.AddWaitEvent(this, "SJJob.WaitForResult()");
- this.wait();
- SjProtocolWindow.AddWaitEventDONE(this, "SJJob.WaitForResult()");
- }
-
- } catch (InterruptedException var1) {
- }
- }
-
- public void HandleMessage(SJMessage var1) {
- if (var1 != null) {
- switch (var1.GetID()) {
- case 10000:
- this.SetMessageDone();
- this.SendAck(var1);
- return;
- case 10001:
- super.SetMessagePending();
- this.SendAck(var1);
- return;
- case 10002:
- this.SetMessageError();
- this.SendAck(var1);
- return;
- default:
- }
- }
- }
- }
-