/** * Utility to get constants or code gets really wordy. * * @param key * @return */ public static String CONST(String key) { return getEnvironment().getConstants().get(key); }
/** * This returns true or false for * @param req * @param resp * @return * @throws ServletException */ protected boolean doPing(HttpServletRequest req, HttpServletResponse resp) throws ServletException { if (req.getParameterMap().containsKey(PING_PARAMETER)) { // Check if ping is enabled. Set in AbstractEnvironment?? if (!getEnvironment().isPingable()) { warn("Ping attempted on server. Ping not enabled."); // Throw a servlet exception so it is unclear if the server is down or not. // This means it is un-pingable. throw new ServletException("Internal error"); } info("ping ok"); resp.setStatus(HttpStatus.SC_NO_CONTENT); return true; } // Since every request runs through this, logging that no ping was done would just fill up the logs. return false; }
@Override public void init() throws ServletException { super.init(); if (environment == null) { info("loading environment..."); try { loadEnvironment(); } catch (IOException e) { warn("failed to load environment."); throw new GeneralException("Error loading environment", e); } info("done loading environment."); } if (getInitialization() == null) { info("Caution: no initializer set for " + getClass().getSimpleName() + ". Skipping..."); } else { getInitialization().setEnvironment(getEnvironment()); getInitialization().setServlet(this); getInitialization().init(); setExceptionHandler(getInitialization().getExceptionHandler()); } }