INT-2238 interim commit

INT-2238 fixing warning comments

INT-2238 fixing warning comments

INT-2238 fixing warning comments
This commit is contained in:
Oleg Zhurakousky
2011-11-22 05:59:12 -05:00
committed by Mark Fisher
parent dfd039b78e
commit 43f60dae08
22 changed files with 51 additions and 61 deletions

View File

@@ -69,12 +69,12 @@ public class JsonInboundMessageMapper implements InboundMessageMapper<String> {
public JsonInboundMessageMapper(Class<?> payloadType) {
Assert.notNull(payloadType, "payloadType must not be null");
this.payloadType = TypeFactory.type(payloadType);
this.payloadType = TypeFactory.defaultInstance().constructType(payloadType);
}
public JsonInboundMessageMapper(TypeReference<?> typeReference) {
Assert.notNull(typeReference, "typeReference must not be null");
this.payloadType = TypeFactory.type(typeReference);
this.payloadType = TypeFactory.defaultInstance().constructType(typeReference);
}

View File

@@ -33,6 +33,6 @@ public interface HeaderMapper<T> {
void fromHeaders(MessageHeaders headers, T target);
<V> Map<String, V> toHeaders(T source);
Map<String, Object> toHeaders(T source);
}

View File

@@ -51,7 +51,7 @@ import org.springframework.util.ObjectUtils;
*/
public abstract class AbstractRemoteFileOutboundGateway<F> extends AbstractReplyProducingMessageHandler {
protected final SessionFactory sessionFactory;
protected final SessionFactory<F> sessionFactory;
protected final String command;
@@ -91,7 +91,7 @@ public abstract class AbstractRemoteFileOutboundGateway<F> extends AbstractReply
private volatile FileListFilter<F> filter;
public AbstractRemoteFileOutboundGateway(SessionFactory sessionFactory, String command,
public AbstractRemoteFileOutboundGateway(SessionFactory<F> sessionFactory, String command,
String expression) {
this.sessionFactory = sessionFactory;
this.command = command;
@@ -183,7 +183,7 @@ public abstract class AbstractRemoteFileOutboundGateway<F> extends AbstractReply
@Override
protected Object handleRequestMessage(Message<?> requestMessage) {
Session session = this.sessionFactory.getSession();
Session<F> session = this.sessionFactory.getSession();
try {
if (COMMAND_LS.equals(this.command)) {
String dir = this.processor.processMessage(requestMessage);
@@ -225,9 +225,9 @@ public abstract class AbstractRemoteFileOutboundGateway<F> extends AbstractReply
}
}
protected List<?> ls(Session session, String dir) throws IOException {
protected List<?> ls(Session<F> session, String dir) throws IOException {
List<F> lsFiles = new ArrayList<F>();
F[] files = session.<F>list(dir);
F[] files = session.list(dir);
if (!ObjectUtils.isEmpty(files)) {
Collection<F> filteredFiles = this.filterFiles(files);
for (F file : filteredFiles) {
@@ -295,12 +295,11 @@ public abstract class AbstractRemoteFileOutboundGateway<F> extends AbstractReply
* Copy a remote file to the configured local directory.
* @param session
* @param remoteFilePath
* @return
* @throws IOException
*/
protected File get(Session session, String remoteFilePath, String remoteFilename)
protected File get(Session<F> session, String remoteFilePath, String remoteFilename)
throws IOException {
F[] files = session.<F>list(remoteFilePath);
F[] files = session.list(remoteFilePath);
if (files.length != 1 || isDirectory(files[0]) || isLink(files[0])) {
throw new MessagingException(remoteFilePath + " is not a file");
}
@@ -342,7 +341,6 @@ public abstract class AbstractRemoteFileOutboundGateway<F> extends AbstractReply
/**
* @param remoteFilePath
* @return
*/
protected String getRemoteFilename(String remoteFilePath) {
String remoteFileName;
@@ -356,7 +354,7 @@ public abstract class AbstractRemoteFileOutboundGateway<F> extends AbstractReply
return remoteFileName;
}
protected boolean rm(Session session, String remoteFilePath)
protected boolean rm(Session<?> session, String remoteFilePath)
throws IOException {
return session.remove(remoteFilePath);
}

View File

@@ -36,25 +36,25 @@ import org.springframework.integration.util.UpperBound;
* @author Mark Fisher
* @since 2.0
*/
public class CachingSessionFactory implements SessionFactory, DisposableBean {
public class CachingSessionFactory<F> implements SessionFactory<F>, DisposableBean {
private static final Log logger = LogFactory.getLog(CachingSessionFactory.class);
private volatile long sessionWaitTimeout = Integer.MAX_VALUE;
private final LinkedBlockingQueue<Session> queue = new LinkedBlockingQueue<Session>();
private final LinkedBlockingQueue<Session<F>> queue = new LinkedBlockingQueue<Session<F>>();
private final SessionFactory sessionFactory;
private final SessionFactory<F> sessionFactory;
private final UpperBound sessionPermits;
public CachingSessionFactory(SessionFactory sessionFactory) {
public CachingSessionFactory(SessionFactory<F> sessionFactory) {
this(sessionFactory, 0);
}
public CachingSessionFactory(SessionFactory sessionFactory, int sessionCacheSize) {
public CachingSessionFactory(SessionFactory<F> sessionFactory, int sessionCacheSize) {
this.sessionFactory = sessionFactory;
this.sessionPermits = new UpperBound(sessionCacheSize);
}
@@ -69,25 +69,25 @@ public class CachingSessionFactory implements SessionFactory, DisposableBean {
this.sessionWaitTimeout = sessionWaitTimeout;
}
public Session getSession() {
public Session<F> getSession() {
boolean permitted = this.sessionPermits.tryAcquire(this.sessionWaitTimeout);
if (!permitted) {
throw new IllegalStateException("Timed out while waiting to aquire a Session.");
}
Session session = this.doGetSession();
Session<F> session = this.doGetSession();
return new CachedSession(session);
}
public void destroy() {
if (this.queue != null) {
for (Session session : this.queue) {
for (Session<F> session : this.queue) {
this.closeSession(session);
}
}
}
private Session doGetSession() {
Session session = this.queue.poll();
private Session<F> doGetSession() {
Session<F> session = this.queue.poll();
if (session != null && !session.isOpen()) {
if (logger.isDebugEnabled()) {
logger.debug("Received a stale Session, will attempt to get a new one.");
@@ -100,7 +100,7 @@ public class CachingSessionFactory implements SessionFactory, DisposableBean {
return session;
}
private void closeSession(Session session) {
private void closeSession(Session<F> session) {
try {
if (session != null) {
session.close();
@@ -115,11 +115,11 @@ public class CachingSessionFactory implements SessionFactory, DisposableBean {
}
private class CachedSession implements Session {
private class CachedSession implements Session<F> {
private final Session targetSession;
private final Session<F> targetSession;
private CachedSession(Session targetSession) {
private CachedSession(Session<F> targetSession) {
this.targetSession = targetSession;
}
@@ -135,8 +135,8 @@ public class CachingSessionFactory implements SessionFactory, DisposableBean {
return this.targetSession.remove(path);
}
public <F> F[] list(String path) throws IOException{
return this.targetSession.<F>list(path);
public F[] list(String path) throws IOException{
return this.targetSession.list(path);
}
public void read(String source, OutputStream os) throws IOException{

View File

@@ -29,11 +29,11 @@ import java.io.OutputStream;
* @author Oleg Zhurakousky
* @since 2.0
*/
public interface Session {
public interface Session<T> {
boolean remove(String path) throws IOException;
<F> F[] list(String path) throws IOException;
T[] list(String path) throws IOException;
void read(String source, OutputStream outputStream) throws IOException;

View File

@@ -22,8 +22,8 @@ package org.springframework.integration.file.remote.session;
* @author Mark Fisher
* @since 2.0
*/
public interface SessionFactory {
public interface SessionFactory<F> {
Session getSession();
Session<F> getSession();
}

View File

@@ -73,7 +73,7 @@ public abstract class AbstractInboundFileSynchronizer<F> implements InboundFileS
/**
* the {@link SessionFactory} for acquiring remote file Sessions.
*/
private final SessionFactory sessionFactory;
private final SessionFactory<F> sessionFactory;
/**
* An {@link FileListFilter} that runs against the <emphasis>remote</emphasis> file system view.
@@ -90,7 +90,7 @@ public abstract class AbstractInboundFileSynchronizer<F> implements InboundFileS
/**
* Create a synchronizer with the {@link SessionFactory} used to acquire {@link Session} instances.
*/
public AbstractInboundFileSynchronizer(SessionFactory sessionFactory) {
public AbstractInboundFileSynchronizer(SessionFactory<F> sessionFactory) {
Assert.notNull(sessionFactory, "sessionFactory must not be null");
this.sessionFactory = sessionFactory;
}
@@ -138,11 +138,11 @@ public abstract class AbstractInboundFileSynchronizer<F> implements InboundFileS
}
public void synchronizeToLocalDirectory(File localDirectory) {
Session session = null;
Session<F> session = null;
try {
session = this.sessionFactory.getSession();
Assert.state(session != null, "failed to acquire a Session");
F[] files = session.<F>list(this.remoteDirectory);
F[] files = session.list(this.remoteDirectory);
if (!ObjectUtils.isEmpty(files)) {
Collection<F> filteredFiles = this.filterFiles(files);
for (F file : filteredFiles) {
@@ -169,7 +169,7 @@ public abstract class AbstractInboundFileSynchronizer<F> implements InboundFileS
}
}
private void copyFileToLocalDirectory(String remoteDirectoryPath, F remoteFile, File localDirectory, Session session) throws IOException {
private void copyFileToLocalDirectory(String remoteDirectoryPath, F remoteFile, File localDirectory, Session<F> session) throws IOException {
String remoteFileName = this.getFilename(remoteFile);
String localFileName = this.generateLocalFileName(remoteFileName);
String remoteFilePath = remoteDirectoryPath + remoteFileSeparator + remoteFileName;

View File

@@ -34,7 +34,7 @@ import org.springframework.integration.ftp.session.FtpFileInfo;
*/
public class FtpOutboundGateway extends AbstractRemoteFileOutboundGateway<FTPFile> {
public FtpOutboundGateway(SessionFactory sessionFactory, String command,
public FtpOutboundGateway(SessionFactory<FTPFile> sessionFactory, String command,
String expression) {
super(sessionFactory, command, expression);
}

View File

@@ -35,7 +35,7 @@ public class FtpInboundFileSynchronizer extends AbstractInboundFileSynchronizer<
/**
* Create a synchronizer with the {@link SessionFactory} used to acquire {@link Session} instances.
*/
public FtpInboundFileSynchronizer(SessionFactory sessionFactory) {
public FtpInboundFileSynchronizer(SessionFactory<FTPFile> sessionFactory) {
super(sessionFactory);
}

View File

@@ -35,7 +35,7 @@ import org.springframework.util.Assert;
* @author Oleg Zhurakousky
* @since 2.0
*/
class FtpSession implements Session {
class FtpSession implements Session<FTPFile> {
private final Log logger = LogFactory.getLog(this.getClass());
@@ -56,8 +56,7 @@ class FtpSession implements Session {
}
return completed;
}
@SuppressWarnings({"unchecked"})
public FTPFile[] list(String path) throws IOException {
Assert.hasText(path, "path must not be null");
return this.client.listFiles(path);

View File

@@ -310,7 +310,7 @@ public class DefaultHttpHeaderMapper implements HeaderMapper<HttpHeaders>, BeanF
* Depending on which type of adapter is using this mapper, the HttpHeaders might be
* from an HTTP request (inbound adapter) or from an HTTP response (outbound adapter).
*/
public Map<String, ?> toHeaders(HttpHeaders source) {
public Map<String, Object> toHeaders(HttpHeaders source) {
if (logger.isDebugEnabled()) {
logger.debug(MessageFormat.format("inboundHeaderNames={0}", CollectionUtils.arrayToList(inboundHeaderNames)));
}

View File

@@ -113,7 +113,6 @@ public class HttpInboundChannelAdapterParserTests {
}
@Test
@SuppressWarnings("unchecked")
public void getRequestWithHeaders() throws Exception {
DefaultHttpHeaderMapper headerMapper =
(DefaultHttpHeaderMapper) TestUtils.getPropertyValue(withMappedHeaders, "headerMapper");
@@ -122,7 +121,7 @@ public class HttpInboundChannelAdapterParserTests {
headers.set("foo", "foo");
headers.set("bar", "bar");
headers.set("baz", "baz");
Map<String, String> map = (Map<String, String>) headerMapper.toHeaders(headers);
Map<String, Object> map = (Map<String, Object>) headerMapper.toHeaders(headers);
assertTrue(map.size() == 2);
assertEquals("foo", map.get("foo"));
assertEquals("bar", map.get("bar"));

View File

@@ -113,7 +113,6 @@ public class HttpInboundGatewayParserTests {
}
@Test
@SuppressWarnings("unchecked")
public void requestWithHeaders() throws Exception {
DefaultHttpHeaderMapper headerMapper =
(DefaultHttpHeaderMapper) TestUtils.getPropertyValue(withMappedHeaders, "headerMapper");
@@ -122,7 +121,7 @@ public class HttpInboundGatewayParserTests {
headers.set("foo", "foo");
headers.set("bar", "bar");
headers.set("baz", "baz");
Map<String, String> map = (Map<String, String>) headerMapper.toHeaders(headers);
Map<String, Object> map = (Map<String, Object>) headerMapper.toHeaders(headers);
assertTrue(map.size() == 2);
assertEquals("foo", map.get("foo"));
assertEquals("bar", map.get("bar"));
@@ -138,7 +137,6 @@ public class HttpInboundGatewayParserTests {
}
@Test
@SuppressWarnings("unchecked")
public void requestWithHeadersWithConversionService() throws Exception {
DefaultHttpHeaderMapper headerMapper =
(DefaultHttpHeaderMapper) TestUtils.getPropertyValue(withMappedHeadersAndConverter, "headerMapper");
@@ -147,7 +145,7 @@ public class HttpInboundGatewayParserTests {
headers.set("foo", "foo");
headers.set("bar", "bar");
headers.set("baz", "baz");
Map<String, String> map = (Map<String, String>) headerMapper.toHeaders(headers);
Map<String, Object> map = (Map<String, Object>) headerMapper.toHeaders(headers);
assertTrue(map.size() == 2);
assertEquals("foo", map.get("foo"));
assertEquals("bar", map.get("bar"));

View File

@@ -41,7 +41,6 @@ public class TcpNetClientConnectionFactory extends
}
/**
* @return
* @throws IOException
* @throws SocketException
* @throws Exception

View File

@@ -57,7 +57,6 @@ public class TcpNioClientConnectionFactory extends
}
/**
* @return
* @throws Exception
* @throws IOException
* @throws SocketException

View File

@@ -260,7 +260,6 @@ public class ChannelPublishingJmsMessageListener
this.extractReplyPayload = extractReplyPayload;
}
@SuppressWarnings("unchecked")
public void onMessage(javax.jms.Message jmsMessage, Session session) throws JMSException {
Object result = jmsMessage;
if (this.extractRequestPayload) {
@@ -270,7 +269,7 @@ public class ChannelPublishingJmsMessageListener
}
}
Map<String, Object> headers = (Map<String, Object>) headerMapper.toHeaders(jmsMessage);
Map<String, Object> headers = headerMapper.toHeaders(jmsMessage);
Message<?> requestMessage = (result instanceof Message<?>) ?
MessageBuilder.fromMessage((Message<?>) result).copyHeaders(headers).build() :
MessageBuilder.withPayload(result).copyHeaders(headers).build();

View File

@@ -96,7 +96,7 @@ public class JmsDestinationPollingSource extends IntegrationObjectSupport implem
}
try {
// Map headers
Map<String, Object> mappedHeaders = (Map<String, Object>) this.headerMapper.toHeaders(jmsMessage);
Map<String, Object> mappedHeaders = this.headerMapper.toHeaders(jmsMessage);
MessageConverter converter = this.jmsTemplate.getMessageConverter();
Object convertedObject = converter.fromMessage(jmsMessage);
MessageBuilder<Object> builder = (convertedObject instanceof Message)

View File

@@ -398,7 +398,7 @@ public class JmsOutboundGateway extends AbstractReplyProducingMessageHandler {
logger.debug("converted JMS Message [" + jmsReply + "] to integration Message payload [" + result + "]");
}
}
Map<String, Object> jmsReplyHeaders = (Map<String, Object>) this.headerMapper.toHeaders(jmsReply);
Map<String, Object> jmsReplyHeaders = this.headerMapper.toHeaders(jmsReply);
Message<?> replyMessage = null;
if (result instanceof Message){
replyMessage = MessageBuilder.fromMessage((Message<?>) result).copyHeaders(jmsReplyHeaders).build();

View File

@@ -41,7 +41,7 @@ public class SftpOutboundGateway extends AbstractRemoteFileOutboundGateway<LsEnt
* @param options
* @param expression
*/
public SftpOutboundGateway(SessionFactory sessionFactory, String command, String expression) {
public SftpOutboundGateway(SessionFactory<LsEntry> sessionFactory, String command, String expression) {
super(sessionFactory, command, expression);
}

View File

@@ -31,7 +31,7 @@ import com.jcraft.jsch.ChannelSftp.LsEntry;
*/
public class SftpInboundFileSynchronizer extends AbstractInboundFileSynchronizer<LsEntry> {
public SftpInboundFileSynchronizer(SessionFactory sessionFactory) {
public SftpInboundFileSynchronizer(SessionFactory<LsEntry> sessionFactory) {
super(sessionFactory);
}

View File

@@ -45,7 +45,7 @@ import com.jcraft.jsch.SftpException;
* @author Oleg Zhurakousky
* @since 2.0
*/
class SftpSession implements Session {
class SftpSession implements Session<LsEntry> {
private final Log logger = LogFactory.getLog(this.getClass());
@@ -71,7 +71,6 @@ class SftpSession implements Session {
}
}
@SuppressWarnings("unchecked")
public LsEntry[] list(String path) throws IOException {
Assert.state(this.channel != null, "session is not connected");
try {

View File

@@ -22,7 +22,7 @@ import org.springframework.social.twitter.api.Tweet;
import org.springframework.social.twitter.api.Twitter;
/**
* Handles forwarding all new {@link twitter4j.Status} that are 'replies' or 'mentions' to some other tweet.
* Receives Message Tweets
*
* @author Josh Long
* @author Oleg Zhurakousky