Example usage for javax.servlet ServletContext getMajorVersion

List of usage examples for javax.servlet ServletContext getMajorVersion

Introduction

In this page you can find the example usage for javax.servlet ServletContext getMajorVersion.

Prototype

public int getMajorVersion();

Source Link

Document

Returns the major version of the Servlet API that this servlet container supports.

Usage

From source file:net.bull.javamelody.TestMonitoringFilter.java

/**
 * Initialisation.//w w  w  .j av a 2 s  . co m
 * @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: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 ww  . j a  va2 s  .  c  om*/
        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:ro.raisercostin.web.DebuggingFilter.java

public String debug(ServletContext servletContext, HttpServletRequest request, HttpServletResponse response,
        DebuggingPrinter debuggingPrinter, boolean debugAll, boolean debugRequest) {
    final JspFactory jspFactory = JspFactory.getDefaultFactory();
    HttpSession session = request.getSession();
    debuggingPrinter.addHeader();// w ww . j  a  v  a 2 s  .co  m
    debuggingPrinter.addSection("Request Parameters");
    for (Iterator iterator = request.getParameterMap().entrySet().iterator(); iterator.hasNext();) {
        Map.Entry<String, Object> parameter = (Map.Entry<String, Object>) iterator.next();
        addRow(debuggingPrinter, parameter.getKey(),
                StringUtils.arrayToCommaDelimitedString((Object[]) parameter.getValue()));
    }
    debuggingPrinter.endSection();

    if (debugRequest) {
        debuggingPrinter.addSection("Request Header");
        for (Enumeration e = request.getHeaderNames(); e.hasMoreElements();) {
            String parameterName = (String) e.nextElement();
            addRow(debuggingPrinter, parameterName,
                    debuggingPrinter.transform(request.getHeader(parameterName)));
        }
        debuggingPrinter.endSection();

        debuggingPrinter.addSection("Request Attributes");
        java.util.Enumeration en = request.getAttributeNames();
        while (en.hasMoreElements()) {
            String attrName = (String) en.nextElement();
            try {
                addRow(debuggingPrinter, split(attrName, 50), toString2(request.getAttribute(attrName), 120));
            } catch (Exception e) {
                addRow(debuggingPrinter, split(attrName, 50), toString(e, 120));
            }

        }
        debuggingPrinter.endSection();

        debuggingPrinter.addSection("Session Attributes");
        en = session.getAttributeNames();
        while (en.hasMoreElements()) {
            String attrName = (String) en.nextElement();
            try {
                addRow(debuggingPrinter, split(attrName, 50), toString2(session.getAttribute(attrName), 120));
            } catch (Exception e) {
                addRow(debuggingPrinter, split(attrName, 50), toString(e, 120));
            }
        }
        debuggingPrinter.endSection();

        debuggingPrinter.addSection("Request Info");
        addRow(debuggingPrinter, "AuthType", request.getAuthType());
        addRow(debuggingPrinter, "ContextPath", request.getContextPath());
        addRow(debuggingPrinter, "Method", request.getMethod());
        addRow(debuggingPrinter, "PathInfo", request.getPathInfo());
        addRow(debuggingPrinter, "PathTranslated", request.getPathTranslated());
        addRow(debuggingPrinter, "Protocol", request.getProtocol());
        addRow(debuggingPrinter, "QueryString", request.getQueryString());
        addRow(debuggingPrinter, "RemoteAddr", request.getRemoteAddr());
        addRow(debuggingPrinter, "RemoteUser", request.getRemoteUser());
        addRow(debuggingPrinter, "RequestedSessionId", request.getRequestedSessionId());
        addRow(debuggingPrinter, "RequestURI", request.getRequestURI());
        addRow(debuggingPrinter, "RequestURL", request.getRequestURL().toString());
        addRow(debuggingPrinter, "ServletPath", request.getServletPath());
        addRow(debuggingPrinter, "Scheme", request.getScheme());
        addRow(debuggingPrinter, "ServletPath", request.getServletPath());
    }
    if (debugAll) {
        debuggingPrinter.addSection("Server");
        addRow(debuggingPrinter, "Server Info", servletContext.getServerInfo());
        addRow(debuggingPrinter, "Servlet Engine Version",
                servletContext.getMajorVersion() + "." + servletContext.getMinorVersion());
        addRow(debuggingPrinter, "JSP Version", jspFactory.getEngineInfo().getSpecificationVersion());
        debuggingPrinter.endSection();

        debuggingPrinter.addSection("JVM Properties");
        for (Enumeration e = System.getProperties().propertyNames(); e.hasMoreElements();) {
            String parameterName = (String) e.nextElement();
            addRow(debuggingPrinter, parameterName,
                    debuggingPrinter.transform(System.getProperty(parameterName)));
        }
        debuggingPrinter.endSection();

        debuggingPrinter.addSection("Environment");
        for (Map.Entry<String, String> property : System.getenv().entrySet()) {
            addRow(debuggingPrinter, property.getKey(), debuggingPrinter.transform(property.getValue()));
        }
        debuggingPrinter.endSection();

        debuggingPrinter.addSection("Debugger Provided by");
        addRow(debuggingPrinter, "provided by", "raisercostin");
        debuggingPrinter.addRow("source",
                "<a target='_blank' href='http://code.google.com/p/raisercostin/wiki/DebuggingFilter'>http://code.google.com/p/raisercostin/wiki/DebuggingFilter</a>");
        addRow(debuggingPrinter, "version", "1.0");
        addRow(debuggingPrinter, "timestamp", "2008.June.14");
        addRow(debuggingPrinter, "license",
                "<a target='_blank' href='http://www.apache.org/licenses/LICENSE-2.0.html'>Apache License 2.0</a>");
        debuggingPrinter.endSection();
    }
    debuggingPrinter.addFooter();
    return debuggingPrinter.getString();
}

From source file:org.apache.jsp.happyaxis_jsp.java

/**
 *  get servlet version string/*from   w  ww .  j  ava2  s.co  m*/
 *
 */

public String getServletVersion() {
    ServletContext context = getServletConfig().getServletContext();
    int major = context.getMajorVersion();
    int minor = context.getMinorVersion();
    return Integer.toString(major) + '.' + Integer.toString(minor);
}

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.
 *
 **//*ww w .jav  a2 s.com*/

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:org.artifactory.webapp.servlet.ArtifactoryContextConfigListener.java

/**
 * Disable sessionId in URL (Servlet 3.0 containers) by setting the session tracking mode to SessionTrackingMode.COOKIE
 * For Servlet container < 3.0 we use different method (for tomcat 6 we use custom context.xml and for jetty
 * there is a custom jetty.xml file).//from   w  w w  .j  a v a  2s .  co m
 */
@SuppressWarnings("unchecked")
private void setSessionTrackingMode(ServletContext servletContext) {
    // Only for Servlet container version 3.0 and above
    if (servletContext.getMajorVersion() < 3) {
        return;
    }

    // We cannot use ConstantValue.enableURLSessionId.getBoolean() since ArtifactoryHome is not binded yet.
    ArtifactoryHome artifactoryHome = (ArtifactoryHome) servletContext
            .getAttribute(ArtifactoryHome.SERVLET_CTX_ATTR);
    if (artifactoryHome == null) {
        throw new IllegalStateException("Artifactory home not initialized.");
    }

    if (artifactoryHome.getArtifactoryProperties()
            .getBooleanProperty(ConstantValues.supportUrlSessionTracking)) {
        getLogger().debug("Skipping setting session tracking mode to COOKIE, enableURLSessionId flag it on.");
        return;
    }

    try {
        // load enum with reflection
        ClassLoader cl = ClassUtils.getDefaultClassLoader();
        Class<Enum> trackingModeEnum = (Class<Enum>) cl.loadClass("javax.servlet.SessionTrackingMode");
        Enum cookieTrackingMode = Enum.valueOf(trackingModeEnum, "COOKIE");

        // reflective call servletContext.setSessionTrackingModes(trackingModes)
        Method method = servletContext.getClass().getMethod("setSessionTrackingModes", Set.class);
        method.setAccessible(true);
        ReflectionUtils.invokeMethod(method, servletContext, Sets.newHashSet(cookieTrackingMode));
        getLogger().debug("Successfully set session tracking mode to COOKIE");
    } catch (Exception e) {
        getLogger().warn("Failed to set session tracking mode: " + e.getMessage());
    }
}

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 {// w ww.  java2s.  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:org.impalaframework.web.utils.ServletContextUtils.java

public static boolean isAtLeast25(ServletContext servletContext) {
    return servletContext.getMajorVersion() >= 2 && servletContext.getMinorVersion() >= 5;
}

From source file:org.jpublish.servlet.JPublishServlet.java

/**
 * Return true if the ServletContext major and minor version are greater
 * than or equal to the given arguments.
 *
 * @param majorVersion The required major version
 * @param minorVersion The required minor version
 * @return True if the version is equal to or greater than the given args
 *//*from   w ww .j av  a 2  s .  co m*/

private boolean requireVersion(int majorVersion, int minorVersion) {
    ServletContext servletContext = getServletContext();
    return ((servletContext.getMajorVersion() > majorVersion)
            || (servletContext.getMajorVersion() == majorVersion
                    && servletContext.getMinorVersion() >= minorVersion));
}

From source file:org.openflamingo.engine.util.VersionConfigurer.java

/**
 * Notification that the web application initialization
 * process is starting.//from w w w .j  av  a2 s .  co  m
 * All ServletContextListeners are notified of context
 * initialization before any filter or servlet in the web
 * application is initialized.
 *
 * @param servletContextEvent {@link javax.servlet.ServletContextEvent}
 */
@Override
public void contextInitialized(ServletContextEvent servletContextEvent) {
    Log4jWebConfigurer.initLogging(servletContextEvent.getServletContext());

    Properties properties = new Properties();
    ServletContext context = servletContextEvent.getServletContext();
    InputStream inputStream = null;
    try {
        inputStream = context.getResourceAsStream("/WEB-INF/version.properties");
        properties.load(inputStream);
    } catch (Exception ex) {
        throw new IllegalArgumentException("Cannot load a '/WEB/INF/version.properties' file.", ex);
    } finally {
        IOUtils.closeQuietly(inputStream);
    }

    StringBuilder builder = new StringBuilder();

    printHeader(builder, "Application Information");
    Properties appProps = new Properties();
    appProps.put("Application", "Flamingo Workflow Engine");
    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("Build Key", properties.get("build.key"));

    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);

    printHeader(builder, "JVM Heap Information");

    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> getenv = System.getenv();
    Properties envProps = new Properties();
    Set<String> strings = getenv.keySet();
    for (String key : strings) {
        String message = getenv.get(key);
        envProps.put(key, message);
    }

    print(builder, envProps);

    logger.info("=================================================");
    logger.info(" Flamingo Workflow Engine starting...");
    logger.info("=================================================\n{}", builder.toString());
}