2009-07-21 04:39:18 -04:00
|
|
|
/*
|
|
|
|
* DavMail POP/IMAP/SMTP/CalDav/LDAP Exchange Gateway
|
|
|
|
* Copyright (C) 2009 Mickael Guessant
|
|
|
|
*
|
|
|
|
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
*/
|
2008-08-21 18:02:21 -04:00
|
|
|
package davmail.web;
|
|
|
|
|
2009-04-23 10:54:06 -04:00
|
|
|
import davmail.BundleMessage;
|
2011-06-08 15:58:29 -04:00
|
|
|
import davmail.DavGateway;
|
|
|
|
import davmail.Settings;
|
2009-04-03 03:38:31 -04:00
|
|
|
import davmail.ui.tray.DavGatewayTray;
|
2008-08-21 18:02:21 -04:00
|
|
|
|
|
|
|
import javax.servlet.ServletContextEvent;
|
2011-06-08 15:58:29 -04:00
|
|
|
import javax.servlet.ServletContextListener;
|
2008-08-21 18:02:21 -04:00
|
|
|
import java.io.IOException;
|
2011-06-08 15:58:29 -04:00
|
|
|
import java.io.InputStream;
|
2008-08-21 18:02:21 -04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Context Listener to start/stop DavMail
|
|
|
|
*/
|
|
|
|
public class DavGatewayServletContextListener implements ServletContextListener {
|
|
|
|
public void contextInitialized(ServletContextEvent event) {
|
|
|
|
InputStream settingInputStream = null;
|
|
|
|
try {
|
2008-10-01 07:40:36 -04:00
|
|
|
settingInputStream = DavGatewayServletContextListener.class.getClassLoader().getResourceAsStream("davmail.properties");
|
2008-08-21 18:02:21 -04:00
|
|
|
Settings.load(settingInputStream);
|
|
|
|
DavGateway.start();
|
|
|
|
} catch (IOException e) {
|
2009-04-23 10:54:06 -04:00
|
|
|
DavGatewayTray.error(new BundleMessage("LOG_ERROR_LOADING_SETTINGS"), e);
|
2008-08-21 18:02:21 -04:00
|
|
|
} finally {
|
|
|
|
if (settingInputStream != null) {
|
|
|
|
try {
|
|
|
|
settingInputStream.close();
|
|
|
|
} catch (IOException e) {
|
2009-04-24 17:34:33 -04:00
|
|
|
DavGatewayTray.debug(new BundleMessage("LOG_ERROR_CLOSING_CONFIG_FILE"), e);
|
2008-08-21 18:02:21 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2009-04-23 10:54:06 -04:00
|
|
|
DavGatewayTray.debug(new BundleMessage("LOG_DAVMAIL_STARTED"));
|
2008-08-21 18:02:21 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
public void contextDestroyed(ServletContextEvent event) {
|
2009-04-23 10:54:06 -04:00
|
|
|
DavGatewayTray.debug(new BundleMessage("LOG_STOPPING_DAVMAIL"));
|
2008-08-21 18:02:21 -04:00
|
|
|
DavGateway.stop();
|
|
|
|
}
|
|
|
|
}
|