コード例 #1
0
 private void loadChannel(final String channelId, final ChannelConfiguration configuration) {
   this.channels.put(
       channelId,
       new ChannelInstance(
           channelId,
           configuration.getProviderId(),
           configuration.getConfiguration(),
           this.providerTracker,
           this.aspectProcessor,
           this.eventAdmin,
           this.manager,
           this.processorFactoryTracker,
           this.triggerFactoryTracker));
 }
コード例 #2
0
  @Override
  public ChannelId create(
      final String providerId,
      final ChannelDetails details,
      final Map<MetaKey, String> configuration) {
    final String channelId = UUID.randomUUID().toString();

    final String actualProviderId;
    if (providerId != null) {
      actualProviderId = providerId;
    } else {
      actualProviderId = "apm";
    }

    final ChannelConfiguration cfg = new ChannelConfiguration();
    cfg.setProviderId(actualProviderId);
    cfg.setConfiguration(configuration);
    cfg.setDescription(details.getDescription());

    this.providerTracker.run(
        actualProviderId,
        p -> {
          final ChannelProvider provider =
              p.orElseThrow(
                  () ->
                      new IllegalStateException(
                          String.format(
                              "Channel provider '%s' is not registered", actualProviderId)));
          provider.create(channelId, configuration);
        });

    this.manager.accessRun(
        KEY_STORAGE,
        ChannelServiceModify.class,
        channels -> {
          channels.createChannel(channelId, cfg);
        });

    // FIXME: ensure that we are the only active call to the storage manager model KEY_STORAGE
    commitCreateChannel(channelId, actualProviderId, configuration);

    return new ChannelId(channelId);
  }