Hmmm... I am not one of the authors of Maverick, but looking at the source it looks like it is possible to use org.infohazard.maverick.flow.ControllerFactory to get NEW instances. One drawback though... you should have a config node (part of maverick.xml config document), so this does not seem very usefull.
On startup org.infohazard.maverick.Dispatcher (the dispatch servlet) lets
org.infohazard.maverick.flow.Loader load the configuration and construct the
commands (incl. controllers). The Dispatcher keeps a reference to the
commands and uses this to directely execute them. In other words: there is
no way to get a command straight from the Maverick API unless (and here is
your best option I think) you extend the Dispatcher (don't forget to call
the supers :-).
I am not sure what you want to do, but if you want to forward or include a
Maverick command from a Servlet, you can probably better use the
javax.servlet.RequestDispatcher (get it like:
javax.servlet.ServletContext.getRequestDispatcher(yourUrlToMavCommand?) ).
And (probably) for something completely different: see the attachement for a
hack based on the Apache JSTL impl of the core import tag for a class that I
use as a Velocity tool for importing JSP's etc. in a Velocity template. It's
a bit dirty but works for me (I use it like
$importTool.get("/eventscalendar.jsp") ). Maybe you can base what you want
to do on this code?
I could be missing things, so please correct if I am wrong anyone.
Good luck,
Eelco
----- Original Message -----
From: "Valeri Sarantchouk" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Sunday, March 30, 2003 3:52 PM
Subject: Re: [Mav-user] reusable controllers and session objects
> Eelco,
>
> Do you know by any chance if it possible to have
> a controller which itself can be borrowed from some
> kind of controller factory? Similar to servlet thread pool.
>
> Thanks,
>
> Valeri
>
> ---
>
>
>
>
>
> On Sat, 29 Mar 2003 22:31:30
> Eelco Hillenius wrote:
> >Sure, np
> >
> >If you're using ControllerSingleton (or FormBeanUser as it implements
> >ControllerSingleton) you should use the latest version of Maverick from
CVS
> >as a bug that was fixed two weeks ago had the effect that
> >init(controllerNode) was never called for implementors of
> >ControllerSingleton.
> >
> >Eelco
> >
> >----- Original Message -----
> >From: "Valeri Sarantchouk" <[EMAIL PROTECTED]>
> >To: <[EMAIL PROTECTED]>
> >Sent: Saturday, March 29, 2003 10:10 PM
> >Subject: Re: [Mav-user] reusable controllers and session objects
> >
> >
> >> Hi Eelco,
> >>
> >> Thank you! I took a look at Maverick's source code, and
> >> found it: I can simply subclass ControllerSingleton and
> >> use object pools from the subclass.
> >>
> >> Cheers,
> >>
> >> Valeri
> >>
> >> ---
> >>
> >>
> >>
> >>
> >>
> >> On Sat, 29 Mar 2003 21:46:42
> >> Eelco Hillenius wrote:
> >> >I am not sure that understand you well, but...
> >> >
> >> >You can still use sessions (and all other servlet stuff) in Maverick.
> >Just
> >> >get it like getCtx().getRequest().getSession().
> >> >
> >> >If you are working with expensive controllers (controllers that have
to
> >do a
> >> >lot of initialising or have a lot of fields) you can extend
> >> >org.infohazard.maverick.ctl.FormBeanUser or implement
> >> >org.infohazard.maverick.flow.ControllerSingleton. This way, your
> >controllers
> >> >are created only once. Be sure to read the javadocs and explore the
code
> >of
> >> >the org.infohazard.maverick.ctl package to clearify things ;-)
> >> >
> >> >And of course... use inheritance to factor common behaviour in your
> >> >controllers. As for the object pool, sure you can use whatever you
think
> >> >suits you; Maverick won't stop you!
> >> >
> >> >Hope that helps a bit,
> >> >
> >> >Eelco
> >> >
> >> >
> >> >----- Original Message -----
> >> >From: "Valeri Sarantchouk" <[EMAIL PROTECTED]>
> >> >To: <[EMAIL PROTECTED]>
> >> >Sent: Saturday, March 29, 2003 9:14 PM
> >> >Subject: [Mav-user] reusable controllers and session objects
> >> >
> >> >
> >> >> Dear Maverick experts,
> >> >>
> >> >> I am trying to apply Maverick to a "framework-less" web
> >> >> application, and my question is a very basic one.
> >> >>
> >> >> I am trying to avoid creating new objects at every request.
> >> >> Is it possible to use a servlet as a (Trhowaway2)
> >> >> Controller? Or other reusable accross requests conroller.
> >> >>
> >> >> Situation: I have a servlet that checks if there is a
> >> >> Client object in the user's session. If yes, the Client
> >> >> object is reused, otherwise a new Client instance is
> >> >> created. The Client object looks like this:
> >> >>
> >> >> public class Client{
> >> >>
> >> >> private ClientModel model;
> >> >> private ClientModelHandler modelHandler;
> >> >>
> >> >> private CardViewHandler cardViewHandler;
> >> >> private FormViewHandler formViewHandler;
> >> >> private FormPrintHandler formPrintHandler;
> >> >>
> >> >> // methods go here...
> >> >> }
> >> >>
> >> >> ClientModel has 38 fields and its creation and rendering
> >> >> are costly operations. Plus we have at least 70 concurrent
> >> >> users (accessing the same view at the same time) at low
> >> >> periods and 350+ at high, so creating new objects for each
> >> >> request and passing old ones to gc doesn't look good from
> >> >> performace point of view.
> >> >>
> >> >> In "old" application, I use an object pool to get instances
> >> >> of Client objects for new users; and re-use Client objects
> >> >> found in user's session for logged-in users.
> >> >>
> >> >> Can you advise me on how to replicate an object pool with
> >> >> Maverick and how to reuse the same object found in session?
> >> >>
> >> >> Thank you very much!
> >> >>
> >> >> Valeri
> >> >>
> >> >>
> >> >>
> >> >> _____________________________________________________________
> >> >> Get 25MB, POP3, Spam Filtering with LYCOS MAIL PLUS for $19.95/year.
> >> >> http://login.mail.lycos.com/brandPage.shtml?pageId=plus&ref=lmtplus
> >> >>
> >> >>
> >> >> -------------------------------------------------------
> >> >> This SF.net email is sponsored by:
> >> >> The Definitive IT and Networking Event. Be There!
> >> >> NetWorld+Interop Las Vegas 2003 -- Register today!
> >> >> http://ads.sourceforge.net/cgi-bin/redirect.pl?keyn0001en
> >> >> [INVALID FOOTER]
> >> >>
> >> >>
> >> >
> >> >
> >> >
> >> >-------------------------------------------------------
> >> >This SF.net email is sponsored by:
> >> >The Definitive IT and Networking Event. Be There!
> >> >NetWorld+Interop Las Vegas 2003 -- Register today!
> >> >http://ads.sourceforge.net/cgi-bin/redirect.pl?keyn0001en
> >> >[INVALID FOOTER]
> >> >
> >>
> >>
> >> _____________________________________________________________
> >> Get 25MB, POP3, Spam Filtering with LYCOS MAIL PLUS for $19.95/year.
> >> http://login.mail.lycos.com/brandPage.shtml?pageId=plus&ref=lmtplus
> >>
> >>
> >> -------------------------------------------------------
> >> This SF.net email is sponsored by:
> >> The Definitive IT and Networking Event. Be There!
> >> NetWorld+Interop Las Vegas 2003 -- Register today!
> >> http://ads.sourceforge.net/cgi-bin/redirect.pl?keyn0001en
> >> [INVALID FOOTER]
> >>
> >
> >
> >
> >-------------------------------------------------------
> >This SF.net email is sponsored by:
> >The Definitive IT and Networking Event. Be There!
> >NetWorld+Interop Las Vegas 2003 -- Register today!
> >http://ads.sourceforge.net/cgi-bin/redirect.pl?keyn0001en
> >[INVALID FOOTER]
> >
>
>
> _____________________________________________________________
> Get 25MB, POP3, Spam Filtering with LYCOS MAIL PLUS for $19.95/year.
> http://login.mail.lycos.com/brandPage.shtml?pageId=plus&ref=lmtplus
>
>
> -------------------------------------------------------
> This SF.net email is sponsored by:
> The Definitive IT and Networking Event. Be There!
> NetWorld+Interop Las Vegas 2003 -- Register today!
> http://ads.sourceforge.net/cgi-bin/redirect.pl?keyn0001en
> [INVALID FOOTER]
>
>
ImportTool.java
Description: Binary data
