home *** CD-ROM | disk | FTP | other *** search
- package lotus.notes;
-
- public final class AgentLauncher implements Runnable {
- private AgentBase m_agent;
- private AgentInfo m_ai;
- private Session m_session;
-
- public 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 = Session.newInstance();
- } else {
- this.m_session = Session.newInstance(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 var30) {
- System.err.println(JavaString.getFormattedString("error_instantiating", this.m_ai.getAgentClass().getName()));
- ((Throwable)var30).printStackTrace(System.err);
- } catch (IllegalAccessException var31) {
- System.err.println(JavaString.getFormattedString("illegal_access", this.m_ai.getAgentClass().getName()));
- ((Throwable)var31).printStackTrace(System.err);
- return;
- } catch (ClassCastException var32) {
- System.err.println(JavaString.getFormattedString("not_derived", this.m_ai.getAgentClass().getName(), "AgentBase"));
- ((Throwable)var32).printStackTrace(System.err);
- return;
- } catch (InterruptedException var33) {
- return;
- } catch (NotesException var34) {
- System.err.println(JavaString.resource.getString("session_create_error"));
- ((Throwable)var34).printStackTrace();
- return;
- } finally {
- var2.stop();
-
- for(; var1.getActiveNotesThreadCount() > 1; var2.stop()) {
- try {
- Thread.sleep(250L);
- } catch (InterruptedException var29) {
- }
- }
-
- if (var2.activeCount() > 0) {
- try {
- Thread.sleep(250L);
- } catch (InterruptedException var28) {
- }
- }
-
- try {
- var2.destroy();
- } catch (IllegalThreadStateException var27) {
- System.err.println(JavaString.resource.getString("thread_cleanup_error"));
- }
-
- if (this.m_session != null) {
- this.m_session.endAgentContext();
- }
-
- this.m_session = null;
- this.m_ai.setSession((Session)null);
- }
-
- }
- }
-