Note that there are some explanatory texts on larger screens.

plurals
  1. POUsing lotus.domino.Document as a parameter for a function, how do I recycle cleanly?
    primarykey
    data
    text
    <p>I am programming a Server Task Add-In and am trying to make a clean, recyclable code. I am looping through a set of databases, then through some documents within the database.</p> <pre><code> for (String serverAndFilename : listofServerFilenames) { String[] parts = serverAndFilename.split("!!"); currentGECDB = session.getDatabase(parts[0], parts[1]); if (currentGECDB.isOpen()) { collSourceDocuments = currentGECDB.search(this .getSearchFormula(this .getvariablePartOfSearchFormula())); countOfSearchDocuments = collSourceDocuments.getCount(); docToChange = collSourceDocuments .getFirstDocument(); while (docToChange != null) { if (changeNamesFieldsOnThisDocument(docToChange)) { // .... other code here } tmpdoc = collSourceDocuments.getNextDocument(); docToChange.recycle(); docToChange = tmpdoc; } } } } </code></pre> <p>I am concerned about the memory management issues with using a heavy Notes oject as a parameter to a Java function. Whilst checking the changes my function does, I am getting the 'old' values and need to make a recycle() on my document before re-retrieving the document.</p> <p>It seems to me that I am forced to only pass primitives as arguments to an external function i.e. </p> <pre><code>public booleanfunction (String ServerName, String ReplicaIDOfDatabase, String UNIDofDocument) </code></pre> <p>but that would imply many subsequent OpenDatabase calls, which are expensive. </p> <p>Is there a best way to do this?</p> <p>As an example, this is part of a JUnit Test I am making on the result:</p> <pre><code>public void testNewArrivalTaskExample() { try { testNewArrivalTask = GECTaskNewArrival.getTestTask(db, oli); testNewArrivalTask.save(); Document testdocNewArrival_1 = getNewTestSourceCourrierDocument(); for (NamesItemsInProcedure n : NamesItemsInProcedure.values()) { setNamesField(testdocNewArrival_1, n, GECTaskNewArrival.NEW_ARRIVAL_ROLE_MODEL, NamesItemsInProcedure.NOUVELLE_ARRIVEE); } testdocNewArrival_1.replaceItemValue("TestDocumentDescription", "NewArrival_AllFields"); testdocNewArrival_1.save(); GECTaskNewArrival gna = new GECTaskNewArrival(testNewArrivalTask, db, oli); gna.process(); Item itemsuivi = testdocNewArrival_1 .getFirstItem(NamesItemsInProcedure.SUIVI_COURRIER .getItemName()); System.out.println("Content of document without recycle + rebirth:"); printItemValuesToSysout(itemsuivi); System.out.println(NamesItemsInProcedure.SUIVI_COURRIER .getItemName() + " Should contain " + GECTaskNewArrival.NEW_ARRIVAL_NEWPERSON); String noteID = testdocNewArrival_1.getNoteID(); testdocNewArrival_1.recycle(); for (NamesItemsInProcedure n : NamesItemsInProcedure.values()) { boolean result = itemContainsThisForTestDoc(GECAlladin, noteID, n.getItemName(), GECTaskNewArrival.NEW_ARRIVAL_NEWPERSON); switch (n) { case ENCOURS_COURRIER: assertTrue(result); break; case AUTEURS_COURRIER: assertTrue(result); break; case SUIVI_COURRIER: assertTrue(result); break; case ECHEANCEMESSAGENOM_COURRIER: assertTrue(result); break; default: // assertFalse(result); break; } } } catch (NotesException e) { e.printStackTrace(); } } </code></pre> <p>and this is the console result:</p> <pre><code>Content of document without recycle + rebirth: Suivi has these values: Donald VieuxDeLaVieille/dsic/ville-ge` the item belongs to this document 929E` Suivi Should contain CN=Micky NouvelleArrivee/OU=salut/OU=Truc/O=Muche` Suivi has these values:` Donald VieuxDeLaVieille/dsic/ville-ge` CN=Micky NouvelleArrivee/OU=salut/OU=Truc/O=Muche` the item belongs to this document 929E` Suivi contains CN=Micky NouvelleArrivee/OU=salut/OU=Truc/O=Muche` </code></pre> <p>I am still stumped.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload