aspose file tools
The moose likes JSF and the fly likes synchronizing session bean access Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » JSF
Reply Bookmark "synchronizing session bean access" Watch "synchronizing session bean access" New topic
Author

synchronizing session bean access

Yasir Bajwa
Greenhorn

Joined: May 02, 2007
Posts: 23
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

Joined: May 02, 2007
Posts: 23
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?
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: synchronizing session bean access
 
Similar Threads
Passing data between beans
PropertyNotFoundException
JSF Dependency Injection inheritence issue
how to over come conversion error
How to assign a value to a request scoped managed bean property?