List of usage examples for org.springframework.integration.file.remote SessionCallback doInSession
T doInSession(Session<F> session) throws IOException;
From source file:org.springframework.integration.file.remote.RemoteFileTemplate.java
@SuppressWarnings("rawtypes") @Override// ww w . j a v a2 s .c om public <T> T execute(SessionCallback<F, T> callback) { Session<F> session = null; try { session = this.sessionFactory.getSession(); Assert.notNull(session, "failed to acquire a Session"); return callback.doInSession(session); } catch (Exception e) { if (session instanceof CachingSessionFactory<?>.CachedSession) { ((CachingSessionFactory.CachedSession) session).dirty(); } if (e instanceof MessagingException) { throw (MessagingException) e; } throw new MessagingException("Failed to execute on session", e); } finally { if (session != null) { try { session.close(); } catch (Exception ignored) { if (this.logger.isDebugEnabled()) { this.logger.debug("failed to close Session", ignored); } } } } }