01: package org.jacorb.notification.engine;
02:
03: /*
04: * JacORB - a free Java ORB
05: *
06: * Copyright (C) 1997-2004 Gerald Brose.
07: *
08: * This library is free software; you can redistribute it and/or
09: * modify it under the terms of the GNU Library General Public
10: * License as published by the Free Software Foundation; either
11: * version 2 of the License, or (at your option) any later version.
12: *
13: * This library is distributed in the hope that it will be useful,
14: * but WITHOUT ANY WARRANTY; without even the implied warranty of
15: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16: * Library General Public License for more details.
17: *
18: * You should have received a copy of the GNU Library General Public
19: * License along with this library; if not, write to the Free
20: * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21: */
22:
23: import org.jacorb.notification.interfaces.IProxyPushSupplier;
24:
25: /**
26: * @author Alphonse Bendt
27: * @version $Id: WaitRetryStrategy.java,v 1.7 2005/08/21 13:30:16 alphonse.bendt Exp $
28: */
29:
30: public class WaitRetryStrategy extends AbstractRetryStrategy {
31: public static final long WAIT_TIME_DEFAULT = 1000;
32:
33: public static final long WAIT_INCREMENT_DEFAULT = 3000;
34:
35: private long currentTimeToWait_;
36:
37: private long waitTimeIncrement_;
38:
39: // //////////////////////////////////////
40:
41: public WaitRetryStrategy(IProxyPushSupplier pushSupplier,
42: PushOperation pushOperation) {
43: this (pushSupplier, pushOperation, WAIT_TIME_DEFAULT,
44: WAIT_INCREMENT_DEFAULT);
45: }
46:
47: public WaitRetryStrategy(IProxyPushSupplier pushSupplier,
48: PushOperation pushOperation, long startingWaitTime,
49: long waitTimeIncrement) {
50: super (pushSupplier, pushOperation);
51:
52: currentTimeToWait_ = startingWaitTime;
53:
54: waitTimeIncrement_ = waitTimeIncrement;
55: }
56:
57: // //////////////////////////////////////
58:
59: protected long getTimeToWait() {
60: long _timeToWait = currentTimeToWait_;
61:
62: currentTimeToWait_ += waitTimeIncrement_;
63:
64: return _timeToWait;
65: }
66:
67: protected void retryInternal() throws RetryException {
68: try {
69: while (isRetryAllowed()) {
70: try {
71: pushOperation_.invokePush();
72:
73: return;
74: } catch (Exception error) {
75: remoteExceptionOccured(error);
76: }
77: }
78:
79: throw new RetryException("no more retries possible");
80: } finally {
81: dispose();
82: }
83: }
84: }
|