// 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 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; }