com.swordcode.webcore.security.testui.TestAppInitializer.java Source code

Java tutorial

Introduction

Here is the source code for com.swordcode.webcore.security.testui.TestAppInitializer.java

Source

package com.swordcode.webcore.security.testui;

import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.ServletRegistration;
import org.springframework.web.WebApplicationInitializer;
import org.springframework.web.context.ContextLoaderListener;
import org.springframework.web.context.support.AnnotationConfigWebApplicationContext;

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 *
 * @author euclidesflores
 */
public class TestAppInitializer implements WebApplicationInitializer {
    @Override
    public void onStartup(ServletContext container) throws ServletException {
        // Use Spring AnnotationConfigWebApplicationContext to avoid using any xml files.
        AnnotationConfigWebApplicationContext rootContext = new AnnotationConfigWebApplicationContext();
        rootContext.register(TestAppConfig.class);
        container.addListener(new ContextLoaderListener(rootContext));

        ServletRegistration.Dynamic vaadinRoot = container.addServlet("vaadin", new SecurityTestUI.Servlet());
        vaadinRoot.setLoadOnStartup(1);
        vaadinRoot.setAsyncSupported(true);
        vaadinRoot.addMapping("/*");

        //      FilterRegistration.Dynamic jpaFilter = container.addFilter("springJPA", OpenEntityManagerInViewFilter.class);
        //      jpaFilte

        //      Filter f = new OpenEntityManagerInViewFilter();
        //      ServletRegistration.Dynamic filter = container.addFilter("/*", f);//org.springframework.orm.jpa.support.OpenEntityManagerInViewFilter.class);
    }
    /*        XmlWebApplicationContext rootContext = new XmlWebApplicationContext();
    rootContext.setConfigLocations(new String[] { "classpath*:applicationContext.xml" });
    container.addListener(new ContextLoaderListener(rootContext));
        
    ServletRegistration.Dynamic dispatcher = container.addServlet("CXFServlet", CXFServlet.class);
    dispatcher.addMapping("/*");
        }
    */

}