List of usage examples for javax.servlet ServletContext getServerInfo
public String getServerInfo();
From source file:org.apache.tapestry.request.RequestContext.java
/** * Writes the state of the context to the writer, typically for inclusion * in a HTML page returned to the user. This is useful * when debugging. The Inspector uses this as well. * **///from w w w . j a v a 2s .c o m public void write(IMarkupWriter writer) { // Create a box around all of this stuff ... writer.begin("table"); writer.attribute("class", "request-context-border"); writer.begin("tr"); writer.begin("td"); // Get the session, if it exists, and display it. HttpSession session = getSession(); if (session != null) { object(writer, "Session"); writer.begin("table"); writer.attribute("class", "request-context-object"); section(writer, "Properties"); header(writer, "Name", "Value"); pair(writer, "id", session.getId()); datePair(writer, "creationTime", session.getCreationTime()); datePair(writer, "lastAccessedTime", session.getLastAccessedTime()); pair(writer, "maxInactiveInterval", session.getMaxInactiveInterval()); pair(writer, "new", session.isNew()); List names = getSorted(session.getAttributeNames()); int count = names.size(); for (int i = 0; i < count; i++) { if (i == 0) { section(writer, "Attributes"); header(writer, "Name", "Value"); } String name = (String) names.get(i); pair(writer, name, session.getAttribute(name)); } writer.end(); // Session } object(writer, "Request"); writer.begin("table"); writer.attribute("class", "request-context-object"); // Parameters ... List parameters = getSorted(_request.getParameterNames()); int count = parameters.size(); for (int i = 0; i < count; i++) { if (i == 0) { section(writer, "Parameters"); header(writer, "Name", "Value(s)"); } String name = (String) parameters.get(i); String[] values = _request.getParameterValues(name); writer.begin("tr"); writer.attribute("class", getRowClass()); writer.begin("th"); writer.print(name); writer.end(); writer.begin("td"); if (values.length > 1) writer.begin("ul"); for (int j = 0; j < values.length; j++) { if (values.length > 1) writer.beginEmpty("li"); writer.print(values[j]); } writer.end("tr"); } section(writer, "Properties"); header(writer, "Name", "Value"); pair(writer, "authType", _request.getAuthType()); pair(writer, "characterEncoding", _request.getCharacterEncoding()); pair(writer, "contentLength", _request.getContentLength()); pair(writer, "contentType", _request.getContentType()); pair(writer, "method", _request.getMethod()); pair(writer, "pathInfo", _request.getPathInfo()); pair(writer, "pathTranslated", _request.getPathTranslated()); pair(writer, "protocol", _request.getProtocol()); pair(writer, "queryString", _request.getQueryString()); pair(writer, "remoteAddr", _request.getRemoteAddr()); pair(writer, "remoteHost", _request.getRemoteHost()); pair(writer, "remoteUser", _request.getRemoteUser()); pair(writer, "requestedSessionId", _request.getRequestedSessionId()); pair(writer, "requestedSessionIdFromCookie", _request.isRequestedSessionIdFromCookie()); pair(writer, "requestedSessionIdFromURL", _request.isRequestedSessionIdFromURL()); pair(writer, "requestedSessionIdValid", _request.isRequestedSessionIdValid()); pair(writer, "requestURI", _request.getRequestURI()); pair(writer, "scheme", _request.getScheme()); pair(writer, "serverName", _request.getServerName()); pair(writer, "serverPort", _request.getServerPort()); pair(writer, "contextPath", _request.getContextPath()); pair(writer, "servletPath", _request.getServletPath()); // Now deal with any headers List headers = getSorted(_request.getHeaderNames()); count = headers.size(); for (int i = 0; i < count; i++) { if (i == 0) { section(writer, "Headers"); header(writer, "Name", "Value"); } String name = (String) headers.get(i); String value = _request.getHeader(name); pair(writer, name, value); } // Attributes List attributes = getSorted(_request.getAttributeNames()); count = attributes.size(); for (int i = 0; i < count; i++) { if (i == 0) { section(writer, "Attributes"); header(writer, "Name", "Value"); } String name = (String) attributes.get(i); pair(writer, name, _request.getAttribute(name)); } // Cookies ... Cookie[] cookies = _request.getCookies(); if (cookies != null) { for (int i = 0; i < cookies.length; i++) { if (i == 0) { section(writer, "Cookies"); header(writer, "Name", "Value"); } Cookie cookie = cookies[i]; pair(writer, cookie.getName(), cookie.getValue()); } // Cookies loop } writer.end(); // Request object(writer, "Servlet"); writer.begin("table"); writer.attribute("class", "request-context-object"); section(writer, "Properties"); header(writer, "Name", "Value"); pair(writer, "servlet", _servlet); pair(writer, "name", _servlet.getServletName()); pair(writer, "servletInfo", _servlet.getServletInfo()); ServletConfig config = _servlet.getServletConfig(); List names = getSorted(config.getInitParameterNames()); count = names.size(); for (int i = 0; i < count; i++) { if (i == 0) { section(writer, "Init Parameters"); header(writer, "Name", "Value"); } String name = (String) names.get(i); ; pair(writer, name, config.getInitParameter(name)); } writer.end(); // Servlet ServletContext context = config.getServletContext(); object(writer, "Servlet Context"); writer.begin("table"); writer.attribute("class", "request-context-object"); section(writer, "Properties"); header(writer, "Name", "Value"); pair(writer, "majorVersion", context.getMajorVersion()); pair(writer, "minorVersion", context.getMinorVersion()); pair(writer, "serverInfo", context.getServerInfo()); names = getSorted(context.getInitParameterNames()); count = names.size(); for (int i = 0; i < count; i++) { if (i == 0) { section(writer, "Initial Parameters"); header(writer, "Name", "Value"); } String name = (String) names.get(i); pair(writer, name, context.getInitParameter(name)); } names = getSorted(context.getAttributeNames()); count = names.size(); for (int i = 0; i < count; i++) { if (i == 0) { section(writer, "Attributes"); header(writer, "Name", "Value"); } String name = (String) names.get(i); pair(writer, name, context.getAttribute(name)); } writer.end(); // Servlet Context writeSystemProperties(writer); writer.end("table"); // The enclosing border }
From source file:com.dominion.salud.mpr.configuration.MPRInitializer.java
@Override public void onStartup(ServletContext servletContext) throws ServletException { AnnotationConfigWebApplicationContext ctx = new AnnotationConfigWebApplicationContext(); ctx.scan("com.dominion.salud.mpr.configuration"); ctx.setServletContext(servletContext); System.setProperty("mpr.conf.home", findConfigurationAndLogger(ctx)); ctx.refresh();//w w w .j av a2s .c o m ServletRegistration.Dynamic dispatcher = servletContext.addServlet("dispatcher", new DispatcherServlet(ctx)); dispatcher.setLoadOnStartup(1); dispatcher.addMapping("/"); dispatcher.addMapping("/controller/*"); dispatcher.addMapping("/services/*"); servletContext.addListener(new ContextLoaderListener(ctx)); // Configuracion GENERAL DEL MODULO MPRConstantes._MPR_HOME = StringUtils.endsWith(servletContext.getRealPath("/"), File.separator) ? servletContext.getRealPath("/") : servletContext.getRealPath("/") + File.separator; MPRConstantes._MPR_CONF_HOME = ctx.getEnvironment().getProperty("mpr.conf.home"); MPRConstantes._MPR_VERSION = ResourceBundle.getBundle("version").getString("version"); MPRConstantes._MPR_RESOURCES = MPRConstantes._MPR_HOME + "resources" + File.separator; MPRConstantes._MPR_TEMP = MPRConstantes._MPR_HOME + "WEB-INF" + File.separator + "temp" + File.separator; MPRConstantes._MPR_CONTEXT_NAME = servletContext.getServletContextName(); MPRConstantes._MPR_CONTEXT_PATH = servletContext.getContextPath(); MPRConstantes._MPR_CONTEXT_SERVER = servletContext.getServerInfo(); // Configuracion de LOGS DEL MODULO if (StringUtils.isBlank( ((FileAppender) org.apache.log4j.Logger.getRootLogger().getAppender("LOGFILE")).getFile())) { ((FileAppender) org.apache.log4j.Logger.getRootLogger().getAppender("LOGFILE")) .setFile(MPRConstantes._MPR_HOME + "WEB-INF" + File.separator + "classes" + File.separator + "logs" + File.separator + "mpr-desktop.log"); } MPRConstantes._MPR_LOGS = new File( ((FileAppender) org.apache.log4j.Logger.getRootLogger().getAppender("LOGFILE")).getFile()) .getParent(); // Parametrizacion GENERAL DEL SISTEMA MPRConstantes._ENABLE_TECHNICAL_INFORMATION = StringUtils .isNotBlank(ctx.getEnvironment().getProperty("mpr.enable.technical.information")) ? Boolean.parseBoolean(ctx.getEnvironment().getProperty("mpr.enable.technical.information")) : false; // Parametrizacion de CONEXION A EMPI MPRConstantes._EMPI_ENABLE = StringUtils.isNotBlank(ctx.getEnvironment().getProperty("mpr.empi.enable")) ? Boolean.parseBoolean(ctx.getEnvironment().getProperty("mpr.empi.enable")) : false; MPRConstantes._EMPI_USUARIO = StringUtils.isNotBlank(ctx.getEnvironment().getProperty("mpr.empi.usuario")) ? ctx.getEnvironment().getProperty("mpr.empi.usuario") : ""; MPRConstantes._EMPI_SISTEMA = StringUtils.isNotBlank(ctx.getEnvironment().getProperty("mpr.empi.sistema")) ? ctx.getEnvironment().getProperty("mpr.empi.sistema") : ""; MPRConstantes._EMPI_URL = StringUtils.isNotBlank(ctx.getEnvironment().getProperty("mpr.empi.url")) ? ctx.getEnvironment().getProperty("mpr.empi.url") : ""; // Parametrizacion de TAREAS PROGRAMADAS MPRConstantes._TASK_BUZON_IN_PROCESS_MESSAGES = StringUtils .isNotBlank(ctx.getEnvironment().getProperty("mpr.task.buzon.in.process.messages")) ? ctx.getEnvironment().getProperty("mpr.task.buzon.in.process.messages") : MPRConstantes._TASK_BUZON_IN_PROCESS_MESSAGES; MPRConstantes._TASK_BUZON_OUT_PROCESS_MESSAGES = StringUtils .isNotBlank(ctx.getEnvironment().getProperty("mpr.task.buzon.out.process.messages")) ? ctx.getEnvironment().getProperty("mpr.task.buzon.out.process.messages") : MPRConstantes._TASK_BUZON_OUT_PROCESS_MESSAGES; MPRConstantes._TASK_BUZON_IN_HIS_CLEAN = StringUtils .isNotBlank(ctx.getEnvironment().getProperty("mpr.task.buzon.in.his.clean")) ? ctx.getEnvironment().getProperty("mpr.task.buzon.in.his.clean") : MPRConstantes._TASK_BUZON_IN_HIS_CLEAN; MPRConstantes._TASK_BUZON_OUT_HIS_CLEAN = StringUtils .isNotBlank(ctx.getEnvironment().getProperty("mpr.task.buzon.out.his.clean")) ? ctx.getEnvironment().getProperty("mpr.task.buzon.out.his.clean") : MPRConstantes._TASK_BUZON_OUT_HIS_CLEAN; MPRConstantes._TASK_BUZON_IN_HIS_CLEAN_OLD = StringUtils .isNotBlank(ctx.getEnvironment().getProperty("mpr.task.buzon.in.his.clean.old")) ? Integer.parseInt(ctx.getEnvironment().getProperty("mpr.task.buzon.in.his.clean.old")) : MPRConstantes._TASK_BUZON_IN_HIS_CLEAN_OLD; MPRConstantes._TASK_BUZON_OUT_HIS_CLEAN_OLD = StringUtils .isNotBlank(ctx.getEnvironment().getProperty("mpr.task.buzon.out.his.clean.old")) ? Integer.parseInt(ctx.getEnvironment().getProperty("mpr.task.buzon.out.his.clean.old")) : MPRConstantes._TASK_BUZON_OUT_HIS_CLEAN_OLD; MPRConstantes._TASK_BUZON_IN_CLEAN = StringUtils .isNotBlank(ctx.getEnvironment().getProperty("mpr.task.buzon.in.clean")) ? ctx.getEnvironment().getProperty("mpr.task.buzon.in.clean") : MPRConstantes._TASK_BUZON_IN_CLEAN; MPRConstantes._TASK_BUZON_OUT_CLEAN = StringUtils .isNotBlank(ctx.getEnvironment().getProperty("mpr.task.buzon.out.clean")) ? ctx.getEnvironment().getProperty("mpr.task.buzon.out.clean") : MPRConstantes._TASK_BUZON_OUT_CLEAN; MPRConstantes._TASK_BUZON_ERRORES_CLEAN = StringUtils .isNotBlank(ctx.getEnvironment().getProperty("mpr.task.buzon.errores.clean")) ? ctx.getEnvironment().getProperty("mpr.task.buzon.errores.clean") : MPRConstantes._TASK_BUZON_ERRORES_CLEAN; logger.info("Iniciando el modulo de [" + MPRConstantes._MPR_CONTEXT_NAME + "]"); logger.debug(" Configuracion GENERAL DEL MODULO"); logger.debug(" mpr.home: " + MPRConstantes._MPR_HOME); logger.debug(" mpr.conf.home: " + MPRConstantes._MPR_CONF_HOME); logger.debug(" mpr.version: " + MPRConstantes._MPR_VERSION); logger.debug(" mpr.resources: " + MPRConstantes._MPR_RESOURCES); logger.debug(" mpr.temp: " + MPRConstantes._MPR_TEMP); logger.debug(" mpr.logs: " + MPRConstantes._MPR_LOGS); logger.debug(" mpr.logs.file: " + ((FileAppender) org.apache.log4j.Logger.getRootLogger().getAppender("LOGFILE")).getFile()); logger.debug(" mpr.context.name: " + MPRConstantes._MPR_CONTEXT_NAME); logger.debug(" mpr.context.path: " + MPRConstantes._MPR_CONTEXT_PATH); logger.debug(" mpr.context.server: " + MPRConstantes._MPR_CONTEXT_SERVER); logger.debug(" java.version: " + ctx.getEnvironment().getProperty("java.version")); logger.debug(""); logger.debug(" Parametrizacion GENERAL DEL SISTEMA"); logger.debug(" mpr.enable.technical.information: " + MPRConstantes._ENABLE_TECHNICAL_INFORMATION); logger.debug(" Parametrizacion de CONEXION A EMPI"); logger.debug(" mpr.empi.enable: " + MPRConstantes._EMPI_ENABLE); logger.debug(" mpr.empi.usuario: " + MPRConstantes._EMPI_USUARIO); logger.debug(" mpr.empi.sistema: " + MPRConstantes._EMPI_SISTEMA); logger.debug(" mpr.empi.url: " + MPRConstantes._EMPI_URL); logger.debug(" Parametrizacion de TAREAS PROGRAMADAS"); logger.debug( " mpr.task.buzon.in.process.messages: " + MPRConstantes._TASK_BUZON_IN_PROCESS_MESSAGES); logger.debug( " mpr.task.buzon.out.process.messages: " + MPRConstantes._TASK_BUZON_OUT_PROCESS_MESSAGES); logger.debug(" mpr.task.buzon.in.his.clean: " + MPRConstantes._TASK_BUZON_IN_HIS_CLEAN); logger.debug(" mpr.task.buzon.out.his.clean: " + MPRConstantes._TASK_BUZON_OUT_HIS_CLEAN); logger.debug(" mpr.task.buzon.in.his.clean.old: " + MPRConstantes._TASK_BUZON_IN_HIS_CLEAN_OLD); logger.debug(" mpr.task.buzon.out.his.clean.old: " + MPRConstantes._TASK_BUZON_OUT_HIS_CLEAN_OLD); logger.debug(" mpr.task.buzon.in.clean: " + MPRConstantes._TASK_BUZON_IN_CLEAN); logger.debug(" mpr.task.buzon.out.clean: " + MPRConstantes._TASK_BUZON_OUT_CLEAN); logger.debug(" mpr.task.buzon.errores.clean: " + MPRConstantes._TASK_BUZON_ERRORES_CLEAN); logger.debug(" Variables de ENTORNO de utilidad"); logger.debug(" catalina.home: " + ctx.getEnvironment().getProperty("catalina.home")); logger.debug(" jboss.home.dir: " + ctx.getEnvironment().getProperty("jboss.home.dir")); logger.info("Modulo [" + MPRConstantes._MPR_CONTEXT_NAME + "] iniciado correctamente"); }
From source file:net.bull.javamelody.TestMonitoringFilter.java
/** * Initialisation.//from ww w.j a v a2 s.com * @throws ServletException e */ @Before public void setUp() throws ServletException { try { final Field field = MonitoringFilter.class.getDeclaredField("instanceCreated"); field.setAccessible(true); field.set(null, false); } catch (final IllegalAccessException e) { throw new IllegalStateException(e); } catch (final NoSuchFieldException e) { throw new IllegalStateException(e); } final FilterConfig config = createNiceMock(FilterConfig.class); final ServletContext context = createNiceMock(ServletContext.class); expect(config.getServletContext()).andReturn(context).anyTimes(); expect(config.getFilterName()).andReturn(FILTER_NAME).anyTimes(); // anyTimes sur getInitParameter car TestJdbcDriver a pu fixer la proprit systme false expect(context.getInitParameter(Parameters.PARAMETER_SYSTEM_PREFIX + Parameter.DISABLED.getCode())) .andReturn(null).anyTimes(); expect(config.getInitParameter(Parameter.DISABLED.getCode())).andReturn(null).anyTimes(); expect(context.getMajorVersion()).andReturn(2).anyTimes(); expect(context.getMinorVersion()).andReturn(5).anyTimes(); expect(context.getServletContextName()).andReturn("test webapp").anyTimes(); // mockJetty pour avoir un applicationServerIconName dans JavaInformations expect(context.getServerInfo()).andReturn("mockJetty").anyTimes(); // dependencies pour avoir des dpendances dans JavaInformations final Set<String> dependencies = new LinkedHashSet<String>( Arrays.asList("/WEB-INF/lib/jrobin.jar", "/WEB-INF/lib/javamelody.jar")); // et flags pour considrer que les ressources pom.xml et web.xml existent JavaInformations.setWebXmlExistsAndPomXmlExists(true, true); expect(context.getResourcePaths("/WEB-INF/lib/")).andReturn(dependencies).anyTimes(); expect(context.getContextPath()).andReturn(CONTEXT_PATH).anyTimes(); monitoringFilter = new MonitoringFilter(); monitoringFilter.setApplicationType("Test"); replay(config); replay(context); monitoringFilter.init(config); verify(config); verify(context); }
From source file:org.opencms.main.CmsServletContainerSettings.java
/** * Creates a new object.<p>/*from w w w . j a v a 2 s . co m*/ * * @param context used to find out specifics of the servlet container */ public CmsServletContainerSettings(ServletContext context) { // CmsSystemInfo<init> has to call this with null (for setup) if (context != null) { // check for OpenCms home (base) directory path String webInfRfsPath = context.getInitParameter(OpenCmsServlet.SERVLET_PARAM_OPEN_CMS_HOME); if (CmsStringUtil.isEmpty(webInfRfsPath)) { webInfRfsPath = CmsFileUtil.searchWebInfFolder(context.getRealPath("/")); if (CmsStringUtil.isEmpty(webInfRfsPath)) { throw new CmsInitException(Messages.get().container(Messages.ERR_CRITICAL_INIT_FOLDER_0)); } } // set the default web application name // read the the default name from the servlet context parameters String defaultWebApplication = context.getInitParameter("DefaultWebApplication"); // read the the OpenCms servlet mapping from the servlet context parameters String servletMapping = context.getInitParameter(OpenCmsServlet.SERVLET_PARAM_OPEN_CMS_SERVLET); if (servletMapping == null) { throw new CmsInitException(Messages.get().container(Messages.ERR_CRITICAL_INIT_SERVLET_0)); } // read the servlet container name String servletContainerName = context.getServerInfo(); // web application context: // read it from the servlet context parameters // this is needed in case an application server specific deployment descriptor is used to changed the webapp context String webApplicationContext = context .getInitParameter(OpenCmsServlet.SERVLET_PARAM_WEB_APPLICATION_CONTEXT); if (CmsStringUtil.isEmptyOrWhitespaceOnly(webApplicationContext)) { try { URL contextRelativeUrl = context.getResource("/"); webApplicationContext = contextRelativeUrl.getPath(); String[] pathTokens = CmsStringUtil.splitAsArray(webApplicationContext, '/'); if (pathTokens.length == 1) { /* * There may be a "" context configured (e.g. in GlassFish). */ webApplicationContext = ""; } else { webApplicationContext = pathTokens[pathTokens.length - 1]; } } catch (MalformedURLException e) { LOG.error(Messages.get().getBundle().key(Messages.LOG_INIT_CONTEXTNAME_0), e); } } // init values: init(webInfRfsPath, defaultWebApplication, servletMapping, servletContainerName, webApplicationContext); // finally care for the speciality of different servlet containers: initContainerSpecifics(context); } }
From source file:org.exem.flamingo.web.util.ApplicationInformationDisplayContextListener.java
@Override public void contextInitialized(ServletContextEvent servletContextEvent) { System.setProperty("PID", SystemUtils.getPid()); Properties properties = new Properties(); ServletContext context = servletContextEvent.getServletContext(); InputStream inputStream = null; try {// ww w.j a va 2s. com inputStream = context.getResourceAsStream("/WEB-INF/app.properties"); properties.load(inputStream); } catch (Exception ex) { throw new IllegalArgumentException("Cannot load a '/WEB/INF/app.properties' file.", ex); } finally { IOUtils.closeQuietly(inputStream); } // See : http://patorjk.com/software/taag/#p=display&f=Slant&t=Flamingo StringBuilder builder = new StringBuilder(); builder.append(" ________ _ \n" + " / ____/ /___ _____ ___ (_)___ ____ _____ \n" + " / /_ / / __ `/ __ `__ \\/ / __ \\/ __ `/ __ \\\n" + " / __/ / / /_/ / / / / / / / / / / /_/ / /_/ /\n" + "/_/ /_/\\__,_/_/ /_/ /_/_/_/ /_/\\__, /\\____/ \n" + " /____/ "); printHeader(builder, "Application Information"); Properties appProps = new Properties(); appProps.put("Instance", StringUtils.isEmpty(System.getProperty("instance")) ? "** UNKNOWN **" : System.getProperty("instance")); appProps.put("Version", properties.get("version")); appProps.put("Build Date", properties.get("build.timestamp")); appProps.put("Build Number", properties.get("build.number")); appProps.put("Revision Number", properties.get("revision.number")); appProps.put("Organization", properties.get("organization")); appProps.put("Homepage", properties.get("homepage")); if (context != null) { appProps.put("Application Server", context.getServerInfo() + " - Servlet API " + context.getMajorVersion() + "." + context.getMinorVersion()); } Properties systemProperties = System.getProperties(); appProps.put("Java Version", systemProperties.getProperty("java.version", UNKNOWN) + " - " + systemProperties.getProperty("java.vendor", UNKNOWN)); appProps.put("Current Working Directory", systemProperties.getProperty("user.dir", UNKNOWN)); print(builder, appProps); Properties memPros = new Properties(); final Runtime rt = Runtime.getRuntime(); final long maxMemory = rt.maxMemory() / MEGA_BYTES; final long totalMemory = rt.totalMemory() / MEGA_BYTES; final long freeMemory = rt.freeMemory() / MEGA_BYTES; final long usedMemory = totalMemory - freeMemory; memPros.put("Maximum Allowable Memory", maxMemory + "MB"); memPros.put("Total Memory", totalMemory + "MB"); memPros.put("Free Memory", freeMemory + "MB"); memPros.put("Used Memory", usedMemory + "MB"); print(builder, memPros); printHeader(builder, "Java System Properties"); Properties sysProps = new Properties(); for (final Map.Entry<Object, Object> entry : systemProperties.entrySet()) { sysProps.put(entry.getKey(), entry.getValue()); } print(builder, sysProps); printHeader(builder, "System Environments"); Map<String, String> envs = System.getenv(); Properties envProps = new Properties(); Set<String> strings = envs.keySet(); for (String key : strings) { String message = envs.get(key); envProps.put(key, message); } print(builder, envProps); WebLogbackConfigurer.initLogging(servletContextEvent.getServletContext()); System.out.println(builder.toString()); logger.info("============================================================"); logger.info(" Now starting ..... PID: " + SystemUtils.getPid()); logger.info("============================================================"); }
From source file:com.dominion.salud.pedicom.configuration.PEDICOMInitializer.java
@Override public void onStartup(ServletContext servletContext) throws ServletException { AnnotationConfigWebApplicationContext ctx = new AnnotationConfigWebApplicationContext(); ctx.scan("com.dominion.salud.pedicom.configuration"); ctx.setServletContext(servletContext); PEDICOMConstantes._NOMBRE_CONFIG = servletContext.getInitParameter("NOMBRE_CONFIG"); System.setProperty("pedicom.conf.home", findConfigurationAndLogger(ctx)); ctx.refresh();//from w ww . ja va 2 s . co m // Spring Dispatcher ServletRegistration.Dynamic dispatcher = servletContext.addServlet("dispatcher", new DispatcherServlet(ctx)); dispatcher.setInitParameter("contextClass", ctx.getClass().getName()); dispatcher.setLoadOnStartup(1); dispatcher.addMapping("/"); dispatcher.addMapping("/controller/*"); servletContext.addListener(new ContextLoaderListener(ctx)); // Configuracion general PEDICOMConstantes._HOME = StringUtils.endsWith(servletContext.getRealPath("/"), File.separator) ? servletContext.getRealPath("/") : servletContext.getRealPath("/") + File.separator; PEDICOMConstantes._CONF_HOME = ctx.getEnvironment().getProperty("pedicom.conf.home"); PEDICOMConstantes._TEMP = PEDICOMConstantes._HOME + "WEB-INF" + File.separator + "temp" + File.separator; PEDICOMConstantes._VERSION = ResourceBundle.getBundle("version").getString("version"); PEDICOMConstantes._LOGS = PEDICOMConstantes._HOME + "WEB-INF" + File.separator + "classes" + File.separator + "logs"; PEDICOMConstantes._CONTEXT_NAME = servletContext.getServletContextName(); PEDICOMConstantes._CONTEXT_PATH = servletContext.getContextPath(); PEDICOMConstantes._CONTEXT_SERVER = servletContext.getServerInfo(); PEDICOMConstantes._ENABLE_TECHNICAL_INFORMATION = StringUtils.isNotBlank( ResourceBundle.getBundle("application").getString("pedicom.enable.technical.information")) ? Boolean.parseBoolean(ResourceBundle.getBundle("application") .getString("pedicom.enable.technical.information")) : false; PEDICOMConstantes._SCHEDULER_SEND_MAIL_CRON = StringUtils .isNotBlank(ResourceBundle.getBundle("application").getString("pedicom_scheduler_send_mail_cron")) ? PEDICOMConstantes._SCHEDULER_SEND_MAIL_CRON = ResourceBundle.getBundle("application") .getString("pedicom_scheduler_send_mail_cron") : PEDICOMConstantes._SCHEDULER_SEND_MAIL_CRON; PEDICOMConstantes._SCHEDULER_UPDATE_EXISTENCIAS_CRON = StringUtils.isNotBlank( ResourceBundle.getBundle("application").getString("pedicom_scheduler_update_existencias_cron")) ? PEDICOMConstantes._SCHEDULER_SEND_MAIL_CRON = ResourceBundle.getBundle("application") .getString("pedicom_scheduler_update_existencias_cron") : PEDICOMConstantes._SCHEDULER_UPDATE_EXISTENCIAS_CRON; // Configuracion de LOGS DEL MODULO if (StringUtils.isBlank( ((FileAppender) org.apache.log4j.Logger.getRootLogger().getAppender("LOGFILE")).getFile())) { ((FileAppender) org.apache.log4j.Logger.getRootLogger().getAppender("LOGFILE")) .setFile(PEDICOMConstantes._HOME + "WEB-INF" + File.separator + "classes" + File.separator + "logs" + File.separator + "mpr-desktop.log"); } PEDICOMConstantes._LOGS = new File( ((FileAppender) org.apache.log4j.Logger.getRootLogger().getAppender("LOGFILE")).getFile()) .getParent(); Environment env = ctx.getEnvironment(); XmlUnmarshaler xml = new XmlUnmarshaler(); Datos datos = (Datos) xml.unmarshal(); logger.info(" Datasources"); for (Datasources dat : datos.getDatasources()) { if (dat.getNombreDatasource().equals("Central")) { PEDICOMConstantes.EXISTENCIAS_EXISTE = true; } logger.info(" codCentro: " + dat.getCodCentro()); logger.info(" nombreDatasource: " + dat.getNombreDatasource()); logger.info(" driverClassName: " + dat.getDriverClassName()); logger.info(" jndi: " + dat.getJndi()); logger.info(" url: " + dat.getUrl()); logger.info(" username: " + dat.getUsername()); logger.info(" usernameEmail: " + dat.getUsernameEmail()); logger.info(" passwordEmail: " + dat.getPasswordEmail()); logger.info(" from: " + dat.getFrom()); logger.info(" host: " + dat.getHost()); logger.info(" port: " + dat.getPort()); logger.info(" TLS: " + dat.getTLS()); logger.info(" SSL: " + dat.getSSL()); } // ctx.refresh(); // PropertyConfigurator.configureAndWatch("log4j"); logger.info(" Configuracion general del sistema"); logger.info(" pedicom.home: " + PEDICOMConstantes._HOME); logger.info(" pedicom.conf.home: " + PEDICOMConstantes._CONF_HOME); logger.info(" pedicom.temp: " + PEDICOMConstantes._TEMP); logger.info(" pedicom.version: " + PEDICOMConstantes._VERSION); logger.info(" pedicom.logs: " + PEDICOMConstantes._LOGS); logger.info(" pedicom.context.name: " + PEDICOMConstantes._CONTEXT_NAME); logger.info(" pedicom.context.path: " + PEDICOMConstantes._CONTEXT_PATH); logger.info(" pedicom.context.server: " + PEDICOMConstantes._CONTEXT_SERVER); logger.info(" Parametrizacion del sistema"); logger.info(" pedicom.enable.technical.information: " + PEDICOMConstantes._ENABLE_TECHNICAL_INFORMATION); logger.info( " pedicom_scheduler_send_mail_cron: " + PEDICOMConstantes._SCHEDULER_SEND_MAIL_CRON); logger.info(" pedicom_scheduler_update_existencias_cron: " + PEDICOMConstantes._SCHEDULER_UPDATE_EXISTENCIAS_CRON); logger.info(" Modulo configurado correctamente"); logger.info("MODULO INICIADO CORRECTAMENTE"); }
From source file:com.dominion.salud.nomenclator.configuration.NOMENCLATORInitializer.java
@Override public void onStartup(ServletContext servletContext) throws ServletException { AnnotationConfigWebApplicationContext ctx = new AnnotationConfigWebApplicationContext(); ctx.scan("com.dominion.salud.nomenclator.configuration"); ctx.setServletContext(servletContext); ctx.refresh();/*from w w w . j a v a2 s .co m*/ logger.info(" Registrando servlets de configuracion"); ServletRegistration.Dynamic dispatcher = servletContext.addServlet("dispatcher", new DispatcherServlet(ctx)); dispatcher.setInitParameter("contextClass", ctx.getClass().getName()); dispatcher.setLoadOnStartup(1); logger.info(" Agregando mapping: /"); dispatcher.addMapping("/"); logger.info(" Agregando mapping: /controller/*"); dispatcher.addMapping("/controller/*"); logger.info(" Agregando mapping: /services/*"); dispatcher.addMapping("/services/*"); servletContext.addListener(new ContextLoaderListener(ctx)); logger.info(" Servlets de configuracion registrados correctamente"); // Configuracion general logger.info(" Iniciando la configuracion del modulo"); NOMENCLATORConstantes._HOME = StringUtils.endsWith(servletContext.getRealPath("/"), File.separator) ? servletContext.getRealPath("/") : servletContext.getRealPath("/") + File.separator; NOMENCLATORConstantes._TEMP = NOMENCLATORConstantes._HOME + "WEB-INF" + File.separator + "temp" + File.separator; NOMENCLATORConstantes._VERSION = ResourceBundle.getBundle("version").getString("version"); NOMENCLATORConstantes._LOGS = NOMENCLATORConstantes._HOME + "WEB-INF" + File.separator + "classes" + File.separator + "logs"; NOMENCLATORConstantes._CONTEXT_NAME = servletContext.getServletContextName(); NOMENCLATORConstantes._CONTEXT_PATH = servletContext.getContextPath(); NOMENCLATORConstantes._CONTEXT_SERVER = servletContext.getServerInfo(); NOMENCLATORConstantes._ENABLE_TECHNICAL_INFORMATION = StringUtils.isNotBlank( ResourceBundle.getBundle("application").getString("nomenclator.enable.technical.information")) ? Boolean.parseBoolean(ResourceBundle.getBundle("application") .getString("nomenclator.enable.technical.information")) : false; PropertyConfigurator.configureAndWatch("log4j"); logger.info(" Configuracion general del sistema"); logger.info(" nomenclator.home: " + NOMENCLATORConstantes._HOME); logger.info(" nomenclator.temp: " + NOMENCLATORConstantes._TEMP); logger.info(" nomenclator.version: " + NOMENCLATORConstantes._VERSION); logger.info(" nomenclator.logs: " + NOMENCLATORConstantes._LOGS); logger.info(" nomenclator.context.name: " + NOMENCLATORConstantes._CONTEXT_NAME); logger.info(" nomenclator.context.path: " + NOMENCLATORConstantes._CONTEXT_PATH); logger.info(" nomenclator.context.server: " + NOMENCLATORConstantes._CONTEXT_SERVER); logger.info(" Parametrizacion del sistema"); logger.info(" nomenclator.enable.technical.information: " + NOMENCLATORConstantes._ENABLE_TECHNICAL_INFORMATION); logger.info(" Modulo configurado correctamente"); logger.info("MODULO INICIADO CORRECTAMENTE"); }
From source file:fll.web.GatherBugReport.java
protected void processRequest(final HttpServletRequest request, final HttpServletResponse response, final ServletContext application, final HttpSession session) throws IOException, ServletException { final DataSource datasource = ApplicationAttributes.getDataSource(application); Connection connection = null; ZipOutputStream zipOut = null; final StringBuilder message = new StringBuilder(); try {/* w w w. j av a 2 s .c o m*/ if (null != SessionAttributes.getMessage(session)) { message.append(SessionAttributes.getMessage(session)); } connection = datasource.getConnection(); final Document challengeDocument = ApplicationAttributes.getChallengeDocument(application); final File fllWebInfDir = new File(application.getRealPath("/WEB-INF")); final String nowStr = new SimpleDateFormat("yyyy-MM-dd_HH-mm").format(new Date()); final File bugReportFile = File.createTempFile(nowStr, ".zip", fllWebInfDir); zipOut = new ZipOutputStream(new FileOutputStream(bugReportFile)); final String description = request.getParameter("bug_description"); if (null != description) { zipOut.putNextEntry(new ZipEntry("bug_description.txt")); zipOut.write(description.getBytes(Utilities.DEFAULT_CHARSET)); } zipOut.putNextEntry(new ZipEntry("server_info.txt")); zipOut.write(String.format( "Java version: %s%nJava vendor: %s%nOS Name: %s%nOS Arch: %s%nOS Version: %s%nServlet API: %d.%d%nServlet container: %s%n", System.getProperty("java.vendor"), // System.getProperty("java.version"), // System.getProperty("os.name"), // System.getProperty("os.arch"), // System.getProperty("os.version"), // application.getMajorVersion(), application.getMinorVersion(), // application.getServerInfo()).getBytes(Utilities.DEFAULT_CHARSET)); addDatabase(zipOut, connection, challengeDocument); addLogFiles(zipOut, application); message.append(String.format( "<i>Bug report saved to '%s', please notify the computer person in charge to look for bug report files.</i>", bugReportFile.getAbsolutePath())); session.setAttribute(SessionAttributes.MESSAGE, message); response.sendRedirect(response.encodeRedirectURL(request.getContextPath() + "/")); } catch (final SQLException sqle) { throw new RuntimeException(sqle); } finally { SQLFunctions.close(connection); IOUtils.closeQuietly(zipOut); } }
From source file:net.bull.javamelody.internal.model.JavaInformations.java
public JavaInformations(ServletContext servletContext, boolean includeDetails) { // CHECKSTYLE:ON super();/*from www .java 2 s . c om*/ memoryInformations = new MemoryInformations(); tomcatInformationsList = TomcatInformations.buildTomcatInformationsList(); sessionCount = SessionListener.getSessionCount(); sessionAgeSum = SessionListener.getSessionAgeSum(); activeThreadCount = JdbcWrapper.getActiveThreadCount(); usedConnectionCount = JdbcWrapper.getUsedConnectionCount(); activeConnectionCount = JdbcWrapper.getActiveConnectionCount(); maxConnectionCount = JdbcWrapper.getMaxConnectionCount(); transactionCount = JdbcWrapper.getTransactionCount(); systemLoadAverage = buildSystemLoadAverage(); systemCpuLoad = buildSystemCpuLoad(); processCpuTimeMillis = buildProcessCpuTimeMillis(); unixOpenFileDescriptorCount = buildOpenFileDescriptorCount(); unixMaxFileDescriptorCount = buildMaxFileDescriptorCount(); host = Parameters.getHostName() + '@' + Parameters.getHostAddress(); os = buildOS(); availableProcessors = Runtime.getRuntime().availableProcessors(); javaVersion = System.getProperty("java.runtime.name") + ", " + System.getProperty("java.runtime.version"); jvmVersion = System.getProperty("java.vm.name") + ", " + System.getProperty("java.vm.version") + ", " + System.getProperty("java.vm.info"); if (servletContext == null) { serverInfo = null; contextPath = null; contextDisplayName = null; webappVersion = null; } else { serverInfo = servletContext.getServerInfo(); contextPath = Parameters.getContextPath(servletContext); contextDisplayName = servletContext.getServletContextName(); webappVersion = MavenArtifact.getWebappVersion(); } startDate = START_DATE; jvmArguments = buildJvmArguments(); final ThreadMXBean threadBean = ManagementFactory.getThreadMXBean(); threadCount = threadBean.getThreadCount(); peakThreadCount = threadBean.getPeakThreadCount(); totalStartedThreadCount = threadBean.getTotalStartedThreadCount(); freeDiskSpaceInTemp = Parameters.TEMPORARY_DIRECTORY.getFreeSpace(); springBeanExists = SPRING_AVAILABLE && SpringContext.getSingleton() != null; if (includeDetails) { dataBaseVersion = buildDataBaseVersion(); dataSourceDetails = buildDataSourceDetails(); threadInformationsList = buildThreadInformationsList(); cacheInformationsList = CacheInformations.buildCacheInformationsList(); jobInformationsList = JobInformations.buildJobInformationsList(); pid = PID.getPID(); } else { dataBaseVersion = null; dataSourceDetails = null; threadInformationsList = null; cacheInformationsList = null; jobInformationsList = null; pid = null; } }
From source file:org.apache.click.service.XmlConfigService.java
/** * @see ConfigService#onInit(ServletContext) * * @param servletContext the application servlet context * @throws Exception if an error occurs initializing the application *///from w w w .j a v a 2s. c o m public void onInit(ServletContext servletContext) throws Exception { Validate.notNull(servletContext, "Null servletContext parameter"); this.servletContext = servletContext; onGoogleAppEngine = servletContext.getServerInfo().startsWith(GOOGLE_APP_ENGINE); // Set default logService early to log errors when services fail. logService = new ConsoleLogService(); messagesMapService = new DefaultMessagesMapService(); InputStream inputStream = ClickUtils.getClickConfig(servletContext); try { Document document = ClickUtils.buildDocument(inputStream, this); Element rootElm = document.getDocumentElement(); // Load the log service loadLogService(rootElm); // Load the application mode and set the logger levels loadMode(rootElm); if (logService.isInfoEnabled()) { logService.info("*** Initializing Click " + ClickUtils.getClickVersion() + " in " + getApplicationMode() + " mode ***"); String msg = "initialized LogService: " + logService.getClass().getName(); getLogService().info(msg); } // Deploy click resources deployFiles(rootElm); // Load the format class loadFormatClass(rootElm); // Load the common headers loadHeaders(rootElm); // Load the pages loadPages(rootElm); // Load the error and not-found pages loadDefaultPages(); // Load the charset loadCharset(rootElm); // Load the locale loadLocale(rootElm); // Load the File Upload service loadFileUploadService(rootElm); // Load the Templating service loadTemplateService(rootElm); // Load the Resource service loadResourceService(rootElm); // Load the Messages Map service loadMessagesMapService(rootElm); // Load the PageInterceptors loadPageInterceptors(rootElm); } finally { ClickUtils.close(inputStream); } }