mirror of
https://github.com/jenkinsci/jenkins.git
synced 2026-11-04 15:45:52 +00:00
adding a method to experiment with the dynamic loading of a plugin
This commit is contained in:
1 parent
64f2b3d361
commit
94faaf3f56
3 files changed
+142
-58
No files matched your search
@@ -23,19 +23,12 @@
|
||||
*/
|
||||
package hudson;
|
||||
|
||||
import static hudson.init.InitMilestone.PLUGINS_PREPARED;
|
||||
import static hudson.init.InitMilestone.PLUGINS_STARTED;
|
||||
import static hudson.init.InitMilestone.PLUGINS_LISTED;
|
||||
|
||||
import com.google.inject.Guice;
|
||||
import com.google.inject.Injector;
|
||||
import hudson.PluginWrapper.Dependency;
|
||||
import hudson.init.InitMilestone;
|
||||
import hudson.init.InitStrategy;
|
||||
import hudson.init.InitializerFinder;
|
||||
import hudson.model.AbstractModelObject;
|
||||
import hudson.model.Failure;
|
||||
import jenkins.ClassLoaderReflectionToolkit;
|
||||
import jenkins.model.Jenkins;
|
||||
import hudson.model.UpdateCenter;
|
||||
import hudson.model.UpdateSite;
|
||||
import hudson.util.CyclicGraphDetector;
|
||||
@@ -43,6 +36,9 @@ import hudson.util.CyclicGraphDetector.CycleDetectedException;
|
||||
import hudson.util.FormValidation;
|
||||
import hudson.util.PersistedList;
|
||||
import hudson.util.Service;
|
||||
import jenkins.ClassLoaderReflectionToolkit;
|
||||
import jenkins.InitReactorRunner;
|
||||
import jenkins.model.Jenkins;
|
||||
import org.apache.commons.fileupload.FileItem;
|
||||
import org.apache.commons.fileupload.disk.DiskFileItemFactory;
|
||||
import org.apache.commons.fileupload.servlet.ServletFileUpload;
|
||||
@@ -66,25 +62,26 @@ import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Enumeration;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Hashtable;
|
||||
import java.util.List;
|
||||
import java.util.ListIterator;
|
||||
import java.util.Set;
|
||||
import java.util.Map;
|
||||
import java.util.HashMap;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.ConcurrentMap;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import static hudson.init.InitMilestone.*;
|
||||
|
||||
/**
|
||||
* Manages {@link PluginWrapper}s.
|
||||
*
|
||||
@@ -329,6 +326,37 @@ public abstract class PluginManager extends AbstractModelObject {
|
||||
}});
|
||||
}
|
||||
|
||||
/**
|
||||
* TODO: revisit where/how to expose this. This is an experiment.
|
||||
*/
|
||||
public void dynamicLoad(File arc) throws Exception {
|
||||
PluginWrapper p = strategy.createPluginWrapper(arc);
|
||||
if (getPlugin(p.getShortName())!=null)
|
||||
throw new IllegalArgumentException("Dynamic reloading isn't possible");
|
||||
|
||||
// TODO: check cyclic dependency
|
||||
|
||||
activePlugins.add(p);
|
||||
|
||||
try {
|
||||
p.resolvePluginDependencies();
|
||||
strategy.load(p);
|
||||
|
||||
p.getPlugin().postInitialize();
|
||||
} catch (Exception e) {
|
||||
failedPlugins.add(new FailedPlugin(p.getShortName(), e));
|
||||
activePlugins.remove(p);
|
||||
plugins.remove(p);
|
||||
throw e;
|
||||
}
|
||||
|
||||
// run initializers
|
||||
// TODO: need to ignore base types
|
||||
Reactor r = new Reactor(InitMilestone.ordering());
|
||||
r.addAll(new InitializerFinder(p.classLoader).discoverTasks(r));
|
||||
new InitReactorRunner().run(r);
|
||||
}
|
||||
|
||||
/**
|
||||
* If the war file has any "/WEB-INF/plugins/*.hpi", extract them into the plugin directory.
|
||||
*
|
||||
|
||||
Reference in new issue
Block a user