Asterisk-Java

org.asteriskjava.manager.internal
Class ManagerReaderImpl

java.lang.Object
  extended by org.asteriskjava.manager.internal.ManagerReaderImpl
All Implemented Interfaces:
java.lang.Runnable, ManagerReader

public class ManagerReaderImpl
extends java.lang.Object
implements ManagerReader

Default implementation of the ManagerReader interface.

Version:
$Id: ManagerReaderImpl.java 878 2007-08-01 22:04:11Z srt $
Author:
srt

Constructor Summary
ManagerReaderImpl(org.asteriskjava.manager.internal.Dispatcher dispatcher, java.lang.Object source)
          Creates a new ManagerReaderImpl.
 
Method Summary
 void die()
           
 java.io.IOException getTerminationException()
          Returns the Exception that caused this reader to terminate if any.
 boolean isDead()
           
 void registerEventClass(java.lang.Class eventClass)
          Registers a new event type with the underlying EventBuilderImpl.
 void run()
          Reads line by line from the asterisk server, sets the protocol identifier (using a generated ProtocolIdentifierReceivedEvent) as soon as it is received and dispatches the received events and responses via the associated dispatcher.
 void setSocket(SocketConnectionFacade socket)
          Sets the socket to use for reading from the asterisk server.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ManagerReaderImpl

public ManagerReaderImpl(org.asteriskjava.manager.internal.Dispatcher dispatcher,
                         java.lang.Object source)
Creates a new ManagerReaderImpl.

Parameters:
dispatcher - the dispatcher to use for dispatching events and responses.
source - the source to use when creating ManagerEvents
Method Detail

setSocket

public void setSocket(SocketConnectionFacade socket)
Sets the socket to use for reading from the asterisk server.

Specified by:
setSocket in interface ManagerReader
Parameters:
socket - the socket to use for reading from the asterisk server.

registerEventClass

public void registerEventClass(java.lang.Class eventClass)
Description copied from interface: ManagerReader
Registers a new event type with the underlying EventBuilderImpl.

The eventClass must extend ManagerEvent.

Specified by:
registerEventClass in interface ManagerReader
Parameters:
eventClass - class of the event to register.
See Also:
EventBuilder, ManagerEvent

run

public void run()
Reads line by line from the asterisk server, sets the protocol identifier (using a generated ProtocolIdentifierReceivedEvent) as soon as it is received and dispatches the received events and responses via the associated dispatcher.

Specified by:
run in interface java.lang.Runnable
See Also:
Dispatcher.dispatchEvent(ManagerEvent), Dispatcher.dispatchResponse(ManagerResponse)

die

public void die()
Specified by:
die in interface ManagerReader

isDead

public boolean isDead()
Specified by:
isDead in interface ManagerReader

getTerminationException

public java.io.IOException getTerminationException()
Description copied from interface: ManagerReader
Returns the Exception that caused this reader to terminate if any.

Specified by:
getTerminationException in interface ManagerReader
Returns:
the Exception that caused this reader to terminate if any or null if not.

Asterisk-Java

Copyright © 2004-2007 Stefan Reuter. All Rights Reserved.