View Javadoc

1   // ========================================================================
2   // Copyright (c) 2004-2009 Mort Bay Consulting Pty. Ltd.
3   // ------------------------------------------------------------------------
4   // All rights reserved. This program and the accompanying materials
5   // are made available under the terms of the Eclipse Public License v1.0
6   // and Apache License v2.0 which accompanies this distribution.
7   // The Eclipse Public License is available at 
8   // http://www.eclipse.org/legal/epl-v10.html
9   // The Apache License v2.0 is available at
10  // http://www.opensource.org/licenses/apache2.0.php
11  // You may elect to redistribute this code under either of these licenses. 
12  // ========================================================================
13  
14  package org.eclipse.jetty.server.handler.jmx;
15  
16  import java.util.Enumeration;
17  import java.util.HashMap;
18  import java.util.Map;
19  
20  import org.eclipse.jetty.server.handler.ContextHandler;
21  import org.eclipse.jetty.util.Attributes;
22  
23  public class ContextHandlerMBean extends AbstractHandlerMBean
24  {
25      public ContextHandlerMBean(Object managedObject)
26      {
27          super(managedObject);
28      }
29  
30      public Map getContextAttributes()
31      {
32          Map map = new HashMap();
33          Attributes attrs = ((ContextHandler)_managed).getAttributes();
34          Enumeration en = attrs.getAttributeNames();
35          while (en.hasMoreElements())
36          {
37              String name = (String)en.nextElement();
38              Object value = attrs.getAttribute(name);
39              map.put(name,value);
40          }
41          return map;
42      }
43      
44      public void setContextAttribute(String name, Object value)
45      {
46          Attributes attrs = ((ContextHandler)_managed).getAttributes();
47          attrs.setAttribute(name,value);
48      }
49      
50      public void setContextAttribute(String name, String value)
51      {
52          Attributes attrs = ((ContextHandler)_managed).getAttributes();
53          attrs.setAttribute(name,value);
54      }
55      
56      public void removeContextAttribute(String name)
57      {
58          Attributes attrs = ((ContextHandler)_managed).getAttributes();
59          attrs.removeAttribute(name);
60      }
61  }