Ryan Shaw wrote:

> Hello,
> 
> I have been looking at Berin's ContainerManager stuff
> in the Excalibur scratchpad. It looks pretty cool but
> I want to make sure I understand how it is intended to
> be used.
> 
> Say I want to use Framework/Excalibur from a servlet.
> So I create a subclass of AbstractContainer called
> ServletContextContainer. Then my initialization servlet
> creates a new ContainerManager, with all the parameters
> specified (including the classname of my new 
> ServletContextContainer) and places the Container
> Manager in the ServletContext.


So far so good!


> 
> Then my other servlets can get the ContainerManager
> out of the ServletContext and use it...but how? It 
> doesn't seem to expose any methods that would give
> my servlets access to, say, the container's component
> manager...
> 
> Can anyone enlighten me?


When designing it, I had in mind that the Container would
have a special interface that you would call to handle whatever
request you needed.  For instance, In Cocoon, they have an inteface
which the Cocoon Component and all Sitemaps implement called
Processor:

interface Processor
{
     process( Environment env, String uri ); // an external request, delegates to the 
full method
     process( Environment env, String uri, boolean isRequestInternal );
}

This would allow you to use it like this:


void service( ServletRequest request, ServletResponse response )
{
     Environment env = new Environment( m_servletContext, request, response );
     Processor proc = (Processor) m_containerManager.getContainer();

     proc.process( env, request.getRequestURI() );
}

As you can see, this greatly simplifies the code that is currently in
CocoonServlet's service method.  I left out the code used for determining
the length of time a request took to process, ensuring that the ContextClassLoader
is set, and other Environment management code.


I did consider making the Container's ComponentManager available, but that is
a clear cut example of Subversion of Control.  The Container's ComponentManager
is for that level of abstraction and below.  The parent ComponentManager (that
of the ContainerManager) is at a peer level with the Servlet, so is able to
be made available to the Servlet.





-- 

"They that give up essential liberty to obtain a little temporary safety
  deserve neither liberty nor safety."
                 - Benjamin Franklin


--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to