提交 70c10658 编写于 作者: N Nigel Magnay

Stage 1 : Create hudson.model.Jenkins, make Hudson derive from Jenkins.

Signed-off-by: NNigel Magnay <nigel.magnay@gmail.com>
上级 84a78d5b
......@@ -126,7 +126,7 @@ THE SOFTWARE.
<Match>
<!-- just a diagnostics method -->
<Class name="hudson.model.Hudson" />
<Class name="hudson.model.Jenkins" />
<Bug pattern="DM_GC" />
</Match>
......
......@@ -24,7 +24,7 @@
package hudson.util
import hudson.model.Computer
import hudson.model.Hudson
import hudson.model.Jenkins
import hudson.model.Label
import hudson.model.Queue.BlockedItem
import hudson.model.Queue.BuildableItem
......@@ -49,7 +49,7 @@ public class LoadMonitorImpl extends SafeTimerTask {
public LoadMonitorImpl(File dataFile) {
this.dataFile = dataFile;
labels = Hudson.getInstance().labels*.name;
labels = Jenkins.getInstance().labels*.name;
printHeaders();
Trigger.timer.scheduleAtFixedRate(this,0,10*1000);
}
......@@ -74,7 +74,7 @@ public class LoadMonitorImpl extends SafeTimerTask {
def data = [];
data.add(quote(FORMATTER.format(now)));
def h = Hudson.getInstance();
def h = Jenkins.getInstance();
def items = h.queue.items;
def filterByType = {Class type -> items.findAll { type.isInstance(it) } }
......
......@@ -24,7 +24,6 @@
package hudson;
import hudson.model.Saveable;
import hudson.model.Hudson;
import java.io.IOException;
......@@ -78,7 +77,7 @@ import java.io.IOException;
* </ol>
*
* <p>
* See {@link Hudson#save()} as an example if you are not sure how to implement {@link Saveable}.
* See {@link hudson.model.Jenkins#save()} as an example if you are not sure how to implement {@link Saveable}.
*
* @author Kohsuke Kawaguchi
* @since 1.249
......
......@@ -24,7 +24,7 @@
package hudson;
import hudson.PluginWrapper.Dependency;
import hudson.model.Hudson;
import hudson.model.Jenkins;
import hudson.util.IOException2;
import hudson.util.MaskingClassLoader;
import hudson.util.VersionNumber;
......@@ -258,7 +258,7 @@ public class ClassicPluginStrategy implements PluginStrategy {
public void initializeComponents(PluginWrapper plugin) {
}
public <T> List<ExtensionComponent<T>> findComponents(Class<T> type, Hudson hudson) {
public <T> List<ExtensionComponent<T>> findComponents(Class<T> type, Jenkins hudson) {
List<ExtensionFinder> finders;
if (type==ExtensionFinder.class) {
......@@ -269,7 +269,7 @@ public class ClassicPluginStrategy implements PluginStrategy {
}
/**
* See {@link ExtensionFinder#scout(Class, Hudson)} for the dead lock issue and what this does.
* See {@link ExtensionFinder#scout(Class, hudson.model.Jenkins)} for the dead lock issue and what this does.
*/
if (LOGGER.isLoggable(Level.FINER))
LOGGER.log(Level.FINER,"Scout-loading ExtensionList: "+type, new Throwable());
......
package hudson;
import hudson.model.Hudson;
import hudson.Util;
import hudson.model.Jenkins;
import javax.jmdns.JmDNS;
import javax.jmdns.ServiceInfo;
......@@ -20,7 +19,7 @@ import java.util.logging.Logger;
public class DNSMultiCast implements Closeable {
private JmDNS jmdns;
public DNSMultiCast(Hudson hudson) {
public DNSMultiCast(Jenkins hudson) {
if (disabled) return; // escape hatch
try {
......@@ -31,7 +30,7 @@ public class DNSMultiCast implements Closeable {
if (rootURL!=null)
props.put("url", rootURL);
try {
props.put("version",String.valueOf(Hudson.getVersion()));
props.put("version",String.valueOf(Jenkins.getVersion()));
} catch (IllegalArgumentException e) {
// failed to parse the version number
}
......
......@@ -25,7 +25,7 @@
package hudson;
import hudson.model.AbstractProject;
import hudson.model.Hudson;
import hudson.model.Jenkins;
import hudson.security.ACL;
import java.util.ArrayList;
......@@ -60,7 +60,7 @@ public class DependencyRunner implements Runnable {
Set<AbstractProject> topLevelProjects = new HashSet<AbstractProject>();
// Get all top-level projects
LOGGER.fine("assembling top level projects");
for (AbstractProject p : Hudson.getInstance().getAllItems(AbstractProject.class))
for (AbstractProject p : Jenkins.getInstance().getAllItems(AbstractProject.class))
if (p.getUpstreamProjects().size() == 0) {
LOGGER.fine("adding top level project " + p.getName());
topLevelProjects.add(p);
......
......@@ -25,7 +25,7 @@ package hudson;
import hudson.model.Descriptor;
import hudson.model.Describable;
import hudson.model.Hudson;
import hudson.model.Jenkins;
import hudson.model.ViewDescriptor;
import hudson.model.Descriptor.FormException;
import hudson.util.AdaptedIterator;
......@@ -49,7 +49,7 @@ import net.sf.json.JSONObject;
* {@link ExtensionList} for holding a set of {@link Descriptor}s, which is a group of descriptors for
* the same extension point.
*
* Use {@link Hudson#getDescriptorList(Class)} to obtain instances.
* Use {@link hudson.model.Jenkins#getDescriptorList(Class)} to obtain instances.
*
* @param <D>
* Represents the descriptor type. This is {@code Descriptor<T>} normally but often there are subtypes
......@@ -67,7 +67,7 @@ public class DescriptorExtensionList<T extends Describable<T>, D extends Descrip
*/
@SuppressWarnings({"unchecked", "rawtypes"})
public static <T extends Describable<T>,D extends Descriptor<T>>
DescriptorExtensionList<T,D> createDescriptorList(Hudson hudson, Class<T> describableType) {
DescriptorExtensionList<T,D> createDescriptorList(Jenkins hudson, Class<T> describableType) {
if (describableType == (Class) Publisher.class) {
return (DescriptorExtensionList) new DescriptorExtensionListImpl(hudson);
}
......@@ -79,7 +79,7 @@ public class DescriptorExtensionList<T extends Describable<T>, D extends Descrip
*/
private final Class<T> describableType;
protected DescriptorExtensionList(Hudson hudson, Class<T> describableType) {
protected DescriptorExtensionList(Jenkins hudson, Class<T> describableType) {
super(hudson, (Class)Descriptor.class, (CopyOnWriteArrayList)getLegacyDescriptors(describableType));
this.describableType = describableType;
}
......
......@@ -27,7 +27,7 @@ import com.google.common.collect.ImmutableList;
import hudson.init.InitMilestone;
import net.java.sezpoz.Index;
import net.java.sezpoz.IndexItem;
import hudson.model.Hudson;
import hudson.model.Jenkins;
import hudson.model.Descriptor;
import org.kohsuke.accmod.Restricted;
import org.kohsuke.accmod.restrictions.NoExternalUse;
......@@ -59,10 +59,10 @@ import java.lang.reflect.Method;
public abstract class ExtensionFinder implements ExtensionPoint {
/**
* @deprecated as of 1.356
* Use and implement {@link #find(Class, Hudson)} that allows us to put some metadata.
* Use and implement {@link #find(Class, hudson.model.Jenkins)} that allows us to put some metadata.
*/
@Restricted(NoExternalUse.class)
public <T> Collection<T> findExtensions(Class<T> type, Hudson hudson) {
public <T> Collection<T> findExtensions(Class<T> type, Jenkins hudson) {
return Collections.emptyList();
}
......@@ -82,15 +82,15 @@ public abstract class ExtensionFinder implements ExtensionPoint {
* @return
* Can be empty but never null.
* @since 1.356
* Older implementations provide {@link #findExtensions(Class, Hudson)}
* Older implementations provide {@link #findExtensions(Class, hudson.model.Jenkins)}
*/
public abstract <T> Collection<ExtensionComponent<T>> find(Class<T> type, Hudson hudson);
public abstract <T> Collection<ExtensionComponent<T>> find(Class<T> type, Jenkins hudson);
/**
* A pointless function to work around what appears to be a HotSpot problem. See JENKINS-5756 and bug 6933067
* on BugParade for more details.
*/
public <T> Collection<ExtensionComponent<T>> _find(Class<T> type, Hudson hudson) {
public <T> Collection<ExtensionComponent<T>> _find(Class<T> type, Jenkins hudson) {
return find(type,hudson);
}
......@@ -115,7 +115,7 @@ public abstract class ExtensionFinder implements ExtensionPoint {
* This inconsistent locking order results in a dead lock, you see.
*
* <p>
* So to reduce the likelihood, this method is called in prior to {@link #find(Class, Hudson)} invocation,
* So to reduce the likelihood, this method is called in prior to {@link #find(Class, hudson.model.Jenkins)} invocation,
* but from outside the lock. The implementation is expected to perform all the class initialization activities
* from here.
*
......@@ -124,7 +124,7 @@ public abstract class ExtensionFinder implements ExtensionPoint {
* Also see http://kohsuke.org/2010/09/01/deadlock-that-you-cant-avoid/ for how class initialization
* can results in a dead lock.
*/
public void scout(Class extensionType, Hudson hudson) {
public void scout(Class extensionType, Jenkins hudson) {
}
/**
......@@ -152,13 +152,13 @@ public abstract class ExtensionFinder implements ExtensionPoint {
// 4. thread Y decides to load extensions, now blocked on SZ.
// 5. dead lock
if (indices==null) {
ClassLoader cl = Hudson.getInstance().getPluginManager().uberClassLoader;
ClassLoader cl = Jenkins.getInstance().getPluginManager().uberClassLoader;
indices = ImmutableList.copyOf(Index.load(Extension.class, Object.class, cl));
}
return indices;
}
public <T> Collection<ExtensionComponent<T>> find(Class<T> type, Hudson hudson) {
public <T> Collection<ExtensionComponent<T>> find(Class<T> type, Jenkins hudson) {
List<ExtensionComponent<T>> result = new ArrayList<ExtensionComponent<T>>();
for (IndexItem<Extension,Object> item : getIndices()) {
......@@ -194,7 +194,7 @@ public abstract class ExtensionFinder implements ExtensionPoint {
}
@Override
public void scout(Class extensionType, Hudson hudson) {
public void scout(Class extensionType, Jenkins hudson) {
for (IndexItem<Extension,Object> item : getIndices()) {
try {
// we might end up having multiple threads concurrently calling into element(),
......
......@@ -24,13 +24,12 @@
package hudson;
import hudson.init.InitMilestone;
import hudson.model.Hudson;
import hudson.model.Jenkins;
import hudson.util.AdaptedIterator;
import hudson.util.DescriptorList;
import hudson.util.Memoizer;
import hudson.util.Iterators;
import hudson.ExtensionPoint.LegacyInstancesAreScopedToHudson;
import hudson.PluginStrategy;
import java.util.AbstractList;
import java.util.ArrayList;
......@@ -38,7 +37,6 @@ import java.util.Collection;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
import java.util.Vector;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.logging.Level;
......@@ -53,20 +51,20 @@ import java.util.logging.Logger;
* manual registration,
*
* <p>
* All {@link ExtensionList} instances should be owned by {@link Hudson}, even though
* extension points can be defined by anyone on any type. Use {@link Hudson#getExtensionList(Class)}
* and {@link Hudson#getDescriptorList(Class)} to obtain the instances.
* All {@link ExtensionList} instances should be owned by {@link hudson.model.Jenkins}, even though
* extension points can be defined by anyone on any type. Use {@link hudson.model.Jenkins#getExtensionList(Class)}
* and {@link hudson.model.Jenkins#getDescriptorList(Class)} to obtain the instances.
*
* @param <T>
* Type of the extension point. This class holds instances of the subtypes of 'T'.
*
* @author Kohsuke Kawaguchi
* @since 1.286
* @see Hudson#getExtensionList(Class)
* @see Hudson#getDescriptorList(Class)
* @see hudson.model.Jenkins#getExtensionList(Class)
* @see hudson.model.Jenkins#getDescriptorList(Class)
*/
public class ExtensionList<T> extends AbstractList<T> {
public final Hudson hudson;
public final Jenkins hudson;
public final Class<T> extensionType;
/**
......@@ -81,7 +79,7 @@ public class ExtensionList<T> extends AbstractList<T> {
*/
private final CopyOnWriteArrayList<ExtensionComponent<T>> legacyInstances;
protected ExtensionList(Hudson hudson, Class<T> extensionType) {
protected ExtensionList(Jenkins hudson, Class<T> extensionType) {
this(hudson,extensionType,new CopyOnWriteArrayList<ExtensionComponent<T>>());
}
......@@ -92,7 +90,7 @@ public class ExtensionList<T> extends AbstractList<T> {
* omits this uses a new {@link Vector}, making the storage lifespan tied to the life of {@link ExtensionList}.
* If the manually registered instances are scoped to VM level, the caller should pass in a static list.
*/
protected ExtensionList(Hudson hudson, Class<T> extensionType, CopyOnWriteArrayList<ExtensionComponent<T>> legacyStore) {
protected ExtensionList(Jenkins hudson, Class<T> extensionType, CopyOnWriteArrayList<ExtensionComponent<T>> legacyStore) {
this.hudson = hudson;
this.extensionType = extensionType;
this.legacyInstances = legacyStore;
......@@ -200,7 +198,7 @@ public class ExtensionList<T> extends AbstractList<T> {
private List<ExtensionComponent<T>> ensureLoaded() {
if(extensions!=null)
return extensions; // already loaded
if(Hudson.getInstance().getInitLevel().compareTo(InitMilestone.PLUGINS_PREPARED)<0)
if(Jenkins.getInstance().getInitLevel().compareTo(InitMilestone.PLUGINS_PREPARED)<0)
return legacyInstances; // can't perform the auto discovery until all plugins are loaded, so just make the legacy instances visible
synchronized (getLoadLock()) {
......@@ -250,7 +248,7 @@ public class ExtensionList<T> extends AbstractList<T> {
return r;
}
public static <T> ExtensionList<T> create(Hudson hudson, Class<T> type) {
public static <T> ExtensionList<T> create(Jenkins hudson, Class<T> type) {
if(type.getAnnotation(LegacyInstancesAreScopedToHudson.class)!=null)
return new ExtensionList<T>(hudson,type);
else {
......
......@@ -23,7 +23,7 @@
*/
package hudson;
import hudson.model.Hudson;
import hudson.model.Jenkins;
import hudson.tasks.UserNameResolver;
import hudson.util.CopyOnWriteList;
......@@ -37,7 +37,7 @@ import java.util.Collection;
*
* <p>
* Instances of this class can be created statically as a singleton, but it provides the view
* to {@link ExtensionList} of the current {@link Hudson}.
* to {@link ExtensionList} of the current {@link hudson.model.Jenkins}.
* Write operations to this list will update the legacy instances on {@link ExtensionList}.
*
* <p>
......@@ -58,7 +58,7 @@ public class ExtensionListView {
public static <T> List<T> createList(final Class<T> type) {
return new AbstractList<T>() {
private ExtensionList<T> storage() {
return Hudson.getInstance().getExtensionList(type);
return Jenkins.getInstance().getExtensionList(type);
}
@Override
......@@ -103,7 +103,7 @@ public class ExtensionListView {
public static <T> CopyOnWriteList<T> createCopyOnWriteList(final Class<T> type) {
return new CopyOnWriteList<T>() {
private ExtensionList<T> storage() {
return Hudson.getInstance().getExtensionList(type);
return Jenkins.getInstance().getExtensionList(type);
}
@Override
......
......@@ -23,8 +23,6 @@
*/
package hudson;
import hudson.model.Hudson;
import static java.lang.annotation.ElementType.TYPE;
import java.lang.annotation.Retention;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
......@@ -50,7 +48,7 @@ import java.lang.annotation.Target;
public interface ExtensionPoint {
/**
* Used by designers of extension points (direct subtypes of {@link ExtensionPoint}) to indicate that
* the legacy instances are scoped to {@link Hudson} instance. By default, legacy instances are
* the legacy instances are scoped to {@link hudson.model.Jenkins} instance. By default, legacy instances are
* static scope.
*/
@Target(TYPE)
......
......@@ -27,7 +27,7 @@ package hudson;
import hudson.Launcher.LocalLauncher;
import hudson.Launcher.RemoteLauncher;
import hudson.model.Hudson;
import hudson.model.Jenkins;
import hudson.model.TaskListener;
import hudson.model.AbstractProject;
import hudson.model.Item;
......@@ -755,7 +755,7 @@ public final class FilePath implements Serializable {
}
} else {
// the file is on the local machine.
return callable.invoke(new File(remote), Hudson.MasterComputer.localChannel);
return callable.invoke(new File(remote), Jenkins.MasterComputer.localChannel);
}
}
......@@ -765,7 +765,7 @@ public final class FilePath implements Serializable {
*/
public <T> Future<T> actAsync(final FileCallable<T> callable) throws IOException, InterruptedException {
try {
return (channel!=null ? channel : Hudson.MasterComputer.localChannel)
return (channel!=null ? channel : Jenkins.MasterComputer.localChannel)
.callAsync(new FileCallableWrapper<T>(callable));
} catch (IOException e) {
// wrap it into a new IOException so that we get the caller's stack trace as well.
......@@ -1896,7 +1896,7 @@ public final class FilePath implements Serializable {
private static void checkPermissionForValidate() {
AccessControlled subject = Stapler.getCurrentRequest().findAncestorObject(AbstractProject.class);
if (subject == null)
Hudson.getInstance().checkPermission(Hudson.ADMINISTER);
Jenkins.getInstance().checkPermission(Jenkins.ADMINISTER);
else
subject.checkPermission(Item.CONFIGURE);
}
......@@ -1920,7 +1920,7 @@ public final class FilePath implements Serializable {
public VirtualChannel getChannel() {
if(channel!=null) return channel;
else return Hudson.MasterComputer.localChannel;
else return Jenkins.MasterComputer.localChannel;
}
/**
......
......@@ -30,7 +30,7 @@ import hudson.model.Computer;
import hudson.model.Describable;
import hudson.model.Job;
import hudson.model.TaskListener;
import hudson.model.Hudson;
import hudson.model.Jenkins;
import hudson.model.listeners.RunListener;
import hudson.scm.SCM;
......@@ -174,7 +174,7 @@ public abstract class FileSystemProvisioner implements ExtensionPoint, Describab
public abstract WorkspaceSnapshot snapshot(AbstractBuild<?,?> build, FilePath ws, String glob, TaskListener listener) throws IOException, InterruptedException;
public FileSystemProvisionerDescriptor getDescriptor() {
return (FileSystemProvisionerDescriptor) Hudson.getInstance().getDescriptorOrDie(getClass());
return (FileSystemProvisionerDescriptor) Jenkins.getInstance().getDescriptorOrDie(getClass());
}
/**
......@@ -186,7 +186,7 @@ public abstract class FileSystemProvisioner implements ExtensionPoint, Describab
* Returns all the registered {@link FileSystemProvisioner} descriptors.
*/
public static DescriptorExtensionList<FileSystemProvisioner,FileSystemProvisionerDescriptor> all() {
return Hudson.getInstance().<FileSystemProvisioner,FileSystemProvisionerDescriptor>getDescriptorList(FileSystemProvisioner.class);
return Jenkins.getInstance().<FileSystemProvisioner,FileSystemProvisionerDescriptor>getDescriptorList(FileSystemProvisioner.class);
}
/**
......
......@@ -27,27 +27,8 @@ package hudson;
import hudson.cli.CLICommand;
import hudson.console.ConsoleAnnotationDescriptor;
import hudson.console.ConsoleAnnotatorFactory;
import hudson.model.AbstractProject;
import hudson.model.Action;
import hudson.model.Describable;
import hudson.model.Descriptor;
import hudson.model.DescriptorVisibilityFilter;
import hudson.model.Hudson;
import hudson.model.Item;
import hudson.model.ItemGroup;
import hudson.model.Items;
import hudson.model.Job;
import hudson.model.JobPropertyDescriptor;
import hudson.model.ModelObject;
import hudson.model.Node;
import hudson.model.PageDecorator;
import hudson.model.ParameterDefinition;
import hudson.model.*;
import hudson.model.ParameterDefinition.ParameterDescriptor;
import hudson.model.Project;
import hudson.model.Run;
import hudson.model.TopLevelItem;
import hudson.model.View;
import hudson.model.JDK;
import hudson.search.SearchableModelObject;
import hudson.security.AccessControlled;
import hudson.security.AuthorizationStrategy;
......@@ -187,7 +168,7 @@ public class Functions {
}
public JDK.DescriptorImpl getJDKDescriptor() {
return Hudson.getInstance().getDescriptorByType(JDK.DescriptorImpl.class);
return Jenkins.getInstance().getDescriptorByType(JDK.DescriptorImpl.class);
}
/**
......@@ -291,7 +272,7 @@ public class Functions {
* </pre>
*
* <p>
* The head portion is the part of the URL from the {@link Hudson}
* The head portion is the part of the URL from the {@link hudson.model.Jenkins}
* object to the first {@link Run} subtype. When "next/prev build"
* is chosen, this part remains intact.
*
......@@ -376,7 +357,7 @@ public class Functions {
}
public static List<LogRecord> getLogRecords() {
return Hudson.logRecords;
return Jenkins.logRecords;
}
public static String printLogRecord(LogRecord r) {
......@@ -569,7 +550,7 @@ public class Functions {
}
public static void checkPermission(Permission permission) throws IOException, ServletException {
checkPermission(Hudson.getInstance(),permission);
checkPermission(Jenkins.getInstance(),permission);
}
public static void checkPermission(AccessControlled object, Permission permission) throws IOException, ServletException {
......@@ -598,7 +579,7 @@ public class Functions {
return;
}
}
checkPermission(Hudson.getInstance(),permission);
checkPermission(Jenkins.getInstance(),permission);
}
}
......@@ -609,7 +590,7 @@ public class Functions {
* If null, returns true. This defaulting is convenient in making the use of this method terse.
*/
public static boolean hasPermission(Permission permission) throws IOException, ServletException {
return hasPermission(Hudson.getInstance(),permission);
return hasPermission(Jenkins.getInstance(),permission);
}
/**
......@@ -629,14 +610,14 @@ public class Functions {
return ((AccessControlled)o).hasPermission(permission);
}
}
return Hudson.getInstance().hasPermission(permission);
return Jenkins.getInstance().hasPermission(permission);
}
}
public static void adminCheck(StaplerRequest req, StaplerResponse rsp, Object required, Permission permission) throws IOException, ServletException {
// this is legacy --- all views should be eventually converted to
// the permission based model.
if(required!=null && !Hudson.adminCheck(req,rsp)) {
if(required!=null && !Hudson.adminCheck(req, rsp)) {
// check failed. commit the FORBIDDEN response, then abort.
rsp.setStatus(HttpServletResponse.SC_FORBIDDEN);
rsp.getOutputStream().close();
......@@ -652,7 +633,7 @@ public class Functions {
* Infers the hudson installation URL from the given request.
*/
public static String inferHudsonURL(StaplerRequest req) {
String rootUrl = Hudson.getInstance().getRootUrl();
String rootUrl = Jenkins.getInstance().getRootUrl();
if(rootUrl !=null)
// prefer the one explicitly configured, to work with load-balancer, frontend, etc.
return rootUrl;
......@@ -694,7 +675,7 @@ public class Functions {
}
public static List<Descriptor<ComputerLauncher>> getComputerLauncherDescriptors() {
return Hudson.getInstance().<ComputerLauncher,Descriptor<ComputerLauncher>>getDescriptorList(ComputerLauncher.class);
return Jenkins.getInstance().<ComputerLauncher,Descriptor<ComputerLauncher>>getDescriptorList(ComputerLauncher.class);
}
public static List<Descriptor<RetentionStrategy<?>>> getRetentionStrategyDescriptors() {
......@@ -715,7 +696,7 @@ public class Functions {
public static List<NodePropertyDescriptor> getNodePropertyDescriptors(Class<? extends Node> clazz) {
List<NodePropertyDescriptor> result = new ArrayList<NodePropertyDescriptor>();
Collection<NodePropertyDescriptor> list = (Collection) Hudson.getInstance().getDescriptorList(NodeProperty.class);
Collection<NodePropertyDescriptor> list = (Collection) Jenkins.getInstance().getDescriptorList(NodeProperty.class);
for (NodePropertyDescriptor npd : list) {
if (npd.isApplicable(clazz)) {
result.add(npd);
......@@ -730,7 +711,7 @@ public class Functions {
*/
public static Collection<Descriptor> getSortedDescriptorsForGlobalConfig() {
Map<String,Descriptor> r = new TreeMap<String, Descriptor>();
for (Descriptor<?> d : Hudson.getInstance().getExtensionList(Descriptor.class)) {
for (Descriptor<?> d : Jenkins.getInstance().getExtensionList(Descriptor.class)) {
if (d.getGlobalConfigPage()==null) continue;
r.put(buildSuperclassHierarchy(d.clazz, new StringBuilder()).toString(),d);
}
......@@ -787,7 +768,7 @@ public class Functions {
ItemGroup ig = i.getParent();
url = i.getShortUrl()+url;
if(ig==Hudson.getInstance()) {
if(ig== Jenkins.getInstance()) {
assert i instanceof TopLevelItem;
if(view!=null && view.contains((TopLevelItem)i)) {
// if p and the current page belongs to the same view, then return a relative path
......@@ -987,14 +968,14 @@ public class Functions {
}
public static String getVersion() {
return Hudson.VERSION;
return Jenkins.VERSION;
}
/**
* Resoruce path prefix.
*/
public static String getResourcePath() {
return Hudson.RESOURCE_PATH;
return Jenkins.RESOURCE_PATH;
}
public static String getViewResource(Object it, String path) {
......@@ -1006,7 +987,7 @@ public class Functions {
clazz = ((Descriptor)it).clazz;
StringBuilder buf = new StringBuilder(Stapler.getCurrentRequest().getContextPath());
buf.append(Hudson.VIEW_RESOURCE_PATH).append('/');
buf.append(Jenkins.VIEW_RESOURCE_PATH).append('/');
buf.append(clazz.getName().replace('.','/').replace('$','/'));
buf.append('/').append(path);
......@@ -1082,7 +1063,7 @@ public class Functions {
* Checks if the current user is anonymous.
*/
public static boolean isAnonymous() {
return Hudson.getAuthentication() instanceof AnonymousAuthenticationToken;
return Jenkins.getAuthentication() instanceof AnonymousAuthenticationToken;
}
/**
......@@ -1169,7 +1150,7 @@ public class Functions {
public String getServerName() {
// Try to infer this from the configured root URL.
// This makes it work correctly when Hudson runs behind a reverse proxy.
String url = Hudson.getInstance().getRootUrl();
String url = Jenkins.getInstance().getRootUrl();
try {
if(url!=null) {
String host = new URL(url).getHost();
......@@ -1219,7 +1200,7 @@ public class Functions {
*/
public static List<PageDecorator> getPageDecorators() {
// this method may be called to render start up errors, at which point Hudson doesn't exist yet. see HUDSON-3608
if(Hudson.getInstance()==null) return Collections.emptyList();
if(Jenkins.getInstance()==null) return Collections.emptyList();
return PageDecorator.all();
}
......@@ -1241,13 +1222,13 @@ public class Functions {
}
public static String getCrumb(StaplerRequest req) {
Hudson h = Hudson.getInstance();
Jenkins h = Jenkins.getInstance();
CrumbIssuer issuer = h != null ? h.getCrumbIssuer() : null;
return issuer != null ? issuer.getCrumb(req) : "";
}
public static String getCrumbRequestField() {
Hudson h = Hudson.getInstance();
Jenkins h = Jenkins.getInstance();
CrumbIssuer issuer = h != null ? h.getCrumbIssuer() : null;
return issuer != null ? issuer.getDescriptor().getCrumbRequestField() : "";
}
......
......@@ -25,7 +25,7 @@ package hudson;
import hudson.Proc.LocalProc;
import hudson.model.Computer;
import hudson.model.Hudson;
import hudson.model.Jenkins;
import hudson.model.TaskListener;
import hudson.model.Node;
import hudson.remoting.Callable;
......@@ -130,7 +130,7 @@ public abstract class Launcher {
* {@link Computer#currentComputer()}
*/
public Computer getComputer() {
for( Computer c : Hudson.getInstance().getComputers() )
for( Computer c : Jenkins.getInstance().getComputers() )
if(c.getChannel()==channel)
return c;
return null;
......@@ -677,7 +677,7 @@ public abstract class Launcher {
*/
public static class LocalLauncher extends Launcher {
public LocalLauncher(TaskListener listener) {
this(listener,Hudson.MasterComputer.localChannel);
this(listener, Jenkins.MasterComputer.localChannel);
}
public LocalLauncher(TaskListener listener, VirtualChannel channel) {
......
package hudson;
import hudson.model.Hudson;
import hudson.model.Jenkins;
import hudson.model.Node;
import hudson.model.Executor;
import hudson.tasks.BuildWrapper;
......@@ -45,6 +45,6 @@ public abstract class LauncherDecorator implements ExtensionPoint {
* Returns all the registered {@link LauncherDecorator}s.
*/
public static ExtensionList<LauncherDecorator> all() {
return Hudson.getInstance().getExtensionList(LauncherDecorator.class);
return Jenkins.getInstance().getExtensionList(LauncherDecorator.class);
}
}
......@@ -24,7 +24,7 @@
package hudson;
import hudson.model.Hudson;
import hudson.model.Jenkins;
import java.io.File;
import java.io.IOException;
......@@ -42,8 +42,8 @@ import java.util.logging.Logger;
* @author Kohsuke Kawaguchi
*/
public class LocalPluginManager extends PluginManager {
private final Hudson hudson;
public LocalPluginManager(Hudson hudson) {
private final Jenkins hudson;
public LocalPluginManager(Jenkins hudson) {
super(hudson.servletContext, new File(hudson.getRootDir(),"plugins"));
this.hudson = hudson;
}
......
......@@ -23,7 +23,7 @@
*/
package hudson;
import hudson.model.Hudson;
import hudson.model.Jenkins;
import hudson.model.Descriptor;
import hudson.model.Saveable;
import hudson.model.listeners.ItemListener;
......@@ -100,7 +100,7 @@ public abstract class Plugin implements Saveable {
*
* <p>
* This method is called after {@link #setServletContext(ServletContext)} is invoked.
* You can also use {@link Hudson#getInstance()} to access the singleton hudson instance,
* You can also use {@link hudson.model.Jenkins#getInstance()} to access the singleton hudson instance,
* although the plugin start up happens relatively early in the initialization
* stage and not all the data are loaded in Hudson.
*
......@@ -242,8 +242,8 @@ public abstract class Plugin implements Saveable {
* @since 1.245
*/
protected XmlFile getConfigXml() {
return new XmlFile(Hudson.XSTREAM,
new File(Hudson.getInstance().getRootDir(),wrapper.getShortName()+".xml"));
return new XmlFile(Jenkins.XSTREAM,
new File(Jenkins.getInstance().getRootDir(),wrapper.getShortName()+".xml"));
}
......
......@@ -32,7 +32,7 @@ import hudson.init.InitStrategy;
import hudson.init.InitializerFinder;
import hudson.model.AbstractModelObject;
import hudson.model.Failure;
import hudson.model.Hudson;
import hudson.model.Jenkins;
import hudson.model.UpdateCenter;
import hudson.model.UpdateSite;
import hudson.util.CyclicGraphDetector;
......@@ -103,7 +103,7 @@ public abstract class PluginManager extends AbstractModelObject {
/**
* @deprecated as of 1.355
* {@link PluginManager} can now live longer than {@link Hudson} instance, so
* {@link PluginManager} can now live longer than {@link hudson.model.Jenkins} instance, so
* use {@code Hudson.getInstance().servletContext} instead.
*/
public final ServletContext context;
......@@ -150,7 +150,7 @@ public abstract class PluginManager extends AbstractModelObject {
/**
* Called immediately after the construction.
* This is a separate method so that code executed from here will see a valid value in
* {@link Hudson#pluginManager}.
* {@link hudson.model.Jenkins#pluginManager}.
*/
public TaskBuilder initTasks(final InitStrategy initStrategy) {
TaskBuilder builder;
......@@ -265,7 +265,7 @@ public abstract class PluginManager extends AbstractModelObject {
* Once the plugins are listed, schedule their initialization.
*/
public void run(Reactor session) throws Exception {
Hudson.getInstance().lookup.set(PluginInstanceStore.class,new PluginInstanceStore());
Jenkins.getInstance().lookup.set(PluginInstanceStore.class,new PluginInstanceStore());
TaskGraphBuilder g = new TaskGraphBuilder();
// schedule execution of loading plugins
......@@ -486,10 +486,10 @@ public abstract class PluginManager extends AbstractModelObject {
}
public HttpResponse doUpdateSources(StaplerRequest req) throws IOException {
Hudson.getInstance().checkPermission(Hudson.ADMINISTER);
Jenkins.getInstance().checkPermission(Jenkins.ADMINISTER);
if (req.hasParameter("remove")) {
UpdateCenter uc = Hudson.getInstance().getUpdateCenter();
UpdateCenter uc = Jenkins.getInstance().getUpdateCenter();
BulkChange bc = new BulkChange(uc);
try {
for (String id : req.getParameterValues("sources"))
......@@ -515,7 +515,7 @@ public abstract class PluginManager extends AbstractModelObject {
n = n.substring(7);
if (n.indexOf(".") > 0) {
String[] pluginInfo = n.split("\\.");
UpdateSite.Plugin p = Hudson.getInstance().getUpdateCenter().getById(pluginInfo[1]).getPlugin(pluginInfo[0]);
UpdateSite.Plugin p = Jenkins.getInstance().getUpdateCenter().getById(pluginInfo[1]).getPlugin(pluginInfo[0]);
if(p==null)
throw new Failure("No such plugin: "+n);
p.deploy();
......@@ -530,8 +530,8 @@ public abstract class PluginManager extends AbstractModelObject {
* Bare-minimum configuration mechanism to change the update center.
*/
public HttpResponse doSiteConfigure(@QueryParameter String site) throws IOException {
Hudson hudson = Hudson.getInstance();
hudson.checkPermission(Hudson.ADMINISTER);
Jenkins hudson = Jenkins.getInstance();
hudson.checkPermission(Jenkins.ADMINISTER);
UpdateCenter uc = hudson.getUpdateCenter();
PersistedList<UpdateSite> sites = uc.getSites();
for (UpdateSite s : sites) {
......@@ -549,8 +549,8 @@ public abstract class PluginManager extends AbstractModelObject {
@QueryParameter("proxy.port") String port,
@QueryParameter("proxy.userName") String userName,
@QueryParameter("proxy.password") String password) throws IOException {
Hudson hudson = Hudson.getInstance();
hudson.checkPermission(Hudson.ADMINISTER);
Jenkins hudson = Jenkins.getInstance();
hudson.checkPermission(Jenkins.ADMINISTER);
server = Util.fixEmptyAndTrim(server);
if(server==null) {
......@@ -572,7 +572,7 @@ public abstract class PluginManager extends AbstractModelObject {
*/
public HttpResponse doUploadPlugin(StaplerRequest req) throws IOException, ServletException {
try {
Hudson.getInstance().checkPermission(Hudson.ADMINISTER);
Jenkins.getInstance().checkPermission(Jenkins.ADMINISTER);
ServletFileUpload upload = new ServletFileUpload(new DiskFileItemFactory());
......
......@@ -23,7 +23,7 @@
*/
package hudson;
import hudson.model.Hudson;
import hudson.model.Jenkins;
import java.io.File;
import java.io.IOException;
......@@ -74,5 +74,5 @@ public interface PluginStrategy extends ExtensionPoint {
* @return Sequence of components
* @since 1.400
*/
public abstract <T> List<ExtensionComponent<T>> findComponents(Class<T> type, Hudson hudson);
public abstract <T> List<ExtensionComponent<T>> findComponents(Class<T> type, Jenkins hudson);
}
......@@ -25,7 +25,7 @@
package hudson;
import hudson.PluginManager.PluginInstanceStore;
import hudson.model.Hudson;
import hudson.model.Jenkins;
import hudson.model.UpdateCenter;
import hudson.model.UpdateSite;
import hudson.util.VersionNumber;
......@@ -255,7 +255,7 @@ public class PluginWrapper implements Comparable<PluginWrapper> {
* Gets the instance of {@link Plugin} contributed by this plugin.
*/
public Plugin getPlugin() {
return Hudson.lookup(PluginInstanceStore.class).store.get(this);
return Jenkins.lookup(PluginInstanceStore.class).store.get(this);
}
/**
......@@ -389,7 +389,7 @@ public class PluginWrapper implements Comparable<PluginWrapper> {
}
public void setPlugin(Plugin plugin) {
Hudson.lookup(PluginInstanceStore.class).store.put(this,plugin);
Jenkins.lookup(PluginInstanceStore.class).store.put(this,plugin);
plugin.wrapper = this;
}
......@@ -439,7 +439,7 @@ public class PluginWrapper implements Comparable<PluginWrapper> {
* the user may have installed a plugin locally developed.
*/
public UpdateSite.Plugin getUpdateInfo() {
UpdateCenter uc = Hudson.getInstance().getUpdateCenter();
UpdateCenter uc = Jenkins.getInstance().getUpdateCenter();
UpdateSite.Plugin p = uc.getPlugin(getShortName());
if(p!=null && p.isNewerThan(getVersion())) return p;
return null;
......@@ -449,7 +449,7 @@ public class PluginWrapper implements Comparable<PluginWrapper> {
* returns the {@link UpdateSite.Plugin} object, or null.
*/
public UpdateSite.Plugin getInfo() {
UpdateCenter uc = Hudson.getInstance().getUpdateCenter();
UpdateCenter uc = Jenkins.getInstance().getUpdateCenter();
return uc.getPlugin(getShortName());
}
......@@ -486,7 +486,7 @@ public class PluginWrapper implements Comparable<PluginWrapper> {
* Where is the backup file?
*/
public File getBackupFile() {
return new File(Hudson.getInstance().getRootDir(),"plugins/"+getShortName() + ".bak");
return new File(Jenkins.getInstance().getRootDir(),"plugins/"+getShortName() + ".bak");
}
/**
......@@ -513,25 +513,25 @@ public class PluginWrapper implements Comparable<PluginWrapper> {
//
//
public HttpResponse doMakeEnabled() throws IOException {
Hudson.getInstance().checkPermission(Hudson.ADMINISTER);
Jenkins.getInstance().checkPermission(Jenkins.ADMINISTER);
enable();
return HttpResponses.ok();
}
public HttpResponse doMakeDisabled() throws IOException {
Hudson.getInstance().checkPermission(Hudson.ADMINISTER);
Jenkins.getInstance().checkPermission(Jenkins.ADMINISTER);
disable();
return HttpResponses.ok();
}
public HttpResponse doPin() throws IOException {
Hudson.getInstance().checkPermission(Hudson.ADMINISTER);
Jenkins.getInstance().checkPermission(Jenkins.ADMINISTER);
new FileOutputStream(pinFile).close();
return HttpResponses.ok();
}
public HttpResponse doUnpin() throws IOException {
Hudson.getInstance().checkPermission(Hudson.ADMINISTER);
Jenkins.getInstance().checkPermission(Jenkins.ADMINISTER);
pinFile.delete();
return HttpResponses.ok();
}
......
......@@ -23,7 +23,7 @@
*/
package hudson;
import hudson.model.Hudson;
import hudson.model.Jenkins;
import hudson.model.Saveable;
import hudson.model.listeners.SaveableListener;
import hudson.util.Scrambler;
......@@ -52,7 +52,7 @@ import com.thoughtworks.xstream.XStream;
* <a href="http://java.sun.com/javase/6/docs/technotes/guides/net/http-auth.html">
* Http Authentication</a>).
*
* @see Hudson#proxy
* @see hudson.model.Jenkins#proxy
*/
public final class ProxyConfiguration implements Saveable {
public final String name;
......@@ -95,7 +95,7 @@ public final class ProxyConfiguration implements Saveable {
}
public static XmlFile getXmlFile() {
return new XmlFile(XSTREAM, new File(Hudson.getInstance().getRootDir(), "proxy.xml"));
return new XmlFile(XSTREAM, new File(Jenkins.getInstance().getRootDir(), "proxy.xml"));
}
public static ProxyConfiguration load() throws IOException {
......@@ -110,7 +110,7 @@ public final class ProxyConfiguration implements Saveable {
* This method should be used wherever {@link URL#openConnection()} to internet URLs is invoked directly.
*/
public static URLConnection open(URL url) throws IOException {
Hudson h = Hudson.getInstance(); // this code might run on slaves
Jenkins h = Jenkins.getInstance(); // this code might run on slaves
ProxyConfiguration p = h!=null ? h.proxy : null;
if(p==null)
return url.openConnection();
......@@ -122,7 +122,7 @@ public final class ProxyConfiguration implements Saveable {
@Override
public PasswordAuthentication getPasswordAuthentication() {
if (getRequestorType()!=RequestorType.PROXY) return null;
ProxyConfiguration p = Hudson.getInstance().proxy;
ProxyConfiguration p = Jenkins.getInstance().proxy;
return new PasswordAuthentication(p.getUserName(),
p.getPassword().toCharArray());
}
......
......@@ -23,7 +23,7 @@
*/
package hudson;
import hudson.model.Hudson;
import hudson.model.Jenkins;
import hudson.model.Computer;
import hudson.slaves.OfflineCause;
import hudson.slaves.SlaveComputer;
......@@ -67,7 +67,7 @@ import java.util.logging.Logger;
* unauthorized remote slaves.
*
* <p>
* The approach here is to have {@link Hudson#getSecretKey() a secret key} on the master.
* The approach here is to have {@link hudson.model.Jenkins#getSecretKey() a secret key} on the master.
* This key is sent to the slave inside the <tt>.jnlp</tt> file
* (this file itself is protected by HTTP form-based authentication that
* we use everywhere else in Hudson), and the slave sends this
......@@ -116,7 +116,7 @@ public final class TcpSlaveAgentListener extends Thread {
}
private String getSecretKey() {
return Hudson.getInstance().getSecretKey();
return Jenkins.getInstance().getSecretKey();
}
@Override
......@@ -231,7 +231,7 @@ public final class TcpSlaveAgentListener extends Thread {
}
final String nodeName = in.readUTF();
SlaveComputer computer = (SlaveComputer) Hudson.getInstance().getComputer(nodeName);
SlaveComputer computer = (SlaveComputer) Jenkins.getInstance().getComputer(nodeName);
if(computer==null) {
error(out, "No such slave: "+nodeName);
return;
......@@ -260,7 +260,7 @@ public final class TcpSlaveAgentListener extends Thread {
}
final String nodeName = request.getProperty("Node-Name");
SlaveComputer computer = (SlaveComputer) Hudson.getInstance().getComputer(nodeName);
SlaveComputer computer = (SlaveComputer) Jenkins.getInstance().getComputer(nodeName);
if(computer==null) {
error(out, "No such slave: "+nodeName);
return;
......
......@@ -23,7 +23,7 @@
*/
package hudson;
import hudson.model.Hudson;
import hudson.model.Jenkins;
import java.net.SocketAddress;
......@@ -54,6 +54,6 @@ public abstract class UDPBroadcastFragment implements ExtensionPoint {
* Returns all the registered {@link UDPBroadcastFragment}s.
*/
public static ExtensionList<UDPBroadcastFragment> all() {
return Hudson.getInstance().getExtensionList(UDPBroadcastFragment.class);
return Jenkins.getInstance().getExtensionList(UDPBroadcastFragment.class);
}
}
......@@ -23,9 +23,8 @@
*/
package hudson;
import hudson.model.Hudson;
import hudson.model.Jenkins;
import hudson.util.OneShotEvent;
import hudson.Util;
import java.io.IOException;
import java.net.BindException;
......@@ -47,13 +46,13 @@ import java.util.logging.Logger;
* @author Kohsuke Kawaguchi
*/
public class UDPBroadcastThread extends Thread {
private final Hudson hudson;
private final Jenkins hudson;
public final OneShotEvent ready = new OneShotEvent();
private MulticastSocket mcs;
private boolean shutdown;
public UDPBroadcastThread(Hudson hudson) throws IOException {
public UDPBroadcastThread(Jenkins hudson) throws IOException {
super("Hudson UDP "+PORT+" monitoring thread");
this.hudson = hudson;
mcs = new MulticastSocket(PORT);
......@@ -76,7 +75,7 @@ public class UDPBroadcastThread extends Thread {
TcpSlaveAgentListener tal = hudson.getTcpSlaveAgentListener();
StringBuilder rsp = new StringBuilder("<hudson>");
tag(rsp,"version",Hudson.VERSION);
tag(rsp,"version", Jenkins.VERSION);
tag(rsp,"url",hudson.getRootUrl());
tag(rsp,"server-id", Util.getDigestOf(hudson.getSecretKey()));
tag(rsp,"slave-port",tal==null?null:tal.getPort());
......
......@@ -24,7 +24,7 @@
package hudson;
import hudson.model.TaskListener;
import hudson.model.Hudson;
import hudson.model.Jenkins;
import static hudson.util.jna.GNUCLibrary.LIBC;
import hudson.util.IOException2;
......@@ -1106,7 +1106,7 @@ public class Util {
*/
public static String wrapToErrorSpan(String s) {
s = "<span class=error><img src='"+
Stapler.getCurrentRequest().getContextPath()+ Hudson.RESOURCE_PATH+
Stapler.getCurrentRequest().getContextPath()+ Jenkins.RESOURCE_PATH+
"/images/none.gif' height=16 width=1>"+s+"</span>";
return s;
}
......
......@@ -26,6 +26,7 @@ package hudson;
import com.thoughtworks.xstream.converters.reflection.PureJavaReflectionProvider;
import com.thoughtworks.xstream.core.JVM;
import hudson.model.Hudson;
import hudson.model.Jenkins;
import hudson.model.User;
import hudson.triggers.SafeTimerTask;
import hudson.triggers.Trigger;
......@@ -41,8 +42,6 @@ import hudson.util.HudsonFailedToLoad;
import hudson.util.ChartUtil;
import hudson.util.AWTProblem;
import org.jvnet.localizer.LocaleProvider;
import org.kohsuke.stapler.Stapler;
import org.kohsuke.stapler.StaplerRequest;
import org.kohsuke.stapler.jelly.JellyFacet;
import org.apache.tools.ant.types.FileSet;
......@@ -74,7 +73,7 @@ public final class WebAppMain implements ServletContextListener {
private static final String APP = "app";
/**
* Creates the sole instance of {@link Hudson} and register it to the {@link ServletContext}.
* Creates the sole instance of {@link hudson.model.Jenkins} and register it to the {@link ServletContext}.
*/
public void contextInitialized(ServletContextEvent event) {
try {
......@@ -249,7 +248,7 @@ public final class WebAppMain implements ServletContextListener {
* Installs log handler to monitor all Hudson logs.
*/
private void installLogger() {
Hudson.logRecords = handler.getView();
Jenkins.logRecords = handler.getView();
Logger.getLogger("hudson").addHandler(handler);
}
......@@ -330,7 +329,7 @@ public final class WebAppMain implements ServletContextListener {
}
public void contextDestroyed(ServletContextEvent event) {
Hudson instance = Hudson.getInstance();
Jenkins instance = Jenkins.getInstance();
if(instance!=null)
instance.cleanUp();
......
......@@ -30,7 +30,7 @@ import hudson.ExtensionPoint;
import hudson.cli.declarative.CLIMethod;
import hudson.ExtensionPoint.LegacyInstancesAreScopedToHudson;
import hudson.cli.declarative.OptionHandlerExtension;
import hudson.model.Hudson;
import hudson.model.Jenkins;
import hudson.remoting.Callable;
import hudson.remoting.Channel;
import hudson.remoting.ChannelProperty;
......@@ -170,17 +170,17 @@ public abstract class CLICommand implements ExtensionPoint, Cloneable {
SecurityContext sc = SecurityContextHolder.getContext();
Authentication old = sc.getAuthentication();
CliAuthenticator authenticator = Hudson.getInstance().getSecurityRealm().createCliAuthenticator(this);
CliAuthenticator authenticator = Jenkins.getInstance().getSecurityRealm().createCliAuthenticator(this);
new ClassParser().parse(authenticator,p);
try {
p.parseArgument(args.toArray(new String[args.size()]));
Authentication auth = authenticator.authenticate();
if (auth==Hudson.ANONYMOUS)
if (auth== Jenkins.ANONYMOUS)
auth = loadStoredAuthentication();
sc.setAuthentication(auth); // run the CLI with the right credential
if (!(this instanceof LoginCommand || this instanceof HelpCommand))
Hudson.getInstance().checkPermission(Hudson.READ);
Jenkins.getInstance().checkPermission(Jenkins.READ);
return run();
} catch (CmdLineException e) {
stderr.println(e.getMessage());
......@@ -207,7 +207,7 @@ public abstract class CLICommand implements ExtensionPoint, Cloneable {
} catch (IOException e) {
stderr.println("Failed to access the stored credential");
e.printStackTrace(stderr); // recover
return Hudson.ANONYMOUS;
return Jenkins.ANONYMOUS;
}
}
......@@ -225,10 +225,10 @@ public abstract class CLICommand implements ExtensionPoint, Cloneable {
* @param auth
* Always non-null.
* If the underlying transport had already performed authentication, this object is something other than
* {@link Hudson#ANONYMOUS}.
* {@link hudson.model.Jenkins#ANONYMOUS}.
*/
protected boolean shouldPerformAuthentication(Authentication auth) {
return auth==Hudson.ANONYMOUS;
return auth== Jenkins.ANONYMOUS;
}
/**
......@@ -245,11 +245,11 @@ public abstract class CLICommand implements ExtensionPoint, Cloneable {
* then this method can return a valid identity of the client.
*
* <p>
* If the transport doesn't do authentication, this method returns {@link Hudson#ANONYMOUS}.
* If the transport doesn't do authentication, this method returns {@link hudson.model.Jenkins#ANONYMOUS}.
*/
public Authentication getTransportAuthentication() {
Authentication a = channel.getProperty(TRANSPORT_AUTHENTICATION);
if (a==null) a = Hudson.ANONYMOUS;
if (a==null) a = Jenkins.ANONYMOUS;
return a;
}
......@@ -342,7 +342,7 @@ public abstract class CLICommand implements ExtensionPoint, Cloneable {
*/
protected void registerOptionHandlers() {
try {
for (Class c : Index.list(OptionHandlerExtension.class,Hudson.getInstance().pluginManager.uberClassLoader,Class.class)) {
for (Class c : Index.list(OptionHandlerExtension.class, Jenkins.getInstance().pluginManager.uberClassLoader,Class.class)) {
Type t = Types.getBaseClass(c, OptionHandler.class);
CmdLineParser.registerHandler(Types.erasure(Types.getTypeArgument(t,0)), c);
}
......@@ -355,7 +355,7 @@ public abstract class CLICommand implements ExtensionPoint, Cloneable {
* Returns all the registered {@link CLICommand}s.
*/
public static ExtensionList<CLICommand> all() {
return Hudson.getInstance().getExtensionList(CLICommand.class);
return Jenkins.getInstance().getExtensionList(CLICommand.class);
}
/**
......
......@@ -24,7 +24,7 @@
package hudson.cli;
import hudson.remoting.Channel;
import hudson.model.Hudson;
import hudson.model.Jenkins;
import org.apache.commons.discovery.resource.ClassLoaders;
import org.apache.commons.discovery.resource.classes.DiscoverClasses;
import org.apache.commons.discovery.resource.names.DiscoverServiceNames;
......@@ -91,7 +91,7 @@ public class CliManagerImpl implements CliEntryPoint, Serializable {
static {
// register option handlers that are defined
ClassLoaders cls = new ClassLoaders();
cls.put(Hudson.getInstance().getPluginManager().uberClassLoader);
cls.put(Jenkins.getInstance().getPluginManager().uberClassLoader);
ResourceNameIterator servicesIter =
new DiscoverServiceNames(cls).findResourceNames(OptionHandler.class.getName());
......
......@@ -2,8 +2,8 @@ package hudson.cli;
import hudson.FilePath;
import hudson.FilePath.FileCallable;
import hudson.model.Hudson;
import hudson.model.Hudson.MasterComputer;
import hudson.model.Jenkins;
import hudson.model.Jenkins.MasterComputer;
import hudson.os.PosixAPI;
import hudson.remoting.Callable;
import hudson.remoting.Channel;
......@@ -58,19 +58,19 @@ public class ClientAuthenticationCache implements Serializable {
/**
* Gets the persisted authentication for this Hudson.
*
* @return {@link Hudson#ANONYMOUS} if no such credential is found, or if the stored credential is invalid.
* @return {@link hudson.model.Jenkins#ANONYMOUS} if no such credential is found, or if the stored credential is invalid.
*/
public Authentication get() {
Hudson h = Hudson.getInstance();
Jenkins h = Jenkins.getInstance();
Secret userName = Secret.decrypt(props.getProperty(getPropertyKey()));
if (userName==null) return Hudson.ANONYMOUS; // failed to decrypt
if (userName==null) return Jenkins.ANONYMOUS; // failed to decrypt
try {
UserDetails u = h.getSecurityRealm().loadUserByUsername(userName.toString());
return new UsernamePasswordAuthenticationToken(u.getUsername(), u.getPassword(), u.getAuthorities());
} catch (AuthenticationException e) {
return Hudson.ANONYMOUS;
return Jenkins.ANONYMOUS;
} catch (DataAccessException e) {
return Hudson.ANONYMOUS;
return Jenkins.ANONYMOUS;
}
}
......@@ -78,7 +78,7 @@ public class ClientAuthenticationCache implements Serializable {
* Computes the key that identifies this Hudson among other Hudsons that the user has a credential for.
*/
private String getPropertyKey() {
String url = Hudson.getInstance().getRootUrl();
String url = Jenkins.getInstance().getRootUrl();
if (url!=null) return url;
return Secret.fromString("key").toString();
}
......@@ -87,7 +87,7 @@ public class ClientAuthenticationCache implements Serializable {
* Persists the specified authentication.
*/
public void set(Authentication a) throws IOException, InterruptedException {
Hudson h = Hudson.getInstance();
Jenkins h = Jenkins.getInstance();
// make sure that this security realm is capable of retrieving the authentication by name,
// as it's not required.
......
......@@ -24,7 +24,7 @@
package hudson.cli;
import hudson.model.Hudson;
import hudson.model.Jenkins;
import hudson.model.Job;
import hudson.model.Run;
import hudson.remoting.Callable;
......@@ -51,7 +51,7 @@ public abstract class CommandDuringBuild extends CLICommand {
if (envs[0]==null || envs[1]==null)
throw new CmdLineException("This CLI command works only when invoked from inside a build");
Job j = Hudson.getInstance().getItemByFullName(envs[0],Job.class);
Job j = Jenkins.getInstance().getItemByFullName(envs[0],Job.class);
if (j==null) throw new CmdLineException("No such job: "+envs[0]);
try {
......
......@@ -23,7 +23,7 @@
*/
package hudson.cli;
import hudson.model.Hudson;
import hudson.model.Jenkins;
import hudson.model.TopLevelItem;
import hudson.Extension;
import hudson.model.Item;
......@@ -49,7 +49,7 @@ public class CopyJobCommand extends CLICommand {
public String dst;
protected int run() throws Exception {
Hudson h = Hudson.getInstance();
Jenkins h = Jenkins.getInstance();
h.checkPermission(Item.CREATE);
if (h.getItem(dst)!=null) {
......
......@@ -23,7 +23,7 @@
*/
package hudson.cli;
import hudson.model.Hudson;
import hudson.model.Jenkins;
import hudson.Extension;
import hudson.model.Item;
import org.kohsuke.args4j.Argument;
......@@ -44,7 +44,7 @@ public class CreateJobCommand extends CLICommand {
public String name;
protected int run() throws Exception {
Hudson h = Hudson.getInstance();
Jenkins h = Jenkins.getInstance();
h.checkPermission(Item.CREATE);
if (h.getItem(name)!=null) {
......
......@@ -26,7 +26,7 @@ package hudson.cli;
import groovy.lang.GroovyShell;
import groovy.lang.Binding;
import hudson.model.AbstractProject;
import hudson.model.Hudson;
import hudson.model.Jenkins;
import hudson.model.Item;
import hudson.model.Run;
import hudson.remoting.Callable;
......@@ -70,7 +70,7 @@ public class GroovyCommand extends CLICommand implements Serializable {
protected int run() throws Exception {
// this allows the caller to manipulate the JVM state, so require the admin privilege.
Hudson.getInstance().checkPermission(Hudson.ADMINISTER);
Jenkins.getInstance().checkPermission(Jenkins.ADMINISTER);
Binding binding = new Binding();
binding.setProperty("out",new PrintWriter(stdout,true));
......@@ -80,7 +80,7 @@ public class GroovyCommand extends CLICommand implements Serializable {
binding.setProperty("channel",channel);
String j = getClientEnvironmentVariable("JOB_NAME");
if (j!=null) {
Item job = Hudson.getInstance().getItemByFullName(j);
Item job = Jenkins.getInstance().getItemByFullName(j);
binding.setProperty("currentJob", job);
String b = getClientEnvironmentVariable("BUILD_NUMBER");
if (b!=null && job instanceof AbstractProject) {
......@@ -89,7 +89,7 @@ public class GroovyCommand extends CLICommand implements Serializable {
}
}
GroovyShell groovy = new GroovyShell(Hudson.getInstance().getPluginManager().uberClassLoader, binding);
GroovyShell groovy = new GroovyShell(Jenkins.getInstance().getPluginManager().uberClassLoader, binding);
groovy.run(loadScript(),"RemoteClass",remaining.toArray(new String[remaining.size()]));
return 0;
}
......
......@@ -24,7 +24,7 @@
package hudson.cli;
import hudson.Extension;
import hudson.model.Hudson;
import hudson.model.Jenkins;
import hudson.remoting.ChannelClosedException;
import groovy.lang.Binding;
import groovy.lang.Closure;
......@@ -58,7 +58,7 @@ public class GroovyshCommand extends CLICommand {
@Override
public int main(List<String> args, Locale locale, InputStream stdin, PrintStream stdout, PrintStream stderr) {
// this allows the caller to manipulate the JVM state, so require the admin privilege.
Hudson.getInstance().checkPermission(Hudson.ADMINISTER);
Jenkins.getInstance().checkPermission(Jenkins.ADMINISTER);
// TODO: ^as this class overrides main() (which has authentication stuff),
// how to get ADMIN permission for this command?
......@@ -76,8 +76,8 @@ public class GroovyshCommand extends CLICommand {
Binding binding = new Binding();
// redirect "println" to the CLI
binding.setProperty("out", new PrintWriter(stdout,true));
binding.setProperty("hudson", hudson.model.Hudson.getInstance()); // backward compatibility
binding.setProperty("jenkins", hudson.model.Hudson.getInstance());
binding.setProperty("hudson", Jenkins.getInstance()); // backward compatibility
binding.setProperty("jenkins", Jenkins.getInstance());
IO io = new IO(new BufferedInputStream(stdin),stdout,stderr);
......
......@@ -24,7 +24,7 @@
package hudson.cli;
import hudson.Extension;
import hudson.model.Hudson;
import hudson.model.Jenkins;
import java.util.Map;
import java.util.TreeMap;
......@@ -42,7 +42,7 @@ public class HelpCommand extends CLICommand {
}
protected int run() {
if (!Hudson.getInstance().hasPermission(Hudson.READ)) {
if (!Jenkins.getInstance().hasPermission(Jenkins.READ)) {
stderr.println("You must authenticate to access this Hudson.\n"
+ "Use --username/--password/--password-file parameters or login command.");
return 0;
......
......@@ -25,7 +25,7 @@ package hudson.cli;
import hudson.Extension;
import hudson.FilePath;
import hudson.model.Hudson;
import hudson.model.Jenkins;
import hudson.model.UpdateSite;
import hudson.model.UpdateSite.Data;
import hudson.util.EditDistance;
......@@ -65,8 +65,8 @@ public class InstallPluginCommand extends CLICommand {
public boolean restart;
protected int run() throws Exception {
Hudson h = Hudson.getInstance();
h.checkPermission(Hudson.ADMINISTER);
Jenkins h = Jenkins.getInstance();
h.checkPermission(Jenkins.ADMINISTER);
for (String source : sources) {
// is this a file?
......@@ -132,6 +132,6 @@ public class InstallPluginCommand extends CLICommand {
}
private FilePath getTargetFile() {
return new FilePath(new File(Hudson.getInstance().getPluginManager().rootDir,name+".hpi"));
return new FilePath(new File(Jenkins.getInstance().getPluginManager().rootDir,name+".hpi"));
}
}
......@@ -26,7 +26,7 @@ package hudson.cli;
import hudson.Extension;
import hudson.AbortException;
import hudson.EnvVars;
import hudson.model.Hudson;
import hudson.model.Jenkins;
import hudson.model.AbstractProject;
import hudson.model.Run;
import hudson.model.Executor;
......@@ -64,8 +64,8 @@ public class InstallToolCommand extends CLICommand {
}
protected int run() throws Exception {
Hudson h = Hudson.getInstance();
h.checkPermission(Hudson.READ);
Jenkins h = Jenkins.getInstance();
h.checkPermission(Jenkins.READ);
// where is this build running?
BuildIDs id = channel.call(new BuildIDs());
......@@ -73,7 +73,7 @@ public class InstallToolCommand extends CLICommand {
if (!id.isComplete())
throw new AbortException("This command can be only invoked from a build executing inside Hudson");
AbstractProject p = Hudson.getInstance().getItemByFullName(id.job, AbstractProject.class);
AbstractProject p = Jenkins.getInstance().getItemByFullName(id.job, AbstractProject.class);
if (p==null)
throw new AbortException("No such job found: "+id.job);
p.checkPermission(Item.CONFIGURE);
......
package hudson.cli;
import hudson.Extension;
import hudson.model.Hudson;
import hudson.model.Jenkins;
import org.acegisecurity.Authentication;
import org.kohsuke.args4j.CmdLineException;
......@@ -24,13 +24,13 @@ public class LoginCommand extends CLICommand {
*/
@Override
protected Authentication loadStoredAuthentication() throws InterruptedException {
return Hudson.ANONYMOUS;
return Jenkins.ANONYMOUS;
}
@Override
protected int run() throws Exception {
Authentication a = Hudson.getAuthentication();
if (a==Hudson.ANONYMOUS)
Authentication a = Jenkins.getAuthentication();
if (a== Jenkins.ANONYMOUS)
throw new CmdLineException("No credentials specified."); // this causes CLI to show the command line options.
ClientAuthenticationCache store = new ClientAuthenticationCache(channel);
......
......@@ -25,7 +25,7 @@ package hudson.cli;
import hudson.tasks.Mailer;
import hudson.Extension;
import hudson.model.Hudson;
import hudson.model.Jenkins;
import hudson.model.Item;
import javax.mail.internet.MimeMessage;
......@@ -46,7 +46,7 @@ public class MailCommand extends CLICommand {
}
protected int run() throws Exception {
Hudson.getInstance().checkPermission(Item.CONFIGURE);
Jenkins.getInstance().checkPermission(Item.CONFIGURE);
Transport.send(new MimeMessage(Mailer.descriptor().createSession(),stdin));
return 0;
}
......
......@@ -24,7 +24,7 @@
package hudson.cli;
import hudson.Extension;
import hudson.model.Hudson;
import hudson.model.Jenkins;
/**
* Shows the version.
......@@ -40,7 +40,7 @@ public class VersionCommand extends CLICommand {
protected int run() {
// CLICommand.main checks Hudson.READ permission.. no other check needed.
stdout.println(Hudson.VERSION);
stdout.println(Jenkins.VERSION);
return 0;
}
}
......@@ -29,7 +29,7 @@ import hudson.ExtensionFinder;
import hudson.Util;
import hudson.cli.CLICommand;
import hudson.cli.CloneableCLICommand;
import hudson.model.Hudson;
import hudson.model.Jenkins;
import hudson.remoting.Channel;
import hudson.security.CliAuthenticator;
import org.acegisecurity.Authentication;
......@@ -63,7 +63,7 @@ import java.util.logging.Logger;
*/
@Extension
public class CLIRegisterer extends ExtensionFinder {
public <T> Collection<ExtensionComponent<T>> find(Class<T> type, Hudson hudson) {
public <T> Collection<ExtensionComponent<T>> find(Class<T> type, Jenkins hudson) {
if (type==CLICommand.class)
return (List)discover(hudson);
else
......@@ -74,7 +74,7 @@ public class CLIRegisterer extends ExtensionFinder {
* Finds a resolved method annotated with {@link CLIResolver}.
*/
private Method findResolver(Class type) throws IOException {
List<Method> resolvers = Util.filter(Index.list(CLIResolver.class, Hudson.getInstance().getPluginManager().uberClassLoader), Method.class);
List<Method> resolvers = Util.filter(Index.list(CLIResolver.class, Jenkins.getInstance().getPluginManager().uberClassLoader), Method.class);
for ( ; type!=null; type=type.getSuperclass())
for (Method m : resolvers)
if (m.getReturnType()==type)
......@@ -82,7 +82,7 @@ public class CLIRegisterer extends ExtensionFinder {
return null;
}
private List<ExtensionComponent<CLICommand>> discover(final Hudson hudson) {
private List<ExtensionComponent<CLICommand>> discover(final Jenkins hudson) {
LOGGER.fine("Listing up @CLIMethod");
List<ExtensionComponent<CLICommand>> r = new ArrayList<ExtensionComponent<CLICommand>>();
......@@ -142,17 +142,17 @@ public class CLIRegisterer extends ExtensionFinder {
binders.add(new MethodBinder(chains.pop(),parser));
// authentication
CliAuthenticator authenticator = Hudson.getInstance().getSecurityRealm().createCliAuthenticator(this);
CliAuthenticator authenticator = Jenkins.getInstance().getSecurityRealm().createCliAuthenticator(this);
new ClassParser().parse(authenticator,parser);
// fill up all the binders
parser.parseArgument(args);
Authentication auth = authenticator.authenticate();
if (auth==Hudson.ANONYMOUS)
if (auth== Jenkins.ANONYMOUS)
auth = loadStoredAuthentication();
sc.setAuthentication(auth); // run the CLI with the right credential
hudson.checkPermission(Hudson.READ);
hudson.checkPermission(Jenkins.READ);
// resolve them
Object instance = null;
......
......@@ -24,7 +24,6 @@
package hudson.cli.declarative;
import hudson.cli.CLICommand;
import hudson.model.Hudson;
import org.jvnet.hudson.annotation_indexer.Indexed;
import org.kohsuke.args4j.CmdLineException;
......@@ -48,7 +47,7 @@ import java.lang.annotation.Target;
* <p>
* If the chosen resolver method is an instance method on type <tt>S</tt>, the "parent resolver" is then
* located to resolve an instance of type 'S'. This process repeats until a static resolver method is discovered
* (since most of Hudson's model objects are anchored to the root {@link Hudson} object, normally that would become
* (since most of Hudson's model objects are anchored to the root {@link hudson.model.Jenkins} object, normally that would become
* the top-most resolver method.)
*
* <p>
......
......@@ -24,7 +24,7 @@
package hudson.cli.handlers;
import hudson.model.AbstractProject;
import hudson.model.Hudson;
import hudson.model.Jenkins;
import org.kohsuke.args4j.CmdLineException;
import org.kohsuke.args4j.CmdLineParser;
import org.kohsuke.args4j.OptionDef;
......@@ -46,7 +46,7 @@ public class AbstractProjectOptionHandler extends OptionHandler<AbstractProject>
@Override
public int parseArguments(Parameters params) throws CmdLineException {
Hudson h = Hudson.getInstance();
Jenkins h = Jenkins.getInstance();
String src = params.getParameter(0);
AbstractProject s = h.getItemByFullName(src,AbstractProject.class);
......
package hudson.cli.handlers;
import hudson.model.AbstractProject;
import hudson.model.Hudson;
import hudson.model.Jenkins;
import hudson.model.TopLevelItem;
import org.kohsuke.MetaInfServices;
import org.kohsuke.args4j.CmdLineException;
......@@ -24,7 +24,7 @@ public class TopLevelItemOptionHandler extends OptionHandler<TopLevelItem> {
@Override
public int parseArguments(Parameters params) throws CmdLineException {
Hudson h = Hudson.getInstance();
Jenkins h = Jenkins.getInstance();
String src = params.getParameter(0);
TopLevelItem s = h.getItem(src);
......
......@@ -24,7 +24,7 @@
package hudson.console;
import com.trilead.ssh2.crypto.Base64;
import hudson.model.Hudson;
import hudson.model.Jenkins;
import hudson.remoting.ObjectInputStreamEx;
import hudson.util.IOException2;
import hudson.util.Secret;
......@@ -116,11 +116,11 @@ public class AnnotatedLargeText<T> extends LargeText {
String base64 = req!=null ? req.getHeader("X-ConsoleAnnotator") : null;
if (base64!=null) {
Cipher sym = Secret.getCipher("AES");
sym.init(Cipher.DECRYPT_MODE, Hudson.getInstance().getSecretKeyAsAES128());
sym.init(Cipher.DECRYPT_MODE, Jenkins.getInstance().getSecretKeyAsAES128());
ObjectInputStream ois = new ObjectInputStreamEx(new GZIPInputStream(
new CipherInputStream(new ByteArrayInputStream(Base64.decode(base64.toCharArray())),sym)),
Hudson.getInstance().pluginManager.uberClassLoader);
Jenkins.getInstance().pluginManager.uberClassLoader);
long timestamp = ois.readLong();
if (TimeUnit2.HOURS.toMillis(1) > abs(System.currentTimeMillis()-timestamp))
// don't deserialize something too old to prevent a replay attack
......@@ -156,7 +156,7 @@ public class AnnotatedLargeText<T> extends LargeText {
try {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
Cipher sym = Secret.getCipher("AES");
sym.init(Cipher.ENCRYPT_MODE, Hudson.getInstance().getSecretKeyAsAES128());
sym.init(Cipher.ENCRYPT_MODE, Jenkins.getInstance().getSecretKeyAsAES128());
ObjectOutputStream oos = new ObjectOutputStream(new GZIPOutputStream(new CipherOutputStream(baos,sym)));
oos.writeLong(System.currentTimeMillis()); // send timestamp to prevent a replay attack
oos.writeObject(caw.getConsoleAnnotator());
......
......@@ -26,7 +26,7 @@ package hudson.console;
import hudson.DescriptorExtensionList;
import hudson.ExtensionPoint;
import hudson.model.Descriptor;
import hudson.model.Hudson;
import hudson.model.Jenkins;
import hudson.util.TimeUnit2;
import org.kohsuke.stapler.StaplerRequest;
import org.kohsuke.stapler.StaplerResponse;
......@@ -89,6 +89,6 @@ public abstract class ConsoleAnnotationDescriptor extends Descriptor<ConsoleNote
* Returns all the registered {@link ConsoleAnnotationDescriptor} descriptors.
*/
public static DescriptorExtensionList<ConsoleNote<?>,ConsoleAnnotationDescriptor> all() {
return (DescriptorExtensionList)Hudson.getInstance().getDescriptorList(ConsoleNote.class);
return (DescriptorExtensionList) Jenkins.getInstance().getDescriptorList(ConsoleNote.class);
}
}
......@@ -26,7 +26,7 @@ package hudson.console;
import hudson.Extension;
import hudson.ExtensionList;
import hudson.ExtensionPoint;
import hudson.model.Hudson;
import hudson.model.Jenkins;
import hudson.model.Run;
import hudson.util.TimeUnit2;
import org.jvnet.tiger_types.Types;
......@@ -127,6 +127,6 @@ public abstract class ConsoleAnnotatorFactory<T> implements ExtensionPoint {
* All the registered instances.
*/
public static ExtensionList<ConsoleAnnotatorFactory> all() {
return Hudson.getInstance().getExtensionList(ConsoleAnnotatorFactory.class);
return Jenkins.getInstance().getExtensionList(ConsoleAnnotatorFactory.class);
}
}
......@@ -27,7 +27,7 @@ package hudson.console;
import hudson.ExtensionList;
import hudson.ExtensionPoint;
import hudson.model.AbstractBuild;
import hudson.model.Hudson;
import hudson.model.Jenkins;
import java.io.IOException;
import java.io.OutputStream;
......@@ -52,6 +52,6 @@ public abstract class ConsoleLogFilter implements ExtensionPoint {
* All the registered {@link ConsoleLogFilter}s.
*/
public static ExtensionList<ConsoleLogFilter> all() {
return Hudson.getInstance().getExtensionList(ConsoleLogFilter.class);
return Jenkins.getInstance().getExtensionList(ConsoleLogFilter.class);
}
}
......@@ -26,7 +26,7 @@ package hudson.console;
import hudson.Functions;
import hudson.MarkupText;
import hudson.model.Describable;
import hudson.model.Hudson;
import hudson.model.Jenkins;
import hudson.model.Run;
import hudson.remoting.ObjectInputStreamEx;
import hudson.util.IOException2;
......@@ -140,7 +140,7 @@ public abstract class ConsoleNote<T> implements Serializable, Describable<Consol
public abstract ConsoleAnnotator annotate(T context, MarkupText text, int charPos);
public ConsoleAnnotationDescriptor getDescriptor() {
return (ConsoleAnnotationDescriptor)Hudson.getInstance().getDescriptorOrDie(getClass());
return (ConsoleAnnotationDescriptor) Jenkins.getInstance().getDescriptorOrDie(getClass());
}
/**
......@@ -221,7 +221,7 @@ public abstract class ConsoleNote<T> implements Serializable, Describable<Consol
return null; // not a valid postamble
ObjectInputStream ois = new ObjectInputStreamEx(
new GZIPInputStream(new ByteArrayInputStream(buf)), Hudson.getInstance().pluginManager.uberClassLoader);
new GZIPInputStream(new ByteArrayInputStream(buf)), Jenkins.getInstance().pluginManager.uberClassLoader);
return (ConsoleNote) ois.readObject();
} catch (Error e) {
// for example, bogus 'sz' can result in OutOfMemoryError.
......
......@@ -25,7 +25,7 @@ package hudson.console;
import hudson.Extension;
import hudson.MarkupText;
import hudson.model.Hudson;
import hudson.model.Jenkins;
import java.io.IOException;
import java.util.logging.Level;
......@@ -53,7 +53,7 @@ public class HyperlinkNote extends ConsoleNote {
public ConsoleAnnotator annotate(Object context, MarkupText text, int charPos) {
String url = this.url;
if (url.startsWith("/"))
url = Hudson.getInstance().getRootUrl()+url.substring(1);
url = Jenkins.getInstance().getRootUrl()+url.substring(1);
text.addHyperlink(charPos,charPos+length,url);
return null;
}
......
......@@ -24,7 +24,7 @@
package hudson.diagnosis;
import hudson.Extension;
import hudson.model.Hudson;
import hudson.model.Jenkins;
import hudson.model.PeriodicWork;
import org.jvnet.animal_sniffer.IgnoreJRERequirement;
......@@ -45,8 +45,8 @@ public class HudsonHomeDiskUsageChecker extends PeriodicWork {
@IgnoreJRERequirement
protected void doRun() {
try {
long free = Hudson.getInstance().getRootDir().getUsableSpace();
long total = Hudson.getInstance().getRootDir().getTotalSpace();
long free = Jenkins.getInstance().getRootDir().getUsableSpace();
long total = Jenkins.getInstance().getRootDir().getTotalSpace();
if(free<=0 || total<=0) {
// information unavailable. pointless to try.
LOGGER.info("JENKINS_HOME disk usage information isn't available. aborting to monitor");
......
......@@ -24,7 +24,7 @@
package hudson.diagnosis;
import hudson.model.AdministrativeMonitor;
import hudson.model.Hudson;
import hudson.model.Jenkins;
import hudson.model.AbstractModelObject;
import hudson.Extension;
import hudson.ExtensionPoint;
......@@ -129,7 +129,7 @@ public final class HudsonHomeDiskUsageMonitor extends AdministrativeMonitor {
* All registered {@link Solution}s.
*/
public static ExtensionList<Solution> all() {
return Hudson.getInstance().getExtensionList(Solution.class);
return Jenkins.getInstance().getExtensionList(Solution.class);
}
}
}
......@@ -28,7 +28,7 @@ import hudson.PluginWrapper;
import hudson.init.Initializer;
import hudson.model.AdministrativeMonitor;
import hudson.model.Descriptor;
import hudson.model.Hudson;
import hudson.model.Jenkins;
import java.text.MessageFormat;
import java.util.ArrayList;
......@@ -61,7 +61,7 @@ public class NullIdDescriptorMonitor extends AdministrativeMonitor {
}
private void verify() {
Hudson h = Hudson.getInstance();
Jenkins h = Jenkins.getInstance();
for (Descriptor d : h.getExtensionList(Descriptor.class)) {
PluginWrapper p = h.getPluginManager().whichPlugin(d.getClass());
String id;
......
......@@ -25,7 +25,7 @@ package hudson.diagnosis;
import hudson.XmlFile;
import hudson.model.AdministrativeMonitor;
import hudson.model.Hudson;
import hudson.model.Jenkins;
import hudson.Extension;
import hudson.model.Item;
import hudson.model.Job;
......@@ -84,7 +84,7 @@ public class OldDataMonitor extends AdministrativeMonitor {
}
private static void remove(Saveable obj, boolean isDelete) {
OldDataMonitor odm = (OldDataMonitor)Hudson.getInstance().getAdministrativeMonitor("OldData");
OldDataMonitor odm = (OldDataMonitor) Jenkins.getInstance().getAdministrativeMonitor("OldData");
synchronized (odm) {
if (odm.updating) return; // Skip during doUpgrade or doDiscard
odm.data.remove(obj);
......@@ -128,7 +128,7 @@ public class OldDataMonitor extends AdministrativeMonitor {
* @param version Hudson release when the data structure changed.
*/
public static void report(Saveable obj, String version) {
OldDataMonitor odm = (OldDataMonitor)Hudson.getInstance().getAdministrativeMonitor("OldData");
OldDataMonitor odm = (OldDataMonitor) Jenkins.getInstance().getAdministrativeMonitor("OldData");
synchronized (odm) {
try {
VersionRange vr = odm.data.get(obj);
......@@ -174,7 +174,7 @@ public class OldDataMonitor extends AdministrativeMonitor {
}
}
if (buf.length() == 0) return;
OldDataMonitor odm = (OldDataMonitor)Hudson.getInstance().getAdministrativeMonitor("OldData");
OldDataMonitor odm = (OldDataMonitor) Jenkins.getInstance().getAdministrativeMonitor("OldData");
synchronized (odm) {
VersionRange vr = odm.data.get(obj);
if (vr != null) vr.extra = buf.toString();
......@@ -183,7 +183,7 @@ public class OldDataMonitor extends AdministrativeMonitor {
}
public static class VersionRange {
private static VersionNumber currentVersion = Hudson.getVersion();
private static VersionNumber currentVersion = Jenkins.getVersion();
VersionNumber min, max;
boolean single = true;
......
......@@ -24,7 +24,7 @@
package hudson.diagnosis;
import hudson.model.AdministrativeMonitor;
import hudson.model.Hudson;
import hudson.model.Jenkins;
import hudson.Extension;
import org.kohsuke.stapler.StaplerRequest;
import org.kohsuke.stapler.StaplerResponse;
......@@ -42,7 +42,7 @@ import java.io.IOException;
@Extension
public class TooManyJobsButNoView extends AdministrativeMonitor {
public boolean isActivated() {
Hudson h = Hudson.getInstance();
Jenkins h = Jenkins.getInstance();
return h.getViews().size()==1 && h.getItemMap().size()> THRESHOLD;
}
......
......@@ -32,7 +32,7 @@ import hudson.model.AbstractProject;
import hudson.model.TaskListener;
import hudson.model.AbstractBuild;
import hudson.model.BuildListener;
import hudson.model.Hudson;
import hudson.model.Jenkins;
import hudson.model.Result;
import hudson.model.PermalinkProjectAction.Permalink;
import hudson.Launcher;
......@@ -94,7 +94,7 @@ public class WorkspaceSnapshotSCM extends SCM {
* @return never null.
*/
public Snapshot resolve() throws ResolvedFailedException {
Hudson h = Hudson.getInstance();
Jenkins h = Jenkins.getInstance();
AbstractProject<?,?> job = h.getItemByFullName(jobName, AbstractProject.class);
if(job==null) {
if(h.getItemByFullName(jobName)==null) {
......
......@@ -2,7 +2,6 @@ package hudson.init;
import org.jvnet.hudson.reactor.ReactorListener;
import org.kohsuke.MetaInfServices;
import hudson.model.Hudson;
/**
* {@link ReactorListener}s that get notified of the Hudson initialization process.
......@@ -16,7 +15,7 @@ import hudson.model.Hudson;
* To register, put {@link MetaInfServices} on your implementation.
*
* @author Kohsuke Kawaguchi
* @see Hudson#buildReactorListener()
* @see hudson.model.Jenkins#buildReactorListener()
*/
public interface InitReactorListener extends ReactorListener {
}
......@@ -42,7 +42,7 @@ import java.util.List;
import java.util.Set;
import java.util.logging.Logger;
import hudson.model.Hudson;
import hudson.model.Jenkins;
import static java.util.logging.Level.WARNING;
......@@ -119,8 +119,8 @@ public class InitializerFinder extends TaskBuilder {
* Determines the parameter injection of the initialization method.
*/
private Object lookUp(Class<?> type) {
if (type== Hudson.class)
return Hudson.getInstance();
if (type== Jenkins.class)
return Jenkins.getInstance();
throw new IllegalArgumentException("Unable to inject "+type);
}
......
......@@ -31,7 +31,7 @@ import java.io.IOException;
import java.net.URL;
import java.util.logging.Logger;
import hudson.model.Hudson;
import hudson.model.Jenkins;
import static hudson.init.InitMilestone.JOB_LOADED;
import hudson.init.Initializer;
......@@ -42,7 +42,7 @@ import hudson.init.Initializer;
*/
public class GroovyInitScript {
@Initializer(after=JOB_LOADED)
public static void init(Hudson h) throws IOException {
public static void init(Jenkins h) throws IOException {
URL bundledInitScript = h.servletContext.getResource("/WEB-INF/init.groovy");
if (bundledInitScript!=null) {
LOGGER.info("Executing bundled init script: "+bundledInitScript);
......@@ -57,7 +57,7 @@ public class GroovyInitScript {
}
private static void execute(GroovyCodeSource initScript) throws IOException {
GroovyShell shell = new GroovyShell(Hudson.getInstance().getPluginManager().uberClassLoader);
GroovyShell shell = new GroovyShell(Jenkins.getInstance().getPluginManager().uberClassLoader);
shell.evaluate(initScript);
}
......
......@@ -25,7 +25,7 @@ package hudson.init.impl;
import static hudson.init.InitMilestone.JOB_LOADED;
import hudson.init.Initializer;
import hudson.model.Hudson;
import hudson.model.Jenkins;
import hudson.model.Messages;
import org.apache.commons.io.FileUtils;
......@@ -38,7 +38,7 @@ import java.io.IOException;
*/
public class InitialUserContent {
@Initializer(after=JOB_LOADED)
public static void init(Hudson h) throws IOException {
public static void init(Jenkins h) throws IOException {
File userContentDir = new File(h.getRootDir(), "userContent");
if(!userContentDir.exists()) {
userContentDir.mkdirs();
......
......@@ -26,7 +26,7 @@ package hudson.lifecycle;
import hudson.ExtensionPoint;
import hudson.Functions;
import hudson.Util;
import hudson.model.Hudson;
import hudson.model.Jenkins;
import java.io.File;
import java.io.IOException;
......@@ -60,7 +60,7 @@ public abstract class Lifecycle implements ExtensionPoint {
String p = System.getProperty("hudson.lifecycle");
if(p!=null) {
try {
ClassLoader cl = Hudson.getInstance().getPluginManager().uberClassLoader;
ClassLoader cl = Jenkins.getInstance().getPluginManager().uberClassLoader;
instance = (Lifecycle)cl.loadClass(p).newInstance();
} catch (InstantiationException e) {
InstantiationError x = new InstantiationError(e.getMessage());
......
......@@ -23,7 +23,7 @@
*/
package hudson.lifecycle;
import hudson.model.Hudson;
import hudson.model.Jenkins;
import java.io.IOException;
/**
......@@ -37,7 +37,7 @@ public class SolarisSMFLifecycle extends Lifecycle {
*/
@Override
public void restart() throws IOException, InterruptedException {
Hudson h = Hudson.getInstance();
Jenkins h = Jenkins.getInstance();
if (h != null)
h.cleanUp();
System.exit(0);
......
......@@ -33,7 +33,7 @@ import java.io.IOException;
import static hudson.util.jna.GNUCLibrary.*;
import hudson.Platform;
import hudson.model.Hudson;
import hudson.model.Jenkins;
/**
* {@link Lifecycle} implementation when Hudson runs on the embedded
......@@ -63,7 +63,7 @@ public class UnixLifecycle extends Lifecycle {
@Override
public void restart() throws IOException, InterruptedException {
Hudson h = Hudson.getInstance();
Jenkins h = Jenkins.getInstance();
if (h != null)
h.cleanUp();
......
......@@ -25,7 +25,7 @@ package hudson.lifecycle;
import hudson.Functions;
import hudson.model.ManagementLink;
import hudson.model.Hudson;
import hudson.model.Jenkins;
import hudson.AbortException;
import hudson.Extension;
import hudson.util.StreamTaskListener;
......@@ -106,7 +106,7 @@ public class WindowsInstallerLink extends ManagementLink {
return;
}
Hudson.getInstance().checkPermission(Hudson.ADMINISTER);
Jenkins.getInstance().checkPermission(Jenkins.ADMINISTER);
File dir = new File(_dir).getAbsoluteFile();
dir.mkdirs();
......@@ -164,10 +164,10 @@ public class WindowsInstallerLink extends ManagementLink {
rsp.sendRedirect(req.getContextPath()+"/");
return;
}
Hudson.getInstance().checkPermission(Hudson.ADMINISTER);
Jenkins.getInstance().checkPermission(Jenkins.ADMINISTER);
rsp.forward(this,"_restart",req);
final File oldRoot = Hudson.getInstance().getRootDir();
final File oldRoot = Jenkins.getInstance().getRootDir();
// initiate an orderly shutdown after we finished serving this request
new Thread("terminator") {
......@@ -231,7 +231,7 @@ public class WindowsInstallerLink extends ManagementLink {
protected final void sendError(String message, StaplerRequest req, StaplerResponse rsp) throws ServletException, IOException {
req.setAttribute("message",message);
req.setAttribute("pre",true);
rsp.forward(Hudson.getInstance(),"error",req);
rsp.forward(Jenkins.getInstance(),"error",req);
}
/**
......@@ -255,7 +255,7 @@ public class WindowsInstallerLink extends ManagementLink {
// from JNLP from https://hudson.dev.java.net/), also put this link on the navigation bar to increase
// visibility
if(System.getProperty(WindowsInstallerLink.class.getName()+".prominent")!=null)
Hudson.getInstance().getActions().add(link);
Jenkins.getInstance().getActions().add(link);
return link;
}
......
......@@ -26,7 +26,7 @@ package hudson.lifecycle;
import hudson.FilePath;
import hudson.Launcher.LocalLauncher;
import hudson.Util;
import hudson.model.Hudson;
import hudson.model.Jenkins;
import hudson.util.StreamTaskListener;
import hudson.util.jna.Kernel32;
import static hudson.util.jna.Kernel32.MOVEFILE_DELAY_UNTIL_REBOOT;
......@@ -59,7 +59,7 @@ public class WindowsServiceLifecycle extends Lifecycle {
*/
private void updateHudsonExeIfNeeded() {
try {
File rootDir = Hudson.getInstance().getRootDir();
File rootDir = Jenkins.getInstance().getRootDir();
URL exe = getClass().getResource("/windows-service/jenkins.exe");
String ourCopy = Util.getDigestOf(exe.openStream());
......@@ -106,7 +106,7 @@ public class WindowsServiceLifecycle extends Lifecycle {
String baseName = dest.getName();
baseName = baseName.substring(0,baseName.indexOf('.'));
File rootDir = Hudson.getInstance().getRootDir();
File rootDir = Jenkins.getInstance().getRootDir();
File copyFiles = new File(rootDir,baseName+".copies");
FileWriter w = new FileWriter(copyFiles, true);
......
......@@ -28,7 +28,7 @@ import hudson.BulkChange;
import hudson.Util;
import hudson.XmlFile;
import hudson.model.AbstractModelObject;
import hudson.model.Hudson;
import hudson.model.Jenkins;
import hudson.model.Saveable;
import hudson.model.listeners.SaveableListener;
import hudson.util.CopyOnWriteList;
......@@ -57,7 +57,7 @@ import java.util.logging.Logger;
*
* <h3>Access Control</h3>
* {@link LogRecorder} is only visible for administrators, and this access control happens at
* {@link Hudson#getLog()}, the sole entry point for binding {@link LogRecorder} to URL.
* {@link hudson.model.Jenkins#getLog()}, the sole entry point for binding {@link LogRecorder} to URL.
*
* @author Kohsuke Kawaguchi
* @see LogRecorderManager
......@@ -150,7 +150,7 @@ public class LogRecorder extends AbstractModelObject implements Saveable {
}
public LogRecorderManager getParent() {
return Hudson.getInstance().getLog();
return Jenkins.getInstance().getLog();
}
/**
......@@ -162,7 +162,7 @@ public class LogRecorder extends AbstractModelObject implements Saveable {
String newName = src.getString("name"), redirect = ".";
XmlFile oldFile = null;
if(!name.equals(newName)) {
Hudson.checkGoodName(newName);
Jenkins.checkGoodName(newName);
oldFile = getConfigFile();
// rename
getParent().logRecorders.remove(name);
......@@ -227,7 +227,7 @@ public class LogRecorder extends AbstractModelObject implements Saveable {
* The file we save our configuration.
*/
private XmlFile getConfigFile() {
return new XmlFile(XSTREAM, new File(Hudson.getInstance().getRootDir(),"log/"+name+".xml"));
return new XmlFile(XSTREAM, new File(Jenkins.getInstance().getRootDir(),"log/"+name+".xml"));
}
/**
......
......@@ -28,7 +28,7 @@ import hudson.Functions;
import hudson.init.Initializer;
import static hudson.init.InitMilestone.PLUGINS_PREPARED;
import hudson.model.AbstractModelObject;
import hudson.model.Hudson;
import hudson.model.Jenkins;
import hudson.model.RSS;
import hudson.tasks.Mailer;
import hudson.util.CopyOnWriteMap;
......@@ -85,7 +85,7 @@ public class LogRecorderManager extends AbstractModelObject {
*/
public void load() throws IOException {
logRecorders.clear();
File dir = new File(Hudson.getInstance().getRootDir(), "log");
File dir = new File(Jenkins.getInstance().getRootDir(), "log");
File[] files = dir.listFiles((FileFilter)new WildcardFileFilter("*.xml"));
if(files==null) return;
for (File child : files) {
......@@ -101,7 +101,7 @@ public class LogRecorderManager extends AbstractModelObject {
* Creates a new log recorder.
*/
public HttpResponse doNewLogRecorder(@QueryParameter String name) {
Hudson.checkGoodName(name);
Jenkins.checkGoodName(name);
logRecorders.put(name,new LogRecorder(name));
......@@ -113,7 +113,7 @@ public class LogRecorderManager extends AbstractModelObject {
* Configure the logging level.
*/
public HttpResponse doConfigLogger(@QueryParameter String name, @QueryParameter String level) {
Hudson.getInstance().checkPermission(Hudson.ADMINISTER);
Jenkins.getInstance().checkPermission(Jenkins.ADMINISTER);
Level lv;
if(level.equals("inherit"))
lv = null;
......@@ -127,7 +127,7 @@ public class LogRecorderManager extends AbstractModelObject {
* RSS feed for log entries.
*/
public void doRss( StaplerRequest req, StaplerResponse rsp ) throws IOException, ServletException {
doRss(req, rsp, Hudson.logRecords);
doRss(req, rsp, Jenkins.logRecords);
}
/**
......@@ -176,7 +176,7 @@ public class LogRecorderManager extends AbstractModelObject {
}
@Initializer(before=PLUGINS_PREPARED)
public static void init(Hudson h) throws IOException {
public static void init(Jenkins h) throws IOException {
h.getLog().load();
}
}
......@@ -25,7 +25,6 @@ package hudson.markup;
import hudson.ExtensionPoint;
import hudson.model.AbstractDescribableImpl;
import hudson.model.Hudson;
import java.io.IOException;
import java.io.StringWriter;
......@@ -49,7 +48,7 @@ import java.io.Writer;
*
* @author Kohsuke Kawaguchi
* @since 1.391
* @see Hudson#getMarkupFormatter()
* @see hudson.model.Jenkins#getMarkupFormatter()
*/
public abstract class MarkupFormatter extends AbstractDescribableImpl<MarkupFormatter> implements ExtensionPoint {
/**
......
......@@ -25,7 +25,7 @@ package hudson.markup;
import hudson.DescriptorExtensionList;
import hudson.model.Descriptor;
import hudson.model.Hudson;
import hudson.model.Jenkins;
/**
* {@link Descriptor} for {@link MarkupFormatter}.
......@@ -38,7 +38,7 @@ public abstract class MarkupFormatterDescriptor extends Descriptor<MarkupFormatt
* Returns all the registered {@link MarkupFormatterDescriptor}s.
*/
public static DescriptorExtensionList<MarkupFormatter,MarkupFormatterDescriptor> all() {
return Hudson.getInstance().<MarkupFormatter,MarkupFormatterDescriptor>
return Jenkins.getInstance().<MarkupFormatter,MarkupFormatterDescriptor>
getDescriptorList(MarkupFormatter.class);
}
}
......@@ -27,7 +27,7 @@ import hudson.DescriptorExtensionList;
import hudson.ExtensionPoint;
import hudson.Util;
import hudson.model.AbstractDescribableImpl;
import hudson.model.Hudson;
import hudson.model.Jenkins;
import hudson.util.QuotedStringTokenizer;
import org.kohsuke.stapler.StaplerRequest;
import org.kohsuke.stapler.DataBoundConstructor;
......@@ -214,7 +214,7 @@ public class Axis extends AbstractDescribableImpl<Axis> implements Comparable<Ax
* Returns all the registered {@link AxisDescriptor}s.
*/
public static DescriptorExtensionList<Axis,AxisDescriptor> all() {
return Hudson.getInstance().<Axis,AxisDescriptor>getDescriptorList(Axis.class);
return Jenkins.getInstance().<Axis,AxisDescriptor>getDescriptorList(Axis.class);
}
/**
......
......@@ -26,7 +26,7 @@ package hudson.matrix;
import hudson.Util;
import hudson.model.Descriptor;
import hudson.model.Failure;
import hudson.model.Hudson;
import hudson.model.Jenkins;
import hudson.util.FormValidation;
import org.kohsuke.stapler.QueryParameter;
......@@ -58,7 +58,7 @@ public abstract class AxisDescriptor extends Descriptor<Axis> {
return FormValidation.ok();
try {
Hudson.checkGoodName(value);
Jenkins.checkGoodName(value);
return FormValidation.ok();
} catch (Failure e) {
return FormValidation.error(e.getMessage());
......
......@@ -24,7 +24,7 @@
package hudson.matrix;
import hudson.Extension;
import hudson.model.Hudson;
import hudson.model.Jenkins;
import org.kohsuke.stapler.DataBoundConstructor;
import java.util.Arrays;
......@@ -66,7 +66,7 @@ public class JDKAxis extends Axis {
*/
@Override
public boolean isInstantiable() {
return !Hudson.getInstance().getJDKs().isEmpty();
return !Jenkins.getInstance().getJDKs().isEmpty();
}
}
}
......@@ -26,11 +26,10 @@ package hudson.matrix;
import hudson.Extension;
import hudson.Functions;
import hudson.Util;
import hudson.model.Hudson;
import hudson.model.Jenkins;
import hudson.model.labels.LabelAtom;
import org.kohsuke.stapler.DataBoundConstructor;
import java.text.MessageFormat;
import java.util.List;
/**
......@@ -66,7 +65,7 @@ public class LabelAxis extends Axis {
*/
@Override
public boolean isInstantiable() {
Hudson h = Hudson.getInstance();
Jenkins h = Jenkins.getInstance();
return !h.getNodes().isEmpty() || !h.clouds.isEmpty();
}
......
......@@ -25,7 +25,7 @@ package hudson.matrix;
import hudson.Extension;
import hudson.Util;
import hudson.model.Hudson;
import hudson.model.Jenkins;
import java.util.LinkedList;
import java.util.List;
......@@ -55,7 +55,7 @@ public class LabelExpAxis extends Axis {
@Override
public DescriptorImpl getDescriptor() {
return (DescriptorImpl)Hudson.getInstance().getDescriptorOrDie(getClass());
return (DescriptorImpl) Jenkins.getInstance().getDescriptorOrDie(getClass());
}
public String getValuesString(){
......@@ -79,7 +79,7 @@ public class LabelExpAxis extends Axis {
*/
@Override
public boolean isInstantiable() {
Hudson h = Hudson.getInstance();
Jenkins h = Jenkins.getInstance();
return !h.getNodes().isEmpty() || !h.clouds.isEmpty();
}
}
......
......@@ -30,15 +30,12 @@ import hudson.model.AbstractProject;
import hudson.model.BuildListener;
import hudson.model.Executor;
import hudson.model.Fingerprint;
import hudson.model.Hudson;
import hudson.model.Jenkins;
import hudson.model.JobProperty;
import hudson.model.Node;
import hudson.model.ParametersAction;
import hudson.model.Queue;
import hudson.model.Result;
import hudson.model.Cause.UpstreamCause;
import hudson.slaves.WorkspaceList;
import hudson.slaves.WorkspaceList.Lease;
import hudson.tasks.Publisher;
import java.io.File;
......@@ -99,7 +96,7 @@ public class MatrixBuild extends AbstractBuild<MatrixProject,MatrixBuild> {
public String getTooltip() {
MatrixRun r = getRun();
if(r!=null) return r.getIconColor().getDescription();
Queue.Item item = Hudson.getInstance().getQueue().getItem(getParent().getItem(combination));
Queue.Item item = Jenkins.getInstance().getQueue().getItem(getParent().getItem(combination));
if(item!=null)
return item.getWhy();
return null; // fall back
......@@ -284,7 +281,7 @@ public class MatrixBuild extends AbstractBuild<MatrixProject,MatrixBuild> {
}
finally {
// if the build was aborted in the middle. Cancel all the configuration builds.
Queue q = Hudson.getInstance().getQueue();
Queue q = Jenkins.getInstance().getQueue();
synchronized(q) {// avoid micro-locking in q.cancel.
for (MatrixConfiguration c : activeConfigurations) {
if(q.cancel(c))
......
......@@ -31,7 +31,7 @@ import hudson.model.Cause;
import hudson.model.CauseAction;
import hudson.model.DependencyGraph;
import hudson.model.Descriptor;
import hudson.model.Hudson;
import hudson.model.Jenkins;
import hudson.model.Item;
import hudson.model.ItemGroup;
import hudson.model.JDK;
......@@ -203,7 +203,7 @@ public class MatrixConfiguration extends Project<MatrixConfiguration,MatrixRun>
} else{
expr = (exprSlave.equals("")) ? exprLabel : exprSlave;
}
return Hudson.getInstance().getLabel(Util.fixEmpty(expr));
return Jenkins.getInstance().getLabel(Util.fixEmpty(expr));
}
@Override
......@@ -213,7 +213,7 @@ public class MatrixConfiguration extends Project<MatrixConfiguration,MatrixRun>
@Override
public JDK getJDK() {
return Hudson.getInstance().getJDK(combination.get("jdk"));
return Jenkins.getInstance().getJDK(combination.get("jdk"));
}
//
......@@ -325,6 +325,6 @@ public class MatrixConfiguration extends Project<MatrixConfiguration,MatrixRun>
* Can be null.
*/
public boolean scheduleBuild(ParametersAction parameters, Cause c) {
return Hudson.getInstance().getQueue().schedule(this, getQuietPeriod(), parameters, new CauseAction(c))!=null;
return Jenkins.getInstance().getQueue().schedule(this, getQuietPeriod(), parameters, new CauseAction(c))!=null;
}
}
......@@ -34,7 +34,7 @@ import hudson.model.BuildableItemWithBuildWrappers;
import hudson.model.DependencyGraph;
import hudson.model.Descriptor;
import hudson.model.Descriptor.FormException;
import hudson.model.Hudson;
import hudson.model.Jenkins;
import hudson.model.Item;
import hudson.model.ItemGroup;
import hudson.model.Items;
......@@ -145,7 +145,7 @@ public class MatrixProject extends AbstractProject<MatrixProject,MatrixBuild> im
private Result touchStoneResultCondition;
public MatrixProject(String name) {
this(Hudson.getInstance(), name);
this(Jenkins.getInstance(), name);
}
public MatrixProject(ItemGroup parent, String name) {
......@@ -469,7 +469,7 @@ public class MatrixProject extends AbstractProject<MatrixProject,MatrixBuild> im
if(a==null) return Collections.emptySet();
Set<JDK> r = new HashSet<JDK>();
for (String j : a) {
JDK jdk = Hudson.getInstance().getJDK(j);
JDK jdk = Jenkins.getInstance().getJDK(j);
if(jdk!=null)
r.add(jdk);
}
......@@ -483,7 +483,7 @@ public class MatrixProject extends AbstractProject<MatrixProject,MatrixBuild> im
public Set<Label> getLabels() {
Set<Label> r = new HashSet<Label>();
for (Combination c : axes.subList(LabelAxis.class).list())
r.add(Hudson.getInstance().getLabel(Util.join(c.values(),"&&")));
r.add(Jenkins.getInstance().getLabel(Util.join(c.values(),"&&")));
return r;
}
......
......@@ -29,7 +29,7 @@ import hudson.matrix.MatrixConfiguration;
import hudson.matrix.MatrixBuild;
import hudson.matrix.MatrixRun;
import hudson.model.Action;
import hudson.model.Hudson;
import hudson.model.Jenkins;
import hudson.model.Queue;
import hudson.model.Queue.Task;
......@@ -79,6 +79,6 @@ public abstract class MatrixBuildListener implements ExtensionPoint {
* Returns all the registered {@link MatrixBuildListener} descriptors.
*/
public static ExtensionList<MatrixBuildListener> all() {
return Hudson.getInstance().getExtensionList(MatrixBuildListener.class);
return Jenkins.getInstance().getExtensionList(MatrixBuildListener.class);
}
}
......@@ -170,9 +170,9 @@ public abstract class AbstractBuild<P extends AbstractProject<P,R>,R extends Abs
*/
public Node getBuiltOn() {
if (builtOn==null || builtOn.equals(""))
return Hudson.getInstance();
return Jenkins.getInstance();
else
return Hudson.getInstance().getNode(builtOn);
return Jenkins.getInstance().getNode(builtOn);
}
/**
......@@ -407,12 +407,12 @@ public abstract class AbstractBuild<P extends AbstractProject<P,R>,R extends Abs
Node node = getCurrentNode();
assert builtOn==null;
builtOn = node.getNodeName();
hudsonVersion = Hudson.VERSION;
hudsonVersion = Jenkins.VERSION;
this.listener = listener;
launcher = createLauncher(listener);
if (!Hudson.getInstance().getNodes().isEmpty())
listener.getLogger().println(node instanceof Hudson ? Messages.AbstractBuild_BuildingOnMaster() : Messages.AbstractBuild_BuildingRemotely(builtOn));
if (!Jenkins.getInstance().getNodes().isEmpty())
listener.getLogger().println(node instanceof Jenkins ? Messages.AbstractBuild_BuildingOnMaster() : Messages.AbstractBuild_BuildingRemotely(builtOn));
final Lease lease = decideWorkspace(node,Computer.currentComputer().getWorkspaceList());
......@@ -488,7 +488,7 @@ public abstract class AbstractBuild<P extends AbstractProject<P,R>,R extends Abs
}
}
for (NodeProperty nodeProperty: Hudson.getInstance().getGlobalNodeProperties()) {
for (NodeProperty nodeProperty: Jenkins.getInstance().getGlobalNodeProperties()) {
Environment environment = nodeProperty.setUp(AbstractBuild.this, l, listener);
if (environment != null) {
buildEnvironments.add(environment);
......@@ -540,7 +540,7 @@ public abstract class AbstractBuild<P extends AbstractProject<P,R>,R extends Abs
AbstractBuild.this.scm = scm.createChangeLogParser();
AbstractBuild.this.changeSet = AbstractBuild.this.calcChangeSet();
for (SCMListener l : Hudson.getInstance().getSCMListeners())
for (SCMListener l : Jenkins.getInstance().getSCMListeners())
l.onChangeLogParsed(AbstractBuild.this,listener,changeSet);
return;
}
......@@ -709,7 +709,7 @@ public abstract class AbstractBuild<P extends AbstractProject<P,R>,R extends Abs
if (scm==null) {
// for historical reason, null means CVS.
try {
Class<?> c = Hudson.getInstance().getPluginManager().uberClassLoader.loadClass("hudson.scm.CVSChangeLogParser");
Class<?> c = Jenkins.getInstance().getPluginManager().uberClassLoader.loadClass("hudson.scm.CVSChangeLogParser");
scm = (ChangeLogParser)c.newInstance();
} catch (ClassNotFoundException e) {
// if CVS isn't available, fall back to something non-null.
......
......@@ -30,6 +30,6 @@ package hudson.model;
*/
public abstract class AbstractDescribableImpl<T extends AbstractDescribableImpl<T>> implements Describable<T> {
public Descriptor<T> getDescriptor() {
return Hudson.getInstance().getDescriptorOrDie(getClass());
return Jenkins.getInstance().getDescriptorOrDie(getClass());
}
}
......@@ -121,7 +121,7 @@ public abstract class AbstractItem extends Actionable implements Item, HttpDelet
/**
* This bridge method is to maintain binary compatibility with {@link TopLevelItem#getParent()}.
*/
@WithBridgeMethods(value=Hudson.class,castRequired=true)
@WithBridgeMethods(value=Jenkins.class,castRequired=true)
public ItemGroup getParent() {
assert parent!=null;
return parent;
......@@ -329,7 +329,7 @@ public abstract class AbstractItem extends Actionable implements Item, HttpDelet
StaplerRequest request = Stapler.getCurrentRequest();
if(request==null)
throw new IllegalStateException("Not processing a HTTP request");
return Util.encode(Hudson.getInstance().getRootUrl()+getUrl());
return Util.encode(Jenkins.getInstance().getRootUrl()+getUrl());
}
/**
......@@ -343,7 +343,7 @@ public abstract class AbstractItem extends Actionable implements Item, HttpDelet
* Returns the {@link ACL} for this object.
*/
public ACL getACL() {
return Hudson.getInstance().getAuthorizationStrategy().getACL(this);
return Jenkins.getInstance().getAuthorizationStrategy().getACL(this);
}
/**
......@@ -374,7 +374,7 @@ public abstract class AbstractItem extends Actionable implements Item, HttpDelet
}
public Descriptor getDescriptorByName(String className) {
return Hudson.getInstance().getDescriptorByName(className);
return Jenkins.getInstance().getDescriptorByName(className);
}
/**
......@@ -420,7 +420,7 @@ public abstract class AbstractItem extends Actionable implements Item, HttpDelet
// ignore
}
Hudson.getInstance().rebuildDependencyGraph();
Jenkins.getInstance().rebuildDependencyGraph();
}
/**
......@@ -497,7 +497,7 @@ public abstract class AbstractItem extends Actionable implements Item, HttpDelet
@CLIResolver
public static AbstractItem resolveForCLI(
@Argument(required=true,metaVar="NAME",usage="Job name") String name) throws CmdLineException {
AbstractItem item = Hudson.getInstance().getItemByFullName(name, AbstractItem.class);
AbstractItem item = Jenkins.getInstance().getItemByFullName(name, AbstractItem.class);
if (item==null)
throw new CmdLineException(null,Messages.AbstractItem_NoSuchJobExists(name,AbstractProject.findNearest(name).getFullName()));
return item;
......
......@@ -193,10 +193,10 @@ public abstract class AbstractProject<P extends AbstractProject<P,R>,R extends A
* Null if no explicit configuration is required.
*
* <p>
* Can't store {@link JDK} directly because {@link Hudson} and {@link Project}
* Can't store {@link JDK} directly because {@link Jenkins} and {@link Project}
* are saved independently.
*
* @see Hudson#getJDK(String)
* @see Jenkins#getJDK(String)
*/
private volatile String jdk;
......@@ -229,7 +229,7 @@ public abstract class AbstractProject<P extends AbstractProject<P,R>,R extends A
protected AbstractProject(ItemGroup parent, String name) {
super(parent,name);
if(!Hudson.getInstance().getNodes().isEmpty()) {
if(!Jenkins.getInstance().getNodes().isEmpty()) {
// if a new job is configured with Hudson that already has slave nodes
// make it roamable by default
canRoam = true;
......@@ -289,7 +289,7 @@ public abstract class AbstractProject<P extends AbstractProject<P,R>,R extends A
*/
@Exported
public boolean isConcurrentBuild() {
return Hudson.CONCURRENT_BUILD && concurrentBuild;
return Jenkins.CONCURRENT_BUILD && concurrentBuild;
}
public void setConcurrentBuild(boolean b) throws IOException {
......@@ -306,8 +306,8 @@ public abstract class AbstractProject<P extends AbstractProject<P,R>,R extends A
return null;
if(assignedNode==null)
return Hudson.getInstance().getSelfLabel();
return Hudson.getInstance().getLabel(assignedNode);
return Jenkins.getInstance().getSelfLabel();
return Jenkins.getInstance().getLabel(assignedNode);
}
/**
......@@ -333,7 +333,7 @@ public abstract class AbstractProject<P extends AbstractProject<P,R>,R extends A
assignedNode = null;
} else {
canRoam = false;
if(l==Hudson.getInstance().getSelfLabel()) assignedNode = null;
if(l== Jenkins.getInstance().getSelfLabel()) assignedNode = null;
else assignedNode = l.getExpression();
}
save();
......@@ -370,7 +370,7 @@ public abstract class AbstractProject<P extends AbstractProject<P,R>,R extends A
* @return the root project value.
*/
public AbstractProject getRootProject() {
if (this.getParent() instanceof Hudson) {
if (this.getParent() instanceof Jenkins) {
return this;
} else {
return ((AbstractProject) this.getParent()).getRootProject();
......@@ -480,11 +480,11 @@ public abstract class AbstractProject<P extends AbstractProject<P,R>,R extends A
}
public int getQuietPeriod() {
return quietPeriod!=null ? quietPeriod : Hudson.getInstance().getQuietPeriod();
return quietPeriod!=null ? quietPeriod : Jenkins.getInstance().getQuietPeriod();
}
public int getScmCheckoutRetryCount() {
return scmCheckoutRetryCount !=null ? scmCheckoutRetryCount : Hudson.getInstance().getScmCheckoutRetryCount();
return scmCheckoutRetryCount !=null ? scmCheckoutRetryCount : Jenkins.getInstance().getScmCheckoutRetryCount();
}
// ugly name because of EL
......@@ -559,7 +559,7 @@ public abstract class AbstractProject<P extends AbstractProject<P,R>,R extends A
if(disabled==b) return; // noop
this.disabled = b;
if(b)
Hudson.getInstance().getQueue().cancel(this);
Jenkins.getInstance().getQueue().cancel(this);
save();
}
......@@ -638,13 +638,13 @@ public abstract class AbstractProject<P extends AbstractProject<P,R>,R extends A
}
// dependency setting might have been changed by the user, so rebuild.
Hudson.getInstance().rebuildDependencyGraph();
Jenkins.getInstance().rebuildDependencyGraph();
// reflect the submission of the pseudo 'upstream build trriger'.
// this needs to be done after we release the lock on 'this',
// or otherwise we could dead-lock
for (AbstractProject<?,?> p : Hudson.getInstance().getAllItems(AbstractProject.class)) {
for (AbstractProject<?,?> p : Jenkins.getInstance().getAllItems(AbstractProject.class)) {
// Don't consider child projects such as MatrixConfiguration:
if (!p.isConfigurable()) continue;
boolean isUpstream = upstream.contains(p);
......@@ -695,10 +695,10 @@ public abstract class AbstractProject<P extends AbstractProject<P,R>,R extends A
}
// notify the queue as the project might be now tied to different node
Hudson.getInstance().getQueue().scheduleMaintenance();
Jenkins.getInstance().getQueue().scheduleMaintenance();
// this is to reflect the upstream build adjustments done above
Hudson.getInstance().rebuildDependencyGraph();
Jenkins.getInstance().rebuildDependencyGraph();
}
/**
......@@ -781,7 +781,7 @@ public abstract class AbstractProject<P extends AbstractProject<P,R>,R extends A
queueActions.add(new CauseAction(c));
}
WaitingItem i = Hudson.getInstance().getQueue().schedule(this, quietPeriod, queueActions);
WaitingItem i = Jenkins.getInstance().getQueue().schedule(this, quietPeriod, queueActions);
if(i!=null)
return (Future)i.getFuture();
return null;
......@@ -845,19 +845,19 @@ public abstract class AbstractProject<P extends AbstractProject<P,R>,R extends A
*/
@Override
public boolean isInQueue() {
return Hudson.getInstance().getQueue().contains(this);
return Jenkins.getInstance().getQueue().contains(this);
}
@Override
public Queue.Item getQueueItem() {
return Hudson.getInstance().getQueue().getItem(this);
return Jenkins.getInstance().getQueue().getItem(this);
}
/**
* Gets the JDK that this project is configured with, or null.
*/
public JDK getJDK() {
return Hudson.getInstance().getJDK(jdk);
return Jenkins.getInstance().getJDK(jdk);
}
/**
......@@ -1081,9 +1081,9 @@ public abstract class AbstractProject<P extends AbstractProject<P,R>,R extends A
* the given project (provided that all builds went smoothly.)
*/
protected AbstractProject getBuildingDownstream() {
Set<Task> unblockedTasks = Hudson.getInstance().getQueue().getUnblockedTasks();
Set<Task> unblockedTasks = Jenkins.getInstance().getQueue().getUnblockedTasks();
for (AbstractProject tup : Hudson.getInstance().getDependencyGraph().getTransitiveDownstream(this)) {
for (AbstractProject tup : Jenkins.getInstance().getDependencyGraph().getTransitiveDownstream(this)) {
if (tup!=this && (tup.isBuilding() || unblockedTasks.contains(tup)))
return tup;
}
......@@ -1098,9 +1098,9 @@ public abstract class AbstractProject<P extends AbstractProject<P,R>,R extends A
* the given project (provided that all builds went smoothly.)
*/
protected AbstractProject getBuildingUpstream() {
Set<Task> unblockedTasks = Hudson.getInstance().getQueue().getUnblockedTasks();
Set<Task> unblockedTasks = Jenkins.getInstance().getQueue().getUnblockedTasks();
for (AbstractProject tup : Hudson.getInstance().getDependencyGraph().getTransitiveUpstream(this)) {
for (AbstractProject tup : Jenkins.getInstance().getDependencyGraph().getTransitiveUpstream(this)) {
if (tup!=this && (tup.isBuilding() || unblockedTasks.contains(tup)))
return tup;
}
......@@ -1438,12 +1438,12 @@ public abstract class AbstractProject<P extends AbstractProject<P,R>,R extends A
*/
@Exported
public final List<AbstractProject> getDownstreamProjects() {
return Hudson.getInstance().getDependencyGraph().getDownstream(this);
return Jenkins.getInstance().getDependencyGraph().getDownstream(this);
}
@Exported
public final List<AbstractProject> getUpstreamProjects() {
return Hudson.getInstance().getDependencyGraph().getUpstream(this);
return Jenkins.getInstance().getDependencyGraph().getUpstream(this);
}
/**
......@@ -1469,7 +1469,7 @@ public abstract class AbstractProject<P extends AbstractProject<P,R>,R extends A
* @since 1.138
*/
public final Set<AbstractProject> getTransitiveUpstreamProjects() {
return Hudson.getInstance().getDependencyGraph().getTransitiveUpstream(this);
return Jenkins.getInstance().getDependencyGraph().getTransitiveUpstream(this);
}
/**
......@@ -1478,7 +1478,7 @@ public abstract class AbstractProject<P extends AbstractProject<P,R>,R extends A
* @since 1.138
*/
public final Set<AbstractProject> getTransitiveDownstreamProjects() {
return Hudson.getInstance().getDependencyGraph().getTransitiveDownstream(this);
return Jenkins.getInstance().getDependencyGraph().getTransitiveDownstream(this);
}
/**
......@@ -1528,7 +1528,7 @@ public abstract class AbstractProject<P extends AbstractProject<P,R>,R extends A
@Override
protected SearchIndexBuilder makeSearchIndex() {
SearchIndexBuilder sib = super.makeSearchIndex();
if(isBuildable() && hasPermission(Hudson.ADMINISTER))
if(isBuildable() && hasPermission(Jenkins.ADMINISTER))
sib.add("build","build");
return sib;
}
......@@ -1563,7 +1563,7 @@ public abstract class AbstractProject<P extends AbstractProject<P,R>,R extends A
if (!isBuildable())
throw HttpResponses.error(SC_INTERNAL_SERVER_ERROR,new IOException(getFullName()+" is not buildable"));
Hudson.getInstance().getQueue().schedule(this, getDelay(req), getBuildCause(req));
Jenkins.getInstance().getQueue().schedule(this, getDelay(req), getBuildCause(req));
rsp.forwardToPreviousPage(req);
}
......@@ -1630,7 +1630,7 @@ public abstract class AbstractProject<P extends AbstractProject<P,R>,R extends A
public void doCancelQueue( StaplerRequest req, StaplerResponse rsp ) throws IOException, ServletException {
checkPermission(BUILD);
Hudson.getInstance().getQueue().cancel(this);
Jenkins.getInstance().getQueue().cancel(this);
rsp.forwardToPreviousPage(req);
}
......@@ -1855,14 +1855,14 @@ public abstract class AbstractProject<P extends AbstractProject<P,R>,R extends A
Messages.AbstractProject_AssignedLabelString_InvalidBooleanExpression(e.getMessage()));
}
// TODO: if there's an atom in the expression that is empty, report it
if (Hudson.getInstance().getLabel(value).isEmpty())
if (Jenkins.getInstance().getLabel(value).isEmpty())
return FormValidation.warning(Messages.AbstractProject_AssignedLabelString_NoMatch());
return FormValidation.ok();
}
public AutoCompletionCandidates doAutoCompleteUpstreamProjects(@QueryParameter String value) {
AutoCompletionCandidates candidates = new AutoCompletionCandidates();
List<Job> jobs = Hudson.getInstance().getItems(Job.class);
List<Job> jobs = Jenkins.getInstance().getItems(Job.class);
for (Job job: jobs) {
if (job.getFullName().startsWith(value)) {
if (job.hasPermission(Item.READ)) {
......@@ -1875,7 +1875,7 @@ public abstract class AbstractProject<P extends AbstractProject<P,R>,R extends A
public AutoCompletionCandidates doAutoCompleteAssignedLabelString(@QueryParameter String value) {
AutoCompletionCandidates c = new AutoCompletionCandidates();
Set<Label> labels = Hudson.getInstance().getLabels();
Set<Label> labels = Jenkins.getInstance().getLabels();
List<String> queries = new AutoCompleteSeeder(value).getSeeds();
for (String term : queries) {
......@@ -1935,13 +1935,13 @@ public abstract class AbstractProject<P extends AbstractProject<P,R>,R extends A
* Finds a {@link AbstractProject} that has the name closest to the given name.
*/
public static AbstractProject findNearest(String name) {
List<AbstractProject> projects = Hudson.getInstance().getItems(AbstractProject.class);
List<AbstractProject> projects = Jenkins.getInstance().getItems(AbstractProject.class);
String[] names = new String[projects.size()];
for( int i=0; i<projects.size(); i++ )
names[i] = projects.get(i).getName();
String nearest = EditDistance.findNearest(name, names);
return (AbstractProject)Hudson.getInstance().getItem(nearest);
return (AbstractProject) Jenkins.getInstance().getItem(nearest);
}
private static final Comparator<Integer> REVERSE_INTEGER_COMPARATOR = new Comparator<Integer>() {
......@@ -1968,7 +1968,7 @@ public abstract class AbstractProject<P extends AbstractProject<P,R>,R extends A
@CLIResolver
public static AbstractProject resolveForCLI(
@Argument(required=true,metaVar="NAME",usage="Job name") String name) throws CmdLineException {
AbstractProject item = Hudson.getInstance().getItemByFullName(name, AbstractProject.class);
AbstractProject item = Jenkins.getInstance().getItemByFullName(name, AbstractProject.class);
if (item==null)
throw new CmdLineException(null,Messages.AbstractItem_NoSuchJobExists(name,AbstractProject.findNearest(name).getFullName()));
return item;
......
......@@ -87,7 +87,7 @@ public interface Action extends ModelObject {
* but this can be used for actions that only contribute <tt>floatBox.jelly</tt>
* and no task list item. The other case where this is useful is
* to avoid showing links that require a privilege when the user is anonymous.
* @see Hudson#isAdmin()
* @see Jenkins#isAdmin()
*/
String getIconFileName();
......
......@@ -53,7 +53,7 @@ import org.kohsuke.stapler.StaplerResponse;
* so by running some code periodically (for this, use {@link TimerTrigger#timer})
*
* <p>
* {@link AdministrativeMonitor}s are bound to URL by {@link Hudson#getAdministrativeMonitor(String)}.
* {@link AdministrativeMonitor}s are bound to URL by {@link Jenkins#getAdministrativeMonitor(String)}.
* See {@link #getUrl()}.
*
* <h3>Views</h3>
......@@ -71,7 +71,7 @@ import org.kohsuke.stapler.StaplerResponse;
*
* @author Kohsuke Kawaguchi
* @since 1.273
* @see Hudson#administrativeMonitors
* @see Jenkins#administrativeMonitors
*/
@LegacyInstancesAreScopedToHudson
public abstract class AdministrativeMonitor extends AbstractModelObject implements ExtensionPoint {
......@@ -111,7 +111,7 @@ public abstract class AdministrativeMonitor extends AbstractModelObject implemen
* Mark this monitor as disabled, to prevent this from showing up in the UI.
*/
public void disable(boolean value) throws IOException {
Hudson hudson = Hudson.getInstance();
Jenkins hudson = Jenkins.getInstance();
Set<String> set = hudson.disabledAdministrativeMonitors;
if(value) set.add(id);
else set.remove(id);
......@@ -126,7 +126,7 @@ public abstract class AdministrativeMonitor extends AbstractModelObject implemen
* he wants to ignore.
*/
public boolean isEnabled() {
return !Hudson.getInstance().disabledAdministrativeMonitors.contains(id);
return !Jenkins.getInstance().disabledAdministrativeMonitors.contains(id);
}
/**
......@@ -143,7 +143,7 @@ public abstract class AdministrativeMonitor extends AbstractModelObject implemen
* URL binding to disable this monitor.
*/
public void doDisable(StaplerRequest req, StaplerResponse rsp) throws IOException {
Hudson.getInstance().checkPermission(Hudson.ADMINISTER);
Jenkins.getInstance().checkPermission(Jenkins.ADMINISTER);
disable(true);
rsp.sendRedirect2(req.getContextPath()+"/manage");
}
......@@ -152,6 +152,6 @@ public abstract class AdministrativeMonitor extends AbstractModelObject implemen
* All registered {@link AdministrativeMonitor} instances.
*/
public static ExtensionList<AdministrativeMonitor> all() {
return Hudson.getInstance().getExtensionList(AdministrativeMonitor.class);
return Jenkins.getInstance().getExtensionList(AdministrativeMonitor.class);
}
}
......@@ -54,7 +54,7 @@ public class AllView extends View {
@Override
public String getDescription() {
return Hudson.getInstance().getDescription();
return Jenkins.getInstance().getDescription();
}
@Override
......@@ -70,19 +70,19 @@ public class AllView extends View {
@Override
public Item doCreateItem(StaplerRequest req, StaplerResponse rsp)
throws IOException, ServletException {
return Hudson.getInstance().doCreateItem(req, rsp);
return Jenkins.getInstance().doCreateItem(req, rsp);
}
@Override
public Collection<TopLevelItem> getItems() {
return Hudson.getInstance().getItems();
return Jenkins.getInstance().getItems();
}
@Override
public synchronized void doSubmitDescription( StaplerRequest req, StaplerResponse rsp ) throws IOException, ServletException {
checkPermission(Hudson.ADMINISTER);
checkPermission(Jenkins.ADMINISTER);
Hudson.getInstance().setSystemMessage(req.getParameter("description"));
Jenkins.getInstance().setSystemMessage(req.getParameter("description"));
rsp.sendRedirect(".");
}
......
......@@ -88,7 +88,7 @@ public abstract class AperiodicWork extends SafeTimerTask implements ExtensionPo
* Returns all the registered {@link AperiodicWork}s.
*/
public static ExtensionList<AperiodicWork> all() {
return Hudson.getInstance().getExtensionList(AperiodicWork.class);
return Jenkins.getInstance().getExtensionList(AperiodicWork.class);
}
}
......@@ -102,7 +102,7 @@ public abstract class AsyncAperiodicWork extends AperiodicWork {
* Determines the log file that records the result of this task.
*/
protected File getLogFile() {
return new File(Hudson.getInstance().getRootDir(),name+".log");
return new File(Jenkins.getInstance().getRootDir(),name+".log");
}
/**
......
......@@ -79,7 +79,7 @@ public abstract class AsyncPeriodicWork extends PeriodicWork {
* Determines the log file that records the result of this task.
*/
protected File getLogFile() {
return new File(Hudson.getInstance().getRootDir(),name+".log");
return new File(Jenkins.getInstance().getRootDir(),name+".log");
}
/**
......
......@@ -88,7 +88,7 @@ public enum BallColor implements StatusIcon {
}
public String getImageOf(String size) {
return Stapler.getCurrentRequest().getContextPath()+Hudson.RESOURCE_PATH+"/images/"+size+'/'+image;
return Stapler.getCurrentRequest().getContextPath()+ Jenkins.RESOURCE_PATH+"/images/"+size+'/'+image;
}
/**
......
......@@ -59,7 +59,7 @@ public final class BuildAuthorizationToken {
}
public static void checkPermission(AbstractProject project, BuildAuthorizationToken token, StaplerRequest req, StaplerResponse rsp) throws IOException {
if (!Hudson.getInstance().isUseSecurity())
if (!Jenkins.getInstance().isUseSecurity())
return; // everyone is authorized
if(token!=null && token.token != null) {
......
......@@ -69,6 +69,6 @@ public abstract class BuildVariableContributor implements ExtensionPoint {
* Returns all the registered {@link EnvironmentContributor}s.
*/
public static ExtensionList<BuildVariableContributor> all() {
return Hudson.getInstance().getExtensionList(BuildVariableContributor.class);
return Jenkins.getInstance().getExtensionList(BuildVariableContributor.class);
}
}
......@@ -185,7 +185,7 @@ public abstract class Cause {
public static class UserCause extends Cause {
private String authenticationName;
public UserCause() {
this.authenticationName = Hudson.getAuthentication().getName();
this.authenticationName = Jenkins.getAuthentication().getName();
}
@Exported(visibility=3)
......
......@@ -171,7 +171,7 @@ public /*transient*/ abstract class Computer extends Actionable implements Acces
* This is where the log from the remote agent goes.
*/
protected File getLogFile() {
return new File(Hudson.getInstance().getRootDir(),"slave-"+nodeName+".log");
return new File(Jenkins.getInstance().getRootDir(),"slave-"+nodeName+".log");
}
/**
......@@ -196,7 +196,7 @@ public /*transient*/ abstract class Computer extends Actionable implements Acces
}
public ACL getACL() {
return Hudson.getInstance().getAuthorizationStrategy().getACL(this);
return Jenkins.getInstance().getAuthorizationStrategy().getACL(this);
}
public void checkPermission(Permission permission) {
......@@ -303,7 +303,7 @@ public /*transient*/ abstract class Computer extends Actionable implements Acces
*/
@CLIMethod(name="connect-node")
public void cliConnect(@Option(name="-f",usage="Cancel any currently pending connect operation and retry from scratch") boolean force) throws ExecutionException, InterruptedException {
checkPermission(Hudson.ADMINISTER);
checkPermission(Jenkins.ADMINISTER);
connect(force).get();
}
......@@ -359,7 +359,7 @@ public /*transient*/ abstract class Computer extends Actionable implements Acces
*/
@CLIMethod(name="disconnect-node")
public void cliDisconnect(@Option(name="-m",usage="Record the note about why you are disconnecting this node") String cause) throws ExecutionException, InterruptedException {
checkPermission(Hudson.ADMINISTER);
checkPermission(Jenkins.ADMINISTER);
disconnect(new ByCLI(cause)).get();
}
......@@ -368,13 +368,13 @@ public /*transient*/ abstract class Computer extends Actionable implements Acces
*/
@CLIMethod(name="offline-node")
public void cliOffline(@Option(name="-m",usage="Record the note about why you are disconnecting this node") String cause) throws ExecutionException, InterruptedException {
checkPermission(Hudson.ADMINISTER);
checkPermission(Jenkins.ADMINISTER);
setTemporarilyOffline(true,new ByCLI(cause));
}
@CLIMethod(name="online-node")
public void cliOnline() throws ExecutionException, InterruptedException {
checkPermission(Hudson.ADMINISTER);
checkPermission(Jenkins.ADMINISTER);
setTemporarilyOffline(false,null);
}
......@@ -407,8 +407,8 @@ public /*transient*/ abstract class Computer extends Actionable implements Acces
*/
public Node getNode() {
if(nodeName==null)
return Hudson.getInstance();
return Hudson.getInstance().getNode(nodeName);
return Jenkins.getInstance();
return Jenkins.getInstance().getNode(nodeName);
}
@Exported
......@@ -526,7 +526,7 @@ public /*transient*/ abstract class Computer extends Actionable implements Acces
offlineCause = temporarilyOffline ? cause : null;
this.temporarilyOffline = temporarilyOffline;
getNode().setTemporaryOfflineCause(offlineCause);
Hudson.getInstance().getQueue().scheduleMaintenance();
Jenkins.getInstance().getQueue().scheduleMaintenance();
synchronized (statusChangeLock) {
statusChangeLock.notifyAll();
}
......@@ -568,7 +568,7 @@ public /*transient*/ abstract class Computer extends Actionable implements Acces
}
public RunList getBuilds() {
return new RunList(Hudson.getInstance().getAllItems(Job.class)).node(getNode());
return new RunList(Jenkins.getInstance().getAllItems(Job.class)).node(getNode());
}
/**
......@@ -596,7 +596,7 @@ public /*transient*/ abstract class Computer extends Actionable implements Acces
}
/**
* Called by {@link Hudson#updateComputerList()} to notify {@link Computer} that it will be discarded.
* Called by {@link Jenkins#updateComputerList()} to notify {@link Computer} that it will be discarded.
*/
protected void kill() {
setNumExecutors(0);
......@@ -719,7 +719,7 @@ public /*transient*/ abstract class Computer extends Actionable implements Acces
*/
public final long getDemandStartMilliseconds() {
long firstDemand = Long.MAX_VALUE;
for (Queue.BuildableItem item : Hudson.getInstance().getQueue().getBuildableItems(this)) {
for (Queue.BuildableItem item : Jenkins.getInstance().getQueue().getBuildableItems(this)) {
firstDemand = Math.min(item.buildableStartMilliseconds, firstDemand);
}
return firstDemand;
......@@ -732,7 +732,7 @@ public /*transient*/ abstract class Computer extends Actionable implements Acces
executors.remove(e);
addNewExecutorIfNecessary();
if(!isAlive())
Hudson.getInstance().removeComputer(this);
Jenkins.getInstance().removeComputer(this);
}
/**
......@@ -947,12 +947,12 @@ public /*transient*/ abstract class Computer extends Actionable implements Acces
}
public HttpResponse doToggleOffline(@QueryParameter String offlineMessage) throws IOException, ServletException {
checkPermission(Hudson.ADMINISTER);
checkPermission(Jenkins.ADMINISTER);
if(!temporarilyOffline) {
offlineMessage = Util.fixEmptyAndTrim(offlineMessage);
setTemporarilyOffline(!temporarilyOffline,
OfflineCause.create(hudson.slaves.Messages._SlaveComputer_DisconnectedBy(
Hudson.getAuthentication().getName(),
Jenkins.getAuthentication().getName(),
offlineMessage!=null ? " : " + offlineMessage : "")));
} else {
setTemporarilyOffline(!temporarilyOffline,null);
......@@ -969,7 +969,7 @@ public /*transient*/ abstract class Computer extends Actionable implements Acces
*/
public void doDumpExportTable( StaplerRequest req, StaplerResponse rsp ) throws IOException, ServletException, InterruptedException {
// this is a debug probe and may expose sensitive information
checkPermission(Hudson.ADMINISTER);
checkPermission(Jenkins.ADMINISTER);
rsp.setContentType("text/plain");
PrintWriter w = new PrintWriter(rsp.getCompressedWriter(req));
......@@ -1015,7 +1015,7 @@ public /*transient*/ abstract class Computer extends Actionable implements Acces
protected void _doScript( StaplerRequest req, StaplerResponse rsp, String view) throws IOException, ServletException {
// ability to run arbitrary script is dangerous,
// so tie it to the admin access
checkPermission(Hudson.ADMINISTER);
checkPermission(Jenkins.ADMINISTER);
String text = req.getParameter("script");
if(text!=null) {
......@@ -1037,9 +1037,9 @@ public /*transient*/ abstract class Computer extends Actionable implements Acces
checkPermission(CONFIGURE);
String name = Util.fixEmptyAndTrim(req.getSubmittedForm().getString("name"));
Hudson.checkGoodName(name);
Jenkins.checkGoodName(name);
final Hudson app = Hudson.getInstance();
final Jenkins app = Jenkins.getInstance();
Node result = getNode().reconfigure(req, req.getSubmittedForm());
......@@ -1066,7 +1066,7 @@ public /*transient*/ abstract class Computer extends Actionable implements Acces
@CLIMethod(name="delete-node")
public HttpResponse doDoDelete() throws IOException {
checkPermission(DELETE);
Hudson.getInstance().removeNode(getNode());
Jenkins.getInstance().removeNode(getNode());
return new HttpRedirect("..");
}
......@@ -1104,7 +1104,7 @@ public /*transient*/ abstract class Computer extends Actionable implements Acces
public static Computer currentComputer() {
Executor e = Executor.currentExecutor();
// If no executor then must be on master node
return e != null ? e.getOwner() : Hudson.getInstance().toComputer();
return e != null ? e.getOwner() : Jenkins.getInstance().toComputer();
}
/**
......@@ -1123,7 +1123,7 @@ public /*transient*/ abstract class Computer extends Actionable implements Acces
@CLIResolver
public static Computer resolveForCLI(
@Argument(required=true,metaVar="NAME",usage="Slave name, or empty string for master") String name) throws CmdLineException {
Hudson h = Hudson.getInstance();
Jenkins h = Jenkins.getInstance();
Computer item = h.getComputer(name);
if (item==null) {
List<String> names = new ArrayList<String>();
......
......@@ -26,7 +26,7 @@ public abstract class ComputerPinger implements ExtensionPoint {
* Get all registered instances.
*/
public static ExtensionList<ComputerPinger> all() {
return Hudson.getInstance().getExtensionList(ComputerPinger.class);
return Jenkins.getInstance().getExtensionList(ComputerPinger.class);
}
/**
......
......@@ -87,7 +87,7 @@ public final class ComputerSet extends AbstractModelObject {
@Exported(name="computer",inline=true)
public Computer[] get_all() {
return Hudson.getInstance().getComputers();
return Jenkins.getInstance().getComputers();
}
/**
......@@ -118,7 +118,7 @@ public final class ComputerSet extends AbstractModelObject {
*/
public List<String> get_slaveNames() {
return new AbstractList<String>() {
final List<Node> nodes = Hudson.getInstance().getNodes();
final List<Node> nodes = Jenkins.getInstance().getNodes();
public String get(int index) {
return nodes.get(index).getNodeName();
......@@ -174,11 +174,11 @@ public final class ComputerSet extends AbstractModelObject {
}
public Computer getDynamic(String token, StaplerRequest req, StaplerResponse rsp) {
return Hudson.getInstance().getComputer(token);
return Jenkins.getInstance().getComputer(token);
}
public void do_launchAll(StaplerRequest req, StaplerResponse rsp) throws IOException {
Hudson.getInstance().checkPermission(Hudson.ADMINISTER);
Jenkins.getInstance().checkPermission(Jenkins.ADMINISTER);
for(Computer c : get_all()) {
if(c.isLaunchSupported())
......@@ -193,7 +193,7 @@ public final class ComputerSet extends AbstractModelObject {
* TODO: ajax on the client side to wait until the update completion might be nice.
*/
public void doUpdateNow( StaplerRequest req, StaplerResponse rsp ) throws IOException, ServletException {
Hudson.getInstance().checkPermission(Hudson.ADMINISTER);
Jenkins.getInstance().checkPermission(Jenkins.ADMINISTER);
for (NodeMonitor nodeMonitor : NodeMonitor.getAll()) {
Thread t = nodeMonitor.triggerUpdate();
......@@ -208,8 +208,8 @@ public final class ComputerSet extends AbstractModelObject {
public synchronized void doCreateItem( StaplerRequest req, StaplerResponse rsp,
@QueryParameter String name, @QueryParameter String mode,
@QueryParameter String from ) throws IOException, ServletException {
final Hudson app = Hudson.getInstance();
app.checkPermission(Hudson.ADMINISTER); // TODO: new permission?
final Jenkins app = Jenkins.getInstance();
app.checkPermission(Jenkins.ADMINISTER); // TODO: new permission?
if(mode!=null && mode.equals("copy")) {
name = checkName(name);
......@@ -225,8 +225,8 @@ public final class ComputerSet extends AbstractModelObject {
}
// copy through XStream
String xml = Hudson.XSTREAM.toXML(src);
Node result = (Node)Hudson.XSTREAM.fromXML(xml);
String xml = Jenkins.XSTREAM.toXML(src);
Node result = (Node) Jenkins.XSTREAM.fromXML(xml);
result.setNodeName(name);
result.holdOffLaunchUntilSave = true;
......@@ -252,8 +252,8 @@ public final class ComputerSet extends AbstractModelObject {
public synchronized void doDoCreateItem( StaplerRequest req, StaplerResponse rsp,
@QueryParameter String name,
@QueryParameter String type ) throws IOException, ServletException, FormException {
final Hudson app = Hudson.getInstance();
app.checkPermission(Hudson.ADMINISTER); // TODO: new permission?
final Jenkins app = Jenkins.getInstance();
app.checkPermission(Jenkins.ADMINISTER); // TODO: new permission?
checkName(name);
Node result = NodeDescriptor.all().find(type).newInstance(req, req.getSubmittedForm());
......@@ -272,9 +272,9 @@ public final class ComputerSet extends AbstractModelObject {
throw new Failure("Query parameter 'name' is required");
name = name.trim();
Hudson.checkGoodName(name);
Jenkins.checkGoodName(name);
if(Hudson.getInstance().getNode(name)!=null)
if(Jenkins.getInstance().getNode(name)!=null)
throw new Failure(Messages.ComputerSet_SlaveAlreadyExists(name));
// looks good
......@@ -285,7 +285,7 @@ public final class ComputerSet extends AbstractModelObject {
* Makes sure that the given name is good as a slave name.
*/
public FormValidation doCheckName(@QueryParameter String value) throws IOException, ServletException {
Hudson.getInstance().checkPermission(Hudson.ADMINISTER);
Jenkins.getInstance().checkPermission(Jenkins.ADMINISTER);
if(Util.fixEmpty(value)==null)
return FormValidation.ok();
......@@ -304,7 +304,7 @@ public final class ComputerSet extends AbstractModelObject {
public synchronized void doConfigSubmit( StaplerRequest req, StaplerResponse rsp ) throws IOException, ServletException, FormException {
BulkChange bc = new BulkChange(MONITORS_OWNER);
try {
Hudson.getInstance().checkPermission(Hudson.ADMINISTER);
Jenkins.getInstance().checkPermission(Jenkins.ADMINISTER);
monitors.rebuild(req,req.getSubmittedForm(),getNodeMonitorDescriptors());
// add in the rest of instances are ignored instances
......@@ -324,7 +324,7 @@ public final class ComputerSet extends AbstractModelObject {
* {@link NodeMonitor}s are persisted in this file.
*/
private static XmlFile getConfigFile() {
return new XmlFile(new File(Hudson.getInstance().getRootDir(),"nodeMonitors.xml"));
return new XmlFile(new File(Jenkins.getInstance().getRootDir(),"nodeMonitors.xml"));
}
public Api getApi() {
......
......@@ -61,7 +61,7 @@ import java.util.Stack;
* there's a change (which is relatively rare), a new instance
* will be created. This eliminates the need of synchronization.
*
* @see Hudson#getDependencyGraph()
* @see Jenkins#getDependencyGraph()
* @author Kohsuke Kawaguchi
*/
public final class DependencyGraph implements Comparator<AbstractProject> {
......@@ -85,7 +85,7 @@ public final class DependencyGraph implements Comparator<AbstractProject> {
NotSerilizableSecurityContext system = new NotSerilizableSecurityContext();
system.setAuthentication(ACL.SYSTEM);
SecurityContextHolder.setContext(system);
for( AbstractProject p : Hudson.getInstance().getAllItems(AbstractProject.class) )
for( AbstractProject p : Jenkins.getInstance().getAllItems(AbstractProject.class) )
p.buildDependencyGraph(this);
forward = finalize(forward);
......
......@@ -178,18 +178,18 @@ public abstract class Descriptor<T extends Describable<T>> implements Saveable {
* Returns {@link Descriptor} whose 'clazz' is the same as {@link #getItemType() the item type}.
*/
public Descriptor getItemTypeDescriptor() {
return Hudson.getInstance().getDescriptor(getItemType());
return Jenkins.getInstance().getDescriptor(getItemType());
}
public Descriptor getItemTypeDescriptorOrDie() {
return Hudson.getInstance().getDescriptorOrDie(getItemType());
return Jenkins.getInstance().getDescriptorOrDie(getItemType());
}
/**
* Returns all the descriptors that produce types assignable to the item type.
*/
public List<? extends Descriptor> getApplicableDescriptors() {
return Hudson.getInstance().getDescriptorList(clazz);
return Jenkins.getInstance().getDescriptorList(clazz);
}
}
......@@ -275,7 +275,7 @@ public abstract class Descriptor<T extends Describable<T>> implements Saveable {
/**
* Gets the URL that this Descriptor is bound to, relative to the nearest {@link DescriptorByNameOwner}.
* Since {@link Hudson} is a {@link DescriptorByNameOwner}, there's always one such ancestor to any request.
* Since {@link Jenkins} is a {@link DescriptorByNameOwner}, there's always one such ancestor to any request.
*/
public String getDescriptorUrl() {
return "descriptorByName/"+getId();
......@@ -709,7 +709,7 @@ public abstract class Descriptor<T extends Describable<T>> implements Saveable {
}
private XmlFile getConfigFile() {
return new XmlFile(new File(Hudson.getInstance().getRootDir(),getId()+".xml"));
return new XmlFile(new File(Jenkins.getInstance().getRootDir(),getId()+".xml"));
}
/**
......@@ -834,7 +834,7 @@ public abstract class Descriptor<T extends Describable<T>> implements Saveable {
}
public static Descriptor find(String className) {
return find(Hudson.getInstance().getExtensionList(Descriptor.class),className);
return find(Jenkins.getInstance().getExtensionList(Descriptor.class),className);
}
public static final class FormException extends Exception implements HttpResponse {
......
......@@ -25,7 +25,7 @@ package hudson.model;
/**
* Adds {@link #getDescriptorByName(String)} to bind {@link Descriptor}s to URL.
* Binding them at some specific object (instead of {@link Hudson}), allows
* Binding them at some specific object (instead of {@link Jenkins}), allows
* {@link Descriptor}s to perform context-specific form field validation.
*
* <p>
......@@ -41,7 +41,7 @@ public interface DescriptorByNameOwner extends ModelObject {
* Exposes all {@link Descriptor}s by its name to URL.
*
* <p>
* Implementation should always delegate to {@link Hudson#getDescriptorByName(String)}.
* Implementation should always delegate to {@link Jenkins#getDescriptorByName(String)}.
*
* @param id
* Either {@link Descriptor#getId()} (recommended) or the short name.
......
......@@ -34,7 +34,7 @@ public abstract class DescriptorVisibilityFilter implements ExtensionPoint {
public abstract boolean filter(Object context, Descriptor descriptor);
public static ExtensionList<DescriptorVisibilityFilter> all() {
return Hudson.getInstance().getExtensionList(DescriptorVisibilityFilter.class);
return Jenkins.getInstance().getExtensionList(DescriptorVisibilityFilter.class);
}
public static <T extends Descriptor> List<T> apply(Object context, Iterable<T> source) {
......
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册