Jean-Luc Mathieu wrote:
Good idea, there are various lifecycle methods available that get run only once during the lifetime of your component.Yes, i had already thought about it, but i can't access to Cocoon environment - i wanted to get access to action parameters for instance. Perhaps if I pool the action, is there a method that is run only once, like an
Take your pick on the interface to implement
Startup Phase:
1. constructor as a consequence of instantiation 2. contextualize 3. service or compose 4. configure 5. parameterize 6. initialize 7. start
At various or repeated times after startup:
1. suspend 2. recontextualize 3. recompose 4. reconfigure 5. reparameterize 6. resume
Shutdown Phase:
1. stop 2. dispose 3. finalize at some indeterminate moment by the garbage collector
init-before-saved-object-in-the-pool method ? I have to search more in Avalon framework I think ...
http://avalon.apache.org/doc/index.html http://avalon.apache.org/framework/principals/lifecycle.html
-----Message d'origine----- De : news [mailto:[EMAIL PROTECTED] De la part de Jorg Heymans Envoy� : mardi 2 mars 2004 11:00 � : [EMAIL PROTECTED] Objet : Re: Sub-sitemap static initialization
how about using a static initializer block in the action ?
ie class mybla extends action static{ //your stuff gets executed only once when the class is loaded
}
You can then have different actions for different subsitemaps.
it's a bit of a bodge but could do the trick here.
Jean-Luc Mathieu wrote:
I'm new to this mailing list (and Cocoon), I didn't new this expression,
but it
sounds great ! I will print it and put it on the wall in front of me .. :-D
In fact, I have to run a static method in a class which configure my application. This method must be run once, before some sub-sitemaps that
use
initialized data run. So the operations are :
- Cocoon starts - A user requests a page that is served by a sub-sitemap, say
/cocoon/sub1/...
- The init static method is run - The page is built and served - Another user request a page in the same sub-sitemap (/cocoon/sub1/...) - The page is directly built and served ...
One way to do it is to initialize all data in the init process of the CocoonServlet, but I have to override CocoonServlet, and i lose sitemap hierarchy and scalability - but it works. Second way is what Unico said, but the action is always run, not only the first time the sub-sitemap is mounted - it can become a potential performance bottleneck.
I'm
sure there is a lot of other ways to do it ...
Regards, JL
-----Message d'origine----- De : news [mailto:[EMAIL PROTECTED] De la part de Jorg Heymans Envoy� : mardi 2 mars 2004 10:04 � : [EMAIL PROTECTED] Objet : Re: Sub-sitemap static initialization
Can you explain your use-case a bit more? Remember TUIMTOWTDIIC - there usually is more than one way to do it in Cocoon :) Jean-Luc Mathieu wrote:
Hmm, I tested it, and you're right. Finally, it's not completely what I
wanted
to do. Any other ideas ?
-----Message d'origine----- De : news [mailto:[EMAIL PROTECTED] De la part de Jorg Heymans Envoy� : mardi 2 mars 2004 08:47 � : [EMAIL PROTECTED] Objet : Re: Sub-sitemap static initialization
One thing I can think of that you could do is to wrap your sitemap mount with an action.
The mounting sitemap:
<map:match pattern="blah/**"> <map:act type="initscript"> <map:mount src="sitemap" uri-prefix="blah" /> </map:act> </map:match>
How does the above guarantee that the action is only run once? Subsequent requests to blah/whatever from different users will run the action again IMO, unless there is something in the action that knows it has been run once.
The initscript would execute the script only once.
Hope that helps, Unico
Jean-Luc Mathieu wrote:
Hello !
I have to launch an init script (a Java piece of program) at Cocoon startup (more precisely on the time the first user to connect requests a
specific
sub-sitemap). Is it a simple way to do this using for example sitemaps only, or I have to override CocoonServlet ? Thank you in advance.
Jean-Luc
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
