1 25 package org.objectweb.jonas.web.jetty50.jmx; 26 27 import javax.management.MBeanException ; 28 import javax.management.MBeanServer ; 29 import javax.management.ObjectName ; 30 31 import org.mortbay.jetty.servlet.WebApplicationContext; 32 import org.mortbay.util.LogSupport; 33 import org.mortbay.util.jmx.ModelMBeanImpl; 34 35 import org.apache.commons.logging.Log; 36 import org.apache.commons.logging.LogFactory; 37 38 45 public class J2EEWebModuleMBean extends ModelMBeanImpl { 46 47 50 private static Log log = LogFactory.getLog(J2EEWebModuleMBean.class); 51 52 55 private WebApplicationContext waContext = null; 56 57 60 private ObjectName [] servlets = null; 61 62 66 public J2EEWebModuleMBean() throws MBeanException { 67 super(); 68 } 69 70 73 protected void defineManagedResource() { 74 super.defineManagedResource(); 76 defineAttribute("servlets", READ_ONLY, ON_MBEAN); 77 waContext = (WebApplicationContext) getManagedResource(); 78 } 79 80 83 public ObjectName [] getServlets() { 84 return servlets; 85 } 86 87 92 public synchronized ObjectName uniqueObjectName(MBeanServer mbeanServer, String baseObjectName) { 93 ObjectName jsr77Name = null; 94 95 String context = waContext.getHttpContext().getContextPath(); 97 if (context.length() == 0) { 98 context = "/"; 99 } 100 101 try { 102 jsr77Name = new ObjectName (waContext.getAttribute("J2EEDomainName") 103 + ":J2EEServer=" + waContext.getAttribute("J2EEServerName") 104 + ",J2EEApplication=" + waContext.getAttribute("J2EEApplicationName") 105 + ",j2eeType=WebModule,name=" + context); 106 } catch (Exception e) { 107 log.warn(LogSupport.EXCEPTION, e); 108 } 109 return jsr77Name; 110 } 111 112 } 113 | Popular Tags |