Asterisk-Java

org.asteriskjava.manager
Class ManagerConnectionFactory

java.lang.Object
  extended by org.asteriskjava.manager.ManagerConnectionFactory

public class ManagerConnectionFactory
extends java.lang.Object

This factory is the canonical way to obtain new ManagerConnections.

It creates new connections in state ManagerConnectionState.INITIAL. Before you can start using such a connection (i.e. sending ManagerActions you must ManagerConnection.login() to change its state to ManagerConnectionState.CONNECTED.

Example:

 ManagerConnectionFactory factory;
 ManagerConnection connection;
 
 factory = new ManagerConnectionFactory("localhost", "manager", "secret");
 connection = factory.createManagerConnection();
 connection.login();
 ...
 connection.logoff();
 
If want you can use the factory to create multiple connections to the same server by calling createManagerConnection() multiple times.

Version:
$Id: ManagerConnectionFactory.java 938 2007-12-31 03:23:38Z srt $
Author:
srt
See Also:
ManagerConnection

Constructor Summary
ManagerConnectionFactory(java.lang.String hostname, int port, java.lang.String username, java.lang.String password)
          Creates a new ManagerConnectionFactory with the given connection data.
ManagerConnectionFactory(java.lang.String hostname, java.lang.String username, java.lang.String password)
          Creates a new ManagerConnectionFactory with the given connection data and the default port 5038.
 
Method Summary
 ManagerConnection createManagerConnection()
          Returns a new ManagerConnection in state ManagerConnectionState.CONNECTED.
 ManagerConnection createSecureManagerConnection()
          Returns a new SSL secured ManagerConnection in state ManagerConnectionState.CONNECTED.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ManagerConnectionFactory

public ManagerConnectionFactory(java.lang.String hostname,
                                java.lang.String username,
                                java.lang.String password)
Creates a new ManagerConnectionFactory with the given connection data and the default port 5038.

Parameters:
hostname - the hostname of the Asterisk server to connect to.
username - the username to use for login as defined in Asterisk's manager.conf.
password - the password to use for login as defined in Asterisk's manager.conf.
Since:
0.3

ManagerConnectionFactory

public ManagerConnectionFactory(java.lang.String hostname,
                                int port,
                                java.lang.String username,
                                java.lang.String password)
Creates a new ManagerConnectionFactory with the given connection data.

Parameters:
hostname - the hostname of the Asterisk server to connect to.
port - the port where Asterisk listens for incoming Manager API connections, usually 5038.
username - the username to use for login as defined in Asterisk's manager.conf.
password - the password to use for login as defined in Asterisk's manager.conf.
Since:
0.3
Method Detail

createManagerConnection

public ManagerConnection createManagerConnection()
Returns a new ManagerConnection in state ManagerConnectionState.CONNECTED.

Returns:
the created connection to the Asterisk server.
Since:
0.3

createSecureManagerConnection

public ManagerConnection createSecureManagerConnection()
Returns a new SSL secured ManagerConnection in state ManagerConnectionState.CONNECTED.

Returns:
the created connection to the Asterisk server.
Since:
0.3

Asterisk-Java

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