Magentix2  2.1.1
es.upv.dsic.gti_ia.core.AgentsConnection Class Reference
Collaboration diagram for es.upv.dsic.gti_ia.core.AgentsConnection:

List of all members.

Public Member Functions

int getNumConnections ()
void setNumConnections (int numConnections)

Static Public Member Functions

static void connect ()
static void connect (String qpidHost, int qpidPort, String qpidVhost, String qpdidUser, String qpidPassword, boolean qpidSSL)
static void connect (String qpidHost, int qpidPort, String qpidVhost, String qpdidUser, String qpidPassword, boolean qpidSSL, String sasl_mechs)
static void connect (String qpidHost)
static void disconnect ()
static Connection getConnection ()

Static Public Attributes

static
org.apache.qpid.transport.Connection 
connection = null
static final int MAX_CONS_PER_CON = 120

Static Protected Attributes

static Logger logger = Logger.getLogger(AgentsConnection.class)

Detailed Description

This class work to open a Qpid broker connection.

Author:
Sergio Pajares
Javier Jorge Cano

Definition at line 15 of file AgentsConnection.java.


Member Function Documentation

Connects with a Qpid broker taking the input connection parameters from the Settings.xml file.

Definition at line 40 of file AgentsConnection.java.

                                     {

                c = Configuration.getConfiguration();
                if (c.isSecureMode())
                        return;

                if (connection != null)
                        return;

                connection = new Connection();

                ConnectionSettings connectSettings = new ConnectionSettings();
                connectSettings.setHost(c.getqpidHost());
                connectSettings.setPort(c.getqpidPort());
                connectSettings.setVhost(c.getqpidVhost());
                connectSettings.setUsername(c.getqpidUser());
                connectSettings.setPassword(c.getqpidPassword());
                connectSettings.setUseSSL(c.getqpidSSL());

                connection.connect(connectSettings);
        }
static void es.upv.dsic.gti_ia.core.AgentsConnection.connect ( String  qpidHost,
int  qpidPort,
String  qpidVhost,
String  qpdidUser,
String  qpidPassword,
boolean  qpidSSL 
) [static]

Connects to Qpid broker taking into account all the parameters specified as input.

Parameters:
qpidHostHost where the broker is.
qpidPortPort where the broker is listening.
qpidVhostName for the Vhost to pass to the QPid broker.
qpdidUserUsername to pass to the QPid broker.
qpidPasswordPassword to pass to the QPid broker.
qpidSSLBoolean indicating whether SSL is being used or not.

Definition at line 79 of file AgentsConnection.java.

                                                                                {
                connection = new Connection();
                connection.connect(qpidHost, qpidPort, qpidVhost, qpdidUser,
                                qpidPassword, qpidSSL);
        }
static void es.upv.dsic.gti_ia.core.AgentsConnection.connect ( String  qpidHost,
int  qpidPort,
String  qpidVhost,
String  qpdidUser,
String  qpidPassword,
boolean  qpidSSL,
String  sasl_mechs 
) [static]

Connects to Qpid broker taking into account all the parameters specified as input.

Parameters:
qpidHostHost where the broker is.
qpidPortPort where the broker is listening.
qpidVhostName for the Vhost to pass to the QPid broker.
qpdidUserUsername to pass to the QPid broker.
qpidPasswordPassword to pass to the QPid broker.
qpidSSLBoolean indicating whether SSL is being used or not.
sasl_mechsSASL mechanism used for the secure communication with the broker.

Definition at line 106 of file AgentsConnection.java.

                                           {
                connection = new Connection();
                connection.connect(qpidHost, qpidPort, qpidVhost, qpdidUser,
                                qpidPassword, qpidSSL, sasl_mechs);

        }
static void es.upv.dsic.gti_ia.core.AgentsConnection.connect ( String  qpidHost) [static]

Connects to Qpid broker taking into account the qpidhost parameter and considering the rest as defaults parameters. broker installation

Parameters:
qpidHostHost where the broker is.

Definition at line 122 of file AgentsConnection.java.

                                                    {
                connection = new Connection();
                connection.connect(qpidHost, 5672, "test", "guest", "guest", false);
        }

Disconnects the current connection

Definition at line 132 of file AgentsConnection.java.

                                        {
                try {
                        connection.close();
                }catch(Exception e) {
                        logger.error("Error on disconnect=" + e);
                }
                connection = null;
        }

Method to obtain a connection, it creates a new one when the object have more than 120 connections,

Returns:
A Connection object with the configuration of the file

Definition at line 147 of file AgentsConnection.java.

                                                 {

                numConnections++;
                if (numConnections < MAX_CONS_PER_CON) {
                        return connection;
                } else {
                        numConnections = 0;
                        connection = null;
                        connect();
                        return connection;
                }

        }
Returns:
the numConnections

Definition at line 164 of file AgentsConnection.java.

                                       {

                return numConnections;
        }
Parameters:
numConnectionsthe numConnections to set

Definition at line 173 of file AgentsConnection.java.

                                                          {
                this.numConnections = numConnections;
        }

Member Data Documentation

org.apache.qpid.transport.Connection es.upv.dsic.gti_ia.core.AgentsConnection.connection = null [static]

Used to establish a communication with a Qpid broker. Can be initialized according to the parameters specified in the settings for an agent.

Definition at line 21 of file AgentsConnection.java.

Logger es.upv.dsic.gti_ia.core.AgentsConnection.logger = Logger.getLogger(AgentsConnection.class) [static, protected]

The logger variable considers to print any event that occurs by the agent

Definition at line 32 of file AgentsConnection.java.

Definition at line 27 of file AgentsConnection.java.


The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables