View Javadoc

1   /*
2    *  Copyright 2004-2006 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 org.asteriskjava.manager.internal;
18  
19  import java.io.IOException;
20  
21  import org.asteriskjava.manager.event.ManagerEvent;
22  import org.asteriskjava.util.SocketConnectionFacade;
23  
24  /***
25   * The ManagerReader reads events and responses from the asterisk server, parses
26   * them using EventBuilderImpl and ResponseBuilder and dispatches them to the
27   * associated ManagerConnection.<p>
28   * Do not use this interface in your code, it is intended to be used only by the
29   * DefaultManagerConnection.
30   * 
31   * @see org.asteriskjava.manager.internal.EventBuilder
32   * @see org.asteriskjava.manager.internal.ResponseBuilder
33   * @see org.asteriskjava.manager.DefaultManagerConnection
34   * @author srt
35   * @version $Id: ManagerReader.java 527 2006-08-08 01:48:16Z srt $
36   */
37  public interface ManagerReader extends Runnable
38  {
39  
40      /***
41       * Sets the socket to use for reading from the asterisk server.
42       * 
43       * @param socket the socket to use for reading from the asterisk server.
44       */
45      void setSocket(final SocketConnectionFacade socket);
46  
47      /***
48       * Registers a new event type with the underlying EventBuilderImpl.<p>
49       * The eventClass must extend ManagerEvent.
50       * 
51       * @see EventBuilder
52       * @see ManagerEvent
53       * @param event class of the event to register.
54       */
55      void registerEventClass(Class event);
56  
57      void die();
58  
59      boolean isDead();
60      
61      /***
62       * Returns the Exception that caused this reader to terminate if any.
63       * 
64       * @return the Exception that caused this reader to terminate if any or <code>null</code> if not.
65       */
66      IOException getTerminationException();
67  }