You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cocoon.apache.org by Marcus Crafter <cr...@fztig938.bank.dresdner.net> on 2002/03/22 16:50:22 UTC

Adding values to Cocoon's context

Hi All,

	Hope all is well. I need some advice! :)

	In my quest to avalonize and cocoonize our application, I've
	come up against a problem.

	From what I can see, it's not possible to add context key/values to
	the cocoon context from a servlet subclass for thread safe components.

	Threadsafe component instances are created by the ECM during
	Cocoon's startup in CocoonServlet.init(). If one wants to modify
	CocoonServlet.appContext in a servlet subclass (using values
	from init-param's, etc) then CocoonServlet.init() has to be
	called before the subclass does any work.

	This means, thread safe components that implement Contextualizable
	won't be able to find any context values they need.

	What am I trying to do ? Store values in the Cocoon context that are
	global across all components.

	I've found several solutions:

	1. make CocoonServlet.createCocoon() protected, allowing a
	subclass to override it, accessing the appContext before the Cocoon
	instance is created.

	2. make it possible to defer the creation of the Cocoon
	instance. eg. add an init-param 'create-cocoon-at-startup' which
	will specify whether the Cocoon instance will be created in
	CocoonServlet.init(), or at first request (or by a subclass).
	This allows a subclass to add values to the cocoon context
	during subclass.init().

	3. incorporate Wolfram Eiserts Avalon scratchpad ContextUtility
	class which allows one to specify a <context>..</context> tag
	set in cocoon.xconf that automatically populates the Cocoon context
	with globals. More info under
	http://marc.theaimsgroup.com/?l=avalon-dev&m=101559574528413&w=2

	4. any others ?

	I've tried other combinations of solutions (eg. parent component
	manager), but they all have other problematic issues. :(

	I've implemented all 3 options, but are wondering what everyone
	else thinks or if there is an easier way ?

	Any thoughts ?

	Cheers,

	Marcus

-- 
        .....
     ,,$$$$$$$$$,      Marcus Crafter
    ;$'      '$$$$:    Computer Systems Engineer
    $:         $$$$:   ManageSoft GmbH
     $       o_)$$$:   82-84 Mainzer Landstrasse
     ;$,    _/\ &&:'   60327 Frankfurt Germany
       '     /( &&&
           \_&&&&'
          &&&&.
    &&&&&&&:

---------------------------------------------------------------------
To unsubscribe, e-mail: cocoon-dev-unsubscribe@xml.apache.org
For additional commands, email: cocoon-dev-help@xml.apache.org


RE: Adding values to Cocoon's context

Posted by Vadim Gritsenko <va...@verizon.net>.
> From: Marcus Crafter [mailto:crafterm@fztig938.bank.dresdner.net]
> 
> Hi Vadim,
> 
> 	Thanks for your response mate.
> 
> On Fri, Mar 22, 2002 at 11:09:41AM -0500, Vadim Gritsenko wrote:
> > > From: Marcus Crafter [mailto:crafterm@fztig938.bank.dresdner.net]
> > >
> > > 	4. any others ?
> >
> > Here it is:
> >
> > Write another servlet populating context and set startup order in
the
> > web.xml so it is initialized before Cocoon servlet.
> 
> 	hmm.. I'm not sure if I understand you -
CocoonServlet.appContext is
> 	protected so I can't access it from another servlet class, it
> 	has to be in a subclass of CocoonServlet ?

Hm. You are talking about Avalon context...


> 	What did I miss ?

I missed. I was thinking about servlet context.

Vadim

 
> 	Cheers,
> 
> 	Marcus
> 
> --
>         .....
>      ,,$$$$$$$$$,      Marcus Crafter
>     ;$'      '$$$$:    Computer Systems Engineer
>     $:         $$$$:   ManageSoft GmbH
>      $       o_)$$$:   82-84 Mainzer Landstrasse
>      ;$,    _/\ &&:'   60327 Frankfurt Germany
>        '     /( &&&
>            \_&&&&'
>           &&&&.
>     &&&&&&&:
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: cocoon-dev-unsubscribe@xml.apache.org
> For additional commands, email: cocoon-dev-help@xml.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: cocoon-dev-unsubscribe@xml.apache.org
For additional commands, email: cocoon-dev-help@xml.apache.org


Re: Adding values to Cocoon's context

Posted by Marcus Crafter <cr...@fztig938.bank.dresdner.net>.
Hi Vadim,

	Thanks for your response mate.

On Fri, Mar 22, 2002 at 11:09:41AM -0500, Vadim Gritsenko wrote:
> > From: Marcus Crafter [mailto:crafterm@fztig938.bank.dresdner.net]
> > 
> > 	4. any others ?
> 
> Here it is:
> 
> Write another servlet populating context and set startup order in the
> web.xml so it is initialized before Cocoon servlet.

	hmm.. I'm not sure if I understand you - CocoonServlet.appContext is
	protected so I can't access it from another servlet class, it
	has to be in a subclass of CocoonServlet ?

	What did I miss ?

	Cheers,

	Marcus

-- 
        .....
     ,,$$$$$$$$$,      Marcus Crafter
    ;$'      '$$$$:    Computer Systems Engineer
    $:         $$$$:   ManageSoft GmbH
     $       o_)$$$:   82-84 Mainzer Landstrasse
     ;$,    _/\ &&:'   60327 Frankfurt Germany
       '     /( &&&
           \_&&&&'
          &&&&.
    &&&&&&&:

---------------------------------------------------------------------
To unsubscribe, e-mail: cocoon-dev-unsubscribe@xml.apache.org
For additional commands, email: cocoon-dev-help@xml.apache.org


RE: Adding values to Cocoon's context

Posted by Vadim Gritsenko <va...@verizon.net>.
> From: Marcus Crafter [mailto:crafterm@fztig938.bank.dresdner.net]
> 
> Hi All,
> 
> 	Hope all is well. I need some advice! :)
> 
> 	In my quest to avalonize and cocoonize our application, I've
> 	come up against a problem.
> 
> 	From what I can see, it's not possible to add context key/values
to
> 	the cocoon context from a servlet subclass for thread safe
components.
> 
> 	Threadsafe component instances are created by the ECM during
> 	Cocoon's startup in CocoonServlet.init(). If one wants to modify
> 	CocoonServlet.appContext in a servlet subclass (using values
> 	from init-param's, etc) then CocoonServlet.init() has to be
> 	called before the subclass does any work.
> 
> 	This means, thread safe components that implement
Contextualizable
> 	won't be able to find any context values they need.
> 
> 	What am I trying to do ? Store values in the Cocoon context that
are
> 	global across all components.
> 
> 	I've found several solutions:
> 
> 	1. make CocoonServlet.createCocoon() protected, allowing a
> 	subclass to override it, accessing the appContext before the
Cocoon
> 	instance is created.
> 
> 	2. make it possible to defer the creation of the Cocoon
> 	instance. eg. add an init-param 'create-cocoon-at-startup' which
> 	will specify whether the Cocoon instance will be created in
> 	CocoonServlet.init(), or at first request (or by a subclass).
> 	This allows a subclass to add values to the cocoon context
> 	during subclass.init().
> 
> 	3. incorporate Wolfram Eiserts Avalon scratchpad ContextUtility
> 	class which allows one to specify a <context>..</context> tag
> 	set in cocoon.xconf that automatically populates the Cocoon
context
> 	with globals. More info under
> 	http://marc.theaimsgroup.com/?l=avalon-dev&m=101559574528413&w=2
> 
> 	4. any others ?

Here it is:

Write another servlet populating context and set startup order in the
web.xml so it is initialized before Cocoon servlet.

Vadim
 
> 	I've tried other combinations of solutions (eg. parent component
> 	manager), but they all have other problematic issues. :(
> 
> 	I've implemented all 3 options, but are wondering what everyone
> 	else thinks or if there is an easier way ?
> 
> 	Any thoughts ?
> 
> 	Cheers,
> 
> 	Marcus
> 
> --
>         .....
>      ,,$$$$$$$$$,      Marcus Crafter
>     ;$'      '$$$$:    Computer Systems Engineer
>     $:         $$$$:   ManageSoft GmbH
>      $       o_)$$$:   82-84 Mainzer Landstrasse
>      ;$,    _/\ &&:'   60327 Frankfurt Germany
>        '     /( &&&
>            \_&&&&'
>           &&&&.
>     &&&&&&&:


---------------------------------------------------------------------
To unsubscribe, e-mail: cocoon-dev-unsubscribe@xml.apache.org
For additional commands, email: cocoon-dev-help@xml.apache.org