Asterisk-Java

org.asteriskjava.manager
Class ManagerEventListenerProxy

java.lang.Object
  extended by org.asteriskjava.manager.ManagerEventListenerProxy
All Implemented Interfaces:
java.util.EventListener, ManagerEventListener

public class ManagerEventListenerProxy
extends java.lang.Object
implements ManagerEventListener

Proxies a ManagerEventListener and dispatches events asynchronously by using a single threaded executor.

Use this proxy to prevent the reader thread from being blocked while your application processes ManagerEvents. If you want to use the ManagerConnection for sending actions in your ManagerEventListener using a proxy like this one is mandatory; otherwise you will always run into a timeout because the reader thread that is supposed to read the response to your action is still blocked processing the event.

If in doubt use the proxy as it won't hurt.

Example:

 ManagerConnection connection;
 ManagerEventListener myListener;
 ...
 connection.addEventListener(new ManagerEventListenerProxy(myListener));
 

Since:
0.3
Version:
$Id: ManagerEventListenerProxy.java 938 2007-12-31 03:23:38Z srt $
Author:
srt

Constructor Summary
ManagerEventListenerProxy()
          Creates a new ManagerEventListenerProxy.
ManagerEventListenerProxy(ManagerEventListener target)
          Creates a new ManagerEventListenerProxy that notifies the given target asynchronously when new events are received.
 
Method Summary
 void onManagerEvent(ManagerEvent event)
          This method is called when an event is received.
 void setTarget(ManagerEventListener target)
          Sets the target listener that is notified asynchronously when new events are received.
 void shutdown()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ManagerEventListenerProxy

public ManagerEventListenerProxy()
Creates a new ManagerEventListenerProxy.

You must set the target by calling setTarget(ManagerEventListener).


ManagerEventListenerProxy

public ManagerEventListenerProxy(ManagerEventListener target)
Creates a new ManagerEventListenerProxy that notifies the given target asynchronously when new events are received.

Parameters:
target - the target listener to invoke.
Method Detail

setTarget

public void setTarget(ManagerEventListener target)
Sets the target listener that is notified asynchronously when new events are received. c

Parameters:
target - the target listener to invoke.

onManagerEvent

public void onManagerEvent(ManagerEvent event)
Description copied from interface: ManagerEventListener
This method is called when an event is received.

Specified by:
onManagerEvent in interface ManagerEventListener
Parameters:
event - the event that has been received

shutdown

public void shutdown()

Asterisk-Java

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