MCPcopy Create free account
hub / github.com/apache/tomcat / save

Method save

java/org/apache/catalina/manager/ManagerServlet.java:624–673  ·  view source on GitHub ↗

Store server configuration. @param writer Destination for any user message(s) during this operation @param path Optional context path to save @param smClient i18n support for current client's locale

(PrintWriter writer, String path, StringManager smClient)

Source from the content-addressed store, hash-verified

622 * @param smClient i18n support for current client's locale
623 */
624 protected synchronized void save(PrintWriter writer, String path, StringManager smClient) {
625
626 ObjectName storeConfigOname;
627 try {
628 // Note: Hard-coded domain used since this object is per Server/JVM
629 storeConfigOname = new ObjectName("Catalina:type=StoreConfig");
630 } catch (MalformedObjectNameException e) {
631 // Should never happen. The name above is valid.
632 log(sm.getString("managerServlet.exception"), e);
633 writer.println(smClient.getString("managerServlet.exception", e.toString()));
634 return;
635 }
636
637 if (!mBeanServer.isRegistered(storeConfigOname)) {
638 writer.println(smClient.getString("managerServlet.storeConfig.noMBean", storeConfigOname));
639 return;
640 }
641
642 if (path == null || !path.startsWith("/")) {
643 try {
644 mBeanServer.invoke(storeConfigOname, "storeConfig", null, null);
645 writer.println(smClient.getString("managerServlet.saved"));
646 } catch (Exception e) {
647 log(sm.getString("managerServlet.error.storeConfig"), e);
648 writer.println(smClient.getString("managerServlet.exception", e.toString()));
649 }
650 } else {
651 String contextPath = path;
652 if (path.equals("/")) {
653 contextPath = "";
654 }
655 Context context = (Context) host.findChild(contextPath);
656 if (context == null) {
657 writer.println(smClient.getString("managerServlet.noContext", path));
658 return;
659 }
660 try {
661 Boolean result = (Boolean) mBeanServer.invoke(storeConfigOname, "store", new Object[] { context },
662 new String[] { "org.apache.catalina.Context" });
663 if (result.booleanValue()) {
664 writer.println(smClient.getString("managerServlet.savedContext", path));
665 } else {
666 writer.println(smClient.getString("managerServlet.savedContextFail", path));
667 }
668 } catch (Exception e) {
669 log(sm.getString("managerServlet.error.storeContextConfig", path), e);
670 writer.println(smClient.getString("managerServlet.exception", e.toString()));
671 }
672 }
673 }
674
675
676 /**

Callers 1

doGetMethod · 0.95

Calls 10

logMethod · 0.65
getStringMethod · 0.65
toStringMethod · 0.65
invokeMethod · 0.65
equalsMethod · 0.65
findChildMethod · 0.65
printlnMethod · 0.45
isRegisteredMethod · 0.45
startsWithMethod · 0.45
booleanValueMethod · 0.45

Tested by

no test coverage detected