|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.eclipse.core.runtime.PlatformObject org.eclipse.core.internal.jobs.InternalJob org.eclipse.core.runtime.jobs.Job com.ibm.notes.java.api.util.NotesSessionJob
public abstract class NotesSessionJob
Instances of this class allow for executing code on a Notes thread.
Clients must subclass and implement the runInNotesThread method.
It is important not to join this Job to the UI thread.
This class replaces the NotesJob
class to add better memory management
and security context switching.
Example:
NotesSessionJob job = new NotesSessionJob("Job Name"){
protected IStatus runInNotesThread(Session session, IProgressMonitor monitor)
throws NotesException {
System.out.println(session.getUserName());
return Status.OK_STATUS;
}
}
job.schedule();
Running the above code will print out the current user's user name.
public class MailNotesJob extends NotesSessionJob{
private static final String SERVER = "";
private String server;
private String filePath;
public MailNotesJob(String name) {
super(name);
}
protected IStatus runInNotesThread(Session session, IProgressMonitor monitor)
throws NotesException {
DbDirectory dir = session.getDbDirectory(SERVER);
Database mail = dir.openMailDatabase();
server = mail.getServer();
filePath = mail.getFilePath();
mail.recycle();
return Status.OK_STATUS;
}
public String getServer(){
return this.server;
}
public String getFilePath(){
return this.filePath;
}
}
Field Summary |
---|
Fields inherited from class org.eclipse.core.runtime.jobs.Job |
---|
ASYNC_FINISH, BUILD, DECORATE, INTERACTIVE, LONG, NONE, RUNNING, SHORT, SLEEPING, WAITING |
Fields inherited from class org.eclipse.core.internal.jobs.InternalJob |
---|
manager |
Constructor Summary | |
---|---|
NotesSessionJob(String name)
Subclasses must override the constructor to give the Job a user-readable name. |
Method Summary | |
---|---|
protected Session |
createSession()
Create a new session for this Job. |
protected Session |
getSession()
Retrieve the session in which this Job is running. |
protected void |
handle(InterruptedException e)
Handles errors thrown while this job is running. |
protected void |
handle(NotesException e)
Handles Notes errors thrown during the creation or life of the Session. |
protected boolean |
isOnMainThread()
Determines whether this job is running on the main thread or on a background thread. |
protected void |
recycle()
Recycles the session create by the createSession method. |
protected IStatus |
run(IProgressMonitor monitor)
|
protected abstract IStatus |
runInNotesThread(Session session,
IProgressMonitor monitor)
Clients must implement this method with code that is executed on the Notes thread. |
Methods inherited from class org.eclipse.core.runtime.jobs.Job |
---|
addJobChangeListener, belongsTo, cancel, canceling, done, getJobManager, getName, getPriority, getProperty, getResult, getRule, getState, getThread, isBlocking, isSystem, isUser, join, removeJobChangeListener, schedule, schedule, setName, setPriority, setProgressGroup, setProperty, setRule, setSystem, setThread, setUser, shouldRun, shouldSchedule, sleep, wakeUp, wakeUp |
Methods inherited from class org.eclipse.core.internal.jobs.InternalJob |
---|
compareTo, toString |
Methods inherited from class org.eclipse.core.runtime.PlatformObject |
---|
getAdapter |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface org.eclipse.core.runtime.IAdaptable |
---|
getAdapter |
Constructor Detail |
---|
public NotesSessionJob(String name)
name
- name of the jobMethod Detail |
---|
protected final lotus.domino.Session getSession()
protected lotus.domino.Session createSession() throws NotesException
NotesFactory.createSession()
is used in the default implementation.
Allows a subclass to create the session with different arguments.
NotesException
- error through during creationprotected void recycle() throws NotesException
NotesException
- error while recyclingprotected void handle(NotesException e)
e
- error thrownprotected void handle(InterruptedException e)
e
- error thrownprotected boolean isOnMainThread()
protected final IStatus run(IProgressMonitor monitor)
run
in class Job
protected abstract IStatus runInNotesThread(Session session, IProgressMonitor monitor) throws NotesException
session
- the Notes session to use for communicating with Notes back-end elements.monitor
- the progress monitor used for this job
NotesException
- thrown when an error occurs during the operation
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |