caching - Lazy initialization of cache with Spring IBatis -


We are implementing our legacy to the Spring Ibatis model.

It says that I have two classes [both singleton ]

DAOImpl apply DAOInterface

CacheDAOImpl is applicable DAOInterface

Showing the code snippet CacheDAOImpl

Start privatization in . Private Static CashADOML Our Instance = New CashIDOML (); Public static CacheDAOImpl getInstance () {Return to our interns; } object usage DAOImpl to

code snippet

  private DAO GetCacheDAO () {return CacheDAOImpl.getInstance (); } @ Override Public SomeObject lookUpId () {GetCacheDAO Get}. LookUpId (); }  

The above implementation is started only in the cash when a method is applied in the DAIOIMPL, while with the initial spring model, can we do this? Can not work as a lazy-int object, the DAIOIMple can always be used with non-lazy beans

< P> First, the method of defining an object in the form of singleton is to define the method of spring in singleton (which is the default) bean area.

Second, lazy-init should work. Just to make the process of initialization, DAO Bean is different from the process of using it. To wit. When it is manufactured, do not initialize the cache - only when its methods are called.


Comments

Popular posts from this blog

oracle - The fastest way to check if some records in a database table? -

php - multilevel menu with multilevel array -

jQuery UI: Datepicker month format -