-
FEATURED COMPONENTS
First time here? Check out the FAQ!
Hi All!
I'm using ZK+Spring in my project.
Can anybody tell me which approach is better in performance impact:
1. Using ZK controllers as Spring beans(using org.zkoss.zkplus.spring.DelegatingVariableResolver) with autowired DAOs or
2. Using ZK controllers(extended GenericForwardComposer)+SpringUtil.getBean to load spring beans only when necessary?
Should be p.1 ZK controllers declared as spring session scoped beans if p.1 approach is better?
Thanks
Hi bsvSoft,
there is point 3. missing.
We have realized a performance boost by using ZK controllers as Spring beans (extend GenericForwardComposer; zul's using DelegatingVariableResolver ) with autowired DAOs.
to point 2.: with SpringUtil.getBean(): This is not Spring-managed. Do you see the difference.
best
Stephan
Hi bsvSoft,
I second Stephan here. Approach 1 should be more elegant and efficient.
>>Should be p.1 ZK controllers declared as spring session scoped beans if p.1 approach is better?
Not too sure what you mean by above statement but wouldn't recommend controllers in session scope unless you make sure they do not hold any state
Yes, we too.
For the controllers we have a spring 'scope=prototype'.
<bean id="customerListCtrl" class="de.forsthaus.webui.customer.CustomerListCtrl" parent="basisListCtrl" scope="prototype"> <property name="customerService" ref="customerService" /> <property name="tenantService" ref="tenantService" /> </bean>
Hi all,
Thanks for your answers. I understand that SpringUtil.getBean approach is not Spring managed. But can it be faster than zk controllers as spring beans? If bean scope is prototype, then it means, that every time new bean instance will be created, won't it? And every event handler in controller will cause creating new zk controller instance with injecting all necessary dependencies. Am I right?
If so, I think, that it's better to keep zk controllers out of spring context, and get spring bean instances only when necessary using SpringUtil.getBean method. BTW, I checked OpenEntityManagerInView pattern and it works even if zk controller is out from spring context. So, there are no constraints to use SpringUtil.getBean.
Thanks
Seems Spring pre allocate the beans by startUp from the configurationContext file, so it would be faster created.
Our approach is the security and scalability. In a multi user business app use must be sure that no users data are attached from an other user so we load the bean with scope=prototype.
We have spend many hours in debugging Spring and Multi-Threaded Zk app. So our commendation is by using spring and zk let Spring manage all.
Stephan
Hi bsvsoft,
>>And every event handler in controller will cause creating new zk controller instance with injecting all necessary dependencies.
I believe this is not true. Can you clarify more about this if you have seen this behavior and/or any sample code that exibits this?
Hi, Iam new to ZK.. I need an example or some design - for the option 1 - How to use ZK COntrollers as Spring beans...Small example...Dont need entire thing..
For example: My view has a TextBox - username and a btn .
Controller -- Iam intrested in this Part --- when user clicks on btn what happens....
MOdel --> Iam having a Spring IOC + HIbernate..
Asked: 2010-06-24 15:42:35 +0800
Seen: 1,165 times
Last updated: Jul 13 '10