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.ServletHolder; 32 import org.mortbay.jetty.servlet.jsr77.jmx.Jsr77ServletHolderMBean; 33 import org.mortbay.util.LogSupport; 34 35 import org.apache.commons.logging.Log; 36 import org.apache.commons.logging.LogFactory; 37 38 43 public class FixedJsr77ServletHolderMBean extends Jsr77ServletHolderMBean { 44 45 48 private static Log log = LogFactory.getLog(FixedJsr77ServletHolderMBean.class); 49 50 53 private ServletHolder servletHolder = null; 54 55 58 private String j2EEDomainName = null; 59 60 63 private String j2EEServerName = null; 64 65 68 private String j2EEApplicationName = null; 69 70 74 public FixedJsr77ServletHolderMBean() throws MBeanException { 75 super(); 76 } 77 78 82 protected void defineManagedResource() { 83 super.defineManagedResource(); 85 servletHolder = (ServletHolder) getManagedResource(); 86 } 87 88 91 public String getJ2EEApplicationName() { 92 return j2EEApplicationName; 93 } 94 95 98 public void setJ2EEApplicationName(String applicationName) { 99 j2EEApplicationName = applicationName; 100 } 101 102 105 public String getJ2EEDomainName() { 106 return j2EEDomainName; 107 } 108 109 112 public void setJ2EEDomainName(String domainName) { 113 j2EEDomainName = domainName; 114 } 115 116 119 public String getJ2EEServerName() { 120 return j2EEServerName; 121 } 122 123 126 public void setJ2EEServerName(String serverName) { 127 j2EEServerName = serverName; 128 } 129 130 135 public synchronized ObjectName uniqueObjectName(MBeanServer mbeanServer, String baseObjectName) { 136 ObjectName jsr77Name = null; 137 String context = servletHolder.getHttpContext().getContextPath(); 138 if (context.length() == 0) { 139 context = "/"; 140 } 141 142 try { 143 jsr77Name = new ObjectName (getJ2EEDomainName() 144 + ":J2EEServer=" + getJ2EEServerName() 145 + ",J2EEApplication=" + getJ2EEApplicationName() 146 + ",WebModule=" + context 147 + ",j2eeType=Servlet,name=" + servletHolder.getName()); 148 } catch (Exception e) { 149 log.warn(LogSupport.EXCEPTION, e); 150 } 151 return jsr77Name; 152 } 153 154 } 155 | Popular Tags |