On Thu, 21 Jun 2001, Oleg V Alexeev wrote:
> Hello Craig,
>
> Wednesday, June 20, 2001, 8:52:18 PM, you wrote:
>
> CRM> On Wed, 20 Jun 2001, Oleg V Alexeev wrote:
>
> >> Hello Craig,
> >>
> >> Interesting question and clear answer... 8)
> >>
>
> CRM> Yah, I really enjoy the interesting ones :-).
>
> >> What do you think about such caching for Class? With this approach we
> >> call forName() method only once - no other overhead.
> >>
>
> CRM> Class loaders do this kind of caching already, so I guess I don't see all
> CRM> that much benefit.
>
> CRM> For Struts in particular, if you're concerned about repeated
> CRM> Class.forName() calls, a better strategy is avoidance -- arrange your
> CRM> application so that the form beans are created for you ahead of
> CRM> time. Then Struts will never have to call it.
>
> Sorry, but I have not idea how to do so. Explain please, how can I
> "arrange your application so that the form beans are created for you
> ahead of time"? Is it step in struts-config or no?
>
I guess that comment was a little bit terse ...
Basically, I like the design pattern where there are no links from one
page directly to another page -- instead, you always go through an
Action. In particular, this action can create the form bean and install
it into the appropriate scope (either request or session), and then
forward to the page. The action could choose to recycle such beans from a
pool, if it wanted to.
An instance of this pattern is in the Struts example application. When
you select the option to modify existing registration information, the
link goes to path "/editRegistration.do", which creates the appropriate
form bean and then forwards to "/registration.jsp". Now, the <html:form>
tag on that page will see that the bean already exists, so it does not
need to be instantiated.
The other place Struts creates form beans dynamically is in the
controller, when processing the incoming request. Again, this only
happens if the form bean does not alredy exist in appropriate scope. For
example, if you use session scope then the existing bean will be reused,
so a particular bean will only be created once (instead of once per
request).
> CRM> Or, throw you can just throw hardware at it and take advantage of Moore's
> CRM> Law ... :-)
>
> --
> Best regards,
> Oleg mailto:[EMAIL PROTECTED]
>
>
Craig