Fixed #1679 - making DeploymentManager usable in JMX without error

This commit is contained in:
Joakim Erdfelt 2017-07-19 15:29:31 -07:00
parent ce4a8df311
commit 86b4870d14
1 changed files with 30 additions and 2 deletions

View File

@ -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<App> getApps(Node node)
{
List<App> ret = new ArrayList<App>();
List<App> ret = new ArrayList<>();
for (AppEntry entry : _apps)
{
if (entry.lifecyleNode == node)
@ -593,12 +594,39 @@ public class DeploymentManager extends ContainerLifeCycle
return _lifecycle.getNodes();
}
@ManagedOperation(value="list apps that are located at specified App LifeCycle nodes", impact="ACTION")
@SuppressWarnings("unused")
@ManagedOperation(value="list nodes that are tracked by DeploymentManager", impact="INFO")
public Collection<String> getNodeNames()
{
return _lifecycle.getNodes().stream().map(Node::getName).collect(Collectors.toList());
}
public Collection<App> 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<String> getAppNames(@Name("nodeName") String nodeName)
{
Node node = _lifecycle.getNodeByName(nodeName);
if(node == null)
{
throw new IllegalArgumentException("Unable to find node [" + nodeName + "]");
}
List<String> 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
{