mirror of
https://github.com/moparisthebest/davmail
synced 2024-12-04 14:52:24 -05:00
J2EE webapp packaging to deploy DavMail in any application server
git-svn-id: http://svn.code.sf.net/p/davmail/code/trunk@130 3d1905a2-6b24-0410-a738-b14d5a86fcbd
This commit is contained in:
parent
1f0d4cdb1d
commit
75fe578336
15
build.xml
15
build.xml
@ -44,6 +44,7 @@
|
||||
<include name="*.jar"/>
|
||||
<exclude name="nsisant*.jar"/>
|
||||
<exclude name="jsmoothgen-ant.jar"/>
|
||||
<exclude name="servlet-api.jar"/>
|
||||
</fileset>
|
||||
</copy>
|
||||
<copy file="davmail.sh" todir="dist"/>
|
||||
@ -63,6 +64,20 @@
|
||||
<exclude name="lib/swt*.jar"/>
|
||||
</fileset>
|
||||
</zip>
|
||||
<copy todir="dist/web">
|
||||
<fileset dir="src/web"/>
|
||||
</copy>
|
||||
<copy todir="dist/web/WEB-INF/lib">
|
||||
<fileset dir="dist/lib">
|
||||
<include name="*.jar"/>
|
||||
<exclude name="nsisant*.jar"/>
|
||||
<exclude name="jsmoothgen-ant.jar"/>
|
||||
<exclude name="lib/swt*.jar"/>
|
||||
</fileset>
|
||||
</copy>
|
||||
<jar destfile="dist/davmail-${version}.war">
|
||||
<fileset dir="dist/web"/>
|
||||
</jar>
|
||||
<tar tarfile="dist/davmail-linux-x86-${version}.tgz" compression="gzip">
|
||||
<tarfileset prefix="davmail-linux-x86-${version}" dir="dist" filemode="755">
|
||||
<include name="davmail.sh"/>
|
||||
|
BIN
lib/servlet-api.jar
Normal file
BIN
lib/servlet-api.jar
Normal file
Binary file not shown.
@ -35,22 +35,7 @@ public class DavGateway {
|
||||
|
||||
public static void start() {
|
||||
// first stop existing servers
|
||||
if (smtpServer != null) {
|
||||
smtpServer.close();
|
||||
try {
|
||||
smtpServer.join();
|
||||
} catch (InterruptedException e) {
|
||||
DavGatewayTray.warn("Exception waiting for listener to die", e);
|
||||
}
|
||||
}
|
||||
if (popServer != null) {
|
||||
popServer.close();
|
||||
try {
|
||||
popServer.join();
|
||||
} catch (InterruptedException e) {
|
||||
DavGatewayTray.warn("Exception waiting for listener to die", e);
|
||||
}
|
||||
}
|
||||
DavGateway.stop();
|
||||
int smtpPort = Settings.getIntProperty("davmail.smtpPort");
|
||||
if (smtpPort == 0) {
|
||||
smtpPort = SmtpServer.DEFAULT_PORT;
|
||||
@ -74,4 +59,23 @@ public class DavGateway {
|
||||
|
||||
}
|
||||
|
||||
public static void stop() {
|
||||
if (smtpServer != null) {
|
||||
smtpServer.close();
|
||||
try {
|
||||
smtpServer.join();
|
||||
} catch (InterruptedException e) {
|
||||
DavGatewayTray.warn("Exception waiting for listener to die", e);
|
||||
}
|
||||
}
|
||||
if (popServer != null) {
|
||||
popServer.close();
|
||||
try {
|
||||
popServer.join();
|
||||
} catch (InterruptedException e) {
|
||||
DavGatewayTray.warn("Exception waiting for listener to die", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
40
src/java/davmail/web/DavGatewayServletContextListener.java
Normal file
40
src/java/davmail/web/DavGatewayServletContextListener.java
Normal file
@ -0,0 +1,40 @@
|
||||
package davmail.web;
|
||||
|
||||
import davmail.Settings;
|
||||
import davmail.DavGateway;
|
||||
import davmail.tray.DavGatewayTray;
|
||||
|
||||
import javax.servlet.ServletContextListener;
|
||||
import javax.servlet.ServletContextEvent;
|
||||
import java.io.InputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* Context Listener to start/stop DavMail
|
||||
*/
|
||||
public class DavGatewayServletContextListener implements ServletContextListener {
|
||||
public void contextInitialized(ServletContextEvent event) {
|
||||
InputStream settingInputStream = null;
|
||||
try {
|
||||
settingInputStream = DavGatewayServlet.class.getClassLoader().getResourceAsStream("davmail.properties");
|
||||
Settings.load(settingInputStream);
|
||||
DavGateway.start();
|
||||
} catch (IOException e) {
|
||||
DavGatewayTray.error("Error loading settings file from classpath: ", e);
|
||||
} finally {
|
||||
if (settingInputStream != null) {
|
||||
try {
|
||||
settingInputStream.close();
|
||||
} catch (IOException e) {
|
||||
DavGatewayTray.debug("Error closing configuration file: ", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
DavGatewayTray.debug("DavMail Gateway started");
|
||||
}
|
||||
|
||||
public void contextDestroyed(ServletContextEvent event) {
|
||||
DavGatewayTray.debug("Stopping DavMail Gateway...");
|
||||
DavGateway.stop();
|
||||
}
|
||||
}
|
11
src/web/WEB-INF/classes/davmail.properties
Normal file
11
src/web/WEB-INF/classes/davmail.properties
Normal file
@ -0,0 +1,11 @@
|
||||
davmail.url=http://exchangeServer/exchange/
|
||||
davmail.popPort=1110
|
||||
davmail.smtpPort=1025
|
||||
davmail.keepDelay=30
|
||||
davmail.allowRemote=true
|
||||
davmail.enableProxy=false
|
||||
davmail.proxyHost=
|
||||
davmail.proxyPort=
|
||||
davmail.proxyUser=
|
||||
davmail.proxyPassword=
|
||||
davmail.server=true
|
18
src/web/WEB-INF/web.xml
Normal file
18
src/web/WEB-INF/web.xml
Normal file
@ -0,0 +1,18 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<web-app xmlns="http://java.sun.com/xml/ns/javaee"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
|
||||
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
|
||||
version="2.5">
|
||||
<description>
|
||||
Ever wanted to get rid of Outlook ? DavMail is a POP/SMTP exchange gateway allowing
|
||||
users to use any mail client (e.g. Thunderbird) with an Exchange server, even from the internet
|
||||
through Outlook Web Access. DavMail gateway is implemented in java and should run on
|
||||
any platform. Releases are tested on Windows and Linux (Ubuntu). MacOS support is currently
|
||||
limited to server (headless) mode. Tested successfully with the Iphone (gateway running on a
|
||||
server).
|
||||
</description>
|
||||
<listener>
|
||||
<listener-class>davmail.web.DavGatewayServletContextListener</listener-class>
|
||||
</listener>
|
||||
</web-app>
|
Loading…
Reference in New Issue
Block a user