提交 29697efd 编写于 作者: K kohsuke

Plugin is now optional

git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@15898 71c3de6d-444a-0410-be80-ed276b4c234a
上级 03b39802
...@@ -169,11 +169,6 @@ public class ClassicPluginStrategy implements PluginStrategy { ...@@ -169,11 +169,6 @@ public class ClassicPluginStrategy implements PluginStrategy {
} }
public void load(PluginWrapper wrapper) throws IOException { public void load(PluginWrapper wrapper) throws IOException {
String className = wrapper.getPluginClass();
if(className ==null) {
throw new IOException("Plugin installation failed. No 'Plugin-Class' entry in the manifest of "+wrapper.getShortName());
}
loadPluginDependencies(wrapper.getDependencies(), loadPluginDependencies(wrapper.getDependencies(),
wrapper.getOptionalDependencies()); wrapper.getOptionalDependencies());
...@@ -185,6 +180,11 @@ public class ClassicPluginStrategy implements PluginStrategy { ...@@ -185,6 +180,11 @@ public class ClassicPluginStrategy implements PluginStrategy {
ClassLoader old = Thread.currentThread().getContextClassLoader(); ClassLoader old = Thread.currentThread().getContextClassLoader();
Thread.currentThread().setContextClassLoader(wrapper.classLoader); Thread.currentThread().setContextClassLoader(wrapper.classLoader);
try { try {
String className = wrapper.getPluginClass();
if(className==null) {
// use the default dummy instance
wrapper.setPlugin(Plugin.NONE);
} else {
try { try {
Class clazz = wrapper.classLoader.loadClass(className); Class clazz = wrapper.classLoader.loadClass(className);
Object o = clazz.newInstance(); Object o = clazz.newInstance();
...@@ -199,6 +199,7 @@ public class ClassicPluginStrategy implements PluginStrategy { ...@@ -199,6 +199,7 @@ public class ClassicPluginStrategy implements PluginStrategy {
} catch (InstantiationException e) { } catch (InstantiationException e) {
throw new IOException2("Unable to create instance of " + className + " from " + wrapper.getShortName(),e); throw new IOException2("Unable to create instance of " + className + " from " + wrapper.getShortName(),e);
} }
}
// initialize plugin // initialize plugin
try { try {
......
...@@ -229,4 +229,12 @@ public abstract class Plugin implements Saveable { ...@@ -229,4 +229,12 @@ public abstract class Plugin implements Saveable {
return new XmlFile(Hudson.XSTREAM, return new XmlFile(Hudson.XSTREAM,
new File(Hudson.getInstance().getRootDir(),wrapper.getShortName()+".xml")); new File(Hudson.getInstance().getRootDir(),wrapper.getShortName()+".xml"));
} }
/**
* Dummy instance of {@link Plugin} to be used when a plugin didn't
* supply one on its own.
*
* @since 1.288
*/
public static final Plugin NONE = new Plugin() {};
} }
...@@ -31,7 +31,6 @@ import java.io.FileOutputStream; ...@@ -31,7 +31,6 @@ import java.io.FileOutputStream;
import java.io.IOException; import java.io.IOException;
import java.io.OutputStream; import java.io.OutputStream;
import java.net.URL; import java.net.URL;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.jar.Manifest; import java.util.jar.Manifest;
import java.util.logging.Logger; import java.util.logging.Logger;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册