View Javadoc

1   //
2   //  ========================================================================
3   //  Copyright (c) 1995-2016 Mort Bay Consulting Pty. Ltd.
4   //  ------------------------------------------------------------------------
5   //  All rights reserved. This program and the accompanying materials
6   //  are made available under the terms of the Eclipse Public License v1.0
7   //  and Apache License v2.0 which accompanies this distribution.
8   //
9   //      The Eclipse Public License is available at
10  //      http://www.eclipse.org/legal/epl-v10.html
11  //
12  //      The Apache License v2.0 is available at
13  //      http://www.opensource.org/licenses/apache2.0.php
14  //
15  //  You may elect to redistribute this code under either of these licenses.
16  //  ========================================================================
17  //
18  
19  package org.eclipse.jetty.deploy.jmx;
20  
21  import java.util.ArrayList;
22  import java.util.Collection;
23  import java.util.List;
24  
25  import org.eclipse.jetty.deploy.App;
26  import org.eclipse.jetty.deploy.AppProvider;
27  import org.eclipse.jetty.deploy.DeploymentManager;
28  import org.eclipse.jetty.deploy.graph.Node;
29  import org.eclipse.jetty.jmx.ObjectMBean;
30  import org.eclipse.jetty.server.handler.ContextHandler;
31  
32  public class DeploymentManagerMBean extends ObjectMBean
33  {
34      private final DeploymentManager _manager;
35      
36      public DeploymentManagerMBean(Object managedObject)
37      {
38          super(managedObject);
39          _manager=(DeploymentManager)managedObject;
40      }
41      
42      public Collection<String> getNodes()
43      {
44          List<String> nodes = new ArrayList<String>();
45          for (Node node: _manager.getNodes())
46              nodes.add(node.getName());
47          return nodes;
48      }
49  
50      public Collection<String> getApps()
51      {
52          List<String> apps=new ArrayList<String>();
53          for (App app: _manager.getApps())
54              apps.add(app.getOriginId());
55          return apps;
56      }
57      
58      public Collection<String> getApps(String nodeName)
59      {
60          List<String> apps=new ArrayList<String>();
61          for (App app: _manager.getApps(nodeName))
62              apps.add(app.getOriginId());
63          return apps;
64      }
65      
66      public Collection<ContextHandler> getContexts() throws Exception
67      {
68          List<ContextHandler> apps=new ArrayList<ContextHandler>();
69          for (App app: _manager.getApps())
70              apps.add(app.getContextHandler());
71          return apps;
72      }
73      
74      public Collection<AppProvider> getAppProviders()
75      {
76          return _manager.getAppProviders();
77      }
78      
79      public void requestAppGoal(String appId, String nodeName)
80      {
81          _manager.requestAppGoal(appId, nodeName);
82      }
83  }