Always display the restart button on the update center page, if the current environment supports it.

(<a href="http://www.nabble.com/Restarting-Hudson-%28as-Windows-service%29-from-web-UI--td21069038.html">report</a>)


git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@13720 71c3de6d-444a-0410-be80-ed276b4c234a
This commit is contained in:
kohsuke committed 2008-12-18 17:27:55 +00:00
1 parent c19ecbf318
commit 0dd472ccab
8 files changed
+25 -26

No files matched your search

@@ -83,18 +83,19 @@ public abstract class Lifecycle implements ExtensionPoint {
public boolean canRewriteHudsonWar() {
// if we don't know where hudson.war is, it's impossible to replace.
if(getHudsonWar()==null) return false;
return isOverridden("rewriteHudsonWar",File.class);
}
private boolean isOverridden(String methodName, Class... types) {
// the rewriteHudsonWar method isn't overridden.
try {
return !getClass().getMethod("rewriteHudsonWar",File.class).equals(
Lifecycle.class.getMethod("rewriteHudsonWar",File.class));
return !getClass().getMethod(methodName, types).equals(
Lifecycle.class.getMethod(methodName,types));
} catch (NoSuchMethodException e) {
throw new AssertionError(e);
}
}
/**
* If this life cycle supports a restart of Hudson, do so.
* Otherwise, throw {@link UnsupportedOperationException},
@@ -111,4 +112,11 @@ public abstract class Lifecycle implements ExtensionPoint {
public void restart() throws IOException, InterruptedException {
throw new UnsupportedOperationException();
}
/**
* Can the {@link #restart()} method restart Hudson?
*/
public boolean canRestart() {
return isOverridden("restart");
}
}
@@ -1162,6 +1162,10 @@ public final class Hudson extends View implements ItemGroup<TopLevelItem>, Node,
HudsonFilter.AUTHENTICATION_MANAGER.setDelegate(sc.manager);
HudsonFilter.USER_DETAILS_SERVICE_PROXY.setDelegate(sc.userDetails);
}
public Lifecycle getLifecycle() {
return Lifecycle.get();
}
/**
* Returns the root {@link ACL}.
@@ -838,19 +838,13 @@ public class UpdateCenter extends AbstractModelObject {
}
protected void onSuccess() {
status = new RestartNeeded();
status = new Success();
}
@Override
protected void replace(File dst, File src) throws IOException {
Lifecycle.get().rewriteHudsonWar(src);
}
/**
* Indicates that the upgrade needs a restart.
*/
public class RestartNeeded extends InstallationStatus {
}
}
/**