Author: veithen
Date: Fri Oct 10 15:00:18 2008
New Revision: 703586
URL: http://svn.apache.org/viewvc?rev=703586&view=rev
Log:
Mail transport: Create the JavaMail session once and store it in the
PollTableEntry, so that we don't need to recreate it every time.
Modified:
webservices/commons/trunk/modules/transport/modules/mail/src/main/java/org/apache/axis2/transport/mail/MailTransportListener.java
webservices/commons/trunk/modules/transport/modules/mail/src/main/java/org/apache/axis2/transport/mail/PollTableEntry.java
Modified:
webservices/commons/trunk/modules/transport/modules/mail/src/main/java/org/apache/axis2/transport/mail/MailTransportListener.java
URL:
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/transport/modules/mail/src/main/java/org/apache/axis2/transport/mail/MailTransportListener.java?rev=703586&r1=703585&r2=703586&view=diff
==============================================================================
---
webservices/commons/trunk/modules/transport/modules/mail/src/main/java/org/apache/axis2/transport/mail/MailTransportListener.java
(original)
+++
webservices/commons/trunk/modules/transport/modules/mail/src/main/java/org/apache/axis2/transport/mail/MailTransportListener.java
Fri Oct 10 15:00:18 2008
@@ -19,7 +19,6 @@
package org.apache.axis2.transport.mail;
-import org.apache.axiom.soap.SOAPEnvelope;
import org.apache.axis2.AxisFault;
import org.apache.axis2.Constants;
import org.apache.axis2.addressing.EndpointReference;
@@ -116,6 +115,7 @@
int retryCount = 0;
int maxRetryCount = entry.getMaxRetryCount();
long reconnectionTimeout = entry.getReconnectTimeout();
+ Session session = entry.getSession();
Store store = null;
while (!connected) {
@@ -123,11 +123,9 @@
retryCount++;
if (log.isDebugEnabled()) {
log.debug("Attempting to connect to POP3/IMAP server for :
" +
- entry.getEmailAddress() + " using " +
entry.getProperties());
+ entry.getEmailAddress() + " using " +
session.getProperties());
}
- Session session = Session.getInstance(entry.getProperties(),
null);
- session.setDebug(log.isTraceEnabled());
store = session.getStore(entry.getProtocol());
if (entry.getUserName() != null && entry.getPassword() !=
null) {
@@ -560,9 +558,10 @@
}
List<Parameter> params = paramIncl.getParameters();
+ Properties props = new Properties();
for (Parameter p : params) {
if (p.getName().startsWith("mail.")) {
- entry.addProperty(p.getName(), (String) p.getValue());
+ props.setProperty(p.getName(), (String) p.getValue());
}
if (MailConstants.MAIL_POP3_USERNAME.equals(p.getName()) ||
@@ -578,6 +577,9 @@
}
}
+ Session session = Session.getInstance(props, null);
+ session.setDebug(log.isTraceEnabled());
+ entry.setSession(session);
entry.setContentType(
ParamUtils.getOptionalParam(paramIncl,
MailConstants.TRANSPORT_MAIL_CONTENT_TYPE));
Modified:
webservices/commons/trunk/modules/transport/modules/mail/src/main/java/org/apache/axis2/transport/mail/PollTableEntry.java
URL:
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/transport/modules/mail/src/main/java/org/apache/axis2/transport/mail/PollTableEntry.java?rev=703586&r1=703585&r2=703586&view=diff
==============================================================================
---
webservices/commons/trunk/modules/transport/modules/mail/src/main/java/org/apache/axis2/transport/mail/PollTableEntry.java
(original)
+++
webservices/commons/trunk/modules/transport/modules/mail/src/main/java/org/apache/axis2/transport/mail/PollTableEntry.java
Fri Oct 10 15:00:18 2008
@@ -21,7 +21,6 @@
import java.util.ArrayList;
import java.util.List;
-import java.util.Properties;
import java.util.StringTokenizer;
import javax.mail.Session;
@@ -50,8 +49,8 @@
private String password = null;
/** The protocol to be used - pop3 or imap */
private String protocol = null;
- /** Store POP3 or IMAP mail properties */
- Properties properties = new Properties();
+ /** The JavaMail session used to connect to the mail store */
+ private Session session;
/** The mail folder from which to check mail */
private String folder;
@@ -212,12 +211,12 @@
this.protocol = protocol;
}
- public Properties getProperties() {
- return properties;
+ public Session getSession() {
+ return session;
}
- public void addProperty(String name, String value) {
- properties.put(name, value);
+ public void setSession(Session session) {
+ this.session = session;
}
public void addPreserveHeaders(String headerList) {