1 21 22 package uk.org.primrose.pool.servlet; 23 24 import java.io.IOException ; 25 import javax.servlet.http.HttpServlet ; 26 import javax.naming.*; 27 import java.lang.reflect.*; 28 29 public class PoolDestructorServlet extends HttpServlet { 30 public void destroy() { 31 try { 32 Context ctx = new InitialContext(); 33 Object object = ctx.lookup("java:comp/env/shutdownPrimrose"); 34 Class targetClass = object.getClass(); 35 Method[] publicMethods = targetClass.getMethods(); 36 for (int j = 0; j < publicMethods.length; j++) { 37 String fieldName = publicMethods[j].getName(); 38 Class typeClass = publicMethods[j].getReturnType(); 39 String fieldType = typeClass.getName(); 40 if (fieldName.equals("shutdown")) { 41 publicMethods[j].invoke(object, new Object []{}); 42 break; 43 } 44 45 } 46 47 } catch (Exception e) { 48 e.printStackTrace(); 49 } 50 51 } 52 } 53 | Popular Tags |