com.ibm.domino.xsp.module.nsf
Class ThreadSessionExecutor<T>

java.lang.Object
  extended by com.ibm.domino.xsp.module.nsf.ThreadSessionExecutor<T>

public abstract class ThreadSessionExecutor<T>
extends java.lang.Object

Notes Session Executor.

This class executes a method with a Notes session object, in a thread that will be properly initialized and a Notes Session object created. The ThreadClassLoader is also being set to the NSF module class loader when the executor was created.

 // In the XPages thread
 ThreadSessionExecutor exec = new ThreadSessionExecutor() {
     protected Object execute(Session session) {
         // .... do something with the session ....
     }
 } 
 // In a different thread, like an eclipse job
 // using a ThreadSessionExecutor
 protected IStatus run(IProgressMonitor monitor) {
   try {
     return exec.run();
   } catch(Exception ex) {
     return Status.CANCEL_STATUS;
   }
 }
 
 


Constructor Summary
ThreadSessionExecutor()
          Construct an executor using the credentials of the current web user.
ThreadSessionExecutor(boolean fullAdminAccess)
          Construct an executor using the credentials of the current designer user.
 
Method Summary
 T run()
          Execute the task.
protected abstract  T run(lotus.domino.Session session)
          Actual method to execute within the session context.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ThreadSessionExecutor

public ThreadSessionExecutor()
Construct an executor using the credentials of the current web user. Note that this constructor MUST be called from an XPages thread.


ThreadSessionExecutor

public ThreadSessionExecutor(boolean fullAdminAccess)
Construct an executor using the credentials of the current designer user. Note that this constructor MUST be called from an XPages thread.

Parameters:
fullAdminAccess - true if it should use the full admin access
Method Detail

run

public T run()
      throws java.lang.Exception
Execute the task. Note that this method MUST be called from outside of a Notes Thread, like from a thread pool or Eclipse job. Note that this method should be executed within a thread with sufficient rights. It sets the following:
  • Session with the desired user credentials
  • Thread class loader from the NSF module that created the executor
  • Security manager context

Returns:
Throws:
lotus.domino.NotesException
java.lang.Exception

run

protected abstract T run(lotus.domino.Session session)
                  throws java.lang.Exception
Actual method to execute within the session context. This method has to be provided by the user.

Parameters:
session -
Returns:
Throws:
java.lang.Exception