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 gd...@apache.org on 2005/07/11 17:49:55 UTC
svn commit: r210150 [7/35] - in /webservices/axis/trunk/java: ./ etc/
modules/addressing/
modules/addressing/src/org/apache/axis2/handlers/addressing/
modules/addressing/test-resources/
modules/addressing/test/org/apache/axis2/handlers/addressing/ modu...
Modified: webservices/axis/trunk/java/modules/core/src/org/apache/axis2/transport/http/ListingAgent.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/core/src/org/apache/axis2/transport/http/ListingAgent.java?rev=210150&r1=210149&r2=210150&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/core/src/org/apache/axis2/transport/http/ListingAgent.java (original)
+++ webservices/axis/trunk/java/modules/core/src/org/apache/axis2/transport/http/ListingAgent.java Mon Jul 11 08:49:30 2005
@@ -83,9 +83,8 @@
private final boolean allowListSingleService = true;
private OutputStream out = null;
- public void handle(
- HttpServletRequest httpServletRequest,
- HttpServletResponse httpServletResponse,OutputStream out)
+ public void handle(HttpServletRequest httpServletRequest,
+ HttpServletResponse httpServletResponse, OutputStream out)
throws IOException {
this.out = out;
String filePart = httpServletRequest.getRequestURL().toString();
@@ -151,14 +150,12 @@
private void listServices(HttpServletRequest req, HttpServletResponse res) throws IOException {
HashMap services = configContext.getAxisConfiguration().getServices();
req.getSession().setAttribute(Constants.SERVICE_MAP, services);
- req.getSession().setAttribute(
- Constants.ERROR_SERVICE_MAP,
- configContext.getAxisConfiguration().getFaulytServices());
+ req.getSession().setAttribute(Constants.ERROR_SERVICE_MAP,
+ configContext.getAxisConfiguration().getFaulytServices());
res.sendRedirect(LIST_MULTIPLE_SERVICE_JSP_NAME);
}
/**
- *
* @param req
* @param res
* @throws IOException
@@ -167,9 +164,8 @@
throws IOException {
HashMap services = configContext.getAxisConfiguration().getServices();
req.getSession().setAttribute(Constants.SERVICE_MAP, services);
- req.getSession().setAttribute(
- Constants.ERROR_SERVICE_MAP,
- configContext.getAxisConfiguration().getFaulytServices());
+ req.getSession().setAttribute(Constants.ERROR_SERVICE_MAP,
+ configContext.getAxisConfiguration().getFaulytServices());
res.sendRedirect(LIST_SRVICES_JSP_NAME);
}
@@ -180,6 +176,7 @@
req.getSession().setAttribute(Constants.MODULE_ENGAMENT, null);
res.sendRedirect(SELECT_SERVICE_JSP_NAME);
}
+
private void adminLogging(HttpServletRequest req, HttpServletResponse res) throws IOException {
String username = req.getParameter("userName");
String password = req.getParameter("password");
@@ -212,9 +209,8 @@
HashMap modules =
((AxisConfigurationImpl) configContext.getAxisConfiguration()).getModules();
req.getSession().setAttribute(Constants.MODULE_MAP, modules);
- req.getSession().setAttribute(
- Constants.ERROR_MODULE_MAP,
- configContext.getAxisConfiguration().getFaulytModules());
+ req.getSession().setAttribute(Constants.ERROR_MODULE_MAP,
+ configContext.getAxisConfiguration().getFaulytModules());
res.sendRedirect(LIST_AVAILABLE_MODULES_JSP_NAME);
}
@@ -228,9 +224,8 @@
if (moduleName != null) {
try {
configContext.getAxisConfiguration().engageModule(new QName(moduleName));
- req.getSession().setAttribute(
- Constants.ENGAGE_STATUS,
- moduleName + " module engaged globally Successfully");
+ req.getSession().setAttribute(Constants.ENGAGE_STATUS,
+ moduleName + " module engaged globally Successfully");
} catch (AxisFault axisFault) {
req.getSession().setAttribute(Constants.ENGAGE_STATUS, axisFault.getMessage());
}
@@ -255,25 +250,20 @@
} else {
serviceName = (String) req.getSession().getAttribute("service");
}
- req.getSession().setAttribute(
- Constants.OPEARTION_MAP,
- configContext
- .getAxisConfiguration()
- .getService(new QName(serviceName))
- .getOperations());
+ req.getSession().setAttribute(Constants.OPEARTION_MAP,
+ configContext
+ .getAxisConfiguration()
+ .getService(new QName(serviceName))
+ .getOperations());
req.getSession().setAttribute(Constants.ENGAGE_STATUS, null);
String operationName = (String) req.getParameter("operation");
if (serviceName != null && moduleName != null && operationName != null) {
try {
OperationDescription od =
- configContext.getAxisConfiguration().getService(
- new QName(serviceName)).getOperation(
- new QName(operationName));
- od.engageModule(
- configContext.getAxisConfiguration().getModule(new QName(moduleName)));
- req.getSession().setAttribute(
- Constants.ENGAGE_STATUS,
- moduleName + " module engaged to the operation Successfully");
+ configContext.getAxisConfiguration().getService(new QName(serviceName)).getOperation(new QName(operationName));
+ od.engageModule(configContext.getAxisConfiguration().getModule(new QName(moduleName)));
+ req.getSession().setAttribute(Constants.ENGAGE_STATUS,
+ moduleName + " module engaged to the operation Successfully");
} catch (AxisFault axisFault) {
req.getSession().setAttribute(Constants.ENGAGE_STATUS, axisFault.getMessage());
}
@@ -281,6 +271,7 @@
req.getSession().setAttribute("operation", null);
res.sendRedirect(ENGAGE_TO_OPERATION_JSP_NAME);
}
+
private void engageModulesToService(HttpServletRequest req, HttpServletResponse res)
throws IOException {
HashMap modules =
@@ -296,12 +287,9 @@
if (serviceName != null && moduleName != null) {
try {
- configContext.getAxisConfiguration().getService(
- new QName(serviceName)).engageModule(
- configContext.getAxisConfiguration().getModule(new QName(moduleName)));
- req.getSession().setAttribute(
- Constants.ENGAGE_STATUS,
- moduleName + " module engaged to the service Successfully");
+ configContext.getAxisConfiguration().getService(new QName(serviceName)).engageModule(configContext.getAxisConfiguration().getModule(new QName(moduleName)));
+ req.getSession().setAttribute(Constants.ENGAGE_STATUS,
+ moduleName + " module engaged to the service Successfully");
} catch (AxisFault axisFault) {
req.getSession().setAttribute(Constants.ENGAGE_STATUS, axisFault.getMessage());
}
@@ -328,9 +316,8 @@
private void viewGlobalHandlers(HttpServletRequest req, HttpServletResponse res)
throws IOException {
- req.getSession().setAttribute(
- Constants.GLOBAL_HANDLERS,
- configContext.getAxisConfiguration());
+ req.getSession().setAttribute(Constants.GLOBAL_HANDLERS,
+ configContext.getAxisConfiguration());
res.sendRedirect(VIEW_GLOBAL_HANDLERS_JSP_NAME);
}
@@ -338,16 +325,15 @@
throws IOException {
String service = (String) req.getParameter("service");
if (service != null) {
- req.getSession().setAttribute(
- Constants.SERVICE_HANDLERS,
- configContext.getAxisConfiguration().getService(new QName(service)));
+ req.getSession().setAttribute(Constants.SERVICE_HANDLERS,
+ configContext.getAxisConfiguration().getService(new QName(service)));
}
res.sendRedirect(VIEW_SERVICE_HANDLERS_JSP_NAME);
}
private void listPhases(HttpServletRequest req, HttpServletResponse res) throws IOException {
ArrayList phaselist = new ArrayList();
- PhasesInfo info = ((AxisConfigurationImpl)configContext.getAxisConfiguration()).getPhasesinfo();
+ PhasesInfo info = ((AxisConfigurationImpl) configContext.getAxisConfiguration()).getPhasesinfo();
phaselist.add(info.getINPhases());
phaselist.add(info.getIN_FaultPhases());
phaselist.add(info.getOUTPhases());
@@ -377,11 +363,11 @@
if ((services != null) && !services.isEmpty()) {
Object serviceObj = services.get(new QName(serviceName));
if (serviceObj != null) {
- if(wsdl != null){
+ if (wsdl != null) {
// StringWriter writer = new StringWriter();
res.setContentType("text/xml");
PrintWriter out_writer = new PrintWriter(out);
- ((ServiceDescription)serviceObj).printWSDL(out_writer,filePart);
+ ((ServiceDescription) serviceObj).printWSDL(out_writer, filePart);
// String wsdl_value = writer.toString().trim() ;
// if(wsdl_value == null || wsdl_value.trim().equals("")){
// wsdl_value = "WSDL is not available!!!";
@@ -395,7 +381,7 @@
out.close();
wsdl = null;
return;
- } else {
+ } else {
req.getSession().setAttribute(Constants.SINGLE_SERVICE, serviceObj);
}
}
Modified: webservices/axis/trunk/java/modules/core/src/org/apache/axis2/transport/http/ServletBasedOutTransportInfo.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/core/src/org/apache/axis2/transport/http/ServletBasedOutTransportInfo.java?rev=210150&r1=210149&r2=210150&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/core/src/org/apache/axis2/transport/http/ServletBasedOutTransportInfo.java (original)
+++ webservices/axis/trunk/java/modules/core/src/org/apache/axis2/transport/http/ServletBasedOutTransportInfo.java Mon Jul 11 08:49:30 2005
@@ -21,10 +21,12 @@
public class ServletBasedOutTransportInfo implements HTTPOutTransportInfo {
private HttpServletResponse response;
- public ServletBasedOutTransportInfo(HttpServletResponse response){
+
+ public ServletBasedOutTransportInfo(HttpServletResponse response) {
this.response = response;
}
- public void setContentType(String contentType){
+
+ public void setContentType(String contentType) {
response.setContentType(contentType);
}
}
Modified: webservices/axis/trunk/java/modules/core/src/org/apache/axis2/transport/http/SimpleHTTPOutTransportInfo.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/core/src/org/apache/axis2/transport/http/SimpleHTTPOutTransportInfo.java?rev=210150&r1=210149&r2=210150&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/core/src/org/apache/axis2/transport/http/SimpleHTTPOutTransportInfo.java (original)
+++ webservices/axis/trunk/java/modules/core/src/org/apache/axis2/transport/http/SimpleHTTPOutTransportInfo.java Mon Jul 11 08:49:30 2005
@@ -17,9 +17,10 @@
*/
package org.apache.axis2.transport.http;
-public class SimpleHTTPOutTransportInfo implements HTTPOutTransportInfo{
+public class SimpleHTTPOutTransportInfo implements HTTPOutTransportInfo {
private SimpleHTTPOutputStream outInfo;
- public SimpleHTTPOutTransportInfo(SimpleHTTPOutputStream outInfo){
+
+ public SimpleHTTPOutTransportInfo(SimpleHTTPOutputStream outInfo) {
this.outInfo = outInfo;
}
Modified: webservices/axis/trunk/java/modules/core/src/org/apache/axis2/transport/http/SimpleHTTPOutputStream.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/core/src/org/apache/axis2/transport/http/SimpleHTTPOutputStream.java?rev=210150&r1=210149&r2=210150&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/core/src/org/apache/axis2/transport/http/SimpleHTTPOutputStream.java (original)
+++ webservices/axis/trunk/java/modules/core/src/org/apache/axis2/transport/http/SimpleHTTPOutputStream.java Mon Jul 11 08:49:30 2005
@@ -27,16 +27,15 @@
private boolean written = false;
private boolean chuncked = false;
private String contentType = null;
-
- public SimpleHTTPOutputStream(
- OutputStream out,boolean chuncked)
- throws AxisFault {
+
+ public SimpleHTTPOutputStream(OutputStream out, boolean chuncked)
+ throws AxisFault {
super(out);
this.chuncked = chuncked;
}
public void write(byte[] b) throws IOException {
- if(!written){
+ if (!written) {
writeHeader();
}
out.write(b);
@@ -49,7 +48,7 @@
* @throws java.io.IOException
*/
public void write(byte[] b, int off, int len) throws IOException {
- if(!written){
+ if (!written) {
writeHeader();
}
out.write(b, off, len);
@@ -60,28 +59,28 @@
* @throws java.io.IOException
*/
public void write(int b) throws IOException {
- if(!written){
+ if (!written) {
writeHeader();
}
out.write(b);
}
- public void writeHeader() throws IOException{
+ public void writeHeader() throws IOException {
StringBuffer buf = new StringBuffer();
- if(chuncked){
+ if (chuncked) {
buf.append(new String(HTTPConstants.HEADER_PROTOCOL_11)).append(" ");
buf.append(new String(HTTPConstants.OK)).append("\n");
buf.append(HTTPConstants.HEADER_TRANSFER_ENCODING).append(": ");
buf.append(HTTPConstants.HEADER_TRANSFER_ENCODING_CHUNKED).append("\n");
- if(contentType != null){
+ if (contentType != null) {
buf.append(HTTPConstants.HEADER_CONTENT_TYPE).append(": ");
buf.append(contentType).append("\n");
}
buf.append("\n");
- }else{
+ } else {
buf.append(new String(HTTPConstants.HTTP));
buf.append(new String(HTTPConstants.OK)).append("\n");
- if(contentType != null){
+ if (contentType != null) {
buf.append(HTTPConstants.HEADER_CONTENT_TYPE).append(": ");
buf.append(contentType).append("\n");
}
@@ -89,34 +88,34 @@
}
out.write(buf.toString().getBytes());
written = true;
- if(chuncked){
+ if (chuncked) {
out.flush();
- out = new ChunkedOutputStream(out);
+ out = new ChunkedOutputStream(out);
}
-
+
}
public void finalize() throws IOException {
if (!written) {
out.write(new String(HTTPConstants.NOCONTENT).getBytes());
written = true;
- } else{
+ } else {
out.flush();
}
- if(chuncked){
+ if (chuncked) {
//TODO sometimes the out stream is closed by the client
try {
- ((ChunkedOutputStream)out).eos();
+ ((ChunkedOutputStream) out).eos();
} catch (IOException e) {
}
}
}
-
+
/* (non-Javadoc)
* @see java.io.OutputStream#close()
*/
public void close() throws IOException {
- if(!written){
+ if (!written) {
finalize();
}
super.close();
Modified: webservices/axis/trunk/java/modules/core/src/org/apache/axis2/transport/http/SimpleHTTPServer.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/core/src/org/apache/axis2/transport/http/SimpleHTTPServer.java?rev=210150&r1=210149&r2=210150&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/core/src/org/apache/axis2/transport/http/SimpleHTTPServer.java (original)
+++ webservices/axis/trunk/java/modules/core/src/org/apache/axis2/transport/http/SimpleHTTPServer.java Mon Jul 11 08:49:30 2005
@@ -62,7 +62,7 @@
* latch to true if stop() is called
*/
private boolean stopped = false;
-
+
private boolean chuncked = false;
private int port;
@@ -114,18 +114,18 @@
public void run() {
try {
while (!stopped) {
- // Accept and process requests from the socket
- Socket socket = null;
- try {
- socket = serverSocket.accept();
- } catch (java.io.InterruptedIOException iie) {
- } catch (Exception e) {
- log.debug(e);
- break;
- }
- if (socket != null) {
- configurationContext.getThreadPool().addWorker(new HTTPWorker(configurationContext,socket));
- }
+ // Accept and process requests from the socket
+ Socket socket = null;
+ try {
+ socket = serverSocket.accept();
+ } catch (java.io.InterruptedIOException iie) {
+ } catch (Exception e) {
+ log.debug(e);
+ break;
+ }
+ if (socket != null) {
+ configurationContext.getThreadPool().addWorker(new HTTPWorker(configurationContext, socket));
+ }
}
} catch (IOException e) {
log.error(e);
@@ -160,10 +160,10 @@
* @throws Exception
*/
public void start() throws AxisFault {
- if(serverSocket == null){
+ if (serverSocket == null) {
serverSocket = ListenerManager.openSocket(port);
}
-
+
Thread newThread = new Thread(this);
newThread.start();
}
@@ -230,35 +230,34 @@
ServerSocket serverSoc = null;
serverSoc = new ServerSocket(Integer.parseInt(args[1]));
SimpleHTTPServer receiver = new SimpleHTTPServer(args[0], serverSoc);
- System.out.println(
- "starting SimpleHTTPServer in port "
- + args[1]
- + " using the repository "
- + new File(args[0]).getAbsolutePath());
+ System.out.println("starting SimpleHTTPServer in port "
+ + args[1]
+ + " using the repository "
+ + new File(args[0]).getAbsolutePath());
receiver.setServerSocket(serverSoc);
Thread thread = new Thread(receiver);
thread.setDaemon(true);
try {
System.out.println("[Axis2] Using the Repository " + new File(args[0]).getAbsolutePath());
- System.out.println("[Axis2] Starting the SimpleHTTPServer on port "+ args[1]);
+ System.out.println("[Axis2] Starting the SimpleHTTPServer on port " + args[1]);
thread.start();
- System.out.println("[Axis2] SimpleHTTPServer started");
+ System.out.println("[Axis2] SimpleHTTPServer started");
System.in.read();
} finally {
receiver.stop();
}
}
+
/* (non-Javadoc)
* @see org.apache.axis2.transport.TransportListener#replyToEPR(java.lang.String)
*/
public EndpointReference replyToEPR(String serviceName) {
- return new EndpointReference(
- AddressingConstants.WSA_REPLY_TO,
- "http://127.0.0.1:" + (serverSocket.getLocalPort()) + "/axis/services/" + serviceName);
+ return new EndpointReference(AddressingConstants.WSA_REPLY_TO,
+ "http://127.0.0.1:" + (serverSocket.getLocalPort()) + "/axis/services/" + serviceName);
}
public void init(ConfigurationContext axisConf, TransportInDescription transprtIn)
- throws AxisFault {
+ throws AxisFault {
this.configurationContext = axisConf;
Parameter param = transprtIn.getParameter(PARAM_PORT);
if (param != null) {
Modified: webservices/axis/trunk/java/modules/core/src/org/apache/axis2/transport/local/LocalTransportReceiver.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/core/src/org/apache/axis2/transport/local/LocalTransportReceiver.java?rev=210150&r1=210149&r2=210150&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/core/src/org/apache/axis2/transport/local/LocalTransportReceiver.java (original)
+++ webservices/axis/trunk/java/modules/core/src/org/apache/axis2/transport/local/LocalTransportReceiver.java Mon Jul 11 08:49:30 2005
@@ -42,6 +42,7 @@
public static ConfigurationContext CONFIG_CONTEXT;
private ConfigurationContext confContext;
+
public LocalTransportReceiver(ConfigurationContext configContext) {
confContext = configContext;
}
@@ -53,18 +54,15 @@
public void processMessage(InputStream in, EndpointReference to) throws AxisFault {
try {
TransportInDescription tIn =
- confContext.getAxisConfiguration().getTransportIn(
- new QName(Constants.TRANSPORT_LOCAL));
+ confContext.getAxisConfiguration().getTransportIn(new QName(Constants.TRANSPORT_LOCAL));
TransportOutDescription tOut =
- confContext.getAxisConfiguration().getTransportOut(
- new QName(Constants.TRANSPORT_LOCAL));
+ confContext.getAxisConfiguration().getTransportOut(new QName(Constants.TRANSPORT_LOCAL));
MessageContext msgCtx = new MessageContext(confContext, tIn, tOut);
msgCtx.setTo(to);
msgCtx.setServerSide(true);
XMLStreamReader reader =
- XMLInputFactory.newInstance().createXMLStreamReader(
- new BufferedReader(new InputStreamReader(in)));
+ XMLInputFactory.newInstance().createXMLStreamReader(new BufferedReader(new InputStreamReader(in)));
StAXBuilder builder = new StAXSOAPModelBuilder(reader);
msgCtx.setEnvelope((SOAPEnvelope) builder.getDocumentElement());
Modified: webservices/axis/trunk/java/modules/core/src/org/apache/axis2/transport/local/LocalTransportSender.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/core/src/org/apache/axis2/transport/local/LocalTransportSender.java?rev=210150&r1=210149&r2=210150&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/core/src/org/apache/axis2/transport/local/LocalTransportSender.java (original)
+++ webservices/axis/trunk/java/modules/core/src/org/apache/axis2/transport/local/LocalTransportSender.java Mon Jul 11 08:49:30 2005
@@ -27,6 +27,7 @@
public class LocalTransportSender extends AbstractTransportSender {
private ByteArrayOutputStream out;
+
public LocalTransportSender() {
}
@@ -35,8 +36,8 @@
return out;
}
- public void finalizeSendWithToAddress(MessageContext msgContext,OutputStream out)
- throws AxisFault {
+ public void finalizeSendWithToAddress(MessageContext msgContext, OutputStream out)
+ throws AxisFault {
try {
InputStream in = new ByteArrayInputStream(this.out.toByteArray());
LocalTransportReceiver localTransportReceiver = new LocalTransportReceiver();
@@ -51,7 +52,7 @@
/* (non-Javadoc)
* @see org.apache.axis2.transport.AbstractTransportSender#openTheConnection(org.apache.axis2.addressing.EndpointReference)
*/
- protected OutputStream openTheConnection(EndpointReference epr,MessageContext msgContext) throws AxisFault {
+ protected OutputStream openTheConnection(EndpointReference epr, MessageContext msgContext) throws AxisFault {
//out = new PipedOutputStream();
out = new ByteArrayOutputStream();
return out;
@@ -60,17 +61,15 @@
/* (non-Javadoc)
* @see org.apache.axis2.transport.AbstractTransportSender#startSendWithOutputStreamFromIncomingConnection(org.apache.axis2.context.MessageContext, java.io.Writer)
*/
- public OutputStream startSendWithOutputStreamFromIncomingConnection(
- MessageContext msgContext,
- OutputStream out)
- throws AxisFault {
+ public OutputStream startSendWithOutputStreamFromIncomingConnection(MessageContext msgContext,
+ OutputStream out)
+ throws AxisFault {
throw new UnsupportedOperationException();
}
- public void finalizeSendWithOutputStreamFromIncomingConnection(
- MessageContext msgContext,OutputStream out)
- throws AxisFault {
+ public void finalizeSendWithOutputStreamFromIncomingConnection(MessageContext msgContext, OutputStream out)
+ throws AxisFault {
throw new UnsupportedOperationException();
}
Modified: webservices/axis/trunk/java/modules/core/src/org/apache/axis2/transport/mail/EMailSender.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/core/src/org/apache/axis2/transport/mail/EMailSender.java?rev=210150&r1=210149&r2=210150&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/core/src/org/apache/axis2/transport/mail/EMailSender.java (original)
+++ webservices/axis/trunk/java/modules/core/src/org/apache/axis2/transport/mail/EMailSender.java Mon Jul 11 08:49:30 2005
@@ -28,9 +28,9 @@
/**
* @author hemapani
- *
- * To change the template for this generated type comment go to
- * Window>Preferences>Java>Code Generation>Code and Comments
+ * <p/>
+ * To change the template for this generated type comment go to
+ * Window>Preferences>Java>Code Generation>Code and Comments
*/
public class EMailSender {
private String user;
@@ -48,7 +48,7 @@
public void send(String subject, String targetEmail, String message) throws AxisFault {
try {
final PasswordAuthentication authentication =
- new PasswordAuthentication(user, password);
+ new PasswordAuthentication(user, password);
Properties props = new Properties();
props.put("mail.user", user);
props.put("mail.host", host);
@@ -65,9 +65,9 @@
msg.setFrom(new InternetAddress((user)));
msg.addRecipient(Message.RecipientType.TO, new InternetAddress(targetEmail));
msg.setSubject(subject);
-
+
msg.addHeaderLine("Content-Type: text/plain; charset=us-ascii");
-
+
msg.setText(message);
msg.setHeader("Content-Transfer-Encoding", "7bit");
Transport.send(msg);
Modified: webservices/axis/trunk/java/modules/core/src/org/apache/axis2/transport/mail/MailClient.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/core/src/org/apache/axis2/transport/mail/MailClient.java?rev=210150&r1=210149&r2=210150&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/core/src/org/apache/axis2/transport/mail/MailClient.java (original)
+++ webservices/axis/trunk/java/modules/core/src/org/apache/axis2/transport/mail/MailClient.java Mon Jul 11 08:49:30 2005
@@ -1,103 +1,92 @@
package org.apache.axis2.transport.mail;
+
import javax.mail.*;
import javax.mail.internet.MimeMessage;
import java.io.IOException;
import java.util.Properties;
public class MailClient
- extends Authenticator
-{
- public static final int SHOW_MESSAGES = 1;
- public static final int CLEAR_MESSAGES = 2;
- public static final int SHOW_AND_CLEAR =
- SHOW_MESSAGES + CLEAR_MESSAGES;
-
- protected String from;
- protected Session session;
- protected PasswordAuthentication authentication;
-
- public MailClient(String user, String host)
- {
- this(user, host, user, false);
- }
-
- public MailClient(String user, String host, String password)
- {
- this(user, host, password , false);
- }
-
- public MailClient(String user, String host, String password, boolean debug)
- {
- from = user + '@' + host;
- authentication = new PasswordAuthentication(user, password);
- Properties props = new Properties();
- props.put("mail.user", user);
- props.put("mail.host", host);
- props.put("mail.debug", debug ? "true" : "false");
- props.put("mail.store.protocol", "pop3");
- props.put("mail.transport.protocol", "smtp");
- session = Session.getInstance(props, this);
- }
-
- public PasswordAuthentication getPasswordAuthentication()
- {
- return authentication;
- }
-
- public void sendMessage(
- String to, String subject, String content, String soapAction)
- throws MessagingException
- {
- System.out.println("SENDING message from " + from + " to " + to);
- System.out.println();
- MimeMessage msg = new MimeMessage(session);
- msg.setHeader("transport.mail.soapaction",soapAction);
- msg.addRecipients(Message.RecipientType.TO, to);
- msg.setSubject(subject);
- msg.setText(content);
- Transport.send(msg);
- }
-
- public int checkInbox(int mode)
- throws MessagingException, IOException
- {
- int numMessages = 0;
- if (mode == 0) return 0;
- boolean show = (mode & SHOW_MESSAGES) > 0;
- boolean clear = (mode & CLEAR_MESSAGES) > 0;
- String action =
- (show ? "Show" : "") +
- (show && clear ? " and " : "") +
- (clear ? "Clear" : "");
- System.out.println(action + " INBOX for " + from);
- Store store = session.getStore();
- store.connect();
- Folder root = store.getDefaultFolder();
- Folder inbox = root.getFolder("inbox");
- inbox.open(Folder.READ_WRITE);
- Message[] msgs = inbox.getMessages();
- numMessages = msgs.length;
- if (msgs.length == 0 && show)
- {
- System.out.println("No messages in inbox");
- }
- for (int i = 0; i < msgs.length; i++)
- {
- MimeMessage msg = (MimeMessage)msgs[i];
- if (show)
- {
- System.out.println(" From: " + msg.getFrom()[0]);
- System.out.println(" Subject: " + msg.getSubject());
- System.out.println(" Content: " + msg.getContent());
- }
- if (clear)
- {
- msg.setFlag(Flags.Flag.DELETED, true);
- }
- }
- inbox.close(true);
- store.close();
- System.out.println();
- return numMessages;
- }
+ extends Authenticator {
+ public static final int SHOW_MESSAGES = 1;
+ public static final int CLEAR_MESSAGES = 2;
+ public static final int SHOW_AND_CLEAR =
+ SHOW_MESSAGES + CLEAR_MESSAGES;
+
+ protected String from;
+ protected Session session;
+ protected PasswordAuthentication authentication;
+
+ public MailClient(String user, String host) {
+ this(user, host, user, false);
+ }
+
+ public MailClient(String user, String host, String password) {
+ this(user, host, password, false);
+ }
+
+ public MailClient(String user, String host, String password, boolean debug) {
+ from = user + '@' + host;
+ authentication = new PasswordAuthentication(user, password);
+ Properties props = new Properties();
+ props.put("mail.user", user);
+ props.put("mail.host", host);
+ props.put("mail.debug", debug ? "true" : "false");
+ props.put("mail.store.protocol", "pop3");
+ props.put("mail.transport.protocol", "smtp");
+ session = Session.getInstance(props, this);
+ }
+
+ public PasswordAuthentication getPasswordAuthentication() {
+ return authentication;
+ }
+
+ public void sendMessage(String to, String subject, String content, String soapAction)
+ throws MessagingException {
+ System.out.println("SENDING message from " + from + " to " + to);
+ System.out.println();
+ MimeMessage msg = new MimeMessage(session);
+ msg.setHeader("transport.mail.soapaction", soapAction);
+ msg.addRecipients(Message.RecipientType.TO, to);
+ msg.setSubject(subject);
+ msg.setText(content);
+ Transport.send(msg);
+ }
+
+ public int checkInbox(int mode)
+ throws MessagingException, IOException {
+ int numMessages = 0;
+ if (mode == 0) return 0;
+ boolean show = (mode & SHOW_MESSAGES) > 0;
+ boolean clear = (mode & CLEAR_MESSAGES) > 0;
+ String action =
+ (show ? "Show" : "") +
+ (show && clear ? " and " : "") +
+ (clear ? "Clear" : "");
+ System.out.println(action + " INBOX for " + from);
+ Store store = session.getStore();
+ store.connect();
+ Folder root = store.getDefaultFolder();
+ Folder inbox = root.getFolder("inbox");
+ inbox.open(Folder.READ_WRITE);
+ Message[] msgs = inbox.getMessages();
+ numMessages = msgs.length;
+ if (msgs.length == 0 && show) {
+ System.out.println("No messages in inbox");
+ }
+ for (int i = 0; i < msgs.length; i++) {
+ MimeMessage msg = (MimeMessage) msgs[i];
+ if (show) {
+ System.out.println(" From: " + msg.getFrom()[0]);
+ System.out.println(" Subject: " + msg.getSubject());
+ System.out.println(" Content: " + msg.getContent());
+ }
+ if (clear) {
+ msg.setFlag(Flags.Flag.DELETED, true);
+ }
+ }
+ inbox.close(true);
+ store.close();
+ System.out.println();
+ return numMessages;
+ }
}
Modified: webservices/axis/trunk/java/modules/core/src/org/apache/axis2/transport/mail/MailConstants.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/core/src/org/apache/axis2/transport/mail/MailConstants.java?rev=210150&r1=210149&r2=210150&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/core/src/org/apache/axis2/transport/mail/MailConstants.java (original)
+++ webservices/axis/trunk/java/modules/core/src/org/apache/axis2/transport/mail/MailConstants.java Mon Jul 11 08:49:30 2005
@@ -13,8 +13,6 @@
public final static String SUBJECT = "transport.mail.subject";
-
-
public final static String POP3_HOST = "transport.mail.pop3.host";
public final static String POP3_USER = "transport.mail.pop3.user";
@@ -23,15 +21,13 @@
public final static String RAPLY_TO = "transport.mail.replyToAddress";
public final static String HEADER_SOAP_ACTION = "transport.mail.soapaction";
-
+
public final static String CONTENT_TYPE = "transport.mail.contenttype";
-
+
public final static String CONTENT_LOCAION = "transport.mail.contentlocation";
-
-
-
-
- public final static String SMTP_HOST = "transport.mail.smtp.host";
+
+
+ public final static String SMTP_HOST = "transport.mail.smtp.host";
public final static String SMTP_USER = "transport.mail.smtp.user";
public final static String SMTP_PASSWORD = "transport.mail.smtp.password";
public final static String SMTP_PORT = "transport.mail.smtp.port";
Modified: webservices/axis/trunk/java/modules/core/src/org/apache/axis2/transport/mail/MailTransportSender.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/core/src/org/apache/axis2/transport/mail/MailTransportSender.java?rev=210150&r1=210149&r2=210150&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/core/src/org/apache/axis2/transport/mail/MailTransportSender.java (original)
+++ webservices/axis/trunk/java/modules/core/src/org/apache/axis2/transport/mail/MailTransportSender.java Mon Jul 11 08:49:30 2005
@@ -33,60 +33,59 @@
private String password;
private String smtpPort = "25";
- private ByteArrayOutputStream byteArrayOutputStream;
+ private ByteArrayOutputStream byteArrayOutputStream;
public MailTransportSender() {
}
- public void finalizeSendWithToAddress(MessageContext msgContext,OutputStream out)
- throws AxisFault {
- try {
- TransportOutDescription transportOut = msgContext.getTransportOut();
- user = Utils.getParameterValue(transportOut.getParameter(MailConstants.SMTP_USER));
- host = Utils.getParameterValue(transportOut.getParameter(MailConstants.SMTP_HOST));
- password =
+ public void finalizeSendWithToAddress(MessageContext msgContext, OutputStream out)
+ throws AxisFault {
+ try {
+ TransportOutDescription transportOut = msgContext.getTransportOut();
+ user = Utils.getParameterValue(transportOut.getParameter(MailConstants.SMTP_USER));
+ host = Utils.getParameterValue(transportOut.getParameter(MailConstants.SMTP_HOST));
+ password =
Utils.getParameterValue(transportOut.getParameter(MailConstants.SMTP_PASSWORD));
- smtpPort = Utils.getParameterValue(transportOut.getParameter(MailConstants.SMTP_PORT));
- if (user != null && host != null && password != null && smtpPort != null) {
- EMailSender sender = new EMailSender(user, host, smtpPort, password);
-
- //TODO this is just a temporary hack, fix this to use input streams
-
-
-
-
- String eprAddress = msgContext.getTo().getAddress();
- int index = eprAddress.indexOf('/');
- String subject = "";
- String email = null;
- if(index >= 0){
- subject = eprAddress.substring(index+1);
- email = eprAddress.substring(0,index);
- }else{
- email = eprAddress;
- }
-
- System.out.println(subject);
- System.out.println(email);
+ smtpPort = Utils.getParameterValue(transportOut.getParameter(MailConstants.SMTP_PORT));
+ if (user != null && host != null && password != null && smtpPort != null) {
+ EMailSender sender = new EMailSender(user, host, smtpPort, password);
+
+ //TODO this is just a temporary hack, fix this to use input streams
+
- sender.send(subject, email,new String(byteArrayOutputStream.toByteArray()));
- } else {
- throw new AxisFault(
- "user, port, host or password not set, "
- + " [user null = "
- + (user == null)
- + ", password null= "
- + (password == null)
- + ", host null "
- + (host == null)
- + ",port null "
- + (smtpPort == null));
+
+ String eprAddress = msgContext.getTo().getAddress();
+ int index = eprAddress.indexOf('/');
+ String subject = "";
+ String email = null;
+ if (index >= 0) {
+ subject = eprAddress.substring(index + 1);
+ email = eprAddress.substring(0, index);
+ } else {
+ email = eprAddress;
}
- } catch (IOException e) {
- throw new AxisFault(e);
+
+ System.out.println(subject);
+ System.out.println(email);
+
+ sender.send(subject, email, new String(byteArrayOutputStream.toByteArray()));
+ } else {
+ throw new AxisFault("user, port, host or password not set, "
+ + " [user null = "
+ + (user == null)
+ + ", password null= "
+ + (password == null)
+ + ", host null "
+ + (host == null)
+ + ",port null "
+ + (smtpPort == null));
+
}
+ } catch (IOException e) {
+ throw new AxisFault(e);
+ }
}
@@ -95,23 +94,23 @@
return out;
}
- protected OutputStream openTheConnection(EndpointReference epr,MessageContext msgContext) throws AxisFault {
+ protected OutputStream openTheConnection(EndpointReference epr, MessageContext msgContext) throws AxisFault {
byteArrayOutputStream = new ByteArrayOutputStream();
- return byteArrayOutputStream;
+ return byteArrayOutputStream;
}
//Output Stream based cases are not supported
- public OutputStream startSendWithOutputStreamFromIncomingConnection(
- MessageContext msgContext,
- OutputStream out)
- throws AxisFault {
+ public OutputStream startSendWithOutputStreamFromIncomingConnection(MessageContext msgContext,
+ OutputStream out)
+ throws AxisFault {
throw new UnsupportedOperationException();
}
- public void finalizeSendWithOutputStreamFromIncomingConnection(
- MessageContext msgContext,OutputStream out)
- throws AxisFault {
+
+ public void finalizeSendWithOutputStreamFromIncomingConnection(MessageContext msgContext, OutputStream out)
+ throws AxisFault {
}
+
/* (non-Javadoc)
* @see org.apache.axis2.transport.TransportSender#cleanUp()
*/
Modified: webservices/axis/trunk/java/modules/core/src/org/apache/axis2/transport/mail/MailWorker.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/core/src/org/apache/axis2/transport/mail/MailWorker.java?rev=210150&r1=210149&r2=210150&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/core/src/org/apache/axis2/transport/mail/MailWorker.java (original)
+++ webservices/axis/trunk/java/modules/core/src/org/apache/axis2/transport/mail/MailWorker.java Mon Jul 11 08:49:30 2005
@@ -78,11 +78,11 @@
try {
TransportInDescription transportIn = reg.getAxisConfiguration().getTransportIn(new QName(Constants.TRANSPORT_MAIL));
TransportOutDescription transportOut = reg.getAxisConfiguration().getTransportOut(new QName(Constants.TRANSPORT_MAIL));
-
- msgContext = new MessageContext(reg,transportIn,transportOut);
+
+ msgContext = new MessageContext(reg, transportIn, transportOut);
msgContext.setServerSide(true);
msgContext.setProperty(MailConstants.CONTENT_TYPE, mimeMessage.getContentType());
- String soapAction = getMailHeader(MailConstants.HEADER_SOAP_ACTION);
+ String soapAction = getMailHeader(MailConstants.HEADER_SOAP_ACTION);
msgContext.setWSAAction(soapAction);
msgContext.setSoapAction(soapAction);
@@ -93,22 +93,21 @@
String replyTo = ((InternetAddress) mimeMessage.getReplyTo()[0]).getAddress();
if (replyTo != null) {
- msgContext.setReplyTo(
- new EndpointReference(AddressingConstants.WSA_REPLY_TO, replyTo));
+ msgContext.setReplyTo(new EndpointReference(AddressingConstants.WSA_REPLY_TO, replyTo));
}
-
+
String recepainets = ((InternetAddress) mimeMessage.getAllRecipients()[0]).getAddress();
if (recepainets != null) {
- msgContext.setTo(new EndpointReference(AddressingConstants.WSA_FROM, recepainets+ "/"+serviceURL));
- }else{
+ msgContext.setTo(new EndpointReference(AddressingConstants.WSA_FROM, recepainets + "/" + serviceURL));
+ } else {
throw new AxisFault("No receptineist found in the Email");
}
// add the SOAPEnvelope
String message = mimeMessage.getContent().toString();
- System.out.println("message["+message+"]");
+ System.out.println("message[" + message + "]");
ByteArrayInputStream bais =
- new ByteArrayInputStream(message.getBytes());
+ new ByteArrayInputStream(message.getBytes());
XMLStreamReader reader = XMLInputFactory.newInstance().createXMLStreamReader(bais);
StAXBuilder builder = new StAXSOAPModelBuilder(reader);
msgContext.setEnvelope((SOAPEnvelope) builder.getDocumentElement());
Modified: webservices/axis/trunk/java/modules/core/src/org/apache/axis2/transport/mail/SimpleMailListener.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/core/src/org/apache/axis2/transport/mail/SimpleMailListener.java?rev=210150&r1=210149&r2=210150&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/core/src/org/apache/axis2/transport/mail/SimpleMailListener.java (original)
+++ webservices/axis/trunk/java/modules/core/src/org/apache/axis2/transport/mail/SimpleMailListener.java Mon Jul 11 08:49:30 2005
@@ -39,10 +39,9 @@
* This is a simple implementation of an SMTP/POP3 server for processing SOAP
* requests via Apache's xml-axis. This is not intended for production use. Its
* intended uses are for demos, debugging, and performance profiling.
- *
+ *
* @author Davanum Srinivas <di...@yahoo.com>
* @author Rob Jellinghaus (robj@unrealities.com)
- *
* @author Chamil Thanthrimudalige <ch...@gmail.com>Changes done to make the
* Class work inside Axis 2.
*/
@@ -73,12 +72,11 @@
public SimpleMailListener() {
}
- public SimpleMailListener(
- String host,
- String port,
- String userid,
- String password,
- String dir) {
+ public SimpleMailListener(String host,
+ String port,
+ String userid,
+ String password,
+ String dir) {
this.host = host;
this.port = port;
this.user = userid;
@@ -97,12 +95,11 @@
}
}
- public SimpleMailListener(
- String host,
- String port,
- String userid,
- String password,
- ConfigurationContext er) {
+ public SimpleMailListener(String host,
+ String port,
+ String userid,
+ String password,
+ ConfigurationContext er) {
this.host = host;
this.port = port;
this.user = userid;
@@ -135,7 +132,7 @@
// Accept and process requests from the socket
if (!stopped) {
String logMessage =
- "Mail listner is being setup to listen to the address "
+ "Mail listner is being setup to listen to the address "
+ user
+ "@"
+ host
@@ -186,11 +183,10 @@
/**
* Start this server.
- *
+ * <p/>
* Spawns a worker thread to listen for HTTP requests.
- *
- * @param daemon
- * a boolean indicating if the thread should be a daemon.
+ *
+ * @param daemon a boolean indicating if the thread should be a daemon.
*/
public void start(boolean daemon) {
if (doThreads) {
@@ -211,7 +207,7 @@
/**
* Stop this server.
- *
+ * <p/>
* This will interrupt any pending accept().
*/
public void stop() {
@@ -236,25 +232,23 @@
ConfigurationContext configurationContext = builder.buildConfigurationContext(args[0]);
SimpleMailListener sas = new SimpleMailListener();
TransportInDescription transportIn =
- configurationContext.getAxisConfiguration().getTransportIn(
- new QName(Constants.TRANSPORT_MAIL));
+ configurationContext.getAxisConfiguration().getTransportIn(new QName(Constants.TRANSPORT_MAIL));
if (transportIn != null) {
sas.init(configurationContext, transportIn);
- System.out.println(
- "Starting the SimpleMailListener with repository "
- + new File(args[0]).getAbsolutePath());
+ System.out.println("Starting the SimpleMailListener with repository "
+ + new File(args[0]).getAbsolutePath());
sas.start();
} else {
- System.out.println(
- "Startup failed, mail transport not configured, Configure the mail trnasport in the axis2.xml file");
+ System.out.println("Startup failed, mail transport not configured, Configure the mail trnasport in the axis2.xml file");
}
}
}
+
/* (non-Javadoc)
* @see org.apache.axis2.transport.TransportListener#init(org.apache.axis2.context.ConfigurationContext, org.apache.axis2.description.TransportInDescription)
*/
public void init(ConfigurationContext configurationContext, TransportInDescription transportIn)
- throws AxisFault {
+ throws AxisFault {
this.configurationContext = configurationContext;
user = Utils.getParameterValue(transportIn.getParameter(MailConstants.POP3_USER));
@@ -263,16 +257,15 @@
port = Utils.getParameterValue(transportIn.getParameter(MailConstants.POP3_PORT));
replyTo = Utils.getParameterValue(transportIn.getParameter(MailConstants.RAPLY_TO));
if (user == null || host == null || password == null || port == null) {
- throw new AxisFault(
- "user, port, host or password not set, "
- + " [user null = "
- + (user == null)
- + ", password null= "
- + (password == null)
- + ", host null "
- + (host == null)
- + ",port null "
- + (port == null));
+ throw new AxisFault("user, port, host or password not set, "
+ + " [user null = "
+ + (user == null)
+ + ", password null= "
+ + (password == null)
+ + ", host null "
+ + (host == null)
+ + ",port null "
+ + (port == null));
}
}
@@ -282,7 +275,7 @@
*/
public EndpointReference replyToEPR(String serviceName) throws AxisFault {
// TODO Auto-generated method stub
- return new EndpointReference(AddressingConstants.WSA_REPLY_TO, replyTo+"/services/"+serviceName);
+ return new EndpointReference(AddressingConstants.WSA_REPLY_TO, replyTo + "/services/" + serviceName);
}
}
Modified: webservices/axis/trunk/java/modules/core/src/org/apache/axis2/transport/mail/server/MailAddress.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/core/src/org/apache/axis2/transport/mail/server/MailAddress.java?rev=210150&r1=210149&r2=210150&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/core/src/org/apache/axis2/transport/mail/server/MailAddress.java (original)
+++ webservices/axis/trunk/java/modules/core/src/org/apache/axis2/transport/mail/server/MailAddress.java Mon Jul 11 08:49:30 2005
@@ -5,20 +5,25 @@
/**
* This is a simple implementation to simplify the usage
* of the Addresses.
+ *
* @author Chamil Thanthrimudalige
*/
-public class MailAddress extends Address{
- String mailAddy = null;
- public MailAddress(String mAddy){
- this.mailAddy = mAddy;
- }
- public boolean equals(Object addr) {
- return this.mailAddy.equals(addr);
- }
- public String getType() {
- return "text/plain";
- }
- public String toString() {
- return this.mailAddy;
- }
+public class MailAddress extends Address {
+ String mailAddy = null;
+
+ public MailAddress(String mAddy) {
+ this.mailAddy = mAddy;
+ }
+
+ public boolean equals(Object addr) {
+ return this.mailAddy.equals(addr);
+ }
+
+ public String getType() {
+ return "text/plain";
+ }
+
+ public String toString() {
+ return this.mailAddy;
+ }
}
Modified: webservices/axis/trunk/java/modules/core/src/org/apache/axis2/transport/mail/server/MailConstants.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/core/src/org/apache/axis2/transport/mail/server/MailConstants.java?rev=210150&r1=210149&r2=210150&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/core/src/org/apache/axis2/transport/mail/server/MailConstants.java (original)
+++ webservices/axis/trunk/java/modules/core/src/org/apache/axis2/transport/mail/server/MailConstants.java Mon Jul 11 08:49:30 2005
@@ -6,9 +6,9 @@
*/
public interface MailConstants {
- public final int SMTP_SERVER_PORT = (1024 + 25);
- public final String SERVER_DOMAIN = "localhost";
- public final int POP_SERVER_PORT = (1024 + 110);
+ public final int SMTP_SERVER_PORT = (1024 + 25);
+ public final String SERVER_DOMAIN = "localhost";
+ public final int POP_SERVER_PORT = (1024 + 110);
public final String COMMAND_UNKNOWN = "550 Unknown command";
public final String COMMAND_EXIT = "EXIT";
Modified: webservices/axis/trunk/java/modules/core/src/org/apache/axis2/transport/mail/server/MailServer.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/core/src/org/apache/axis2/transport/mail/server/MailServer.java?rev=210150&r1=210149&r2=210150&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/core/src/org/apache/axis2/transport/mail/server/MailServer.java (original)
+++ webservices/axis/trunk/java/modules/core/src/org/apache/axis2/transport/mail/server/MailServer.java Mon Jul 11 08:49:30 2005
@@ -11,33 +11,34 @@
* @author Chamil Thanthrimudalige
*/
public class MailServer {
- Storage st = null;
- public ConfigurationContext configurationContext = null;
- protected static Log log = LogFactory.getLog(SimpleMailListener.class.getName());
-
- public MailServer(String dir, int popPort,int smtpPort) throws AxisFault {
- try {
- ConfigurationContextFactory builder = new ConfigurationContextFactory();
- configurationContext = builder.buildConfigurationContext(dir);
- } catch (Exception e) {
- log.error(e);
- }
- try {
- System.out.println("Sleeping for a bit to let the engine start up.");
- Thread.sleep(2000);
- } catch (InterruptedException e1) {
- log.error(e1);
- }
- st = new Storage();
- // Start up the two servers and lets have some fun. - CT
- SMTPServer smtpServer = new SMTPServer(st,configurationContext,smtpPort);
- smtpServer.start();
- POP3Server pop3Server = new POP3Server(st,popPort);
- pop3Server.start();
+ Storage st = null;
+ public ConfigurationContext configurationContext = null;
+ protected static Log log = LogFactory.getLog(SimpleMailListener.class.getName());
+ public MailServer(String dir, int popPort, int smtpPort) throws AxisFault {
+ try {
+ ConfigurationContextFactory builder = new ConfigurationContextFactory();
+ configurationContext = builder.buildConfigurationContext(dir);
+ } catch (Exception e) {
+ log.error(e);
+ }
+ try {
+ System.out.println("Sleeping for a bit to let the engine start up.");
+ Thread.sleep(2000);
+ } catch (InterruptedException e1) {
+ log.error(e1);
}
- public MailServer(ConfigurationContext configurationContext,int popPort,int smtpPort) throws AxisFault{
- this.configurationContext = configurationContext;
+ st = new Storage();
+ // Start up the two servers and lets have some fun. - CT
+ SMTPServer smtpServer = new SMTPServer(st, configurationContext, smtpPort);
+ smtpServer.start();
+ POP3Server pop3Server = new POP3Server(st, popPort);
+ pop3Server.start();
+
+ }
+
+ public MailServer(ConfigurationContext configurationContext, int popPort, int smtpPort) throws AxisFault {
+ this.configurationContext = configurationContext;
try {
System.out.println("Sleeping for a bit to let the engine start up.");
Thread.sleep(2000);
@@ -45,11 +46,11 @@
log.error(e1);
}
- st = new Storage();
- // Start up the two servers and lets have some fun. - CT
- SMTPServer smtpServer = new SMTPServer(st,configurationContext,smtpPort);
- smtpServer.start();
- POP3Server pop3Server = new POP3Server(st,popPort);
- pop3Server.start();
- }
+ st = new Storage();
+ // Start up the two servers and lets have some fun. - CT
+ SMTPServer smtpServer = new SMTPServer(st, configurationContext, smtpPort);
+ smtpServer.start();
+ POP3Server pop3Server = new POP3Server(st, popPort);
+ pop3Server.start();
+ }
}
Modified: webservices/axis/trunk/java/modules/core/src/org/apache/axis2/transport/mail/server/MailSorter.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/core/src/org/apache/axis2/transport/mail/server/MailSorter.java?rev=210150&r1=210149&r2=210150&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/core/src/org/apache/axis2/transport/mail/server/MailSorter.java (original)
+++ webservices/axis/trunk/java/modules/core/src/org/apache/axis2/transport/mail/server/MailSorter.java Mon Jul 11 08:49:30 2005
@@ -28,6 +28,7 @@
* being sent to the Axis engine. If a mail is to be sent to the engine then a
* new Axis engine is created using the configuration in the MailServer class
* and the receive method is called.
+ *
* @author Chamil Thanthrimudalige
*/
public class MailSorter {
@@ -35,22 +36,22 @@
private ArrayList sUsers = new ArrayList(); // Special users. They are hard coded for the time being to axis2-server@localhost and axis2-server@127.0.0.1
private ConfigurationContext configurationContext = null;
protected static Log log = LogFactory.getLog(MailSorter.class.getName());
-
- public MailSorter(Storage st,ConfigurationContext configurationContext){
+
+ public MailSorter(Storage st, ConfigurationContext configurationContext) {
this.st = st;
sUsers.add("axis2-server@localhost");
sUsers.add("axis2-server@127.0.0.1");
this.configurationContext = configurationContext;
}
- public void sort(String user, MimeMessage msg){
- if (sUsers.contains(user)){
+ public void sort(String user, MimeMessage msg) {
+ if (sUsers.contains(user)) {
processMail(configurationContext, msg);
} else {
st.addMail(user, msg);
}
}
-
+
public void processMail(ConfigurationContext confContext, MimeMessage mimeMessage) {
// create an Axis server
AxisEngine engine = new AxisEngine(confContext);
@@ -58,9 +59,9 @@
// create and initialize a message context
try {
msgContext =
- new MessageContext(confContext,
- confContext.getAxisConfiguration().getTransportIn(new QName(Constants.TRANSPORT_MAIL)),
- confContext.getAxisConfiguration().getTransportOut(new QName(Constants.TRANSPORT_MAIL)));
+ new MessageContext(confContext,
+ confContext.getAxisConfiguration().getTransportIn(new QName(Constants.TRANSPORT_MAIL)),
+ confContext.getAxisConfiguration().getTransportOut(new QName(Constants.TRANSPORT_MAIL)));
msgContext.setServerSide(true);
msgContext.setProperty(MailConstants.CONTENT_TYPE, mimeMessage.getContentType());
@@ -73,22 +74,21 @@
String replyTo = ((InternetAddress) mimeMessage.getReplyTo()[0]).getAddress();
if (replyTo != null) {
- msgContext.setReplyTo(
- new EndpointReference(AddressingConstants.WSA_REPLY_TO, replyTo));
+ msgContext.setReplyTo(new EndpointReference(AddressingConstants.WSA_REPLY_TO, replyTo));
}
-
+
String recepainets = ((InternetAddress) mimeMessage.getAllRecipients()[0]).getAddress();
-
-
+
+
if (recepainets != null) {
- msgContext.setTo(new EndpointReference(AddressingConstants.WSA_FROM, recepainets+ "/"+serviceURL));
+ msgContext.setTo(new EndpointReference(AddressingConstants.WSA_FROM, recepainets + "/" + serviceURL));
}
// add the SOAPEnvelope
String message = mimeMessage.getContent().toString();
- System.out.println("message["+message+"]");
+ System.out.println("message[" + message + "]");
ByteArrayInputStream bais =
- new ByteArrayInputStream(message.getBytes());
+ new ByteArrayInputStream(message.getBytes());
XMLStreamReader reader = XMLInputFactory.newInstance().createXMLStreamReader(bais);
StAXBuilder builder = new StAXSOAPModelBuilder(reader);
msgContext.setEnvelope((SOAPEnvelope) builder.getDocumentElement());
Modified: webservices/axis/trunk/java/modules/core/src/org/apache/axis2/transport/mail/server/POP3Server.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/core/src/org/apache/axis2/transport/mail/server/POP3Server.java?rev=210150&r1=210149&r2=210150&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/core/src/org/apache/axis2/transport/mail/server/POP3Server.java (original)
+++ webservices/axis/trunk/java/modules/core/src/org/apache/axis2/transport/mail/server/POP3Server.java Mon Jul 11 08:49:30 2005
@@ -1,12 +1,13 @@
package org.apache.axis2.transport.mail.server;
+import org.apache.axis2.engine.AxisFault;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;
-import org.apache.axis2.engine.AxisFault;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
/**
* @author Chamil Thanthrimudalige
*/
@@ -16,25 +17,25 @@
private ServerSocket serverSocket;
private Storage st = null;
-
- public POP3Server(Storage st,int port) throws AxisFault {
- this.st = st;
+
+ public POP3Server(Storage st, int port) throws AxisFault {
+ this.st = st;
try {
serverSocket = new ServerSocket(port);
System.out.println("Server started on port " + port);
- } catch(IOException e) {
+ } catch (IOException e) {
throw new AxisFault(e);
}
}
public void run() {
- while(true) {
+ while (true) {
try {
Socket socket = serverSocket.accept();
POP3Worker thread = new POP3Worker(socket, st);
thread.start();
- } catch(Exception e) {
- log.error(e);
+ } catch (Exception e) {
+ log.error(e);
}
}
}
Modified: webservices/axis/trunk/java/modules/core/src/org/apache/axis2/transport/mail/server/POP3Worker.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/core/src/org/apache/axis2/transport/mail/server/POP3Worker.java?rev=210150&r1=210149&r2=210150&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/core/src/org/apache/axis2/transport/mail/server/POP3Worker.java (original)
+++ webservices/axis/trunk/java/modules/core/src/org/apache/axis2/transport/mail/server/POP3Worker.java Mon Jul 11 08:49:30 2005
@@ -3,26 +3,26 @@
*/
package org.apache.axis2.transport.mail.server;
-import javax.mail.MessagingException;
-import javax.mail.internet.MimeMessage;
-
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import javax.mail.MessagingException;
+import javax.mail.internet.MimeMessage;
import java.io.*;
import java.net.Socket;
import java.util.ArrayList;
import java.util.StringTokenizer;
-public class POP3Worker extends Thread{
+public class POP3Worker extends Thread {
private Socket socket;
private Storage st;
boolean doneProcess = false;
protected static Log log = LogFactory.getLog(POP3Server.class.getName());
- int numDeleted = 0 ; //This is a small hack to get the deleting working with the ArrayList. To keep it simple.
+ int numDeleted = 0; //This is a small hack to get the deleting working with the ArrayList. To keep it simple.
+
public POP3Worker(Socket socket, Storage st) {
- this.socket = socket;
- this.st = st;
+ this.socket = socket;
+ this.st = st;
}
public void run() {
@@ -32,106 +32,108 @@
PrintWriter printWriter = new PrintWriter(socket.getOutputStream(), true);
- printWriter.println(MailConstants.OK+" POP3 server ready");
+ printWriter.println(MailConstants.OK + " POP3 server ready");
String s;
String ps; //ProcessedString
- while(!doneProcess) {
+ while (!doneProcess) {
s = bufferedReader.readLine();
processInput(s, printWriter);
}
socket.close();
- } catch(Exception e) {
+ } catch (Exception e) {
log.error(e);
}
}
+
ArrayList messages = new ArrayList();
- private void processInput(String input, PrintWriter printWriter){
- int listLen = (MailConstants.LIST+" ").length();
- byte[] CR_LF = new byte[] {0x0D, 0x0A};
- byte[] CR_LF_DOT_CR_LF = new byte[] { 0x0D, 0x0A, '.', 0x0D, 0x0A };
+
+ private void processInput(String input, PrintWriter printWriter) {
+ int listLen = (MailConstants.LIST + " ").length();
+ byte[] CR_LF = new byte[]{0x0D, 0x0A};
+ byte[] CR_LF_DOT_CR_LF = new byte[]{0x0D, 0x0A, '.', 0x0D, 0x0A};
String user = "";
- if(input==null) {
+ if (input == null) {
this.doneProcess = true; // This should not be happening
} else {
- ArrayList tokens = new ArrayList();
- StringTokenizer stk = new StringTokenizer(input);
- while (stk.hasMoreTokens()) {
- tokens.add(stk.nextToken());
- }
- if(((String)tokens.get(0)).equals(MailConstants.USER)) {
- user = (String)tokens.get(1);
- messages = st.popUserMails(user);
- printWriter.println(MailConstants.OK);
- } else if(((String)tokens.get(0)).equals(MailConstants.PASS)) {
- printWriter.println(MailConstants.OK); // Passwords are not checked.
- } else if(input.equals(MailConstants.QUIT)) {
- printWriter.println(MailConstants.OK + "POP3 server signing off");
- doneProcess=true;
- } else if(input.equals(MailConstants.STAT)) {
- printWriter.println(MailConstants.OK + messages.size() + " 1"); // We take the maildrop size as one.
- } else if(((String)tokens.get(0)).equals(MailConstants.LIST)) { // scan listing
- if(tokens.size() > 1) {
- try {
- int optArg = Integer.parseInt((String)tokens.get(1));
- int messageArrayIndex = optArg - 1;
- if((messageArrayIndex < messages.size()) && (messageArrayIndex >= 0)) { // that is OK careful with numbering
- printWriter.println(MailConstants.OK + messageArrayIndex + 1 + " 120"); // Mail size of 120 is just some number.
- } else {
- printWriter.println(MailConstants.ERR + "no such message, only " + (messages.size() + 1) + " messages in maildrop");
- }
- } catch(NumberFormatException e) {
- e.printStackTrace();
- printWriter.println(MailConstants.ERR + "problem passing the index. Index submited was " + (String)tokens.get(1));
- }
- } else {
- printWriter.println(MailConstants.OK+messages.size());
- for(int i=0; i<messages.size(); i++) {
- int messageIndex = i+1;
- printWriter.println(messageIndex + " 120"); // List out all the messages with a message size octet of 120
- }
- printWriter.println(".");
- }
- } else if(((String)tokens.get(0)).equals(MailConstants.RETR)) {
- String i = (String)tokens.get(1);
- try {
- int index = Integer.parseInt(i);
- printWriter.println(MailConstants.OK);
- MimeMessage m = (MimeMessage)messages.get(index-1);
-
- m.writeTo(socket.getOutputStream());
- //System.out.println("\n\n\n\n ========This is the mail========");
- //m.writeTo(System.out);//socket.getOutputStream());
- //System.out.println("\n\n\n\n ========This is the mail========");
-
- socket.getOutputStream().write(CR_LF_DOT_CR_LF);// This is a bit of a hack to get it working. Have to find a bette way to handle this.
- socket.getOutputStream().flush();
- } catch(NumberFormatException e) {
- printWriter.println(MailConstants.ERR);
- } catch (IOException e1) {
- printWriter.println(MailConstants.ERR);
- } catch (MessagingException e2) {
- printWriter.println(MailConstants.ERR);
- }
- } else if(((String)tokens.get(0)).equals(MailConstants.DELE)) {
- String smIndex = (String)tokens.get(1);
- try {
- int mIndex = Integer.parseInt(smIndex)-1 - numDeleted; // When one mail is deleted the index of the other mails will reduce. Asumed that the delete will occure from bottom up.
- if((mIndex >= 0) && (mIndex < messages.size())) {
- messages.remove(mIndex);
- numDeleted++;
- printWriter.println(MailConstants.OK);
- } else {
- printWriter.println(MailConstants.ERR);
- }
- } catch(NumberFormatException e) {
- printWriter.println(MailConstants.ERR);
- }
- } else if(((String)tokens.get(0)).equals(MailConstants.NOOP) || ((String)tokens.get(0)).equals(MailConstants.RSET)) {
- printWriter.println(MailConstants.OK);
- } else {
- printWriter.println(MailConstants.ERR);
- }
+ ArrayList tokens = new ArrayList();
+ StringTokenizer stk = new StringTokenizer(input);
+ while (stk.hasMoreTokens()) {
+ tokens.add(stk.nextToken());
+ }
+ if (((String) tokens.get(0)).equals(MailConstants.USER)) {
+ user = (String) tokens.get(1);
+ messages = st.popUserMails(user);
+ printWriter.println(MailConstants.OK);
+ } else if (((String) tokens.get(0)).equals(MailConstants.PASS)) {
+ printWriter.println(MailConstants.OK); // Passwords are not checked.
+ } else if (input.equals(MailConstants.QUIT)) {
+ printWriter.println(MailConstants.OK + "POP3 server signing off");
+ doneProcess = true;
+ } else if (input.equals(MailConstants.STAT)) {
+ printWriter.println(MailConstants.OK + messages.size() + " 1"); // We take the maildrop size as one.
+ } else if (((String) tokens.get(0)).equals(MailConstants.LIST)) { // scan listing
+ if (tokens.size() > 1) {
+ try {
+ int optArg = Integer.parseInt((String) tokens.get(1));
+ int messageArrayIndex = optArg - 1;
+ if ((messageArrayIndex < messages.size()) && (messageArrayIndex >= 0)) { // that is OK careful with numbering
+ printWriter.println(MailConstants.OK + messageArrayIndex + 1 + " 120"); // Mail size of 120 is just some number.
+ } else {
+ printWriter.println(MailConstants.ERR + "no such message, only " + (messages.size() + 1) + " messages in maildrop");
+ }
+ } catch (NumberFormatException e) {
+ e.printStackTrace();
+ printWriter.println(MailConstants.ERR + "problem passing the index. Index submited was " + (String) tokens.get(1));
+ }
+ } else {
+ printWriter.println(MailConstants.OK + messages.size());
+ for (int i = 0; i < messages.size(); i++) {
+ int messageIndex = i + 1;
+ printWriter.println(messageIndex + " 120"); // List out all the messages with a message size octet of 120
+ }
+ printWriter.println(".");
+ }
+ } else if (((String) tokens.get(0)).equals(MailConstants.RETR)) {
+ String i = (String) tokens.get(1);
+ try {
+ int index = Integer.parseInt(i);
+ printWriter.println(MailConstants.OK);
+ MimeMessage m = (MimeMessage) messages.get(index - 1);
+
+ m.writeTo(socket.getOutputStream());
+ //System.out.println("\n\n\n\n ========This is the mail========");
+ //m.writeTo(System.out);//socket.getOutputStream());
+ //System.out.println("\n\n\n\n ========This is the mail========");
+
+ socket.getOutputStream().write(CR_LF_DOT_CR_LF);// This is a bit of a hack to get it working. Have to find a bette way to handle this.
+ socket.getOutputStream().flush();
+ } catch (NumberFormatException e) {
+ printWriter.println(MailConstants.ERR);
+ } catch (IOException e1) {
+ printWriter.println(MailConstants.ERR);
+ } catch (MessagingException e2) {
+ printWriter.println(MailConstants.ERR);
+ }
+ } else if (((String) tokens.get(0)).equals(MailConstants.DELE)) {
+ String smIndex = (String) tokens.get(1);
+ try {
+ int mIndex = Integer.parseInt(smIndex) - 1 - numDeleted; // When one mail is deleted the index of the other mails will reduce. Asumed that the delete will occure from bottom up.
+ if ((mIndex >= 0) && (mIndex < messages.size())) {
+ messages.remove(mIndex);
+ numDeleted++;
+ printWriter.println(MailConstants.OK);
+ } else {
+ printWriter.println(MailConstants.ERR);
+ }
+ } catch (NumberFormatException e) {
+ printWriter.println(MailConstants.ERR);
+ }
+ } else if (((String) tokens.get(0)).equals(MailConstants.NOOP) || ((String) tokens.get(0)).equals(MailConstants.RSET)) {
+ printWriter.println(MailConstants.OK);
+ } else {
+ printWriter.println(MailConstants.ERR);
+ }
}
}
}
Modified: webservices/axis/trunk/java/modules/core/src/org/apache/axis2/transport/mail/server/SMTPServer.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/core/src/org/apache/axis2/transport/mail/server/SMTPServer.java?rev=210150&r1=210149&r2=210150&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/core/src/org/apache/axis2/transport/mail/server/SMTPServer.java (original)
+++ webservices/axis/trunk/java/modules/core/src/org/apache/axis2/transport/mail/server/SMTPServer.java Mon Jul 11 08:49:30 2005
@@ -12,24 +12,26 @@
* @author Chamikara Jayalath
*/
-public class SMTPServer extends Thread{
- private Storage st;
+public class SMTPServer extends Thread {
+ private Storage st;
private ConfigurationContext configurationContext;
private int port;
- public SMTPServer(Storage st,ConfigurationContext configurationContext,int port){
- this.st = st;
- this.configurationContext =configurationContext;
+
+ public SMTPServer(Storage st, ConfigurationContext configurationContext, int port) {
+ this.st = st;
+ this.configurationContext = configurationContext;
this.port = port;
- }
- public void run(){
+ }
+
+ public void run() {
runServer();
}
public void runServer() {
ServerSocket ss = null;
try {
- ss = new ServerSocket(port);
- System.out.println("SMTP Server started on port " + port);
+ ss = new ServerSocket(port);
+ System.out.println("SMTP Server started on port " + port);
} catch (IOException ex) {
ex.printStackTrace();
}
@@ -38,14 +40,14 @@
try {
//wait for a client
Socket socket = ss.accept();
-
- SMTPWorker thread = new SMTPWorker(socket, st,configurationContext);
+
+ SMTPWorker thread = new SMTPWorker(socket, st, configurationContext);
thread.start();
-
+
} catch (IOException ex) {
ex.printStackTrace();
}
}
}
-
+
}