1 16 17 18 package org.apache.webapp.admin; 19 20 import java.text.DateFormat ; 21 import java.util.HashSet ; 22 import java.util.Locale ; 23 import java.util.ResourceBundle ; 24 import javax.management.MBeanServer ; 25 import javax.servlet.ServletException ; 26 import javax.servlet.UnavailableException ; 27 import org.apache.commons.modeler.Registry; 28 import org.apache.struts.action.ActionServlet; 29 import org.apache.struts.util.MessageResources; 30 31 32 39 40 public class ApplicationServlet extends ActionServlet { 41 42 43 45 46 50 public static final String LOCALES_KEY = "applicationLocales"; 51 52 53 55 56 59 protected Registry registry = null; 60 61 62 65 protected MBeanServer server = null; 66 67 68 70 71 76 public Registry getRegistry() throws ServletException { 77 78 if (registry == null) 79 initRegistry(); 80 return (this.registry); 81 82 } 83 84 85 90 public MBeanServer getServer() throws ServletException { 91 92 if (server == null) 93 initServer(); 94 return (this.server); 95 96 } 97 98 99 104 public void init() throws javax.servlet.ServletException { 105 super.init(); 106 initApplicationLocales(); 107 } 108 109 110 112 113 117 protected void initApplicationLocales() { 118 119 ApplicationLocales locales = new ApplicationLocales(this); 120 getServletContext().setAttribute(LOCALES_KEY, locales); 121 122 } 123 124 125 133 protected void initRegistry() throws ServletException { 134 135 registry = Registry.getRegistry(); 136 if (registry == null) 139 throw new UnavailableException ("Registry is not available"); 140 141 } 142 143 144 152 protected void initServer() throws ServletException { 153 154 server = Registry.getRegistry().getMBeanServer(); 155 if (server == null) 158 throw new UnavailableException ("MBeanServer is not available"); 159 160 } 161 162 163 } 164 | Popular Tags |