Tuesday, May 15, 2007

SavePoint Pattern

There are two ways to use SavePoint pattern.1. 'SavePointIndexBased' and2. 'SavePointLabelBased'Both have different type of container inside it having capability to store different objects of its own at different stages wherever required by user for later ussage.You just need to extend your class with either 'SavePointIndexBased' or with 'SavePointLabelBased' and you can bookmark/save object's current state by calling respective 'savePoint' method. In order to retrieve the saved object, user need to call respective 'getSavedPoint' method. There is also facility to roll back the object with any of saved point. It can be done by calling respective 'rollBack' method.SavePointIndexBased:=====================It has Vector container to store objects by index based. So that user can save object's states on different stages to get exact level of bookmarked object's state.SavePointLabelBased:=====================It has Hashtable container to store objects by label based. So that user can label the save point for the later use to get exact labeled object's state.Both classes facilitate the user to store object in different stages for the save point. For example if you are managing some transaction and you are playing with some object. You will need to rollback in case of any failure and in such cases databases and drivers provide the facility and this class will provide you facility to do the same behaviour with your own java object.

No comments: