View Javadoc

1   /*
2    * Copyright  2004-2005 Stefan Reuter
3    *
4    *  Licensed under the Apache License, Version 2.0 (the "License");
5    *  you may not use this file except in compliance with the License.
6    *  You may obtain a copy of the License at
7    *
8    *      http://www.apache.org/licenses/LICENSE-2.0
9    *
10   *  Unless required by applicable law or agreed to in writing, software
11   *  distributed under the License is distributed on an "AS IS" BASIS,
12   *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   *  See the License for the specific language governing permissions and
14   *  limitations under the License.
15   *
16   */
17  package net.sf.asterisk.manager;
18  
19  /***
20   * An EventTimeoutException is thrown if a ManagerResponse or some
21   * ResponseEvents are not completely received within the expected time period.<br>
22   * This exception allows you to retrieve the partial result, that is the events
23   * that have been successfully received before the timeout occured.
24   * 
25   * @author srt
26   * @version $Id: EventTimeoutException.java,v 1.3 2005/10/25 23:25:12 srt Exp $
27   * @since 0.2
28   */
29  public class EventTimeoutException extends TimeoutException
30  {
31      /***
32       * Serial version identifier.
33       */
34      private static final long serialVersionUID = 5461825583966922L;
35      private final ResponseEvents partialResult;
36  
37      /***
38       * Creates a new EventTimeoutException with the given message and partial
39       * result.
40       * 
41       * @param message message with details about the timeout.
42       * @param partialResult the ResponseEvents object filled with the parts that
43       *            have been received before the timeout occured.
44       */
45      public EventTimeoutException(String message, ResponseEvents partialResult)
46      {
47          super(message);
48          this.partialResult = partialResult;
49      }
50  
51      /***
52       * Returns the partial result that has been received before the timeout
53       * occured.<br>
54       * Note: Using the partial result in your application should be avoided
55       * wherever possible. This is only a hack to handle those versions of
56       * Asterisk that don't follow the Manager API conventions, for example by
57       * not sending the correct ActionCompleteEvent.
58       * 
59       * @return the ResponseEvents object filled with the parts that have been
60       *         received before the timeout occured. Note: The response attribute
61       *         may be <code>null</code> when no response has been received.
62       */
63      public ResponseEvents getPartialResult()
64      {
65          return partialResult;
66      }
67  }