long conversation - rich client applications RCP - spring and hibernate (part 2)

Based on my previous post, I have been looking into AOP as a way to help with long conversations. The thinking is that I want to create DAOs and other data access objects but not specifically break spring and hibernate provided methods. Spring itself uses a proxy object on the session factory so that when you create a new session, spring "catches" the call for a new session using the proxy, then manages the session for you.

In a similar way, you really need to make the use of long conversations (an extendend persistent context) more optional and transparent to data access objects. AOP is a good way to do this.

Also, after much consideration, I do believe that in a RCP setting, long conversations are highly application specific but I think they do share characterstics that are very different than web applications. Web applications have better mechanisms for indicating a start and stop approach (a transaction for example). In a RCP, depending on the application, it may be difficult to indicate the starting and stopping point of a conversation. However, many design patters for data access have a start and stop feel to them. For example, if you use the presentation model design pattern for supplying data to a view, each get* method in a presentation method meant to be called by a view could be the start and stop point of a conversation since a presentation model would most likely spread out its calls to a number of DAOs underneath the model. In this way, single methods act as the start and stop of a conversation perhaps similar to the OpenSessionInViewFilter which when you start a filter chain for web viewing (in Spring) the OpenSessionInViewFilter keeps the session open for any other "nested" servlets that are in the chain. In this way, you can have one session supporting the entire view rendering. The get* methods on a presentation model are very similar conceptually. Based on this, a general mechanism for long conversations in a RCP application can be created but may only useful for certain design patterns in an application. Just a thought.

One thing to note, is that spring's AOP mechanisms (which can use AspectJ or spring AOP methods) are incredible useful for this work. In fact, you can implement long conversations (a simple version which is really just a shared session object across method calls for a presentation model) incredible simply. spring is keeper in the handbag of programming tools.

Popular posts from this blog

graphql (facebook), falcor (netflix) and odata and ...

React, Redux, Recompose and some simple steps to remove "some" boilerplate and improve reuse

Using wye and tee with scalaz-stream