Как лучше всего использовать объекты Domino в Java Beans

Я использую функцию для получения доступа к документу конфигурации:

private Document lookupDoc(String key1) {
    try {
        Session sess = ExtLibUtil.getCurrentSession();
        Database wDb = sess.getDatabase(sess.getServerName(), this.dbname1);
        View wView = wDb.getView(this.viewname1);
        Document wDoc = wView.getDocumentByKey(key1, true);
        this.debug("Got a doc for key: [" + key1 + "]");
        return wDoc;
    } catch (NotesException ne) {
        if (this.DispLookupErrors)
            ne.printStackTrace();
        this.lastErrorMsg = ne.text;
        this.debug(this.lastErrorMsg, "error");
    }
    return null;
}

В другом методе я использую эту функцию для получения документа:

Document wDoc = this.lookupDoc(key1);

if (wdoc != null) {
    // do things with the document
    wdoc.recycle();
}

Должен ли я перерабатывать объекты Database и View когда я перерабатываю объект Document? Или они должны быть переработаны до того, как функция вернет документ?

7
задан halfer 11 May 2018 в 14:40
поделиться