1 16 package org.mortbay.jetty.servlet.jmx; 17 18 import javax.management.MBeanException ; 19 import javax.management.MBeanServer ; 20 import javax.management.ObjectName ; 21 22 import org.apache.commons.logging.Log; 23 import org.mortbay.log.LogFactory; 24 import org.mortbay.jetty.servlet.Holder; 25 import org.mortbay.util.LogSupport; 26 import org.mortbay.util.jmx.LifeCycleMBean; 27 28 29 30 35 public class HolderMBean extends LifeCycleMBean 36 { 37 private static Log log = LogFactory.getLog(HolderMBean.class); 38 39 40 private Holder _holder; 41 42 43 46 public HolderMBean() 47 throws MBeanException 48 {} 49 50 51 protected void defineManagedResource() 52 { 53 super.defineManagedResource(); 54 55 defineAttribute("name"); 56 defineAttribute("displayName"); 57 defineAttribute("className"); 58 defineAttribute("initParameters",READ_ONLY,ON_MBEAN); 59 60 _holder=(Holder)getManagedResource(); 61 } 62 63 64 public String getInitParameters() 65 { 66 return ""+_holder.getInitParameters(); 67 } 68 69 70 public synchronized ObjectName uniqueObjectName(MBeanServer server, 71 String objectName) 72 { 73 try 74 { 75 String name=_holder.getDisplayName(); 76 if (name==null || name.length()==0) 77 name=_holder.getClassName(); 78 return new ObjectName (objectName+",name="+name); 79 } 80 catch(Exception e) 81 { 82 log.warn(LogSupport.EXCEPTION,e); 83 return super.uniqueObjectName(server,objectName); 84 } 85 } 86 } 87 | Popular Tags |