Example usage for javax.servlet ServletContextEvent getSource

List of usage examples for javax.servlet ServletContextEvent getSource

Introduction

In this page you can find the example usage for javax.servlet ServletContextEvent getSource.

Prototype

public Object getSource() 

Source Link

Document

The object on which the Event initially occurred.

Usage

From source file:net.firejack.platform.core.utils.TomcatUtils.java

/**
 * @param event/*w ww.java 2 s.  c  om*/
 * @return
 */
public static String getCatalinaHost(ServletContextEvent event) {
    try {
        return (String) ClassUtils.getProperty(event.getSource(), "context.context.hostName");
    } catch (Exception e) {
        logger.warn("Can't find  server port");
    }
    return "localhost";
}

From source file:net.firejack.platform.core.utils.TomcatUtils.java

/**
 * @param event/*from  w w w  .j  av a  2  s. c o m*/
 * @return
 */
public static String getCatalinaContext(ServletContextEvent event) {
    try {
        return (String) ClassUtils.getProperty(event.getSource(), "context.context.encodedPath");
    } catch (Exception e) {
        logger.warn("Can't find  server port");
    }
    return "";
}

From source file:net.firejack.platform.core.utils.TomcatUtils.java

/**
 * @param event/*from w  ww  . j av a 2 s  . c  o m*/
 * @return
 */
public static Integer getCatalinaPort(ServletContextEvent event) {
    try {
        Object[] connectors = (Object[]) ClassUtils.getProperty(event.getSource(),
                "context.context.parent.parent.service.connectors");
        if (connectors != null) {
            for (Object connector : connectors) {
                Object protocolHandler = ClassUtils.getProperty(connector, "protocolHandler");
                if (protocolHandler != null
                        && protocolHandler.getClass().getSimpleName().startsWith("Http11")) {
                    return (Integer) ClassUtils.getProperty(connector, "port");
                }
            }
        }
    } catch (Exception e) {
        logger.warn("Can't find  server port");
    }
    return 80;
}