UniverseUniversity


Home Projects Jobs Clientele Contact

uu


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Db pool [was: My little comments to CPP code]



>>> InitServlet? What is that? (other then that, idea seems to be fine)
>>>
>>
>> It's a servlet that is used for creating the instance of the pool and
>> saving  a pointer to it in ServletContext.
>> Here is how it may look like:
>>
>> void InitServlet::init()
>> {
>>
>>   string numCon =
>> getServletConfig().getInitParameter("num_connections");
>>   ServletContext& ctx = getServletConfig().getServletContext();
>>   uuDBPool* pool = new uuDBPool(numCon);
>>   ctx.setAttribute<uuDBPool*>("uu_pool", pool);
>>
>> }
>>
>> Perhaps I'm going to add InitServlet::destroy() to release all resources
>> and close all connections in the pool.
>>
> How about using UUServlet for that purpose?


I will do that. But in this case I'll have to create an instance of the
pool only if there is no "uu_pool" attribute in the servlet context. I'm
not sure if it's good enough though, maybe I should check if the pool
already exist too. So I have several questions regarding potential
complications.

Are those kind of situations when "Pool does not exist, but uu_pool
attribute is present in ServletContext" or "Pool exists, but no uu_pool
attribute is present in ServletContext" possible due to some DB or server
failures?
I understand that after shutdown all connections will be removed from
m_connections list, but I'm not sure about uuDBPool object. Will it be
destroyed too?
I guess I need to remove "uu_pool" attribute from ServletContext too when
it happens, perhaps in UUServlet::destroy() where supposly all connections
in the pool will be closed.


>> The only problem that I see in having those connection operations in
>> each
>> servlet' service() is that we have to get all 4(or 5) parameters from
>> request each time.
>> Here is how I would do it:
>>
>> Create EnvironmentSetupServlet and include it in Header.cpp.
>> Then retrieve all needed for getConnection(login, password, server,
>> sessionid, timeout) from request(login, password, server) from
>> HttpSession(sessionid) and from
>> getServletConfig()::getInitParameter(timeout).
>> Those parameters will be available in each servlet and from design POW
>> the
>> code will look OK.
>>
> I think you are forgetting about UUServlet again.

Ok, will do it in UUServlet.

>
> --
> Ilya A. Volynets-Evenbakh
> Total Knowledge. CTO
> http://www.total-knowledge.com
>
>



Authoright © Total Knowledge: 2001-2008