INT-2238 interim commit
INT-2238 fixing warning comments INT-2238 fixing warning comments INT-2238 fixing warning comments
This commit is contained in:
committed by
Mark Fisher
parent
dfd039b78e
commit
43f60dae08
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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{
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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();
|
||||
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user