Generified support module
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006 the original author or authors.
|
||||
* Copyright 2005-2010 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -38,7 +38,7 @@ import org.springframework.ws.transport.WebServiceMessageReceiver;
|
||||
* @see #setMessageReceiver(org.springframework.ws.transport.WebServiceMessageReceiver)
|
||||
* @since 1.5.0
|
||||
*/
|
||||
public class WebServiceMessageListener extends JmsMessageReceiver implements SessionAwareMessageListener {
|
||||
public class WebServiceMessageListener extends JmsMessageReceiver implements SessionAwareMessageListener<Message> {
|
||||
|
||||
public void onMessage(Message message, Session session) throws JMSException {
|
||||
try {
|
||||
|
||||
@@ -131,7 +131,7 @@ public abstract class JmsTransportUtils {
|
||||
* #jmsPropertyToHeader(String)}.
|
||||
*/
|
||||
public static Iterator<String> getHeaderNames(Message message) throws JMSException {
|
||||
Enumeration properties = message.getPropertyNames();
|
||||
Enumeration<?> properties = message.getPropertyNames();
|
||||
List<String> results = new ArrayList<String>();
|
||||
while (properties.hasMoreElements()) {
|
||||
String property = (String) properties.nextElement();
|
||||
|
||||
@@ -220,8 +220,8 @@ public class MailMessageReceiver extends AbstractAsyncStandaloneMessageReceiver
|
||||
while (isRunning()) {
|
||||
try {
|
||||
Message[] messages = monitoringStrategy.monitor(folder);
|
||||
for (int i = 0; i < messages.length; i++) {
|
||||
MessageHandler handler = new MessageHandler(messages[i]);
|
||||
for (Message message : messages) {
|
||||
MessageHandler handler = new MessageHandler(message);
|
||||
execute(handler);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -137,7 +137,7 @@ public class MailReceiverConnection extends AbstractReceiverConnection {
|
||||
protected Iterator<String> getRequestHeaderNames() throws IOException {
|
||||
try {
|
||||
List<String> headers = new ArrayList<String>();
|
||||
Enumeration enumeration = requestMessage.getAllHeaders();
|
||||
Enumeration<?> enumeration = requestMessage.getAllHeaders();
|
||||
while (enumeration.hasMoreElements()) {
|
||||
Header header = (Header) enumeration.nextElement();
|
||||
headers.add(header.getName());
|
||||
|
||||
@@ -258,7 +258,7 @@ public class MailSenderConnection extends AbstractSenderConnection {
|
||||
protected Iterator<String> getResponseHeaderNames() throws IOException {
|
||||
try {
|
||||
List<String> headers = new ArrayList<String>();
|
||||
Enumeration enumeration = responseMessage.getAllHeaders();
|
||||
Enumeration<?> enumeration = responseMessage.getAllHeaders();
|
||||
while (enumeration.hasMoreElements()) {
|
||||
Header header = (Header) enumeration.nextElement();
|
||||
headers.add(header.getName());
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2007 the original author or authors.
|
||||
* Copyright 2005-2010 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -157,8 +157,8 @@ public abstract class AbstractMonitoringStrategy implements MonitoringStrategy {
|
||||
* @throws MessagingException in case of JavaMail errors
|
||||
*/
|
||||
protected void deleteMessages(Folder folder, Message[] messages) throws MessagingException {
|
||||
for (int i = 0; i < messages.length; i++) {
|
||||
messages[i].setFlag(Flags.Flag.DELETED, true);
|
||||
for (Message message : messages) {
|
||||
message.setFlag(Flags.Flag.DELETED, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,9 +23,10 @@ import javax.mail.event.MessageCountAdapter;
|
||||
import javax.mail.event.MessageCountEvent;
|
||||
import javax.mail.event.MessageCountListener;
|
||||
|
||||
import com.sun.mail.imap.IMAPFolder;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
import com.sun.mail.imap.IMAPFolder;
|
||||
|
||||
/**
|
||||
* Implementation of the {@link MonitoringStrategy} interface that uses the IMAP IDLE command for asynchronous message
|
||||
* detection.
|
||||
@@ -65,10 +66,10 @@ public class ImapIdleMonitoringStrategy extends AbstractMonitoringStrategy {
|
||||
@Override
|
||||
public void messagesAdded(MessageCountEvent e) {
|
||||
Message[] messages = e.getMessages();
|
||||
for (int i = 0; i < messages.length; i++) {
|
||||
for (Message message : messages) {
|
||||
try {
|
||||
// this will return the flow to the idle call, above
|
||||
messages[i].getLineCount();
|
||||
message.getLineCount();
|
||||
}
|
||||
catch (MessagingException ex) {
|
||||
// ignore
|
||||
|
||||
@@ -74,8 +74,8 @@ public class Pop3PollingMonitoringStrategy extends PollingMonitoringStrategy {
|
||||
protected void deleteMessages(Folder folder, Message[] messages) throws MessagingException {
|
||||
super.deleteMessages(folder, messages);
|
||||
// expunge deleted mails, and make sure we've retrieved them before closing the folder
|
||||
for (int i = 0; i < messages.length; i++) {
|
||||
new MimeMessage((MimeMessage) messages[i]);
|
||||
for (Message message : messages) {
|
||||
new MimeMessage((MimeMessage) message);
|
||||
}
|
||||
MailTransportUtils.closeFolder(folder, true);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2007 the original author or authors.
|
||||
* Copyright 2005-2010 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -29,12 +29,12 @@ import javax.mail.URLName;
|
||||
import javax.mail.internet.AddressException;
|
||||
import javax.mail.internet.InternetAddress;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.springframework.ws.transport.mail.MailTransportConstants;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
/**
|
||||
* Collection of utility methods to work with Mail transports.
|
||||
*
|
||||
@@ -135,7 +135,7 @@ public abstract class MailTransportUtils {
|
||||
int port = name.getPort();
|
||||
String file = name.getFile();
|
||||
String ref = name.getRef();
|
||||
StringBuffer tempURL = new StringBuffer();
|
||||
StringBuilder tempURL = new StringBuilder();
|
||||
if (protocol != null) {
|
||||
tempURL.append(protocol).append(':');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user