📄 cachemanagererrorhandler.java
字号:
/******************************************************************************* * Copyright (C) 2002, 2003 * ingenieurbuero fuer innovative informationstechnik (iiit) * Dipl.-Ing. Joerg Beckmann, Dortmund, Germany * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * * version $Id: CacheManagerErrorHandler.java,v 1.10 2003/04/13 20:28:01 joerg Exp $ ******************************************************************************/package de.iiit.access.server.plugins.cachemanager;import org.apache.log4j.*;import java.util.*;import javax.mail.*;import javax.mail.internet.*;import com.sun.mail.smtp.*;/** This class is used to send mails containing error messages from the CacheManager * to a configurable address. */public class CacheManagerErrorHandler{ /** CVS Version Tag */ private static final String vcid = "$Id: CacheManagerErrorHandler.java,v 1.10 2003/04/13 20:28:01 joerg Exp $"; private static Logger logger = Logger.getLogger("CacheManagerErrorHandler"); private String smtpServer; private int smtpPort; private String smtpUser; private String smtpPassword; private String smtpMailTo; /** Creates a new instance of CacheManagerErrorHandler */ private CacheManagerErrorHandler() { } /** Creates a new instance of CacheManagerErrorHandler * @param cacheManager The parent CacheManager holding the configuration data etc. */ public CacheManagerErrorHandler(CacheManager cacheManager) { smtpServer = cacheManager.smtpServer(); smtpPort = cacheManager.smtpPort(); smtpUser = cacheManager.smtpUser(); smtpPassword = cacheManager.smtpPassword(); smtpMailTo = cacheManager.smtpMailTo(); } /** Create and send an e-mail message * @param message The error message to send by e-mail */ protected void sendMail(String message) { String text = ""; if (smtpServer != null && smtpMailTo != null) { try { text += "An error occured while processing pre-defined expressions:\n"; text += "\n"; text += message + "\n"; text += "\n"; text += "Because it could not be processed, any request for this expression\n"; text += "will deliver results calculated from its old value which may be wrong.\n"; text += "\n"; text += "Kind regards\n"; text += "\n"; text += "Your AccessServer\n"; Session session = Session.getDefaultInstance(System.getProperties(), null); MimeMessage msg = new MimeMessage(session); msg.setFrom(); msg.setRecipients(Message.RecipientType.TO, InternetAddress.parse(smtpMailTo, false)); msg.setSubject("AccessServer CacheManager Error"); msg.setText(text); msg.setSentDate(new Date()); Transport tr = session.getTransport("smtp"); tr.connect(smtpServer, smtpPort, smtpUser, smtpPassword); tr.sendMessage(msg, msg.getAllRecipients()); tr.close(); logger.info("Error mail sent to <" + smtpMailTo + ">"); } catch(MessagingException me) { logger.error("Can't send mail", me); } } }}/** * $Log: CacheManagerErrorHandler.java,v $ * Revision 1.10 2003/04/13 20:28:01 joerg * Package structure modified * * Revision 1.9 2003/04/13 20:16:41 joerg * Package structure modified * * Revision 1.8 2003/01/01 21:04:17 joerg * Copyright-Statement aktualisiert * * Revision 1.7 2002/12/24 21:04:33 joerg * Umbau der Paketstruktur * iiitLdapPlugin integriert * JavaDoc-Kommentare weiter vervollstaendigt. * * Revision 1.6 2002/12/23 11:25:11 joerg * no message * * Revision 1.5 2002/12/21 19:55:03 joerg * Nicht mehr benoetigte Methoden entfernt, interne Methoden auf * private oder protected geaendert. * JavaDoc Kommentare ergaenzt. * * Revision 1.4 2002/12/19 15:54:33 joerg * Paket umbenannt in iiitLdapPlugin * * Revision 1.3 2002/12/08 16:37:33 joerg * Aufraeumungsarbeiten nach dem grossen Umbau * * Revision 1.2 2002/12/08 16:09:46 joerg * Paket-Struktur ueberarbeitet * * Revision 1.1 2002/11/27 12:13:49 joerg * Beim Erkennen fehlerhafte Ausdruecke kann jetzt automatisch * eine Fehler-Mail verschickt werden. * */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -