1 // 2 // ======================================================================== 3 // Copyright (c) 1995-2014 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.server.handler.jmx; 20 21 import java.util.Enumeration; 22 import java.util.HashMap; 23 import java.util.Map; 24 25 import org.eclipse.jetty.server.handler.ContextHandler; 26 import org.eclipse.jetty.util.Attributes; 27 28 public class ContextHandlerMBean extends AbstractHandlerMBean 29 { ContextHandlerMBean(Object managedObject)30 public ContextHandlerMBean(Object managedObject) 31 { 32 super(managedObject); 33 } 34 getContextAttributes()35 public Map getContextAttributes() 36 { 37 Map map = new HashMap(); 38 Attributes attrs = ((ContextHandler)_managed).getAttributes(); 39 Enumeration en = attrs.getAttributeNames(); 40 while (en.hasMoreElements()) 41 { 42 String name = (String)en.nextElement(); 43 Object value = attrs.getAttribute(name); 44 map.put(name,value); 45 } 46 return map; 47 } 48 setContextAttribute(String name, Object value)49 public void setContextAttribute(String name, Object value) 50 { 51 Attributes attrs = ((ContextHandler)_managed).getAttributes(); 52 attrs.setAttribute(name,value); 53 } 54 setContextAttribute(String name, String value)55 public void setContextAttribute(String name, String value) 56 { 57 Attributes attrs = ((ContextHandler)_managed).getAttributes(); 58 attrs.setAttribute(name,value); 59 } 60 removeContextAttribute(String name)61 public void removeContextAttribute(String name) 62 { 63 Attributes attrs = ((ContextHandler)_managed).getAttributes(); 64 attrs.removeAttribute(name); 65 } 66 } 67