You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by sa...@apache.org on 2007/04/03 16:42:11 UTC
svn commit: r525167 - in
/webservices/axis2/branches/java/1_2/modules/kernel/src/org/apache/axis2/transport/mail:
SimpleMailListener.java SynchronousMailListener.java
Author: saminda
Date: Tue Apr 3 07:42:09 2007
New Revision: 525167
URL: http://svn.apache.org/viewvc?view=rev&rev=525167
Log:
Improvements to mail transport to support simulated request/response.
User can configure his mail listener using Properties object
Modified:
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/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=525167&r1=525166&r2=525167
==============================================================================
--- 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 Tue Apr 3 07:42:09 2007
@@ -106,15 +106,6 @@
ArrayList mailParameters = transportIn.getParameters();
- replyTo = Utils.getParameterValue(
- transportIn.getParameter(org.apache.axis2.transport.mail.Constants.RAPLY_TO));
- Parameter listenerWaitIntervalParam = transportIn
- .getParameter(org.apache.axis2.transport.mail.Constants.LISTENER_INTERVAL);
- if (listenerWaitIntervalParam != null) {
- listenerWaitInterval =
- Integer.parseInt(Utils.getParameterValue(listenerWaitIntervalParam));
- }
-
String password = "";
String host = "";
String protocol = "";
@@ -126,8 +117,9 @@
String paramKey = param.getName();
String paramValue = Utils.getParameterValue(param);
if (paramKey == null || paramValue == null) {
- throw new AxisFault(Messages.getMessage("canNotBeNull",
- "Parameter name and value"));
+ String error = Messages.getMessage("canNotBeNull", "Parameter name and value");
+ log.error(error);
+ throw new AxisFault(error);
}
pop3Properties.setProperty(paramKey, paramValue);
@@ -147,11 +139,21 @@
port = paramValue;
}
+ //Transport specific
+ if (paramKey.equals(org.apache.axis2.transport.mail.Constants.RAPLY_TO)) {
+ replyTo = paramValue;
+ }
+ if (paramKey.equals(org.apache.axis2.transport.mail.Constants.LISTENER_INTERVAL)) {
+ listenerWaitInterval = Integer.parseInt(paramValue);
+ }
+
}
if (password.length() == 0 || user.length() == 0 || host.length() == 0 ||
protocol.length() == 0) {
- throw new AxisFault(
- "One or more of Password, User, Host and Protocol are null or empty");
+ String error = SimpleMailListener.class.getName() +
+ " one or more of Password, User, Host and Protocol are null or empty";
+ log.error(error);
+ throw new AxisFault(error);
}
if (port.length() == 0) {
@@ -165,6 +167,50 @@
receiver.setUrlName(urlName);
+ }
+
+ public void initFromRuntime(Properties properties,MessageContext msgContext) throws AxisFault {
+
+ this.configurationContext = msgContext.getConfigurationContext();
+
+ String password = "";
+ String host = "";
+ String protocol = "";
+ String port = "";
+ URLName urlName;
+
+ pop3Properties.clear();
+ pop3Properties.putAll(properties);
+
+ user = properties.getProperty(org.apache.axis2.transport.mail.Constants.POP3_USER);
+ password = properties.getProperty(org.apache.axis2.transport.mail.Constants.POP3_PASSWORD);
+ host = properties.getProperty(org.apache.axis2.transport.mail.Constants.POP3_HOST);
+ protocol = properties.getProperty(org.apache.axis2.transport.mail.Constants.STORE_PROTOCOL);
+ port = properties.getProperty(org.apache.axis2.transport.mail.Constants.POP3_PORT);
+ replyTo = properties.getProperty(org.apache.axis2.transport.mail.Constants.RAPLY_TO);
+ String value =
+ properties.getProperty(org.apache.axis2.transport.mail.Constants.LISTENER_INTERVAL);
+ if (value != null) {
+ listenerWaitInterval = Integer.parseInt(value);
+ }
+
+ if (password.length() == 0 || user.length() == 0 || host.length() == 0 ||
+ protocol.length() == 0) {
+ String error = SimpleMailListener.class.getName() + " one or more of Password, User," +
+ " Host and Protocol are null or empty" + "in runtime settings";
+ log.error(error);
+ throw new AxisFault(error);
+ }
+
+ if (port == null) {
+ urlName = new URLName(protocol, host, -1, "", user, password);
+ } else {
+ urlName = new URLName(protocol, host, Integer.parseInt(port), "", user, password);
+ }
+
+ receiver = new EmailReceiver();
+ receiver.setPop3Properties(pop3Properties);
+ receiver.setUrlName(urlName);
}
/**
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=525167&r1=525166&r2=525167
==============================================================================
--- 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 Tue Apr 3 07:42:09 2007
@@ -22,6 +22,8 @@
import org.apache.axis2.wsdl.WSDLConstants;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+
+import java.util.Properties;
/*
*
*/
@@ -85,7 +87,12 @@
TransportInDescription transportIn = msgContext.getConfigurationContext()
.getAxisConfiguration().getTransportIn(org.apache.axis2.Constants.TRANSPORT_MAIL);
- listener.init(msgContext.getConfigurationContext(), transportIn);
+ Object obj = msgContext.getProperty(Constants.MAIL_POP3);
+ if (obj != null) {
+ listener.initFromRuntime((Properties)obj,msgContext);
+ } else {
+ listener.init(msgContext.getConfigurationContext(), transportIn);
+ }
msgContext.getConfigurationContext().getThreadPool().execute(listener);
listener.start();
---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org