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 1154 2008-08-24 02:05:26Z srt $
Author:
srt

Field Summary
 
Fields inherited from interface org.asteriskjava.manager.internal.ManagerReader
COMMAND_RESULT_RESPONSE_KEY
 
Constructor Summary
ManagerReaderImpl(org.asteriskjava.manager.internal.Dispatcher dispatcher, java.lang.Object source)
          Creates a new ManagerReaderImpl.
 
Method Summary
 void die()
          Terminates this reader.
 void expectResponseClass(java.lang.String internalActionId, java.lang.Class<? extends ManagerResponse> responseClass)
           
 java.io.IOException getTerminationException()
          Returns the Exception that caused this reader to terminate if any.
 boolean isDead()
          Checks whether this reader is terminating or terminated.
 void registerEventClass(java.lang.Class<? extends ManagerEvent> 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<? extends ManagerEvent> 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

expectResponseClass

public void expectResponseClass(java.lang.String internalActionId,
                                java.lang.Class<? extends ManagerResponse> responseClass)
Specified by:
expectResponseClass in interface ManagerReader

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()
Description copied from interface: ManagerReader
Terminates this reader.

Specified by:
die in interface ManagerReader

isDead

public boolean isDead()
Description copied from interface: ManagerReader
Checks whether this reader is terminating or terminated.

Specified by:
isDead in interface ManagerReader
Returns:
true if this reader is terminating or terminated, false otherwise.

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-2009 Stefan Reuter. All Rights Reserved.