package org.openntf.domino.tests.ntf;

import lotus.domino.NotesFactory;

import org.openntf.domino.Database;
import org.openntf.domino.Session;
import org.openntf.domino.thread.DominoThread;
import org.openntf.domino.utils.Factory;

public class DominoRunnable implements Runnable {
	public static void main(String[] args) {
		DominoThread thread = new DominoThread(new DominoRunnable(), "My thread");
		thread.start();
	}

	public DominoRunnable() {
		// whatever you might want to do in your constructor, but stay away from Domino objects
	}

	@Override
	public void run() {
		try {
			Session session = Factory.fromLotus(NotesFactory.createSession(), Session.class, null);
			Database db = session.getDatabase("", "names.nsf");
			// whatever you're gonna do, do it fast!
		} catch (Throwable t) {
			t.printStackTrace();
		}
	}
}

@@ -185,16 +185,61 @@
 Thread;%0A
+import org.openntf.domino.utils.DominoUtils;%0A
 import o
@@ -347,16 +347,22 @@
 id main(
+final 
 String%5B%5D
@@ -626,17 +626,8 @@
 ) %7B%0A
-%09%09try %7B%0A%09
 %09%09Se
@@ -646,79 +646,27 @@
 n = 
-Factory.fromLotus(NotesFactory.createSession(), Session.class, null
+this.getSession(
 );%0A
-%09
 %09%09Da
@@ -717,17 +717,16 @@
 sf%22);%0A%09%09
-%09
 // whate
@@ -763,55 +763,238 @@
 t!%0A%09
-%09%7D catch (Throwable t) %7B%0A%09%09%09t.printStackTrace()
+%7D%0A%0A%09protected Session getSession() %7B%0A%09%09try %7B%0A%09%09%09Session session = Factory.fromLotus(NotesFactory.createSession(), Session.class, null);%0A%09%09%09return session;%0A%09%09%7D catch (Throwable t) %7B%0A%09%09%09DominoUtils.handleException(t);%0A%09%09%09return null
 ;%0A%09%09

Make it easier to get a session from a sub-class