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/Logger.hpp>
10 #include <anna/core/functions.hpp>
12 #include <anna/timex/Engine.hpp>
14 #include <anna/core/util/Millisecond.hpp>
16 #include "Context.hpp"
17 #include "Transaction.hpp"
23 http4comm::Context::Context (anna::timex::Engine& timeController, const Millisecond& timeout) :
24 anna::timex::Context<S64> ("http4comm", timeController, timeout)
27 void http4comm::Context::create (const S64 id, comm::ClientSocket& clientSocket)
28 throw (RuntimeException)
30 http4comm::Transaction* transaction = static_cast <http4comm::Transaction*> (anna::timex::Context <S64>::open (id, 0));
32 transaction->setClientSocket (&clientSocket);
35 string msg ("http4comm::Context::create | Id: ");
36 msg += functions::asHexString (id);
38 msg += transaction->asString ();
39 Logger::information (msg, ANNA_FILE_LOCATION);
44 * Si el fuera necesaria la instancia de una transación y no hay ninguna otra marcada como "no-usada" se
45 * crearía una nueva instancia.
47 anna::timex::Transaction* http4comm::Context::createTransaction (const int /*classType*/)
50 // Si nuestra aplicación tratara más de un tipo de transación tendríamos que obtenerla de
51 // distintos Recycler, uno para cada tipo de transacción.
52 return a_transactions.create ();
56 * Cuando la instancia dela transación no se esté usando se marca como no-usada.
58 void http4comm::Context::releaseTransaction (anna::timex::Transaction* tt)
61 // Si nuestra aplicación tratata más de un tipo tendríamos que obtener el tipo
62 // de la transación y liberar la transación en el Recycler adecuado.
63 http4comm::Transaction* aux = static_cast <http4comm::Transaction*> (tt);
64 a_transactions.release (aux);
69 * Interpreta el identificador de la transación como cadena
71 string http4comm::Context::identifierAsString (const S64& id) const
74 return functions::asHexString (id);
78 * Interpreta el contexto de la transación para obtener su Id de aplicación.
80 const S64& http4comm::Context::contextAsIdentifier (const void* cc) const