Index: src/java/org/apache/nutch/plugin/PluginRepository.java
===================================================================
--- src/java/org/apache/nutch/plugin/PluginRepository.java	(revision 627090)
+++ src/java/org/apache/nutch/plugin/PluginRepository.java	(working copy)
@@ -16,19 +16,29 @@
  */
 package org.apache.nutch.plugin;
 
+import java.io.File;
+import java.io.IOException;
 import java.lang.reflect.Constructor;
 import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.net.URLDecoder;
 import java.util.ArrayList;
 import java.util.HashMap;
-import java.util.WeakHashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.WeakHashMap;
 import java.util.regex.Pattern;
+
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.fs.FileUtil;
+import org.apache.hadoop.util.StringUtils;
+import org.apache.nutch.util.JarUtils;
 import org.apache.nutch.util.NutchConfiguration;
+import org.apache.nutch.util.TempResourceManager;
 
 /**
  * The plugin repositority is a registry of all plugins.
@@ -56,6 +66,62 @@
   private Configuration conf;
 
   public static final Log LOG = LogFactory.getLog(PluginRepository.class);
+  
+  private String handlePluginJars() {
+ 
+    File tempPluginDir = null;
+    ClassLoader loader = this.getClass().getClassLoader();
+    List<String> jarfiles = new ArrayList<String>();
+      
+    try {
+      while (loader != null) {
+        if (loader instanceof URLClassLoader) {
+          URLClassLoader ucl = (URLClassLoader) loader;
+          URL[] urls = ucl.getURLs();
+          for (int i = 0; i < urls.length; i++) {
+            URL url = urls[i];
+            String fullpath = url.toString();
+            if (!fullpath.endsWith("/")) {
+              String fileName = fullpath
+                .substring(fullpath.lastIndexOf("/") + 1);
+              if (fileName.endsWith("plugin.jar") || fileName.endsWith("plugins.jar")) {
+                String toReturn = url.getPath();
+                if (toReturn.startsWith("file:")) {
+                  toReturn = toReturn.substring("file:".length());
+                }
+                String jarfile = URLDecoder.decode(toReturn, "UTF-8");
+                jarfile = jarfile.replaceAll("!.*$", "");
+                jarfiles.add(jarfile);
+              }
+            }
+          }
+        }
+        loader = loader.getParent();
+      }
+    
+      String tempName = conf.get("plugin.jar.tempdir", 
+        System.getProperty("java.io.tmpdir"));
+      String tempPlugins = "plugin_" + System.currentTimeMillis();
+      tempPluginDir = new File(tempName + File.separator + tempPlugins);
+      tempPluginDir.mkdir();
+      TempResourceManager resMan = TempResourceManager.getInstance();
+      resMan.addResource(tempPlugins, tempPluginDir);
+        
+      for (int i = 0; i < jarfiles.size(); i++) {
+        File toUnjar = new File(jarfiles.get(i));
+        JarUtils.unJar(toUnjar, tempPluginDir);
+      }
+      
+      FileUtil.fullyDelete(new File(tempPluginDir, "META-INF"));
+    }
+    catch (IOException e) {
+      LOG.error("Error processing plugin jars: " + 
+        StringUtils.stringifyException(e));
+    }
+    
+    return (tempPluginDir != null && tempPluginDir.exists()) ? 
+      tempPluginDir.getAbsolutePath() : null;
+  }
 
   /**
    * @throws PluginRuntimeException
@@ -66,10 +132,16 @@
     fExtensionPoints = new HashMap<String, ExtensionPoint>();
     this.conf = conf;
     this.auto = conf.getBoolean("plugin.auto-activation", true);
+    
     String[] pluginFolders = conf.getStrings("plugin.folders");
+    String[] allPluginFolders = new String[pluginFolders.length + 1];
+    System.arraycopy(pluginFolders, 0, allPluginFolders, 0, pluginFolders.length);
+    allPluginFolders[allPluginFolders.length - 1] = handlePluginJars();
+    
     PluginManifestParser manifestParser = new PluginManifestParser(conf, this);
     Map<String, PluginDescriptor> allPlugins = manifestParser
-        .parsePluginFolder(pluginFolders);
+        .parsePluginFolder(allPluginFolders);
+
     Pattern excludes = Pattern.compile(conf.get("plugin.excludes", ""));
     Pattern includes = Pattern.compile(conf.get("plugin.includes", ""));
     Map<String, PluginDescriptor> filteredPlugins = filter(excludes, includes,
Index: src/java/org/apache/nutch/util/TempResourceManager.java
===================================================================
--- src/java/org/apache/nutch/util/TempResourceManager.java	(revision 0)
+++ src/java/org/apache/nutch/util/TempResourceManager.java	(revision 0)
@@ -0,0 +1,70 @@
+package org.apache.nutch.util;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.hadoop.fs.FileUtil;
+import org.apache.hadoop.util.StringUtils;
+
+/**
+ * The TempResourceManager class will allow multiple local file resources to be
+ * registered. The manager will then delete those resources when the JVM exits
+ * via a shutdown hook.
+ */
+public class TempResourceManager {
+
+  private static final Log LOG = LogFactory.getLog(TempResourceManager.class);
+  private static final Map<String, File> resources = new HashMap<String, File>();
+  private static TempResourceManager instance = new TempResourceManager();
+  
+  private static class DeleteShutdownThread
+    extends Thread {
+
+    public void run() {
+      Iterator<String> resourceIt = resources.keySet().iterator();
+      while (resourceIt.hasNext()) {
+        String resName = resourceIt.next();
+        File resource = resources.get(resName);
+        try {
+          if (resource != null && resource.exists()) {
+            if (resource.isFile()) {
+              resource.delete();
+            }
+            else if (resource.isDirectory()) {
+              FileUtil.fullyDelete(resource);
+            }
+          }
+        }
+        catch (IOException e) {
+          LOG.debug("Error while removing resource on shutdown: "
+            + resource.getAbsolutePath() + "\n"
+            + StringUtils.stringifyException(e));
+        }
+      }
+      resources.clear();
+    }
+  }
+
+  private TempResourceManager() {
+    Runtime.getRuntime().addShutdownHook(new DeleteShutdownThread());
+  }
+
+  public static TempResourceManager getInstance() {
+    return instance;
+  }
+  
+  public void addResource(String name, File resource) {
+    if (resource != null) {
+      resources.put(name, resource);
+    }
+  }
+  
+  public File removeResource(String name) {
+    return resources.remove(name);
+  }
+}
Index: src/java/org/apache/nutch/util/JarUtils.java
===================================================================
--- src/java/org/apache/nutch/util/JarUtils.java	(revision 0)
+++ src/java/org/apache/nutch/util/JarUtils.java	(revision 0)
@@ -0,0 +1,53 @@
+package org.apache.nutch.util;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.util.Enumeration;
+import java.util.jar.JarEntry;
+import java.util.jar.JarFile;
+
+
+public class JarUtils {
+
+  public static void unJar(File jarFile, File toDir) throws IOException {
+    JarFile jar = new JarFile(jarFile);
+    try {
+      Enumeration entries = jar.entries();
+      while (entries.hasMoreElements()) {
+        JarEntry entry = (JarEntry) entries.nextElement();
+        if (!entry.isDirectory()) {
+          InputStream in = jar.getInputStream(entry);
+          try {
+            File file = new File(toDir, entry.getName());
+            if (!file.getParentFile().mkdirs()) {
+              if (!file.getParentFile().isDirectory()) {
+                throw new IOException("Mkdirs failed to create "
+                  + file.getParentFile().toString());
+              }
+            }
+            OutputStream out = new FileOutputStream(file);
+            try {
+              byte[] buffer = new byte[8192];
+              int i;
+              while ((i = in.read(buffer)) != -1) {
+                out.write(buffer, 0, i);
+              }
+            }
+            finally {
+              out.close();
+            }
+          }
+          finally {
+            in.close();
+          }
+        }
+      }
+    }
+    finally {
+      jar.close();
+    }
+  }
+}

