You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by vupt vupt <vu...@hotmail.com> on 2003/03/26 03:15:47 UTC
how instantiate an Action for each session?
Hi,
I am hoping someone can help me with this. I have created an Action and
would like an instance of that Action to be instantiated for each new
session that uses the Action.
For example, take this snippet from my sitemap.
<map:components>
<map:actions>
<map:action name="JukeBoxAction" src="test.JukeBoxAction"/>
</map:actions>
</map:components>
<map:pipeline>
<map:match pattern="jukeBox/jukeBox.xmap">
<map:act type="JukeBoxAction">
<map:generate src="xmlAction/xmlAction.xsp" type="serverpages"/>
<map:transform src="jukeBox/jukeBox.xsl"/>
<map:serialize type="html"/>
</map:act>
</map:match>
</map:pipeline>
I would like an instance of JukeBoxAction to be created for each person or
session that matches the above pattern.
The behaviour right now is that one instance of the JukeBoxAction object is
created and multiple sessions access the same object instance.
I would like each session to create and use its own JukeBoxAction instance.
Any help with this problem would be most appreciated.
Thanks.
_________________________________________________________________
STOP MORE SPAM with the new MSN 8 and get 2 months FREE*
http://join.msn.com/?page=features/junkmail
---------------------------------------------------------------------
To unsubscribe, e-mail: cocoon-users-unsubscribe@xml.apache.org
For additional commands, e-mail: cocoon-users-help@xml.apache.org
Re: how instantiate an Action for each session?
Posted by Charles Yates <ce...@stanford.edu>.
Component instantiation is handled by the underlying component
framework, Avalon. What you would like to do is _might_ be possible by
mucking with Avalon (ComponentHandlers and such) but there must be an
easier way. For example, your Action could use the Session object to
keep an Object of your choice to handle the per-session functionality
you want. You get the Session from the objectModel Map object passed in
the act() method:
HttpSession session = ObjectModelHelper.getRequest(objectModel).getSession();
MySessionObject obj = (MySessionObject) session.getAttribute("mySessionObj");
if ( null == obj )
obj = new MySessionObject();
session.setAttribute("mySessionObj", obj);
}
Charles
vupt vupt wrote:
> Hi,
>
> I am hoping someone can help me with this. I have created an Action
> and would like an instance of that Action to be instantiated for each
> new session that uses the Action.
>
> For example, take this snippet from my sitemap.
>
> <map:components>
> <map:actions>
> <map:action name="JukeBoxAction" src="test.JukeBoxAction"/>
> </map:actions>
> </map:components>
>
> <map:pipeline>
> <map:match pattern="jukeBox/jukeBox.xmap">
> <map:act type="JukeBoxAction">
> <map:generate src="xmlAction/xmlAction.xsp"
> type="serverpages"/>
> <map:transform src="jukeBox/jukeBox.xsl"/>
> <map:serialize type="html"/>
> </map:act>
> </map:match>
> </map:pipeline>
>
>
> I would like an instance of JukeBoxAction to be created for each
> person or session that matches the above pattern.
>
> The behaviour right now is that one instance of the JukeBoxAction
> object is created and multiple sessions access the same object instance.
>
> I would like each session to create and use its own JukeBoxAction
> instance.
>
> Any help with this problem would be most appreciated.
> Thanks.
>
---------------------------------------------------------------------
To unsubscribe, e-mail: cocoon-users-unsubscribe@xml.apache.org
For additional commands, e-mail: cocoon-users-help@xml.apache.org
RE: how instantiate an Action for each session?
Posted by Reinhard Pötz <re...@gmx.net>.
You can check in the action if the session is new - have a look at the
API (If I'm right there is a "session.isNew()" method ...)
Regards,
Reinhard
> -----Original Message-----
> From: vupt vupt [mailto:vuptme@hotmail.com]
> Sent: Wednesday, March 26, 2003 3:16 AM
> To: cocoon-users@xml.apache.org
> Subject: how instantiate an Action for each session?
>
>
> Hi,
>
> I am hoping someone can help me with this. I have created an
> Action and
> would like an instance of that Action to be instantiated for each new
> session that uses the Action.
>
> For example, take this snippet from my sitemap.
>
> <map:components>
> <map:actions>
> <map:action name="JukeBoxAction" src="test.JukeBoxAction"/>
> </map:actions>
> </map:components>
>
> <map:pipeline>
> <map:match pattern="jukeBox/jukeBox.xmap">
> <map:act type="JukeBoxAction">
> <map:generate src="xmlAction/xmlAction.xsp"
> type="serverpages"/>
> <map:transform src="jukeBox/jukeBox.xsl"/>
> <map:serialize type="html"/>
> </map:act>
> </map:match>
> </map:pipeline>
>
>
> I would like an instance of JukeBoxAction to be created for
> each person or
> session that matches the above pattern.
>
> The behaviour right now is that one instance of the
> JukeBoxAction object is
> created and multiple sessions access the same object instance.
>
> I would like each session to create and use its own
> JukeBoxAction instance.
>
> Any help with this problem would be most appreciated.
> Thanks.
>
>
>
>
>
> _________________________________________________________________
> STOP MORE SPAM with the new MSN 8 and get 2 months FREE*
> http://join.msn.com/?page=features/junkmail
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: cocoon-users-unsubscribe@xml.apache.org
> For additional commands, e-mail: cocoon-users-help@xml.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: cocoon-users-unsubscribe@xml.apache.org
For additional commands, e-mail: cocoon-users-help@xml.apache.org