View Javadoc

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