{ rené.winkelmeyer }

Simple helper method for Domino object recycling

Feb 28, 2013
1 minute

Yesterday I’ve been asked how a simple (general) method for Domino object recycling may look like.

[java] public class DominoUtils { // pass any Domino objects to this method public static void recycleObjects(Object… dominoObjects) { for (Object dominoObject : dominoObjects) { if (dominoObject!=null) { if (dominoObject instanceof lotus.domino.Base) { try { ((lotus.domino.Base)dominoObject).recycle(); } catch (Exception e) { // do nothing } } } } } } [/java]

You can than call it from anywhere like this (in the right order):

[java]DominoUtils.recycleObjects(docThis, vwThat, dbHere, session);[/java]

Having such a helper method makes your code cleaner instead of adding additional if/try/catch clauses for every Domino object to your code.