]>
git.argeo.org Git - gpl/argeo-slc.git/blob - cms/org.argeo.slc.support/src/org/argeo/slc/jsch/JschContextSession.java
1 package org
.argeo
.slc
.jsch
;
3 import org
.apache
.commons
.logging
.Log
;
4 import org
.apache
.commons
.logging
.LogFactory
;
5 import org
.springframework
.beans
.factory
.DisposableBean
;
6 import org
.springframework
.beans
.factory
.InitializingBean
;
8 import com
.jcraft
.jsch
.Session
;
10 /** Caches a JSCH session in the the ssh target. */
11 public class JschContextSession
extends AbstractJschTask
implements
12 InitializingBean
, DisposableBean
{
13 private final static Log log
= LogFactory
.getLog(JschContextSession
.class);
14 private Boolean autoconnect
= false;
17 void run(Session session
) {
19 getSshTarget().setSession(session
);
20 if (log
.isDebugEnabled())
21 log
.debug("Cached SSH context session to " + getSshTarget());
24 public void afterPropertiesSet() throws Exception
{
25 // if (log.isDebugEnabled())
26 // log.debug(getClass() + ".afterPropertiesSet(), " + beanName + ", "
31 } catch (Exception e
) {
32 log
.error("Could not automatically open session", e
);
36 public void destroy() throws Exception
{
41 SshTarget sshTarget
= getSshTarget();
42 synchronized (sshTarget
) {
43 if (sshTarget
.getSession() != null) {
44 sshTarget
.getSession().disconnect();
45 sshTarget
.setSession(null);
46 if (log
.isDebugEnabled())
47 log
.debug("Cleared cached SSH context session to "
53 public void setAutoconnect(Boolean autoconnect
) {
54 this.autoconnect
= autoconnect
;