ChannelSubsystem.java

Go to the documentation of this file.
00001 /* -*-mode:java; c-basic-offset:2; indent-tabs-mode:nil -*- */
00002 /*
00003 Copyright (c) 2005-2011 ymnk, JCraft,Inc. All rights reserved.
00004 
00005 Redistribution and use in source and binary forms, with or without
00006 modification, are permitted provided that the following conditions are met:
00007 
00008   1. Redistributions of source code must retain the above copyright notice,
00009      this list of conditions and the following disclaimer.
00010 
00011   2. Redistributions in binary form must reproduce the above copyright 
00012      notice, this list of conditions and the following disclaimer in 
00013      the documentation and/or other materials provided with the distribution.
00014 
00015   3. The names of the authors may not be used to endorse or promote products
00016      derived from this software without specific prior written permission.
00017 
00018 THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
00019 INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
00020 FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT,
00021 INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT,
00022 INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
00023 LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
00024 OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
00025 LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
00026 NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
00027 EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00028 */
00029 
00030 package com.jcraft.jsch;
00031 
00032 
00046 public class ChannelSubsystem extends ChannelSession{
00047   boolean xforwading=false;
00048   boolean pty=false;
00049   boolean want_reply=true;
00050   String subsystem="";
00051   // javadoc is copied from superclass -- P.E.
00052   public void setXForwarding(boolean foo){ xforwading=foo; }
00053   // javadoc is copied from superclass -- P.E.
00054   public void setPty(boolean foo){ pty=foo; }
00055 
00062   public void setWantReply(boolean foo){ want_reply=foo; }
00063 
00072   public void setSubsystem(String foo){ subsystem=foo; }
00073 
00074 
00075   // javadoc is copied from superclass -- P.E.
00076   public void start() throws JSchException{
00077     Session _session=getSession();
00078     try{
00079       // could have used super.sendRequests() here,
00080       // instead of reimplementing it.
00081       Request request;
00082       if(xforwading){
00083         request=new RequestX11();
00084         request.request(_session, this);
00085       }
00086       if(pty){
00087     request=new RequestPtyReq();
00088     request.request(_session, this);
00089       }
00090       request=new RequestSubsystem();
00091       ((RequestSubsystem)request).request(_session, this, subsystem, want_reply);
00092     }
00093     catch(Exception e){
00094       if(e instanceof JSchException){ throw (JSchException)e; }
00095       if(e instanceof Throwable)
00096         throw new JSchException("ChannelSubsystem", (Throwable)e);
00097       throw new JSchException("ChannelSubsystem");
00098     }
00099     if(io.in!=null){
00100       thread=new Thread(this);
00101       thread.setName("Subsystem for "+_session.host);
00102       if(_session.daemon_thread){
00103         thread.setDaemon(_session.daemon_thread);
00104       }
00105       thread.start();
00106     }
00107   }
00108 
00109   void init() throws JSchException {
00110     io.setInputStream(getSession().in);
00111     io.setOutputStream(getSession().out);
00112   }
00113 
00120   public void setErrStream(java.io.OutputStream out){
00121     setExtOutputStream(out);
00122   }
00123 
00130   public java.io.InputStream getErrStream() throws java.io.IOException {
00131     return getExtInputStream();
00132   }
00133 }

Generated on 5 May 2015 for HPCVIEWER by  doxygen 1.6.1