1 22 package org.jboss.console.plugins.helpers; 23 24 import javax.servlet.ServletConfig ; 25 import javax.servlet.ServletException ; 26 27 42 public class ServletPluginHelper 43 extends javax.servlet.http.HttpServlet 44 { 45 46 48 public static final String WRAPPER_CLASS_PARAM = "WrapperClass"; 49 50 52 protected ServletConfig config = null; 53 54 protected PluginWrapper wrapper = null; 55 56 58 60 62 64 66 public void init (ServletConfig config) throws ServletException 67 { 68 try 69 { 70 super.init (config); 71 72 this.config = config; 73 74 wrapper = createPluginWrapper (); 75 wrapper.init (config); 76 } 77 catch (Throwable e) 78 { 79 log("Failed to init plugin, "+e.getMessage()); 82 } 83 } 84 85 86 public void destroy () 87 { 88 if( wrapper != null ) 89 { 90 wrapper.destroy (); 91 } 92 super.destroy (); 93 } 94 95 97 99 protected PluginWrapper createPluginWrapper () throws Exception 100 { 101 String tmp = config.getInitParameter(WRAPPER_CLASS_PARAM); 102 if (tmp != null && !"".equals(tmp)) 103 { 104 Class clazz = Thread.currentThread().getContextClassLoader().loadClass(tmp); 107 return (PluginWrapper) (clazz.newInstance()); 108 } 109 110 111 return new BasePluginWrapper (); 115 116 } 117 118 120 122 } 123 | Popular Tags |