// Path: src/main/java/com/indeed/proctor/webapp/extensions/CommitMessageDisplayFormatter.java
// public interface CommitMessageDisplayFormatter {
//     public String formatMessage(String commitMessage);
// }


import com.indeed.proctor.webapp.extensions.CommitMessageDisplayFormatter;
import org.apache.commons.lang.StringEscapeUtils;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.BeanFactoryUtils;
import org.springframework.web.context.WebApplicationContext;
import org.springframework.web.context.support.WebApplicationContextUtils;
import javax.servlet.ServletContext;
import javax.servlet.jsp.tagext.TagSupport;
import java.io.IOException;
import java.util.Map;
package com.indeed.proctor.webapp.tags;



/**
 */
public class FormatCommitMessageDisplayTagHandler extends TagSupport {
    private static final Logger LOGGER = Logger.getLogger(FormatCommitMessageDisplayTagHandler.class);

    private String commitMessage;

    public void setCommitMessage(final String commitMessage) {
        this.commitMessage = commitMessage;
    }

    public int doStartTag() {
        try {
            pageContext.getOut().print(formatMessage(commitMessage));
        } catch (IOException e) {
            LOGGER.error("Failed to write formatted commit message to page context", e);
        }

        return SKIP_BODY;
    }

    public String formatMessage(final String commitMessage) {
        final ServletContext servletContext = pageContext.getServletContext();
        final WebApplicationContext context = WebApplicationContextUtils.getRequiredWebApplicationContext(servletContext);
        try {
// Path: src/main/java/com/indeed/proctor/webapp/extensions/CommitMessageDisplayFormatter.java
// public interface CommitMessageDisplayFormatter {
//     public String formatMessage(String commitMessage);
// }


// Path: src/main/java/com/indeed/proctor/webapp/tags/FormatCommitMessageDisplayTagHandler.java
import com.indeed.proctor.webapp.extensions.CommitMessageDisplayFormatter;
import org.apache.commons.lang.StringEscapeUtils;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.BeanFactoryUtils;
import org.springframework.web.context.WebApplicationContext;
import org.springframework.web.context.support.WebApplicationContextUtils;
import javax.servlet.ServletContext;
import javax.servlet.jsp.tagext.TagSupport;
import java.io.IOException;
import java.util.Map;

package com.indeed.proctor.webapp.tags;



/**
 */
public class FormatCommitMessageDisplayTagHandler extends TagSupport {
    private static final Logger LOGGER = Logger.getLogger(FormatCommitMessageDisplayTagHandler.class);

    private String commitMessage;

    public void setCommitMessage(final String commitMessage) {
        this.commitMessage = commitMessage;
    }

    public int doStartTag() {
        try {
            pageContext.getOut().print(formatMessage(commitMessage));
        } catch (IOException e) {
            LOGGER.error("Failed to write formatted commit message to page context", e);
        }

        return SKIP_BODY;
    }

    public String formatMessage(final String commitMessage) {
        final ServletContext servletContext = pageContext.getServletContext();
        final WebApplicationContext context = WebApplicationContextUtils.getRequiredWebApplicationContext(servletContext);
        try {
            final Map<String, CommitMessageDisplayFormatter> formatterBeans = BeanFactoryUtils.beansOfTypeIncludingAncestors(context,CommitMessageDisplayFormatter.class);