[Asterisk-java-cvs] CVS: asterisk-java/src/java/net/sf/asterisk/manager EventTimeoutException.java,N
Brought to you by:
srt
Update of /cvsroot/asterisk-java/asterisk-java/src/java/net/sf/asterisk/manager In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13887/src/java/net/sf/asterisk/manager Modified Files: DefaultManagerConnection.java ManagerConnection.java TimeoutException.java Added Files: EventTimeoutException.java Log Message: Added EventTimeoutException to allow access to the partial result when using buggy actions in Asterisk that dont send the correct ActionResponseEvent. --- NEW FILE: EventTimeoutException.java --- /* * Copyright 2004-2005 Stefan Reuter * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ package net.sf.asterisk.manager; /** * An EventTimeoutException is thrown if a ManagerResponse or ResponseEvents are * not completely received within the expected time period. * * @author srt * @version $Id: EventTimeoutException.java,v 1.1 2005/07/16 22:04:55 srt Exp $ * @since 0.2 */ public class EventTimeoutException extends TimeoutException { /** * Serial version identifier. */ private static final long serialVersionUID = 5461825583966922L; private final ResponseEvents partialResult; /** * Creates a new EventTimeoutException with the given message and partial * result. * * @param message message with details about the timeout. * @param partialResult the ResponseEvents object filled with the parts that * have been received before the timeout occured. */ public EventTimeoutException(String message, ResponseEvents partialResult) { super(message); this.partialResult = partialResult; } /** * Returns the partial result that has been received before the timeout * occured.<br> * Note: Using the partial result in your application should be avoided * wherever possible. This is only a hack to handle those versions of * Asterisk that don't follow the Manager API conventions, for example by * not sending the correct ActionCompleteEvent. * * @return the ResponseEvents object filled with the parts that have been * received before the timeout occured. Note: The response attribute * may be <code>null</code> when no response has been received. */ public ResponseEvents getPartialResult() { return partialResult; } } Index: DefaultManagerConnection.java =================================================================== RCS file: /cvsroot/asterisk-java/asterisk-java/src/java/net/sf/asterisk/manager/DefaultManagerConnection.java,v retrieving revision 1.21 retrieving revision 1.22 diff -u -d -p -r1.21 -r1.22 --- DefaultManagerConnection.java 16 Jul 2005 21:48:16 -0000 1.21 +++ DefaultManagerConnection.java 16 Jul 2005 22:04:54 -0000 1.22 @@ -621,7 +621,7 @@ public class DefaultManagerConnection im } public ResponseEvents sendEventGeneratingAction(EventGeneratingAction action) - throws IOException, TimeoutException, IllegalArgumentException, + throws IOException, EventTimeoutException, IllegalArgumentException, IllegalStateException { return sendEventGeneratingAction(action, defaultEventTimeout); @@ -629,7 +629,7 @@ public class DefaultManagerConnection im public ResponseEvents sendEventGeneratingAction( EventGeneratingAction action, long timeout) throws IOException, - TimeoutException, IllegalArgumentException, IllegalStateException + EventTimeoutException, IllegalArgumentException, IllegalStateException { ResponseEventsImpl responseEvents; ResponseEventHandler responseEventHandler; @@ -709,9 +709,9 @@ public class DefaultManagerConnection im this.responseEventHandlers.remove(internalActionId); } - throw new TimeoutException( + throw new EventTimeoutException( "Timeout waiting for response or response events to " - + action.getAction()); + + action.getAction(), responseEvents); } } Index: ManagerConnection.java =================================================================== RCS file: /cvsroot/asterisk-java/asterisk-java/src/java/net/sf/asterisk/manager/ManagerConnection.java,v retrieving revision 1.10 retrieving revision 1.11 diff -u -d -p -r1.10 -r1.11 --- ManagerConnection.java 16 Jul 2005 21:48:16 -0000 1.10 +++ ManagerConnection.java 16 Jul 2005 22:04:55 -0000 1.11 @@ -166,7 +166,7 @@ public interface ManagerConnection * @return a ResponseEvents that contains the corresponding response and * response events received from the Asterisk server * @throws IOException if the network connection is disrupted. - * @throws TimeoutException if no response or not all response events are + * @throws EventTimeoutException if no response or not all response events are * received within the given timeout period. * @throws IllegalArgumentException if the action is <code>null</code>, * the actionCompleteEventClass property of the action is @@ -179,7 +179,7 @@ public interface ManagerConnection * @since 0.2 */ ResponseEvents sendEventGeneratingAction(EventGeneratingAction action) - throws IOException, TimeoutException, IllegalArgumentException, + throws IOException, EventTimeoutException, IllegalArgumentException, IllegalStateException; /** @@ -199,7 +199,7 @@ public interface ManagerConnection * @return a ResponseEvents that contains the corresponding response and * response events received from the Asterisk server * @throws IOException if the network connection is disrupted. - * @throws TimeoutException if no response or not all response events are + * @throws EventTimeoutException if no response or not all response events are * received within the given timeout period. * @throws IllegalArgumentException if the action is <code>null</code>, * the actionCompleteEventClass property of the action is @@ -212,7 +212,7 @@ public interface ManagerConnection * @since 0.2 */ ResponseEvents sendEventGeneratingAction(EventGeneratingAction action, - long timeout) throws IOException, TimeoutException, + long timeout) throws IOException, EventTimeoutException, IllegalArgumentException, IllegalStateException; /** Index: TimeoutException.java =================================================================== RCS file: /cvsroot/asterisk-java/asterisk-java/src/java/net/sf/asterisk/manager/TimeoutException.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -p -r1.2 -r1.3 --- TimeoutException.java 23 Feb 2005 22:50:57 -0000 1.2 +++ TimeoutException.java 16 Jul 2005 22:04:55 -0000 1.3 @@ -17,8 +17,8 @@ package net.sf.asterisk.manager; /** - * A TimeoutException is thrown if a ManagerResponse is not received within the expected time - * period. + * A TimeoutException is thrown if a ManagerResponse is not received within the + * expected time period. * * @author srt * @version $Id$ @@ -32,6 +32,7 @@ public class TimeoutException extends Ex /** * Creates a new TimeoutException with the given message. + * * @param message message with details about the timeout. */ public TimeoutException(final String message) |