1 // ANNA - Anna is Not Nothingness Anymore //
3 // (c) Copyright 2005-2015 Eduardo Ramos Testillano & Francisco Ruiz Rayo //
5 // See project site at http://redmine.teslayout.com/projects/anna-suite //
6 // See accompanying file LICENSE or copy at http://www.teslayout.com/projects/public/anna.LICENSE //
9 #include <anna/core/tracing/TraceMethod.hpp>
10 #include <anna/core/functions.hpp>
12 #include <anna/dbms/Database.hpp>
13 #include <anna/dbms/Delivery.hpp>
14 #include <anna/dbms/Connection.hpp>
19 void dbms::Delivery::createConnections(dbms::Database& database, const char* prefixName, const char* user, const char* password, const int n)
20 throw(RuntimeException, dbms::DatabaseException) {
23 for(int i = 0; i < n; i ++) {
25 name += functions::asString("%04d", i);
26 this->add(database.createConnection(name.c_str(), user, password));
29 a_iiConnection = this->begin();
32 dbms::Connection& dbms::Delivery::getConnection()
33 throw(RuntimeException) {
34 return *(static_cast <dbms::Connection*>(comm::Delivery::apply()));
37 //--------------------------------------------------------------------------------------------------
38 // Se invoca desde la seccion critica establecida en comm::Delivery::apply.
40 // (0) Si no hay registrada ninguna conexion
41 //--------------------------------------------------------------------------------------------------
42 comm::Resource* dbms::Delivery::do_apply()
43 throw(RuntimeException) {
44 iterator maxii = end();
46 if(a_iiConnection == maxii) // (0)
49 iterator init = a_iiConnection;
50 Connection* result = NULL;
54 w = connection(a_iiConnection);
56 if(a_iiConnection == maxii)
57 a_iiConnection = begin();
59 if(w->isAvailable() == true && w->isEnabled() == true) {
63 } while(a_iiConnection != init);