AgentContext agentContext = session.getAgentContext();
//(Your code goes here)
Database database;
View view;
Document document;
Document temp;
database = agentContext.getCurrentDatabase();
view = database.getView("Enter_View_Name_Here");
document = view.getFirstDocument();
while (document != null) {
//Process the document
System.out.println(document.getCreated());
temp = view.getNextDocument(document); // get the next document
document.recycle(); // recycle the document we''re done with
document = temp;
}
} catch(Exception e) {
e.printStackTrace();
}
}
}
通过对我们创建的所有其他 Domino 对象调用 recycle 包装(wrap up)此示例,如清单 13 所示。
清单 13. 对所有其他 Domino 对象调用 recycle
import lotus.domino. *;
public class JavaAgent extends AgentBase {
public void NotesMain() {
try {
Session session = getSession();
AgentContext agentContext = session.getAgentContext();
// (Your code goes here)
Database database;
View view;
Document document;
Document temp;
database = agentContext.getCurrentDatabase();
view = database.getView("Enter_View_Name_Here");
document = view.getFirstDocument();
while (document != null) {
//Process the document
System.out.println(document.getCreated());
temp = view.getNextDocument(document); // get the next document
document.recycle(); // recycle the document we''re done with
document = temp;
}
if (session !=null)
session.recycle();
if (agentContext !=null)
agentContext.recycle();
if (database !=null)
database.recycle();
if (view != null)
view.recycle();
} catch(Exception e) {
e.printStackTrace();
}
}
}
在IBM Lotus Domino Designer中使用Java构建应用程序(11)
时间:2011-01-24 IBM Oscar Hernandez
表 7 汇总了两种语言的比较。
表 7. 示例 2 两种语言之间的比较
LotusScript |
Java |
示例 2:循环通过 Notes 视图
Dim session As New NotesSession
Dim database As NotesDatabase
Dim view As NotesView
Dim document As NotesDocument
Set database = session.CurrentDatabase
Set view = database.GetView("Enter_View_Name_Here")
Set document = view.GetFirstDocument
While (Not document Is Nothing)
''Process the document
Print document.Created
Set document = view.GetNextDocument(document)
Wend |
|
示例 2:循环通过 Notes 视图
Session session = getSession();
AgentContext agentContext = session.getAgentContext();
Database database;
View view;
Document document;
Document temp;
database = agentContext.getCurrentDatabase();
view = database.getView("Enter_View_Name_Here");
document = view.getFirstDocument();
while (document != null){
//Process the document
System.out.println(document.getCreated());
// get the next document
temp = view.getNextDocument(document);
// recycle the documentwe''re done with
document.recycle();
document = temp;
}
if (session !=null)
session.recycle();
if (agentContext !=null)
agentContext.recycle();
if (database !=null)
database.recycle();
if (view != null)
view.recycle();
|
|