@Override
 public String restart() {
   Map<String, Resettable> resettables = BeanUtils.getBeansOfClass(Resettable.class);
   for (String name : resettables.keySet()) {
     if (logger.isDebugEnabled()) {
       logger.debug("trying to reset bean [" + name + "]...");
     }
     Resettable bean = resettables.get(name);
     if (bean == null) {
       throw new ConfigException(
           "bean [" + name + "] is null, " + "application can not be restarted.");
     }
     bean.reset();
     if (logger.isDebugEnabled()) {
       logger.debug("bean [" + name + "] was reset.");
     }
   }
   if (!isPortletMode()) {
     // it is always this case !
     ExceptionUtils.unmarkExceptionCaught();
     ((HttpSession) FacesContext.getCurrentInstance().getExternalContext().getSession(false))
         .invalidate();
   }
   return "applicationRestarted";
 }
 /** @return true if an exception have been detected. */
 public boolean isException() {
   if (isPortletMode()) {
     FacesContext facesContext = FacesContext.getCurrentInstance();
     ExternalContext externalContext = facesContext.getExternalContext();
     PortletRequest request = (PortletRequest) externalContext.getRequest();
     ContextUtils.bindRequestAndContext(request, (PortletContext) externalContext.getContext());
   }
   return ExceptionUtils.getMarkedExceptionService() != null;
 }
 /**
  * @param context
  * @param ex
  * @throws IOException
  * @throws ServletException
  */
 public void handleException(final FacesContext context, final Exception ex) {
   // besoin d'exposer la requête pour y mettre dans la session le ExceptionService
   PortletRequest request = (PortletRequest) context.getExternalContext().getRequest();
   ContextUtils.exposeRequest(request);
   ExceptionUtils.markExceptionCaught();
   ExceptionService e = null;
   //		try {
   e = ExceptionUtils.catchException(ex);
   //		} catch (Throwable t) {
   //			handleExceptionHandlingException(t);
   //			// never reached, prevent from warnings
   //			return;
   //		}
   ExceptionUtils.markExceptionCaught(e);
   ContextUtils.unexposeRequest(request);
   NavigationHandler navigation = context.getApplication().getNavigationHandler();
   // Redirection vers la page des erreurs
   navigation.handleNavigation(context, "", e.getExceptionView());
 }
Esempio n. 4
0
 /** @see javax.servlet.GenericServlet#init(javax.servlet.ServletConfig) */
 @Override
 public void init(final ServletConfig config) throws ServletException {
   super.init(config);
   try {
     ApplicationService applicationService =
         (ApplicationService) BeanUtils.getBean("applicationService");
     Version version = applicationService.getVersion();
     result = version.toString();
   } catch (Throwable t) {
     result = ExceptionUtils.getShortPrintableStackTrace(t);
   }
 }
Esempio n. 5
0
 /**
  * @throws ServletException
  * @see javax.servlet.http.HttpServlet#service(javax.servlet.ServletRequest,
  *     javax.servlet.ServletResponse)
  */
 @Override
 public void service(
     @SuppressWarnings("unused") final ServletRequest servletRequest,
     final ServletResponse servletResponse)
     throws ServletException {
   try {
     HttpServletResponse response = (HttpServletResponse) servletResponse;
     ServletOutputStream out = response.getOutputStream();
     out.write(result.getBytes());
   } catch (Throwable t) {
     Exception ve = new VersionException(t);
     ExceptionUtils.catchException(ve);
     throw new ServletException(ve);
   }
 }