home *** CD-ROM | disk | FTP | other *** search
- package lotus.domino;
-
- import lotus.notes.AgentThreadGroup;
- import lotus.notes.JavaString;
-
- public final class AgentLauncher implements Runnable {
- private AgentBase m_agent;
- private AgentInfo m_ai;
- private Session m_session;
-
- protected AgentLauncher(AgentInfo var1) {
- this.m_ai = var1;
- }
-
- public void run() {
- AgentThreadGroup var1 = (AgentThreadGroup)Thread.currentThread().getThreadGroup();
- ThreadGroup var2 = var1.getUserThreadGroup();
-
- try {
- if (this.m_ai.getRunContext() == 0) {
- this.m_session = lotus.domino.local.Session.createSession();
- } else {
- this.m_session = lotus.domino.local.Session.createSession(this.m_ai.getRunContext());
- }
-
- this.m_ai.setSession(this.m_session);
- this.m_agent = (AgentBase)this.m_ai.newInstance();
- this.m_agent.startup(this.m_ai);
- this.m_agent.join();
- return;
- } catch (InstantiationException var36) {
- System.err.println(JavaString.getFormattedString("error_instantiating", this.m_ai.getAgentClass().getName()));
- ((Throwable)var36).printStackTrace(System.err);
- } catch (IllegalAccessException var37) {
- System.err.println(JavaString.getFormattedString("illegal_access", this.m_ai.getAgentClass().getName()));
- ((Throwable)var37).printStackTrace(System.err);
- return;
- } catch (ClassCastException var38) {
- System.err.println(this.m_ai.getAgentClass().getName() + " " + JavaString.getFormattedString("not_derived", "AgentBase"));
- ((Throwable)var38).printStackTrace(System.err);
- return;
- } catch (InterruptedException var39) {
- return;
- } catch (NotesException var40) {
- System.err.println(JavaString.resource.getString("session_create_error"));
- ((Throwable)var40).printStackTrace();
- return;
- } finally {
- var2.stop();
-
- for(; var1.getActiveNotesThreadCount() > 1; var2.stop()) {
- try {
- Thread.sleep(250L);
- } catch (InterruptedException var35) {
- }
- }
-
- if (var2.activeCount() > 0) {
- try {
- Thread.sleep(250L);
- } catch (InterruptedException var34) {
- }
- }
-
- try {
- var2.destroy();
- } catch (IllegalThreadStateException var33) {
- System.err.println(JavaString.resource.getString("thread_cleanup_error"));
- }
-
- if (this.m_session != null) {
- try {
- ((lotus.domino.local.Session)this.m_session).endAgentContext();
- } catch (Exception var32) {
- }
- }
-
- this.m_session = null;
- this.m_ai.setSession((Session)null);
- }
-
- }
- }
-