提交 0dd472cc 编写于 作者: K kohsuke

Always display the restart button on the update center page, if the...

    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
上级 c19ecbf3
......@@ -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");
}
}
......@@ -1163,6 +1163,10 @@ public final class Hudson extends View implements ItemGroup<TopLevelItem>, Node,
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 {
}
}
/**
......
<j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:d="jelly:define" xmlns:l="/lib/layout" xmlns:t="/lib/hudson" xmlns:f="/lib/form">
<img src="${imagesURL}/24x24/blue.gif" />
${%blurb}
<form method="post" action="${rootURL}/restart">
<f:submit value="${%Restart Now}" />
</form>
</j:jelly>
\ No newline at end of file
blurb=Hudson needs to be restarted for this change to take effect.
\ No newline at end of file
blurb=Hudson doit être redémarré pour que ce changement prenne effet.
Restart\ Now=Redémarrer maintenant
blurb=\u5909\u66F4\u3092\u53CD\u6620\u3059\u308B\u306B\u306F\u518D\u8D77\u52D5\u3059\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059\u3002
Restart\ Now=\u4ECA\u3059\u3050\u518D\u8D77\u52D5
\ No newline at end of file
......@@ -7,9 +7,14 @@
<l:main-panel>
<h1>${%Installing Plugins/Upgrades}</h1>
<form method="post" action="${rootURL}/restart">
<p class="warning">
${%warning}
<j:if test="${app.lifecycle.canRestart()}">
<f:submit value="${%Restart Now}" />
</j:if>
</p>
</form>
<st:include page="body.jelly" />
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册