FailoverProtectedOperation.java
01 /*
02  *  Licensed to the Apache Software Foundation (ASF) under one
03  *  or more contributor license agreements.  See the NOTICE file
04  *  distributed with this work for additional information
05  *  regarding copyright ownership.  The ASF licenses this file
06  *  to you under the Apache License, Version 2.0 (the
07  *  "License"); you may not use this file except in compliance
08  *  with the License.  You may obtain a copy of the License at
09  *
10  *    http://www.apache.org/licenses/LICENSE-2.0
11  *
12  *  Unless required by applicable law or agreed to in writing,
13  *  software distributed under the License is distributed on an
14  *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15  *  KIND, either express or implied.  See the License for the
16  *  specific language governing permissions and limitations
17  *  under the License.
18  *
19  *
20  */
21 
22 package org.apache.qpid.client.failover;
23 
24 /**
25  * FailoverProtectedOperation is a continuation for an operation that may throw a {@link FailoverException} because
26  * it has been interrupted by the fail-over process. The {@link FailoverRetrySupport} class defines support wrappers
27  * for failover protected operations, in order to provide different handling schemes when failovers occurr.
28  *
29  <p/>The type of checked exception that the operation may perform has been generified, in order that fail over
30  * protected operations can be defined that raise arbitrary exceptions. The actuall exception types used should not
31  * be sub-classes of FailoverException, or else catching FailoverException in the {@link FailoverRetrySupport} classes
32  * will mask the exception.
33  *
34  <p><table id="crc"><caption>CRC Card</caption>
35  <tr><th> Responsibilities
36  <tr><td> Perform an operation that may be interrupted by fail-over.
37  </table>
38  */
39 public interface FailoverProtectedOperation<T, E extends Exception>
40 {
41     /**
42      * Performs the continuations work.
43      *
44      @return Provdes scope for the continuation to return an arbitrary value.
45      *
46      @throws FailoverException If the operation is interrupted by a fail-over notification.
47      */
48     public abstract T execute() throws E, FailoverException;
49 }