/*
   * (non-Javadoc)
   *
   * @see
   * io.joynr.messaging.service.ChannelServiceDelegate#createChannel(java.
   * lang.String, java.lang.String)
   */
  @Override
  public Channel createChannel(String ccid, String trackingId) {

    try {
      // The controller has to assign the channel to a bounce proxy
      // instance.
      ControlledBounceProxyInformation bpInfo = strategy.calculateBounceProxy(ccid);

      URI channelLocation = bpFacade.createChannel(bpInfo, ccid, trackingId);

      Channel channel = new Channel(bpInfo, ccid, channelLocation);

      channelDirectory.addChannel(channel);
      bounceProxyDirectory.updateChannelAssignment(ccid, bpInfo);

      return channel;

    } catch (Throwable e) {
      // TODO do a more fine grained error handling catching different
      // types of errors later on. Note that from current specification,
      // the bounce proxy is not expected to reject this call (Channels
      // are assigned based on performance measures reported by the bounce
      // proxy).
      log.error(
          "Could not create channel on bounce proxy: channel {}, error: {}", ccid, e.getMessage());

      // TODO think of maybe trying to open a channel on a different
      // bounce proxy if it didn't work for this one
      throw new JoynrRuntimeException("Error creating channel on bounce proxy", e);
    }
  }
  /*
   * (non-Javadoc)
   *
   * @see io.joynr.messaging.service.ChannelServiceDelegate#listChannels()
   */
  @Override
  public List<ChannelInformation> listChannels() {
    List<Channel> channels = channelDirectory.getChannels();

    List<ChannelInformation> channelInformationList = new LinkedList<ChannelInformation>();
    for (Channel channel : channels) {

      ChannelInformation channelInfo = new ChannelInformation(channel.getChannelId(), 0, 0);
      channelInformationList.add(channelInfo);
    }
    return channelInformationList;
  }
 /*
  * (non-Javadoc)
  *
  * @see
  * io.joynr.messaging.service.ChannelServiceDelegate#getChannelInformation
  * (java.lang.String)
  */
 @Override
 public Channel getChannel(String ccid) {
   return channelDirectory.getChannel(ccid);
 }