Returns the {@link #channel}. May open it if <code>autoReconnect</code> is set to "true" (default value)
and it's not yet or no longer open.
@return an open channel.
553804
private synchronized Channel channel() throws IOException {
        if (autoReconnect) {
            try {
                connect();
            } catch (GeneralSecurityException e) {
                throw new IOException(e);
            }
        }

        return channel;
    }
437114
public synchronized Channel findOrCreateChannel(ChannelData channelData) throws ChannelException {
        String channelName = channelData.getName();
        Channel rc = this.existingChannels.get(channelName);
        if (null == rc) {
            rc = createChannel(channelData);
            this.existingChannels.put(channelName, rc);
        }
        return rc;
    }
1360369
protected Channel provideChannel() throws IOException {
        if (channel == null || !channel.isOpen()) {
            Connection connection = connectionFactory.newConnection();
            channel = connection.createChannel();
        }
        return channel;
    }
321439
public Channel sessionConnectGenerateChannel(Session session)
            throws JSchException {
    	// set timeout
        session.connect(sshMeta.getSshConnectionTimeoutMillis());
        
        ChannelExec channel = (ChannelExec) session.openChannel("exec");
        channel.setCommand(sshMeta.getCommandLine());

        // if run as super user, assuming the input stream expecting a password
        if (sshMeta.isRunAsSuperUser()) {
        	try {
                channel.setInputStream(null, true);

                OutputStream out = channel.getOutputStream();
                channel.setOutputStream(System.out, true);
                channel.setExtOutputStream(System.err, true);
                channel.setPty(true);
                channel.connect();
                
	            out.write((sshMeta.getPassword()+"\n").getBytes());
	            out.flush();
			} catch (IOException e) {
				logger.error("error in sessionConnectGenerateChannel for super user", e);
			}
        } else {
        	channel.setInputStream(null);
        	channel.connect();
        }

        return channel;

    }
1056223
public synchronized Channel findOrCreateChannel(ChannelData channelData) throws ChannelException {
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) {
            Tr.entry(tc, "findOrCreateChannel: " + channelData.getName());
        }
        String channelName = channelData.getName();
        Channel ret = this.existingChannels.get(channelName);
        if (ret == null) {
            // Create the new channel with the input configuration
            ret = createChannel(channelData);
            this.existingChannels.put(channelName, ret);
        }
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) {
            Tr.exit(tc, "findOrCreateChannel");
        }
        return ret;
    }
792006
@Override
    public Channel getChannelOrFail() throws ChannelClosedException {
        final Channel ch = Channel.current();
        if (ch == null) {
            throw new ChannelClosedException(new IllegalStateException("No channel associated with the thread"));
        }
        return ch;
    }
285175
protected Channel getConsumerChannel() throws IOException, TimeoutException {
        if (consumerChannel == null) {
            synchronized (this) {
                if (consumerChannel == null) {
                    consumerChannel = createChannel();
                }
            }
        }
        return consumerChannel;
    }
353251
public Connection getFrom() {
        final List<Connection> list =
            getIncomingConnections(org.jbpm.workflow.core.Node.CONNECTION_DEFAULT_TYPE);
        if (list.size() == 0) {
            return null;
        }
        if (list.size() == 1) {
        	return list.get(0);
        }
        if ("true".equals(System.getProperty("jbpm.enable.multi.con"))) { 
        	return list.get(0);
        } else {
        	throw new IllegalArgumentException(
    		"Trying to retrieve the from connection but multiple connections are present");
        }
    }
424096
public static Socket getCurrentSocket() {
        ConnectionHandler handler = connectionMap.get(Thread.currentThread());
        return (handler == null ? null : handler.getSocket());
    }
292783
public PrivateChannel getOrCreateChannel(JsonNode data) {
        synchronized (this) {
            if (channel != null) {
                return channel;
            }
            return new PrivateChannelImpl(api, data);
        }
    }
954782
public ChannelSftp getSftpChannel() throws SftpException {

    try {
      ChannelSftp channelSftp = (ChannelSftp) this.session.openChannel("sftp");
      channelSftp.connect();
      return channelSftp;
    } catch (JSchException e) {
      throw new SftpException(0, "Cannot open a channel to SFTP server", e);
    }
  }
760582
public Connection connect() throws IOException {
        Connection connection;
        synchronized (this) {
            if(shutdown) throw ProtocolLogger.ROOT_LOGGER.channelClosed();
            connection = this.connection;
            if(connection == null) {
                connection = connectTask.connect();
                if(connection == null) {
                    throw ProtocolLogger.ROOT_LOGGER.channelClosed();
                }
                boolean ok = false;
                try {
                    // Connection opened notification
                    final ConnectionOpenHandler openHandler = connectTask.getConnectionOpenedHandler();
                    openHandler.connectionOpened(connection);
                    ok = true;
                    this.connection = connection;
                    connection.addCloseHandler(new CloseHandler<Connection>() {
                        @Override
                        public void handleClose(Connection closed, IOException exception) {
                            onConnectionClose(closed);
                        }
                    });
                } finally {
                    if(!ok) {
                        StreamUtils.safeClose(connection);
                    }
                }
            }
        }
        return connection;
    }
963697
public synchronized Channel getRunningChannel(String inputChannelName, Chain chain) {
        if (inputChannelName == null || chain == null) {
            return null;
        }

        Channel channel = null;
        // Ensure the chain is running.
        if (null != this.chainRunningMap.get(chain.getName())) {
            ChannelData[] channels = chain.getChannelsData();
            for (int index = 0; index < channels.length; index++) {
                if (channels[index].getExternalName().equals(inputChannelName)) {
                    channel = chain.getChannels()[index];
                    break;
                }
            }
        }
        return channel;
    }
110993
@Override
    public List<Channel> getChannels()
    {
        List<Channel> channels = new LinkedList<>();
        if (_acceptingParty != null)
            channels.add(_acceptingParty);
        if (_originatingParty != null)
            channels.add(_originatingParty);
        if (_transferTargetParty != null)
            channels.add(_transferTargetParty);
        return channels;
    }
72609
@Override
    public Channel join(String channelName) {
        if (!connected) {
            throw new NotConnectedException();
        }

        ChannelImpl channel = new ChannelImpl(this, channelName);

        /* Attempt to join */
        if (channel.join()) {
            return channel;
        }

        /* Error while joining */
        return null;
    }
183166
public EpollSocketChannelConfig setTcpFastOpenConnect(boolean fastOpenConnect) {
        try {
            ((EpollSocketChannel) channel).socket.setTcpFastOpenConnect(fastOpenConnect);
            return this;
        } catch (IOException e) {
            throw new ChannelException(e);
        }
    }
503191
protected function getChannel()
    {
        if ($this->channel instanceof CmobiAMQPChannel) {
            return $this->channel;
        }
        $this->channel = $this->getConnection()->channel();

        if (!$this->channel instanceof CmobiAMQPChannel) {
            throw new InvalidAMQPChannelException('Failed get AMQPChannel');
        }

        return $this->channel;
    }