Ejemplo n.º 1
0
 /**
  * Instantiates the given Servlet class and performs any required resource injection into the new
  * Servlet instance before returning it.
  */
 @Override
 @SuppressWarnings("unchecked") // doPrivileged() returns the correct type
 public <T extends Servlet> T createServlet(Class<T> clazz) throws ServletException {
   if (SecurityUtil.isPackageProtectionEnabled()) {
     return (T) doPrivileged("createServlet", new Object[] {clazz});
   } else {
     return context.createServlet(clazz);
   }
 }
 @Override
 @SuppressWarnings("unchecked") // doPrivileged() returns the correct type
 public <T extends Servlet> T createServlet(Class<T> c) throws ServletException {
   if (SecurityUtil.isPackageProtectionEnabled()) {
     try {
       return (T) invokeMethod(context, "createServlet", new Object[] {c});
     } catch (Throwable t) {
       ExceptionUtils.handleThrowable(t);
       if (t instanceof ServletException) {
         throw (ServletException) t;
       }
       return null;
     }
   } else {
     return context.createServlet(c);
   }
 }