You are viewing a plain text version of this content. The canonical link for it is here.
Posted to axis-cvs@ws.apache.org by de...@apache.org on 2007/05/16 10:13:32 UTC
svn commit: r538468 - in
/webservices/axis2/branches/java/1_2/modules/kernel/src/org/apache/axis2/transport/mail:
EMailSender.java SimpleMailListener.java SynchronousMailListener.java
Author: deepal
Date: Wed May 16 01:13:31 2007
New Revision: 538468
URL: http://svn.apache.org/viewvc?view=rev&rev=538468
Log:
simulating HTTP req-res in SMTP
Modified:
webservices/axis2/branches/java/1_2/modules/kernel/src/org/apache/axis2/transport/mail/EMailSender.java
webservices/axis2/branches/java/1_2/modules/kernel/src/org/apache/axis2/transport/mail/SimpleMailListener.java
webservices/axis2/branches/java/1_2/modules/kernel/src/org/apache/axis2/transport/mail/SynchronousMailListener.java
Modified: webservices/axis2/branches/java/1_2/modules/kernel/src/org/apache/axis2/transport/mail/EMailSender.java
URL: http://svn.apache.org/viewvc/webservices/axis2/branches/java/1_2/modules/kernel/src/org/apache/axis2/transport/mail/EMailSender.java?view=diff&rev=538468&r1=538467&r2=538468
==============================================================================
--- webservices/axis2/branches/java/1_2/modules/kernel/src/org/apache/axis2/transport/mail/EMailSender.java (original)
+++ webservices/axis2/branches/java/1_2/modules/kernel/src/org/apache/axis2/transport/mail/EMailSender.java Wed May 16 01:13:31 2007
@@ -22,8 +22,8 @@
import org.apache.axiom.soap.SOAP11Constants;
import org.apache.axiom.soap.SOAP12Constants;
import org.apache.axis2.AxisFault;
-import org.apache.axis2.client.Options;
import org.apache.axis2.addressing.EndpointReference;
+import org.apache.axis2.client.Options;
import org.apache.axis2.context.MessageContext;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -32,23 +32,15 @@
import javax.activation.DataHandler;
import javax.activation.DataSource;
import javax.activation.MailcapCommandMap;
-import javax.mail.Authenticator;
-import javax.mail.BodyPart;
-import javax.mail.Message;
-import javax.mail.MessagingException;
-import javax.mail.Multipart;
-import javax.mail.Part;
-import javax.mail.PasswordAuthentication;
-import javax.mail.Session;
-import javax.mail.Transport;
+import javax.mail.*;
import javax.mail.internet.AddressException;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeMessage;
import javax.mail.internet.MimeMultipart;
import java.io.ByteArrayOutputStream;
import java.io.OutputStream;
-import java.util.Properties;
import java.util.Hashtable;
+import java.util.Properties;
public class EMailSender {
private Properties properties;
@@ -116,16 +108,16 @@
if (!epr.hasNoneAddress()) {
mailToInfo = new MailToInfo(epr);
msg.addRecipient(Message.RecipientType.TO,
- new InternetAddress(mailToInfo.getEmailAddress()));
+ new InternetAddress(mailToInfo.getEmailAddress()));
} else {
if (from != null) {
mailToInfo = new MailToInfo(from);
msg.addRecipient(Message.RecipientType.TO,
- new InternetAddress(mailToInfo.getEmailAddress()));
+ new InternetAddress(mailToInfo.getEmailAddress()));
} else {
String error = EMailSender.class.getName() + "Couldn't countinue due to" +
- " FROM addressing is NULL";
+ " FROM addressing is NULL";
log.error(error);
throw new AxisFault(error);
}
@@ -135,10 +127,10 @@
if (from != null) {
mailToInfo = new MailToInfo(from);
msg.addRecipient(Message.RecipientType.TO,
- new InternetAddress(mailToInfo.getEmailAddress()));
+ new InternetAddress(mailToInfo.getEmailAddress()));
} else {
String error = EMailSender.class.getName() + "Couldn't countinue due to" +
- " FROM addressing is NULL and EPR is NULL";
+ " FROM addressing is NULL and EPR is NULL";
log.error(error);
throw new AxisFault(error);
}
@@ -149,7 +141,7 @@
if (mailToInfo.isxServicePath()) {
msg.setHeader(Constants.X_SERVICE_PATH,
- "\"" + mailToInfo.getContentDescription() + "\"");
+ "\"" + mailToInfo.getContentDescription() + "\"");
}
if (inReplyTo != null) {
@@ -191,24 +183,24 @@
.addHeader("Content-Description", "\"" + mailToInfo.getContentDescription() + "\"");
String contentType = format.getContentType() != null ? format.getContentType() :
- Constants.DEFAULT_CONTENT_TYPE;
+ Constants.DEFAULT_CONTENT_TYPE;
if (contentType.indexOf(SOAP11Constants.SOAP_11_CONTENT_TYPE) > -1) {
if (messageContext.getSoapAction() != null) {
messageBodyPart.setHeader(Constants.HEADER_SOAP_ACTION,
- messageContext.getSoapAction());
+ messageContext.getSoapAction());
}
}
if (contentType.indexOf(SOAP12Constants.SOAP_12_CONTENT_TYPE) > -1) {
if (messageContext.getSoapAction() != null) {
messageBodyPart.setHeader("Content-Type",
- contentType + "; charset=" + format.getCharSetEncoding() +
- " ; action=\"" + messageContext.getSoapAction() +
- "\"");
+ contentType + "; charset=" + format.getCharSetEncoding() +
+ " ; action=\"" + messageContext.getSoapAction() +
+ "\"");
}
} else {
messageBodyPart.setHeader("Content-Type",
- contentType + "; charset=" + format.getCharSetEncoding());
+ contentType + "; charset=" + format.getCharSetEncoding());
}
multipart.addBodyPart(messageBodyPart);
@@ -230,24 +222,25 @@
}
private void sendReceive(MessageContext msgContext, String msgId) throws AxisFault {
- storeMessageContext(msgContext,msgId);
- Object obj = msgContext.getProperty(Constants.MAIL_SYNC);
- if (obj == null) {
- return;
- }
+ storeMessageContext(msgContext, msgId);
Options options = msgContext.getOptions();
+ if (!options.isUseSeparateListener()) {
+ SynchronousMailListener listener =
+ new SynchronousMailListener(options.getTimeOutInMilliSeconds());
+ listener.sendReceive(msgContext, msgId);
+ }
- SynchronousMailListener listener =
- new SynchronousMailListener(options.getTimeOutInMilliSeconds());
- listener.sendReceive(msgContext, msgId);
}
- private void storeMessageContext(MessageContext msgContext, String msgId){
+ private void storeMessageContext(MessageContext msgContext, String msgId) {
Hashtable mappingTable = (Hashtable) msgContext.getConfigurationContext().
getProperty(Constants.MAPPING_TABLE);
-
- if(mappingTable!=null){
- mappingTable.put(msgId,msgContext.getMessageID());
+
+ if (mappingTable == null) {
+ mappingTable = new Hashtable();
+ msgContext.setProperty(Constants.MAPPING_TABLE, mappingTable);
}
+ mappingTable.put(msgId, msgContext.getMessageID());
+
}
}
Modified: webservices/axis2/branches/java/1_2/modules/kernel/src/org/apache/axis2/transport/mail/SimpleMailListener.java
URL: http://svn.apache.org/viewvc/webservices/axis2/branches/java/1_2/modules/kernel/src/org/apache/axis2/transport/mail/SimpleMailListener.java?view=diff&rev=538468&r1=538467&r2=538468
==============================================================================
--- webservices/axis2/branches/java/1_2/modules/kernel/src/org/apache/axis2/transport/mail/SimpleMailListener.java (original)
+++ webservices/axis2/branches/java/1_2/modules/kernel/src/org/apache/axis2/transport/mail/SimpleMailListener.java Wed May 16 01:13:31 2007
@@ -166,9 +166,13 @@
receiver = new EmailReceiver();
receiver.setPop3Properties(pop3Properties);
receiver.setUrlName(urlName);
- Hashtable mappingTable = new Hashtable();
- configurationContext.setProperty(
- org.apache.axis2.transport.mail.Constants.MAPPING_TABLE,mappingTable);
+ Object obj = configurationContext.
+ getProperty(org.apache.axis2.transport.mail.Constants.MAPPING_TABLE);
+ if (obj == null) {
+ configurationContext.setProperty(
+ org.apache.axis2.transport.mail.Constants.MAPPING_TABLE, new Hashtable());
+ }
+
}
@@ -214,6 +218,12 @@
receiver = new EmailReceiver();
receiver.setPop3Properties(pop3Properties);
receiver.setUrlName(urlName);
+ Object obj = configurationContext.
+ getProperty(org.apache.axis2.transport.mail.Constants.MAPPING_TABLE);
+ if (obj == null) {
+ configurationContext.setProperty(
+ org.apache.axis2.transport.mail.Constants.MAPPING_TABLE, new Hashtable());
+ }
}
/**
Modified: webservices/axis2/branches/java/1_2/modules/kernel/src/org/apache/axis2/transport/mail/SynchronousMailListener.java
URL: http://svn.apache.org/viewvc/webservices/axis2/branches/java/1_2/modules/kernel/src/org/apache/axis2/transport/mail/SynchronousMailListener.java?view=diff&rev=538468&r1=538467&r2=538468
==============================================================================
--- webservices/axis2/branches/java/1_2/modules/kernel/src/org/apache/axis2/transport/mail/SynchronousMailListener.java (original)
+++ webservices/axis2/branches/java/1_2/modules/kernel/src/org/apache/axis2/transport/mail/SynchronousMailListener.java Wed May 16 01:13:31 2007
@@ -59,6 +59,7 @@
throw new AxisFault(error);
}
if (transportInfo.getInReplyTo().equals(msgId)) {
+ //TODO do the correct operation dispatching here
msgContext.getOperationContext()
.getMessageContext(WSDLConstants.MESSAGE_LABEL_IN_VALUE)
.setEnvelope(msgCtx.getEnvelope());
---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org