コード例 #1
0
  @Override
  public void prepare(Object o) {

    executor = MoreExecutors.listeningDecorator(newFixedThreadPoolWithQueueSize(5, 20));

    Preconditions.checkNotNull(providerQueue);
    Preconditions.checkNotNull(this.klass);
    Preconditions.checkNotNull(configuration.getOauth().getAppId());
    Preconditions.checkNotNull(configuration.getOauth().getAppSecret());
    Preconditions.checkNotNull(configuration.getOauth().getUserAccessToken());

    client = getFacebookClient();

    if (configuration.getInfo() != null && configuration.getInfo().size() > 0) {

      List<String> ids = new ArrayList<String>();
      List<String[]> idsBatches = new ArrayList<String[]>();

      for (String s : configuration.getInfo()) {
        if (s != null) {
          ids.add(s);

          if (ids.size() >= 100) {
            // add the batch
            idsBatches.add(ids.toArray(new String[ids.size()]));
            // reset the Ids
            ids = new ArrayList<String>();
          }
        }
      }
    }
  }
コード例 #2
0
  @Override
  public void startStream() {

    client = getFacebookClient();

    if (configuration.getInfo() != null && configuration.getInfo().size() > 0) {
      for (String id : configuration.getInfo()) {
        executor.submit(new FacebookFeedPollingTask(this, id));
      }
      running.set(true);
    } else {
      try {
        String id = client.getMe().getId();
        executor.submit(new FacebookFeedPollingTask(this, id));
        running.set(true);
      } catch (FacebookException e) {
        LOGGER.error(e.getMessage());
        running.set(false);
      }
    }
  }