コード例 #1
0
  /**
   * Returns a collection of composite sniffers that recognized some parts of the passed archive as
   * components their container handle.
   *
   * <p>If no sniffer recognize the passed archive, an empty collection is returned.
   *
   * @param context deployment context
   * @return possibly empty collection of sniffers that handle the passed archive.
   */
  public Collection<CompositeSniffer> getCompositeSniffers(DeploymentContext context) {
    // it is important to keep an ordered sequence here to keep sniffers
    // in their natural order.

    List<CompositeSniffer> appSniffers =
        getApplicableSniffers(context, getCompositeSniffers(), false);

    // call handles method of the sniffers
    for (CompositeSniffer sniffer : getCompositeSniffers()) {
      if (!appSniffers.contains(sniffer) && sniffer.handles(context)) {
        appSniffers.add(sniffer);
      }
    }
    return appSniffers;
  }
コード例 #2
0
  public Collection<Sniffer> getSniffers(DeploymentContext context, List<URI> uris, Types types) {
    // it is important to keep an ordered sequence here to keep sniffers
    // in their natural order.
    List<Sniffer> regularSniffers = new ArrayList<Sniffer>();
    for (Sniffer sniffer : getSniffers()) {
      if (!(sniffer instanceof CompositeSniffer)) regularSniffers.add(sniffer);
    }

    // scan for registered annotations and retrieve applicable sniffers
    List<Sniffer> appSniffers = this.getApplicableSniffers(uris, types, regularSniffers, true);

    // call handles method of the sniffers
    for (Sniffer sniffer : regularSniffers) {
      if (!appSniffers.contains(sniffer) && sniffer.handles(context)) {
        appSniffers.add(sniffer);
      }
    }
    return appSniffers;
  }