private URL findResource(String resource) {
   ModuleWiring searchWiring = generation.getRevision().getWiring();
   if (searchWiring != null) {
     if ((generation.getRevision().getTypes() & BundleRevision.TYPE_FRAGMENT) != 0) {
       List<ModuleWire> hostWires =
           searchWiring.getRequiredModuleWires(HostNamespace.HOST_NAMESPACE);
       searchWiring = null;
       Long lowestHost = Long.MAX_VALUE;
       if (hostWires != null) {
         // search for the host with the highest ID
         for (ModuleWire hostWire : hostWires) {
           Long hostID = hostWire.getProvider().getRevisions().getModule().getId();
           if (hostID.compareTo(lowestHost) <= 0) {
             lowestHost = hostID;
             searchWiring = hostWire.getProviderWiring();
           }
         }
       }
     }
   }
   if (searchWiring != null) {
     int lastSlash = resource.lastIndexOf('/');
     String path = lastSlash > 0 ? resource.substring(0, lastSlash) : "/"; // $NON-NLS-1$
     String fileName = lastSlash != -1 ? resource.substring(lastSlash + 1) : resource;
     List<URL> result = searchWiring.findEntries(path, fileName, 0);
     return (result == null || result.isEmpty()) ? null : result.get(0);
   }
   // search the raw bundle file for the generation
   return generation.getEntry(resource);
 }