1 package org.jacorb.notification.engine; 2 3 22 23 import org.jacorb.notification.interfaces.IProxyPushSupplier; 24 25 import EDU.oswego.cs.dl.util.concurrent.SynchronizedBoolean; 26 27 31 public class TaskProcessorRetryStrategy extends AbstractRetryStrategy implements 32 PushTaskExecutor.PushTask 33 { 34 37 public final Runnable retryPushOperation_ = new Runnable () 38 { 39 public void run() 40 { 41 pushSupplier_.schedulePush(TaskProcessorRetryStrategy.this); 42 } 43 }; 44 45 private SynchronizedBoolean isCancelled_ = new SynchronizedBoolean(false); 46 47 private final TaskProcessor taskProcessor_; 48 49 private final long backoutInterval_; 50 51 public TaskProcessorRetryStrategy(IProxyPushSupplier pushSupplier, PushOperation pushOperation, 52 TaskProcessor taskProcessor, long backoutInterval) 53 { 54 super(pushSupplier, pushOperation); 55 56 taskProcessor_ = taskProcessor; 57 backoutInterval_ = backoutInterval; 58 } 59 60 protected long getTimeToWait() 61 { 62 return 0; 63 } 64 65 protected void retryInternal() throws RetryException 66 { 67 if (!pushSupplier_.isDisposed()) 68 { 69 pushSupplier_.disableDelivery(); 70 71 taskProcessor_.executeTaskAfterDelay(backoutInterval_, retryPushOperation_); 72 } 73 } 74 75 public void doPush() 76 { 77 if (!isCancelled_.get()) 78 { 79 try 80 { 81 if (!pushSupplier_.isDisposed()) 82 { 83 pushOperation_.invokePush(); 84 pushSupplier_.pushPendingData(); 85 } 86 87 dispose(); 88 } catch (Throwable error) 89 { 90 try 91 { 92 remoteExceptionOccured(error); 93 retry(); 94 } catch (RetryException e) 95 { 96 dispose(); 97 } 98 } 99 } 100 } 101 102 public void cancel() 103 { 104 isCancelled_.set(true); 105 106 dispose(); 107 } 108 } 109 | Popular Tags |