?? listenerset1.java
字號(hào):
package com.sun.j2ee.workflow.control.listeners;import javax.servlet.ServletContext;import javax.servlet.ServletContextEvent;import javax.servlet.ServletContextAttributeEvent;import javax.servlet.ServletContextListener;import javax.servlet.ServletContextAttributeListener;import javax.servlet.http.HttpSessionAttributeListener;import javax.servlet.http.HttpSessionActivationListener;import javax.servlet.http.HttpSessionBindingEvent;import javax.servlet.http.HttpSessionEvent;import javax.servlet.http.HttpSessionListener;import java.io.*;import java.util.Locale;import com.sun.j2ee.workflow.util.Debug;import com.sun.j2ee.workflow.mail.*;import com.sun.j2ee.workflow.mail.exceptions.*;/** * Example listener for context-related application events, which were * introduced in the 2.3 version of the Servlet API. This listener * merely documents the occurrence of such events in the application log * associated with our servlet context. * * @author James Cai */public final class Listenerset1implements ServletContextListener,ServletContextAttributeListener,HttpSessionAttributeListener, HttpSessionListener,HttpSessionActivationListener { private boolean logToFile = false; /* private String logFileASSE = "../webapps/workflow/static/ListenerASSE.txt"; private String logFileAAE = "../webapps/workflow/static/ListenerAAE.txt"; private String logFileSCDE = "../webapps/workflow/static/ListenerSCDE.txt"; private String logFileSATE = "../webapps/workflow/static/ListenerSATE.txt"; private String logFileSACE = "../webapps/workflow/static/ListenerSACE.txt"; private String logFileCIAL = "../webapps/workflow/static/ListenerCIAL.txt"; private FileOutputStream logFileOutASSE=null; private FileOutputStream logFileOutAAE=null; private FileOutputStream logFileOutSCDE=null; private FileOutputStream logFileOutSATE=null; private FileOutputStream logFileOutSACE=null; private FileOutputStream logFileOutCIAL=null; */ private ServletContext context = null; private MailSender amailSender = null; private File baseDir = null; private MailSender getMailSender() { if (amailSender == null) { amailSender = new MailSender(); } return amailSender; } //find the emails of who wants to received a update notice private String getReceiver(String taskid) { return "jian.cai@sun.com"; } public void attributeAdded(ServletContextAttributeEvent event) { /* String message ="attributeAdded('" + event.getName() + "', '" + event.getValue() + "')"; File logFileNotify = new File(baseDir, "NotificationLog.txt"); File logFileMailError = new File(baseDir, "MailError.txt"); if (event.getName().equals("taskupdate")) { EmailModel amesg = new EmailModel("Workflow Update [Do not reply]", "Task Information Updated: "+ "Please See "+"http://localhost:8080/workflow/control/viewtask?task_ID="+ event.getValue()+"for Detail.", getReceiver((String)event.getValue()), Locale.ENGLISH); // try { getMailSender().createAndSendMail(amesg); Debug.log("Mail: to"+ getReceiver((String)event.getValue()), logFileNotify); } catch (Exception ex) { Debug.log("Mail Error:"+ex, logFileMailError); System.out.println(ex); } } */ } //ListenerAAE application attribute public void attributeRemoved(ServletContextAttributeEvent event) { String message = "attributeRemoved('" + event.getName() + "', '" + event.getValue() + "')"; } //ListenerAAE application attribute public void attributeReplaced(ServletContextAttributeEvent event) { String message = "attributeReplaced('" + event.getName() + "', '"+ "')"; } //ListenerSATE session attribute public void attributeAdded(HttpSessionBindingEvent event) { String message = "attributeAdded('" + "', '" + event.getName() + "', '" + "')"; } //ListenerSATE session attribute public void attributeRemoved(HttpSessionBindingEvent event) { String message = "attributeRemoved('" + "', '" + event.getName() + "', '" + "')"; } //ListenerSATE session attribute public void attributeReplaced(HttpSessionBindingEvent event) { String message = "attributeReplaced('" + "', '" + event.getName() + "', '" + "')"; } //ListenerASSE application shutdown public void contextDestroyed(ServletContextEvent event) { String message = "contextDestroyed()"; Debug.println(message); this.context = null; } //ListenerASSE application startup public void contextInitialized(ServletContextEvent event) { this.context = event.getServletContext(); String message = "Workflow: contextInitialized()"; Debug.println(message); baseDir = (File)context.getAttribute("javax.servlet.context.tempdir"); //String empty = null; //if (empty.equals("notnul")) Debug.println("Listenerset1 error coor"); //log(message, logFileASSE, logFileOutASSE); } //ListenerSCDE session created public void sessionCreated(HttpSessionEvent event) { String message = "sessionCreated('" + " new session" + "')"; } //ListenerSCDE session destroyed public void sessionDestroyed(HttpSessionEvent event) { String message = "sessionDestroyed('" + " new session" + "')"; Debug.println("Listenerset1: sessionDestroyed"); String empty = null; if (empty.equals("notnul")) Debug.println("Listenerset1 error"); } //ListenerSACE session activation public void sessionDidActivate(HttpSessionEvent event) { String message = "sessionDidActivate('" + " new session" + "')"; } //ListenerSACE session activation public void sessionWillPassivate(HttpSessionEvent event) { String message = "sessionWillPassivate('" + " new session " + "')"; } }
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -