From 86b4870d140759d4959cdafa63f96fcbc6967e23 Mon Sep 17 00:00:00 2001 From: Joakim Erdfelt Date: Wed, 19 Jul 2017 15:29:31 -0700 Subject: [PATCH] Fixed #1679 - making DeploymentManager usable in JMX without error --- .../jetty/deploy/DeploymentManager.java | 32 +++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/jetty-deploy/src/main/java/org/eclipse/jetty/deploy/DeploymentManager.java b/jetty-deploy/src/main/java/org/eclipse/jetty/deploy/DeploymentManager.java index acccfe5c0aa..a2357f14596 100644 --- a/jetty-deploy/src/main/java/org/eclipse/jetty/deploy/DeploymentManager.java +++ b/jetty-deploy/src/main/java/org/eclipse/jetty/deploy/DeploymentManager.java @@ -28,6 +28,7 @@ import java.util.List; import java.util.Map; import java.util.Queue; import java.util.concurrent.ConcurrentLinkedQueue; +import java.util.stream.Collectors; import org.eclipse.jetty.deploy.bindings.StandardDeployer; import org.eclipse.jetty.deploy.bindings.StandardStarter; @@ -311,7 +312,7 @@ public class DeploymentManager extends ContainerLifeCycle */ public Collection getApps(Node node) { - List ret = new ArrayList(); + List ret = new ArrayList<>(); for (AppEntry entry : _apps) { if (entry.lifecyleNode == node) @@ -592,13 +593,40 @@ public class DeploymentManager extends ContainerLifeCycle { return _lifecycle.getNodes(); } + + @SuppressWarnings("unused") + @ManagedOperation(value="list nodes that are tracked by DeploymentManager", impact="INFO") + public Collection getNodeNames() + { + return _lifecycle.getNodes().stream().map(Node::getName).collect(Collectors.toList()); + } - @ManagedOperation(value="list apps that are located at specified App LifeCycle nodes", impact="ACTION") public Collection getApps(@Name("nodeName") String nodeName) { return getApps(_lifecycle.getNodeByName(nodeName)); } + @SuppressWarnings("unused") + @ManagedOperation(value="list apps that are located at specified App LifeCycle nodes", impact="ACTION") + public Collection getAppNames(@Name("nodeName") String nodeName) + { + Node node = _lifecycle.getNodeByName(nodeName); + if(node == null) + { + throw new IllegalArgumentException("Unable to find node [" + nodeName + "]"); + } + + List ret = new ArrayList<>(); + for (AppEntry entry : _apps) + { + if (entry.lifecyleNode == node) + { + ret.add(String.format("contextPath=%s,originId=%s,appProvider=%s", entry.app.getContextPath(), entry.app.getOriginId(), entry.app.getAppProvider().getClass().getName())); + } + } + return ret; + } + public void scope(XmlConfiguration xmlc, Resource webapp) throws IOException {