On Fri, Jul 5, 2013 at 4:54 PM, Afkham Azeez <[email protected]> wrote: > Folks, > If you are using OSGi services or JCache, you have to ensure that you > don't maintain references as instance attributes. This is because the > objects these references are pointing to can expire. For example, when a > bundle which is providing an OSGi service is restarted, there will be a new > instance of the OSGi service. Similarly, when caches or cache manager > become empty, to reclaim memory, those objects will be invalidated. So, if > you maintain references, they will go stale, and you will run into the > stale reference problem. https://wso2.org/jira/browse/CARBON-14179 is an > example where this has happened. > > So, you should always use the proper methods & APIs to get hold of the > proper objects. In the case of OSGi, it is done using service trackers and > declarative services. In the case of JCache, you need to use the > javax.cache.Caching class to obtain the cache managers & caches. > +1. This is very helpful tip. I noticed that we are keeping references to cache manager in many places. We need to fix them.
Thanks, Sanjeewa. > > > -- > *Afkham Azeez* > Director of Architecture; WSO2, Inc.; http://wso2.com > Member; Apache Software Foundation; http://www.apache.org/ > * <http://www.apache.org/>** > email: **[email protected]* <[email protected]>* cell: +94 77 3320919 > blog: **http://blog.afkham.org* <http://blog.afkham.org>* > twitter: **http://twitter.com/afkham_azeez*<http://twitter.com/afkham_azeez> > * > linked-in: **http://lk.linkedin.com/in/afkhamazeez* > * > * > *Lean . Enterprise . Middleware* > > _______________________________________________ > Dev mailing list > [email protected] > http://wso2.org/cgi-bin/mailman/listinfo/dev > > -- * * *Sanjeewa Malalgoda* WSO2 Inc. Mobile : +94713068779 <http://sanjeewamalalgoda.blogspot.com/>blog :http://sanjeewamalalgoda.blogspot.com/<http://sanjeewamalalgoda.blogspot.com/>
_______________________________________________ Dev mailing list [email protected] http://wso2.org/cgi-bin/mailman/listinfo/dev
