ASF Bugzilla – Attachment 32741 Details for
Bug 57701
Implement "[Redeploy]" button for a web application
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch to provide "redeploy" button on Tomcat Web Application Manager.
patch-557701.diff.patch (text/plain), 13.34 KB, created by
Fernando Boaglio
on 2015-05-18 01:31:19 UTC
(
hide
)
Description:
Patch to provide "redeploy" button on Tomcat Web Application Manager.
Filename:
MIME Type:
Creator:
Fernando Boaglio
Created:
2015-05-18 01:31:19 UTC
Size:
13.34 KB
patch
obsolete
>Index: java/org/apache/catalina/manager/HTMLManagerServlet.java >=================================================================== >--- 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 @@ > "<small><a href=\"{4}\">{5}</a></small></td>\n"; > > private static final String MANAGER_APP_ROW_BUTTON_SECTION = >- " <td class=\"row-left\" bgcolor=\"{13}\">\n" + >+ " <td class=\"row-left\" bgcolor=\"{15}\">\n" + > " <small>\n" + > " {1} \n" + > " {3} \n" + > " {5} \n" + > " {7} \n" + >+ " {9} \n" + > " </small>\n" + > " </td>\n" + > "</tr><tr>\n" + >- " <td class=\"row-left\" bgcolor=\"{13}\">\n" + >- " <form method=\"POST\" action=\"{8}\">\n" + >+ " <td class=\"row-left\" bgcolor=\"{15}\">\n" + >+ " <form method=\"POST\" action=\"{10}\">\n" + > " <small>\n" + >- " <input type=\"submit\" value=\"{9}\"> {10} <input type=\"text\" name=\"idle\" size=\"5\" value=\"{11}\"> {12} \n" + >+ " <input type=\"submit\" value=\"{11}\"> {12} <input type=\"text\" name=\"idle\" size=\"5\" value=\"{13}\"> {14} \n" + > " </small>\n" + > " </form>\n" + > " </td>\n" + >@@ -1140,7 +1167,7 @@ > "</tr>\n"; > > private static final String STARTED_DEPLOYED_APPS_ROW_BUTTON_SECTION = >- " <td class=\"row-left\" bgcolor=\"{13}\">\n" + >+ " <td class=\"row-left\" bgcolor=\"{15}\">\n" + > " <small>{1}</small> \n" + > " <form class=\"inline\" method=\"POST\" action=\"{2}\">" + > " <small><input type=\"submit\" value=\"{3}\"></small>" + >@@ -1151,12 +1178,15 @@ > " <form class=\"inline\" method=\"POST\" action=\"{6}\">" + > " <small><input type=\"submit\" value=\"{7}\"></small>" + > " </form>\n" + >+ " <form class=\"inline\" method=\"POST\" action=\"{8}\">" + >+ " <small><input type=\"submit\" value=\"{9}\"></small>" + >+ " </form>\n" + > " </td>\n" + > " </tr><tr>\n" + >- " <td class=\"row-left\" bgcolor=\"{13}\">\n" + >- " <form method=\"POST\" action=\"{8}\">\n" + >+ " <td class=\"row-left\" bgcolor=\"{15}\">\n" + >+ " <form method=\"POST\" action=\"{10}\">\n" + > " <small>\n" + >- " <input type=\"submit\" value=\"{9}\"> {10} <input type=\"text\" name=\"idle\" size=\"5\" value=\"{11}\"> {12} \n" + >+ " <input type=\"submit\" value=\"{11}\"> {12} <input type=\"text\" name=\"idle\" size=\"5\" value=\"{13}\"> {14} \n" + > " </small>\n" + > " </form>\n" + > " </td>\n" + >@@ -1163,14 +1193,15 @@ > "</tr>\n"; > > private static final String STOPPED_DEPLOYED_APPS_ROW_BUTTON_SECTION = >- " <td class=\"row-left\" bgcolor=\"{13}\" rowspan=\"2\">\n" + >+ " <td class=\"row-left\" bgcolor=\"{15}\" rowspan=\"2\">\n" + > " <form class=\"inline\" method=\"POST\" action=\"{0}\">" + > " <small><input type=\"submit\" value=\"{1}\"></small>" + > " </form>\n" + > " <small>{3}</small> \n" + > " <small>{5}</small> \n" + >- " <form class=\"inline\" method=\"POST\" action=\"{6}\">" + >- " <small><input type=\"submit\" value=\"{7}\"></small>" + >+ " <small>{7}</small> \n" + >+ " <form class=\"inline\" method=\"POST\" action=\"{8}\">" + >+ " <small><input type=\"submit\" value=\"{9}\"></small>" + > " </form>\n" + > " </td>\n" + > "</tr>\n<tr></tr>\n"; >@@ -1184,13 +1215,16 @@ > " <form class=\"inline\" method=\"POST\" action=\"{4}\">" + > " <small><input type=\"submit\" value=\"{5}\"></small>" + > " </form>\n" + >- " <small>{7}</small> \n" + >+ " <form class=\"inline\" method=\"POST\" action=\"{6}\">" + >+ " <small><input type=\"submit\" value=\"{7}\"></small>" + >+ " </form>\n" + >+ " <small>{9}</small> \n" + > " </td>\n" + > " </tr><tr>\n" + >- " <td class=\"row-left\" bgcolor=\"{13}\">\n" + >- " <form method=\"POST\" action=\"{8}\">\n" + >+ " <td class=\"row-left\" bgcolor=\"{15}\">\n" + >+ " <form method=\"POST\" action=\"{10}\">\n" + > " <small>\n" + >- " <input type=\"submit\" value=\"{9}\"> {10} <input type=\"text\" name=\"idle\" size=\"5\" value=\"{11}\"> {12} \n" + >+ " <input type=\"submit\" value=\"{11}\"> {12} <input type=\"text\" name=\"idle\" size=\"5\" value=\"{13}\"> {14} \n" + > " </small>\n" + > " </form>\n" + > " </td>\n" + >@@ -1197,7 +1231,7 @@ > "</tr>\n"; > > private static final String STOPPED_NONDEPLOYED_APPS_ROW_BUTTON_SECTION = >- " <td class=\"row-left\" bgcolor=\"{13}\" rowspan=\"2\">\n" + >+ " <td class=\"row-left\" bgcolor=\"{15}\" rowspan=\"2\">\n" + > " <form class=\"inline\" method=\"POST\" action=\"{0}\">" + > " <small><input type=\"submit\" value=\"{1}\"></small>" + > " </form>\n" + >@@ -1204,6 +1238,7 @@ > " <small>{3}</small> \n" + > " <small>{5}</small> \n" + > " <small>{7}</small> \n" + >+ " <small>{9}</small> \n" + > " </td>\n" + > "</tr>\n<tr></tr>\n"; > >Index: java/org/apache/catalina/manager/LocalStrings.properties >=================================================================== >--- 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} >Index: java/org/apache/catalina/manager/ManagerServlet.java >=================================================================== >--- 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. > *
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 57701
:
32741
|
34076
|
34079