Search in sources :

Example 1 with WebFilterFace

use of org.nutz.boot.starter.WebFilterFace in project nutzboot by nutzam.

the class TomcatStarter method addNutzSupport.

private void addNutzSupport() {
    List<WebFilterFace> filters = appContext.getBeans(WebFilterFace.class);
    Collections.sort(filters, Comparator.comparing(WebFilterFace::getOrder));
    filters.forEach((face) -> addFilter(face));
    appContext.getBeans(WebServletFace.class).forEach((face) -> {
        if (face.getServlet() == null) {
            return;
        }
        addServlet(face);
    });
    appContext.getBeans(WebEventListenerFace.class).forEach((face) -> {
        EventListener listener = face.getEventListener();
        if (listener != null) {
            if ((listener instanceof ServletContextAttributeListener) || (listener instanceof ServletRequestAttributeListener) || (listener instanceof ServletRequestListener) || (listener instanceof HttpSessionIdListener) || (listener instanceof HttpSessionAttributeListener)) {
                this.tomcatContext.addApplicationEventListener(listener);
            }
            if ((listener instanceof ServletContextListener) || (listener instanceof HttpSessionListener)) {
                this.tomcatContext.addApplicationLifecycleListener(listener);
            }
        }
    });
}
Also used : ServletContextAttributeListener(javax.servlet.ServletContextAttributeListener) ServletRequestAttributeListener(javax.servlet.ServletRequestAttributeListener) HttpSessionListener(javax.servlet.http.HttpSessionListener) WebEventListenerFace(org.nutz.boot.starter.WebEventListenerFace) ServletContextListener(javax.servlet.ServletContextListener) ServletRequestListener(javax.servlet.ServletRequestListener) HttpSessionAttributeListener(javax.servlet.http.HttpSessionAttributeListener) WebFilterFace(org.nutz.boot.starter.WebFilterFace) WebServletFace(org.nutz.boot.starter.WebServletFace) EventListener(java.util.EventListener) HttpSessionIdListener(javax.servlet.http.HttpSessionIdListener)

Example 2 with WebFilterFace

use of org.nutz.boot.starter.WebFilterFace in project nutzboot by nutzam.

the class JettyStarter method addNutzSupport.

private void addNutzSupport() {
    List<WebFilterFace> filters = appContext.getBeans(WebFilterFace.class);
    Collections.sort(filters, Comparator.comparing(WebFilterFace::getOrder));
    filters.forEach((face) -> addFilter(face));
    appContext.getBeans(WebServletFace.class).forEach((face) -> {
        if (face.getServlet() == null) {
            return;
        }
        ServletHolder holder = new ServletHolder(face.getServlet());
        holder.setName(face.getName());
        holder.setInitParameters(face.getInitParameters());
        wac.addServlet(holder, face.getPathSpec());
    });
    appContext.getBeans(WebEventListenerFace.class).forEach((face) -> {
        if (face.getEventListener() != null) {
            wac.addEventListener(face.getEventListener());
        }
    });
}
Also used : WebEventListenerFace(org.nutz.boot.starter.WebEventListenerFace) ServletHolder(org.eclipse.jetty.servlet.ServletHolder) WebFilterFace(org.nutz.boot.starter.WebFilterFace) WebServletFace(org.nutz.boot.starter.WebServletFace)

Aggregations

WebEventListenerFace (org.nutz.boot.starter.WebEventListenerFace)2 WebFilterFace (org.nutz.boot.starter.WebFilterFace)2 WebServletFace (org.nutz.boot.starter.WebServletFace)2 EventListener (java.util.EventListener)1 ServletContextAttributeListener (javax.servlet.ServletContextAttributeListener)1 ServletContextListener (javax.servlet.ServletContextListener)1 ServletRequestAttributeListener (javax.servlet.ServletRequestAttributeListener)1 ServletRequestListener (javax.servlet.ServletRequestListener)1 HttpSessionAttributeListener (javax.servlet.http.HttpSessionAttributeListener)1 HttpSessionIdListener (javax.servlet.http.HttpSessionIdListener)1 HttpSessionListener (javax.servlet.http.HttpSessionListener)1 ServletHolder (org.eclipse.jetty.servlet.ServletHolder)1