Nate and Tim’s Excellent Recycle
Devin Olson August 27 2013 08:57:11 AM
During the "Build A Bean Workshop" that Mike McGarel and I presented at MWLUG 2013,I mentioned a wonderful utility method I received from Tim Tripcony,
who in turn based it on some original code (and a bit of conversation) he received from Nathan T. Freeman.
This method safely recycles Domino objects, which if not done every time they are referenced,
will cause your sever to leak memory the way a net leaks water.
If you are using Java in XPages, and are using IBM's Domino API (lotus.domino.*),
then I suggest you add this method to your core library and start using it immediately.
Here it is:
/**
* Recycles all passed in Domino Objects.
*
* @author Nathan T. Freeman, Tim Tripcony
*
* @url: http://nathantfreeman.wordpress.com http://www.timtripcony.com/
*
* @param dominoObjects Domino Objects to be recycled.
*
* @see http://stackoverflow.com/questions/11159444/what-is-the-best-way-to-recycle-domino-objects-in-java-beans
*/
public static void incinerate(Object... dominoObjects) {
for (Object dominoObject : dominoObjects) {
if (null != dominoObject) {
if (dominoObject instanceof Base) {
try {
((Base) dominoObject).recycle();
} catch (NotesException recycleSucks) {
// optionally log exception
}
}
}
}
}
Enjoy!
- Comments [0]