All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.rationaleemotions.SessionCleaner Maven / Gradle / Ivy

Go to download

A simple way of interacting with a remote host for executing commands, scp (upload and download)

The newest version!
package com.rationaleemotions;

import com.jcraft.jsch.Session;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * A worker that cleans sessions via {@link Runtime#addShutdownHook(Thread)}
 */
class SessionCleaner implements Runnable {
    interface Marker {}

    private static final Logger LOGGER = LoggerFactory.getLogger(Marker.class.getEnclosingClass());

    private Session session;

    SessionCleaner(Session session) {
        this.session = session;
    }

    @Override
    public void run() {
        try {
            if (session != null) {
                session.disconnect();
            }
        } catch (Exception e) {
            LOGGER.warn(e.getMessage(),e);
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy