Returns a fake {@link Channel} which is required internally when creating a context.
184120
protected final Channel fakeChannel() {
        if (channel == null) {
            channel = new FakeChannel(eventLoop(), alloc(), remoteAddress(), localAddress());
        }
        return channel;
    }
515238
private ManagedChannel createManagedChannel(ChannelKey channelKey) {
    NettyChannelBuilder channelBuilder = NettyChannelBuilder.forAddress(channelKey.mAddress);
    if (channelKey.mKeepAliveTime.isPresent()) {
      channelBuilder.keepAliveTime(channelKey.mKeepAliveTime.get().getFirst(),
          channelKey.mKeepAliveTime.get().getSecond());
    }
    if (channelKey.mKeepAliveTimeout.isPresent()) {
      channelBuilder.keepAliveTimeout(channelKey.mKeepAliveTimeout.get().getFirst(),
          channelKey.mKeepAliveTimeout.get().getSecond());
    }
    if (channelKey.mMaxInboundMessageSize.isPresent()) {
      channelBuilder.maxInboundMessageSize(channelKey.mMaxInboundMessageSize.get());
    }
    if (channelKey.mFlowControlWindow.isPresent()) {
      channelBuilder.flowControlWindow(channelKey.mFlowControlWindow.get());
    }
    if (channelKey.mChannelType.isPresent()) {
      channelBuilder.channelType(channelKey.mChannelType.get());
    }
    if (channelKey.mEventLoopGroup.isPresent()) {
      channelBuilder.eventLoopGroup(channelKey.mEventLoopGroup.get());
    }
    channelBuilder.usePlaintext();
    return channelBuilder.build();
  }
1140867
public RequestChannel getRequestChannel(Object client)
    {
        try {
            InvocationHandler genericHandler = Proxy.getInvocationHandler(client);
            ThriftInvocationHandler thriftHandler = (ThriftInvocationHandler) genericHandler;
            return thriftHandler.getChannel();
        }
        catch (IllegalArgumentException | ClassCastException e) {
            throw new IllegalArgumentException("Invalid swift client object", e);
        }
    }
868257
protected Channel createChannel(ChannelData config) throws ChannelException   
   {
      if (tc.isEntryEnabled()) SibTr.entry(this, tc, "createChannel", config);
      
      Channel retChannel;
      if (config.isInbound())
      {
         if (tc.isDebugEnabled()) SibTr.debug(this, tc, "createChannel", "inbound");
         try
         {
            Class clazz = Class.forName(JFapChannelConstants.INBOUND_CHANNEL_CLASS);
            Constructor contruct = clazz.getConstructor(new Class[] 
                                                        {
                                                           ChannelFactoryData.class, 
                                                           ChannelData.class 
                                                        });
            retChannel = (Channel) contruct.newInstance(new Object[] 
                                                        { 
                                                           channelFactoryData, 
                                                           config 
                                                        });
         }
         catch (Exception e)
         {
            FFDCFilter.processException(e, 
                                        "com.ibm.ws.sib.jfapchannel.impl.JFapChannelFactory.createChannel",  
                                        JFapChannelConstants.JFAPCHANNELFACT_CREATECHANNEL_01,
                                        this);
            
            if (tc.isDebugEnabled()) SibTr.debug(this, tc, "Unable to instantiate inbound channel", e);

            // Rethrow as a channel exception
            throw new ChannelException(e);
         }
      }
      else
      {
         retChannel = new JFapChannelOutbound(channelFactoryData, config);
      }
      
      if (tc.isEntryEnabled()) SibTr.exit(this, tc, "createChannel", retChannel);
      return retChannel;
   }
816875
public static ConfigurableChannel of(Channel channel) {
    Assert.isTrue(channel instanceof ConfigurableChannel, "The channel {} was not created by Lyra", channel);
    return (ConfigurableChannel) channel;
  }
733383
public static synchronized Channel getChannel() throws IOException {
        if (devnull < 0) {
            devnull = open0("/dev/null", O_RDWR);
        }

        // If we don't have the channel try to create it
        if (!haveChannel) {
            channel = createChannel();
            haveChannel = true;
        }

        // if there is a channel then do the security check before
        // returning it.
        if (channel != null) {
            checkAccess(channel);
        }
        return channel;
    }
890632
def construct_channel(self, *args, **kwargs):
        
        channel = self.get_channel(*args, **kwargs)   # creates ChannelNode from data in self.channel_info
        _build_tree(channel, SAMPLE_TREE)
        raise_for_invalid_channel(channel)

        return channel
36212
public Program getProgramRightNow(Channel channel) {
        ApplicationInfo app = null;
        try {
            app = getApplicationContext().getPackageManager().getApplicationInfo(getApplicationContext().getPackageName(), PackageManager.GET_META_DATA);
            Bundle bundle = app.metaData;
            final String service = bundle.getString("TvInputService");
            String channels = TvContract.buildInputId(new ComponentName(getPackageName(), service.substring(getPackageName().length())));
            Log.d(TAG, new ComponentName(getPackageName(), service.substring(getPackageName().length())).flattenToString());

            List<Program> programs = getPrograms(getApplicationContext(),
                    TvContract.buildChannelUri(channel.getChannelId()));
            Log.d(TAG, "Program from channel "+TvContract.buildChannelUri(channel.getChannelId()));
            Log.d(TAG, "Program from chanel "+channel.getChannelId());
            Program currentProgram = null;
            for(Program p: programs) {
                if(p.getStartTimeUtcMillis() < new Date().getTime()) {
                    currentProgram = p;
                }
            }
            return currentProgram;

        } catch (PackageManager.NameNotFoundException e) {
            e.printStackTrace();
        }
        return null;
    }
48772
public synchronized ChannelFactoryDataImpl findOrCreateChannelFactoryData(Class<?> type) throws ChannelFactoryException {
        ChannelFactoryDataImpl cfd = channelFactories.get(type);
        if (cfd == null) {
            ChannelFactory cf = getChannelFactoryInternal(type, false);
            Class<?>[] deviceInf = null;
            Class<?> applicationInf = null;
            try {
                deviceInf = cf.getDeviceInterface();
            } catch (Exception e) {
                // No FFDC Needed
            }
            try {
                applicationInf = cf.getApplicationInterface();
            } catch (Exception e) {
                // No FFDC Needed
            }
            cfd = new ChannelFactoryDataImpl(type, deviceInf, applicationInf);
            this.channelFactories.put(type, cfd);
        }
        return cfd;
    }
507954
private synchronized void createChannel(String channel) {
        if (!channelExists(channel)) {
            Queue queue = new Queue(channel, true, false, true);
            admin.declareQueue(queue);
            Binding binding = new Binding(channel, DestinationType.QUEUE, exchange.getName(), channel + ".#", null);
            admin.declareBinding(binding);
        }
    }
331822
@SuppressWarnings("unused")
    public synchronized Channel findOrCreateChannel(ChannelData channelData) throws ChannelException {
        String channelName = channelData.getName();
        Channel ret = this.existingChannels.get(channelName);
        if (ret == null) {
            // Create the new channel with the input configuration
            if (null != this.globalBufferSize) {
                // if the factory setting exists, see if the channel overrides it
                // otherwise apply it now
                Map<Object, Object> props = channelData.getPropertyBag();
                if (!props.containsKey(PROP_BUFFERSIZE)) {
                    props.put(PROP_BUFFERSIZE, this.globalBufferSize);
                }
            }
            ret = new HttpDispatcherChannel(channelData, this);
            this.existingChannels.put(channelName, ret);
        }
        return ret;
    }
296032
public static String getRemoteAddress(Channel channel) {
    if (channel != null && channel.remoteAddress() != null) {
      return channel.remoteAddress().toString();
    }
    return "<unknown remote>";
  }
631903
@Override
    public String getExtendedChannelName()
    {
        final StringBuilder name = new StringBuilder();

        if (this._isInAction)
        {
            name.append(this._actionPrefix);
            name.append("/"); //$NON-NLS-1$
        }
        name.append(this._channelName);

        if (this._isMasqueraded)
        {
            name.append(ChannelImpl.MASQ);
        }

        if (this._isZombie)
        {
            name.append(ChannelImpl.ZOMBIE);
        }

        return name.toString();

    }
214096
private GrpcChannelFactory getChannelFactory() {
        if (this.channelFactory == null) {
            final GrpcChannelFactory factory = this.applicationContext.getBean(GrpcChannelFactory.class);
            this.channelFactory = factory;
            return factory;
        }
        return this.channelFactory;
    }
905790
public ServiceRequestContext build() {
        // Determine the client address; use remote address unless overridden.
        final InetAddress clientAddress;
        if (this.clientAddress != null) {
            clientAddress = this.clientAddress;
        } else {
            clientAddress = remoteAddress().getAddress();
        }

        // Build a fake server which never starts up.
        final ServerBuilder serverBuilder = new ServerBuilder().meterRegistry(meterRegistry())
                                                               .workerGroup(eventLoop(), false)
                                                               .service(path(), service);
        serverConfigurators.forEach(configurator -> configurator.accept(serverBuilder));

        final Server server = serverBuilder.build();
        server.addListener(rejectingListener);

        // Retrieve the ServiceConfig of the fake service.
        final ServiceConfig serviceCfg = findServiceConfig(server, path(), service);

        // Build a fake object related with path mapping.
        final PathMappingContext pathMappingCtx = DefaultPathMappingContext.of(
                server.config().defaultVirtualHost(),
                localAddress().getHostString(),
                path(),
                query(),
                ((HttpRequest) request()).headers(),
                null);

        final PathMappingResult pathMappingResult =
                this.pathMappingResult != null ? this.pathMappingResult
                                               : PathMappingResult.of(path(), query());

        // Build the context with the properties set by a user and the fake objects.
        if (isRequestStartTimeSet()) {
            return new DefaultServiceRequestContext(
                    serviceCfg, fakeChannel(), meterRegistry(), sessionProtocol(), pathMappingCtx,
                    pathMappingResult, request(), sslSession(), proxiedAddresses, clientAddress,
                    requestStartTimeNanos(), requestStartTimeMicros());
        } else {
            return new DefaultServiceRequestContext(
                    serviceCfg, fakeChannel(), meterRegistry(), sessionProtocol(), pathMappingCtx,
                    pathMappingResult, request(), sslSession(), proxiedAddresses, clientAddress);
        }
    }
365953
@Override
    public Channel getOpenChannelOrFail() throws ChannelClosedException {
        final Channel ch = getChannelOrFail();
        if (ch.isClosingOrClosed()) { // TODO: Since Remoting 2.33, we still need to explicitly declare minimum Remoting version
            throw new ChannelClosedException(new IllegalStateException("The associated channel " + ch + " is closing down or has closed down", ch.getCloseRequestCause()));
        }
        return ch;
    }
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;
    }