• Anonymous
  • Login
  • Register
Threads and Jobs

Owners Niklas Heidloff, Philippe Riand Project Creation Mar 19, 2012
Contributors - Last Release Mar 19, 2012
Downloads 225Download latest release
Rating
(0 ratings)
Description Threads and Jobs




This project contains samples showing how to create threads and Eclipse jobs from XPages to run longer taking operations asynchronously without blocking the XPages user interface or to run scheduled tasks.

An example is a task that checks on a scheduled basis for new messages in mailboxes, databases, social networks like Facebook and Twitter, etc. Server side code of an XPages application can then get the latest messages simply by reading the cached information from the task.

All samples in this project use a new feature in Domino 8.5.3. com.ibm.domino.xsp.module.nsf.SessionCloner can be used to clone a Domino session of the currently authenticated user. This allows developing threads that run on behalf of a specific user which can use the Domino Java APIs. com.ibm.domino.xsp.module.nsf.ThreadSessionExecutor which leverages SessionCloner adds additional convenience functionality to set context like the current database, it handles session timeouts, etc.

The Eclipse jobs framework (http://www.eclipse.org/articles/Article-Concurrency/jobs-api.html) is a powerful framework used by Eclipse rich client developers. Eclipse jobs are essentially threads plus extra functionality like scheduling, progress monitoring, pooling etc. The XPages runtime supports these Eclipse jobs also server side since the necessary plugin comes with the XPages runtime similarly to the OSGi core framework.

In order to run the samples Domino 8.5.3 is needed. The extension library or upgrade pack 1 is only needed to check and display progress in an XPage via the xe:jsonRpcService control.

The Java code for threads and jobs can either be run in a NSF or as plugin. If run in a NSF the java.policy file needs to be changed to grant permissions. For plugins that is not necessary.

Add this to Domino\jvm\lib\security\java.policy when running the Job from the NSF:

grant {
   permission java.security.AllPermission;
};

Note that the following does not work since the Java code is put as class in NSF as opposed to a jar file in the /lib directory:
grant codeBase "xspnsf://server:0/threadsjob.nsf/-" {
   permission java.security.AllPermission;
};

For more details on permissions read:
http://www-10.lotus.com/ldd/ddwiki.nsf/dx/XPages_in_the_Notes_Client-Security
http://www.mindoo.com/web/blog.nsf/dx/21.10.2009142550KLEGL7.htm
http://www.wissel.net/blog/d6plinks/SHWL-8JYAT5



1. Thread

Setup:
Put ThreadsJob.nsf in Domino data root

Launch ThreadJob.nsf/Thread.xsp


2a. Eclipse Job in NSF

Setup:
Put ThreadsJob.nsf in Domino data root


2b. Eclipse Job as plugin

Setup:
Put ThreadsJobPlugin.nsf in Domino data root
Deploy the feature org.openntf.xsp.simpleSamples.feature and the plugin org.openntf.xsp.simpleSamples
Note: Only the package org.openntf.samples.job is needed, not the other packages in the plugin

Launch ThreadJobPlugin.nsf/Job.xsp



These capabilities are advanced capabilities in addition to the 8.5.3 synchronization improvements as mentioned in Karsten Lehmann's blog (http://www.mindoo.com/web/blog.nsf/dx/17.07.2011101855KLEBRW.htm?opendocument&comments#anc3):
From Phil Riand: "Synchronization no longer happens on the session itself, but on the page instance.  In short, it can now execute 2 different page instances at the same time, while it locks for postback calls to the same page instance and execute them sequentially."
From Karsten: "there will be a new database property called xsp.session.transient. This flag means that unique session objects will be created per request to the server and discarded right after the request ended. This is a first attempt to provide session less mode. If you use this option, then you can create one database with all the services and no synchronization will happen, as each request will have its own session object."
 



Projects can have short and readable URLs, e.g. http://mobilecontrols.openntf.org.

You can request a short URL to your project by sending a mail to support at openntf dot org.
Owners are the people with maximal rights. For example they can create releases and add more contributors.

In order to define multiple owners use "," (comma) as separator.

Because of data privacy you cannot lookup other people's names but you have to type them in.
Enter the contributors or owners here who you want to receive notifications and questions by email.

In order to define multiple owners use "," (comma) as separator.

Because of data privacy you cannot lookup other people's names but you have to type them in.
In addition to the owners additional OpenNTF contributors have to be listed here. Contributors don't have the same access rights as owners, e.g. they cannot create releases.

In order to define multiple owners use "," (comma) as separator.

Because of data privacy you cannot lookup other people's names but you have to type them in.
Enter a short description of the project here (up to 100 characters).

The short description shows up in the project UI and in some of the views.
In this field you should enter a more detailed description of your project.

You can use the rich text editor for rich text formating. You can also enter HTML to embed objects, e.g. to embed a YouTube video or a screenshot of the project. In this case use '[' and ']' to mark the passthrough HTML as such.
A Catalog Release is for projects that are production ready and that are end-user "install friendly".

This property describes whether any release of this project has been added to the catalog.

Learn more about the catalog.
GitHub can be used as source control repository for OpenNTF projects. In this case the Issues from GitHub are used instead of the Defects from OpenNTF.

Contact ip-manager@openntf if you want to have a GitHub project created in the OpenNTF space.

Learn more about OpenNTF on GitHub