--- java/org/apache/catalina/manager/HTMLManagerServlet.java (revision 1679124) +++ java/org/apache/catalina/manager/HTMLManagerServlet.java (working copy) @@ -151,7 +151,7 @@ } else if (command.equals("/upload") || command.equals("/deploy") || command.equals("/reload") || command.equals("/undeploy") || command.equals("/expire") || command.equals("/start") || - command.equals("/stop")) { + command.equals("/stop") || command.equals("/redeploy") ) { message = smClient.getString("managerServlet.postCommand", command); } else { @@ -213,6 +213,8 @@ smClient); } else if (command.equals("/reload")) { message = reload(cn, smClient); + } else if (command.equals("/redeploy")) { + message = redeploy(cn, smClient); } else if (command.equals("/undeploy")) { message = undeploy(cn, smClient); } else if (command.equals("/expire")) { @@ -401,6 +403,7 @@ String appsStart = smClient.getString("htmlManagerServlet.appsStart"); String appsStop = smClient.getString("htmlManagerServlet.appsStop"); String appsReload = smClient.getString("htmlManagerServlet.appsReload"); + String appsRedeploy = smClient.getString("htmlManagerServlet.appsRedeploy"); String appsUndeploy = smClient.getString("htmlManagerServlet.appsUndeploy"); String appsExpire = smClient.getString("htmlManagerServlet.appsExpire"); @@ -476,7 +479,7 @@ writer.print (MessageFormat.format(APPS_ROW_DETAILS_SECTION, args)); - args = new Object[14]; + args = new Object[16]; args[0] = RequestUtil.filter(response.encodeURL(request .getContextPath() + "/html/start?" + pathVersion)); args[1] = appsStart; @@ -487,22 +490,25 @@ .getContextPath() + "/html/reload?" + pathVersion)); args[5] = appsReload; args[6] = RequestUtil.filter(response.encodeURL(request + .getContextPath() + "/html/redeploy?" + pathVersion)); + args[7] = appsRedeploy; + args[8] = RequestUtil.filter(response.encodeURL(request .getContextPath() + "/html/undeploy?" + pathVersion)); - args[7] = appsUndeploy; - args[8] = RequestUtil.filter(response.encodeURL(request + args[9] = appsUndeploy; + args[10] = RequestUtil.filter(response.encodeURL(request .getContextPath() + "/html/expire?" + pathVersion)); - args[9] = appsExpire; - args[10] = smClient.getString( + args[11] = appsExpire; + args[12] = smClient.getString( "htmlManagerServlet.expire.explain"); if (manager == null) { - args[11] = smClient.getString( + args[13] = smClient.getString( "htmlManagerServlet.noManager"); } else { - args[11] = Integer.valueOf( + args[13] = Integer.valueOf( ctxt.getManager().getMaxInactiveInterval()/60); } - args[12] = smClient.getString("htmlManagerServlet.expire.unit"); - args[13] = highlightColor; + args[14] = smClient.getString("htmlManagerServlet.expire.unit"); + args[15] = highlightColor; if (ctxt.getName().equals(this.context.getName())) { writer.print(MessageFormat.format( @@ -617,6 +623,26 @@ } /** + * Redeploy the web application at the specified context path. + * + * @see ManagerServlet#redeploy(PrintWriter, ContextName, StringManager) + * + * @param cn Name of the application to be restarted + * @param smClient StringManager for the client's locale + * @return message String + */ + protected String redeploy(ContextName cn, StringManager smClient) { + + StringWriter stringWriter = new StringWriter(); + PrintWriter printWriter = new PrintWriter(stringWriter); + + super.redeploy(printWriter, cn, smClient); + + return stringWriter.toString(); + } + + + /** * Undeploy the web application at the specified context path. * * @see ManagerServlet#undeploy(PrintWriter, ContextName, StringManager) @@ -1121,19 +1147,20 @@ "{5}\n"; private static final String MANAGER_APP_ROW_BUTTON_SECTION = - " \n" + + " \n" + " \n" + "  {1} \n" + "  {3} \n" + "  {5} \n" + "  {7} \n" + + "  {9} \n" + " \n" + " \n" + "\n" + - " \n" + - "
\n" + + " \n" + + " \n" + " \n" + - "   {10}  {12} \n" + + "   {12}  {14} \n" + " \n" + "
\n" + " \n" + @@ -1140,7 +1167,7 @@ "\n"; private static final String STARTED_DEPLOYED_APPS_ROW_BUTTON_SECTION = - " \n" + + " \n" + "  {1} \n" + "
" + " " + @@ -1151,12 +1178,15 @@ " " + " " + "
\n" + + "
" + + " " + + "
\n" + " \n" + " \n" + - " \n" + - "
\n" + + " \n" + + " \n" + " \n" + - "   {10}  {12} \n" + + "   {12}  {14} \n" + " \n" + "
\n" + " \n" + @@ -1163,14 +1193,15 @@ "\n"; private static final String STOPPED_DEPLOYED_APPS_ROW_BUTTON_SECTION = - " \n" + + " \n" + "
" + " " + "
\n" + "  {3} \n" + "  {5} \n" + - "
" + - " " + + "  {7} \n" + + " " + + " " + "
\n" + " \n" + "\n\n"; @@ -1184,13 +1215,16 @@ "
" + " " + "
\n" + - "  {7} \n" + + "
" + + " " + + "
\n" + + "  {9} \n" + " \n" + " \n" + - " \n" + - "
\n" + + " \n" + + " \n" + " \n" + - "   {10}  {12} \n" + + "   {12}  {14} \n" + " \n" + "
\n" + " \n" + @@ -1197,7 +1231,7 @@ "\n"; private static final String STOPPED_NONDEPLOYED_APPS_ROW_BUTTON_SECTION = - " \n" + + " \n" + "
" + " " + "
\n" + @@ -1204,6 +1238,7 @@ "  {3} \n" + "  {5} \n" + "  {7} \n" + + "  {9} \n" + " \n" + "\n\n"; --- java/org/apache/catalina/manager/LocalStrings.properties (revision 1679124) +++ java/org/apache/catalina/manager/LocalStrings.properties (working copy) @@ -17,6 +17,7 @@ htmlManagerServlet.appsName=Display Name htmlManagerServlet.appsPath=Path htmlManagerServlet.appsReload=Reload +htmlManagerServlet.appsRedeploy=Redeploy htmlManagerServlet.appsUndeploy=Undeploy htmlManagerServlet.appsVersion=Version htmlManagerServlet.appsExpire=Expire sessions @@ -97,6 +98,7 @@ managerServlet.objectNameFail=FAIL - Unable to register object name [{0}] for Manager Servlet managerServlet.postCommand=FAIL - Tried to use command {0} via a GET request but POST is required managerServlet.reloaded=OK - Reloaded application at context path {0} +managerServlet.redeployed=OK - Redeployed application at context path {0} managerServlet.resourcesAll=OK - Listed global resources of all types managerServlet.resourcesType=OK - Listed global resources of type {0} managerServlet.saveFail=FAIL - Configuration save failed: {0} --- java/org/apache/catalina/manager/ManagerServlet.java (revision 1679124) +++ java/org/apache/catalina/manager/ManagerServlet.java (working copy) @@ -1015,7 +1015,61 @@ } + /** + * Reload the web application at the specified context path. + * + * @param writer Writer to render to + * @param cn Name of the application to be restarted + */ + protected void redeploy(PrintWriter writer, ContextName cn, + StringManager smClient) { + if (debug >= 1) + log("restart: Redeploying web application '" + cn + "'"); + + if (!validateContextName(cn, writer, smClient)) { + return; + } + + try { + Context context = (Context) host.findChild(cn.getName()); + if (context == null) { + writer.println(smClient.getString("managerServlet.noContext", + RequestUtil.filter(cn.getDisplayName()))); + return; + } + // It isn't possible for the manager to reload itself + if (context.getName().equals(this.context.getName())) { + writer.println(smClient.getString("managerServlet.noSelf")); + return; + } + + // step 1 of 3 - copy to tmp + File warFile = new File(host.getAppBaseFile(), cn.getBaseName() + ".war"); + String tmpdir = System.getProperty("java.io.tmpdir"); + File tmpWarFile = new File( tmpdir + File.separator+ "_tmp_"+ cn.getBaseName() + ".war" ); + context.stop(); + + copy(warFile, tmpWarFile); + + // step 2 of 3 - undeploy + undeploy(writer,cn,smClient); + + // step 3 of 3 - deploy again =) + copy(tmpWarFile, warFile); + + writer.println(smClient.getString("managerServlet.redeployed", + cn.getDisplayName())); + } catch (Throwable t) { + ExceptionUtils.handleThrowable(t); + log("ManagerServlet.reload[" + cn.getDisplayName() + "]", t); + writer.println(smClient.getString("managerServlet.exception", + t.toString())); + } + + } + + /** * Render a list of available global JNDI resources. *