// Tang Yong Added
  public Sniffer getWeldSniffer(DeploymentContext context) {
    for (Sniffer sniffer : getSniffers()) {
      // using "weld" is a ugly way, because SnifferManagerImpl should not couple with
      // the concreate sniffer, however, I have not still found a good way to do it.
      // If WELD/OSGi can work normally, I will discuss the problem with sahoo.
      if (!"weld".equalsIgnoreCase(sniffer.getModuleType())) {
        continue;
      }

      if (sniffer instanceof CompositeSniffer) {
        continue;
      }

      // If using genericSniffer.handle(context) method, then I will meet a problem
      // about supportsArchiveType(archiveType), currently, weldsniffer supports the following
      // javaee-related ArchiveTypes :
      // 1)WAR
      // 2)EJB
      // 3)RAR
      // So, for a osgi jar, maybe will failed.
      if (sniffer.handles(context.getSource(), context.getClassLoader())) {
        return sniffer;
      }
    }

    return null;
  }
 public Sniffer getSniffer(String appType) {
   assert appType != null;
   for (Sniffer sniffer : getSniffers()) {
     if (appType.equalsIgnoreCase(sniffer.getModuleType())) {
       return sniffer;
     }
   }
   return null;
 }
  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;
  }
 public void validateSniffers(
     Collection<? extends Sniffer> snifferCol, DeploymentContext context) {
   for (Sniffer sniffer : snifferCol) {
     String[] incompatTypes = sniffer.getIncompatibleSnifferTypes();
     if (incompatTypes == null) return;
     for (String type : incompatTypes) {
       for (Sniffer sniffer2 : snifferCol) {
         if (sniffer2.getModuleType().equals(type)) {
           throw new IllegalArgumentException(
               localStrings.getLocalString(
                   "invalidarchivepackaging",
                   "Invalid archive packaging {2}",
                   sniffer.getModuleType(),
                   type,
                   context.getSourceDir().getPath()));
         }
       }
     }
   }
 }
 public boolean canBeIsolated(Sniffer sniffer) {
   // quick and dirty to isolate OSGi container, this avoid clashes between
   // java ee and OSGi fighting to deploy applications.
   // we may need a more generic way of doing this, maybe by adding an API to Sniffer
   return sniffer.getModuleType().equalsIgnoreCase("osgi");
 }