Java Code Examples for org.apache.catalina.util.ContextName#getName()
The following examples show how to use
org.apache.catalina.util.ContextName#getName() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: WebappDeployer.java From tomee with Apache License 2.0 | 5 votes |
private void checkWebapp(final String webappName) { try { final ContextName cn = new ContextName(webappName, true); final String name = "Catalina:type=Deployer,host=localhost"; final ObjectName oname = new ObjectName(name); final String[] params = { cn.getName() }; final String[] signature = { "java.lang.String" }; mBeanServer.invoke(oname, "check", params, signature); } catch (Exception e) { //Ignore } }
Example 2
Source File: HTMLManagerServlet.java From Tomcat8-Source-Read with MIT License | 4 votes |
protected String upload(HttpServletRequest request, StringManager smClient) { String message = ""; try { while (true) { Part warPart = request.getPart("deployWar"); if (warPart == null) { message = smClient.getString( "htmlManagerServlet.deployUploadNoFile"); break; } String filename = warPart.getSubmittedFileName(); if (!filename.toLowerCase(Locale.ENGLISH).endsWith(".war")) { message = smClient.getString( "htmlManagerServlet.deployUploadNotWar", filename); break; } // Get the filename if uploaded name includes a path if (filename.lastIndexOf('\\') >= 0) { filename = filename.substring(filename.lastIndexOf('\\') + 1); } if (filename.lastIndexOf('/') >= 0) { filename = filename.substring(filename.lastIndexOf('/') + 1); } // Identify the appBase of the owning Host of this Context // (if any) File file = new File(host.getAppBaseFile(), filename); if (file.exists()) { message = smClient.getString( "htmlManagerServlet.deployUploadWarExists", filename); break; } ContextName cn = new ContextName(filename, true); String name = cn.getName(); if ((host.findChild(name) != null) && !isDeployed(name)) { message = smClient.getString( "htmlManagerServlet.deployUploadInServerXml", filename); break; } if (isServiced(name)) { message = smClient.getString("managerServlet.inService", name); } else { addServiced(name); try { warPart.write(file.getAbsolutePath()); // Perform new deployment check(name); } finally { removeServiced(name); } } break; } } catch(Exception e) { message = smClient.getString ("htmlManagerServlet.deployUploadFail", e.getMessage()); log(message, e); } return message; }
Example 3
Source File: ManagerServlet.java From Tomcat8-Source-Read with MIT License | 4 votes |
/** * Install an application for the specified path from the specified * web application archive. * * @param writer Writer to render results to * @param tag Revision tag to deploy from * @param cn Name of the application to be installed * @param smClient i18n messages using the locale of the client */ protected void deploy(PrintWriter writer, ContextName cn, String tag, StringManager smClient) { // NOTE: It is assumed that update is always true in this method. // Validate the requested context path if (!validateContextName(cn, writer, smClient)) { return; } String baseName = cn.getBaseName(); String name = cn.getName(); String displayPath = cn.getDisplayName(); // Find the local WAR file File localWar = new File(new File(versioned, tag), baseName + ".war"); File deployedWar = new File(host.getAppBaseFile(), baseName + ".war"); // Copy WAR to appBase try { if (isServiced(name)) { writer.println(smClient.getString("managerServlet.inService", displayPath)); } else { addServiced(name); try { if (!deployedWar.delete()) { writer.println(smClient.getString("managerServlet.deleteFail", deployedWar)); return; } copy(localWar, deployedWar); // Perform new deployment check(name); } finally { removeServiced(name); } } } catch (Exception e) { log("managerServlet.check[" + displayPath + "]", e); writer.println(smClient.getString("managerServlet.exception", e.toString())); return; } writeDeployResult(writer, smClient, name, displayPath); }
Example 4
Source File: HTMLManagerServlet.java From Tomcat7.0.67 with Apache License 2.0 | 4 votes |
protected String upload(HttpServletRequest request, StringManager smClient) { String message = ""; try { while (true) { Part warPart = request.getPart("deployWar"); if (warPart == null) { message = smClient.getString( "htmlManagerServlet.deployUploadNoFile"); break; } String filename = extractFilename(warPart.getHeader("Content-Disposition")); if (!filename.toLowerCase(Locale.ENGLISH).endsWith(".war")) { message = smClient.getString( "htmlManagerServlet.deployUploadNotWar", filename); break; } // Get the filename if uploaded name includes a path if (filename.lastIndexOf('\\') >= 0) { filename = filename.substring(filename.lastIndexOf('\\') + 1); } if (filename.lastIndexOf('/') >= 0) { filename = filename.substring(filename.lastIndexOf('/') + 1); } // Identify the appBase of the owning Host of this Context // (if any) File file = new File(deployed, filename); if (file.exists()) { message = smClient.getString( "htmlManagerServlet.deployUploadWarExists", filename); break; } ContextName cn = new ContextName(filename, true); String name = cn.getName(); if ((host.findChild(name) != null) && !isDeployed(name)) { message = smClient.getString( "htmlManagerServlet.deployUploadInServerXml", filename); break; } if (isServiced(name)) { message = smClient.getString("managerServlet.inService", name); } else { addServiced(name); try { warPart.write(file.getAbsolutePath()); // Perform new deployment check(name); } finally { removeServiced(name); } } break; } } catch(Exception e) { message = smClient.getString ("htmlManagerServlet.deployUploadFail", e.getMessage()); log(message, e); } return message; }
Example 5
Source File: ManagerServlet.java From Tomcat7.0.67 with Apache License 2.0 | 4 votes |
/** * Install an application for the specified path from the specified * web application archive. * * @param writer Writer to render results to * @param tag Revision tag to deploy from * @param cn Name of the application to be installed * @param smClient i18n messages using the locale of the client */ protected void deploy(PrintWriter writer, ContextName cn, String tag, StringManager smClient) { // NOTE: It is assumed that update is always true in this method. // Validate the requested context path if (!validateContextName(cn, writer, smClient)) { return; } String baseName = cn.getBaseName(); String name = cn.getName(); String displayPath = cn.getDisplayName(); // Find the local WAR file File localWar = new File(new File(versioned, tag), baseName + ".war"); File deployedWar = new File(deployed, baseName + ".war"); // Copy WAR to appBase try { if (isServiced(name)) { writer.println(smClient.getString("managerServlet.inService", displayPath)); } else { addServiced(name); try { if (!deployedWar.delete()) { writer.println(smClient.getString("managerServlet.deleteFail", deployedWar)); return; } copy(localWar, deployedWar); // Perform new deployment check(name); } finally { removeServiced(name); } } } catch (Exception e) { log("managerServlet.check[" + displayPath + "]", e); writer.println(smClient.getString("managerServlet.exception", e.toString())); return; } writeDeployResult(writer, smClient, name, displayPath); }
Example 6
Source File: HTMLManagerServlet.java From tomcatsrc with Apache License 2.0 | 4 votes |
protected String upload(HttpServletRequest request, StringManager smClient) { String message = ""; try { while (true) { Part warPart = request.getPart("deployWar"); if (warPart == null) { message = smClient.getString( "htmlManagerServlet.deployUploadNoFile"); break; } String filename = extractFilename(warPart.getHeader("Content-Disposition")); if (!filename.toLowerCase(Locale.ENGLISH).endsWith(".war")) { message = smClient.getString( "htmlManagerServlet.deployUploadNotWar", filename); break; } // Get the filename if uploaded name includes a path if (filename.lastIndexOf('\\') >= 0) { filename = filename.substring(filename.lastIndexOf('\\') + 1); } if (filename.lastIndexOf('/') >= 0) { filename = filename.substring(filename.lastIndexOf('/') + 1); } // Identify the appBase of the owning Host of this Context // (if any) File file = new File(deployed, filename); if (file.exists()) { message = smClient.getString( "htmlManagerServlet.deployUploadWarExists", filename); break; } ContextName cn = new ContextName(filename, true); String name = cn.getName(); if ((host.findChild(name) != null) && !isDeployed(name)) { message = smClient.getString( "htmlManagerServlet.deployUploadInServerXml", filename); break; } if (isServiced(name)) { message = smClient.getString("managerServlet.inService", name); } else { addServiced(name); try { warPart.write(file.getAbsolutePath()); // Perform new deployment check(name); } finally { removeServiced(name); } } break; } } catch(Exception e) { message = smClient.getString ("htmlManagerServlet.deployUploadFail", e.getMessage()); log(message, e); } return message; }
Example 7
Source File: ManagerServlet.java From tomcatsrc with Apache License 2.0 | 4 votes |
/** * Install an application for the specified path from the specified * web application archive. * * @param writer Writer to render results to * @param tag Revision tag to deploy from * @param cn Name of the application to be installed * @param smClient i18n messages using the locale of the client */ protected void deploy(PrintWriter writer, ContextName cn, String tag, StringManager smClient) { // NOTE: It is assumed that update is always true in this method. // Validate the requested context path if (!validateContextName(cn, writer, smClient)) { return; } String baseName = cn.getBaseName(); String name = cn.getName(); String displayPath = cn.getDisplayName(); // Find the local WAR file File localWar = new File(new File(versioned, tag), baseName + ".war"); File deployedWar = new File(deployed, baseName + ".war"); // Copy WAR to appBase try { if (isServiced(name)) { writer.println(smClient.getString("managerServlet.inService", displayPath)); } else { addServiced(name); try { if (!deployedWar.delete()) { writer.println(smClient.getString("managerServlet.deleteFail", deployedWar)); return; } copy(localWar, deployedWar); // Perform new deployment check(name); } finally { removeServiced(name); } } } catch (Exception e) { log("managerServlet.check[" + displayPath + "]", e); writer.println(smClient.getString("managerServlet.exception", e.toString())); return; } writeDeployResult(writer, smClient, name, displayPath); }