• Post Reply Bookmark Topic Watch Topic
  • New Topic

synchronizing session bean access

 
Yasir Bajwa
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I have a managed bean configured something like this:

<managed-bean>
<managed-bean-name>formBean</managed-bean-name>
<managed-bean-class>com.example.Form</managed-bean-class>
<managed-bean-scope>session</managed-bean-scope>
</managed-bean>
<managed-bean>
<managed-bean-name>queryBean</managed-bean-name>
<managed-bean-class>com.example.Query</managed-bean-class>
<managed-bean-scope>request</managed-bean-scope>
<managed-property>
<property-name>form</property-name>
<value>#{formBean}</value>
</managed-property>
</managed-bean>

It works fine in that the queryBean is passed the formBean when access in jsf/jsp page. Within the query class, I access the formBean, but I guess since formBean is in the session scope its possible the user could submit another request and write to the bean while I am reading it. I can synchronize the session, but that seems to defeat the purpose of the managed bean since it defines the scope, and if it changed I would have to update the code as well.

Is there some way to determine the scope of the managed bean through some api, or, perhaps there is a way to synchronize client requests per session with a filter? Is there some standard way of doing that? Thanks
 
Yasir Bajwa
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
anyone?

I was thinking of adding a servlet filter with code something like this.

HttpSession = request.getSession();
synchronized(session) {
chain.doFilter(req,resp);
}

Each request from the same session would be forced to wait ... i think

My app is running in a single JVM. I'm assuming the overhead is setting up and taking down the synchronization, and that it doesn't matter (at least in this case) that I'm in that block for the entire request?
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!