Java 类org.springframework.orm.jpa.support.OpenEntityManagerInViewFilter 实例源码

项目:owsi-core-parent    文件:RestTestUtils.java   
public static ServletAdapter initRestTestServletAdapter(Class<?> applicationConfigClass, int testServerPort,
        String testContextPath, String testServletPath, boolean enableJPA) {
    final ServletAdapter adapter = new ServletAdapter();

    adapter.addInitParameter(ServletContainer.APPLICATION_CONFIG_CLASS, applicationConfigClass.getName());
    adapter.addInitParameter("com.sun.jersey.spi.container.ContainerRequestFilters", LoggingFilter.class.getName());
    adapter.addInitParameter("com.sun.jersey.spi.container.ContainerResponseFilters", LoggingFilter.class.getName());

    adapter.addServletListener(ContextLoaderListener.class.getName());

    if (enableJPA) {
        adapter.addFilter(new OpenEntityManagerInViewFilter(), "openEntityManagerInViewFilter", null);
    }

    adapter.setServletInstance(new SpringServlet());
    adapter.setContextPath(testContextPath);
    adapter.setServletPath(testServletPath);

    return adapter;
}
项目:SJPAReference    文件:ApplicationInitializer.java   
@Override
public void onStartup(ServletContext servletContext) throws ServletException {
    AnnotationConfigWebApplicationContext webAppContext = new AnnotationConfigWebApplicationContext();
    webAppContext.setConfigLocation(getClass().getPackage().getName());

       ServletRegistration.Dynamic dispatcher = servletContext.addServlet(DISPATCHER_SERVLET_NAME, new DispatcherServlet(webAppContext));
       dispatcher.setLoadOnStartup(1);
       dispatcher.addMapping(DISPATCHER_SERVLET_MAPPING);

       OpenEntityManagerInViewFilter openEntityManagerInViewFilter = new OpenEntityManagerInViewFilter();
    openEntityManagerInViewFilter.setEntityManagerFactoryBeanName("entityManagerFactory");

    Dynamic dynamic = servletContext.addFilter("openEntityManagerInViewFilter", openEntityManagerInViewFilter);
    dynamic.addMappingForUrlPatterns(getDispatcherTypes(), false, DISPATCHER_SERVLET_MAPPING);

    servletContext.addListener(new ContextLoaderListener(webAppContext));
}
项目:ctm    文件:WebInitializer.java   
@Override
public void onStartup(ServletContext servletContext) throws ServletException {
    CharacterEncodingFilter filter = new CharacterEncodingFilter();
    filter.setEncoding("UTF-8");
    filter.setForceEncoding(true);
    servletContext.addFilter("characterEncodingFilter", filter).addMappingForUrlPatterns(null, false, "/*");

    servletContext.addFilter("openEntityManagerInViewFilter", new OpenEntityManagerInViewFilter()).addMappingForUrlPatterns(null, false, "/*");

    DelegatingFilterProxy delegatingFilterProxy = new DelegatingFilterProxy();
    delegatingFilterProxy.setTargetFilterLifecycle(true);
    servletContext.addFilter("shiroFilter", delegatingFilterProxy).addMappingForUrlPatterns(null, false, "/*");

    servletContext.addServlet("kaptcha", new KaptchaServlet()).addMapping("/kaptcha");

    super.onStartup(servletContext);
}
项目:entelect-spring-webapp-template    文件:SpringDispatcherServletInitializer.java   
@Override
protected Filter[] getServletFilters() {
    return new Filter[]{
        new OpenEntityManagerInViewFilter(),
        new RecaptchaResponseFilter(),
        new ErrorHandlerFilter()
    };
}
项目:owsi-core-parent    文件:RestServerTestResource.java   
protected void configureContext(WebappContext context) {
    context.setInitParameter(ContextLoader.CONTEXT_CLASS_PARAM, AnnotationConfigWebApplicationContext.class.getName());
    context.setInitParameter(ContextLoader.CONTEXT_INITIALIZER_CLASSES_PARAM, ExtendedApplicationContextInitializer.class.getName());
    if (javaConfigClass != null) {
        context.setInitParameter(ContextLoader.CONFIG_LOCATION_PARAM, javaConfigClass.getName());
    }

    context.addListener(SLF4JLoggingListener.class);
    context.addListener(ContextLoaderListener.class);
    context.addFilter("openEntityManagerInViewFilter", new OpenEntityManagerInViewFilter())
            .addMappingForUrlPatterns(null, "/*");
}
项目:webanno    文件:WebAnnoWebInitializer.java   
@Override
public void onStartup(ServletContext aServletContext) throws ServletException
{
    // 2) Make username accessible to logging framework
    FilterRegistration loggingFilter = aServletContext.addFilter("logging",
            LoggingFilter.class);
    loggingFilter.addMappingForUrlPatterns(EnumSet.of(DispatcherType.REQUEST), false, "/*");

    // 5) Make sure we have one JPA session/transaction per request. Closes session at the
    // end, without this, changed data may not be automatically saved to the DB.
    FilterRegistration openSessionInViewFilter = aServletContext.addFilter("opensessioninview",
            OpenEntityManagerInViewFilter.class);
    openSessionInViewFilter.addMappingForUrlPatterns(EnumSet.of(DispatcherType.REQUEST), false,
            "/*");
}
项目:lumen    文件:WicketConfig.java   
@Bean
public FilterRegistrationBean openEntityManagerInViewFilter() {
    FilterRegistrationBean reg = new FilterRegistrationBean();
    reg.setName("OpenEntityManagerInViewFilter");
    reg.setFilter(new OpenEntityManagerInViewFilter());
    return reg;
}
项目:spring-agora-web    文件:AppInitializer.java   
private void initializeOpenEMInViewFilter(ServletContext container)
{
    OpenEntityManagerInViewFilter sessionFilter = new OpenEntityManagerInViewFilter();
    FilterRegistration.Dynamic filterReg = container.addFilter("Open EM In View Filter", sessionFilter);
    filterReg.addMappingForUrlPatterns(EnumSet.allOf(DispatcherType.class), true, URL_PATTERN_WEB);
    filterReg.addMappingForUrlPatterns(EnumSet.allOf(DispatcherType.class), true, URL_PATTERN_REST);
}
项目:unidle-old    文件:DispatcherServletInitializer.java   
@Override
protected Filter[] getServletFilters() {
    return new Filter[]{
            new MDCInsertingServletFilter(),
            new HiddenHttpMethodFilter(),
            new OpenEntityManagerInViewFilter(),
            new RequestContextFilter(),
            new SecurityContextPersistenceFilter()
    };
}
项目:joinfaces    文件:JpaWebAutoConfiguration.java   
@Bean
@ConditionalOnMissingBean
public OpenEntityManagerInViewFilter openEntityManagerInViewFilter() {
    return new OpenEntityManagerInViewFilter();
}
项目:joinfaces    文件:JpaWebAutoConfigurationTest.java   
@Test
public void testFilterEnabled() {
    OpenEntityManagerInViewFilter filter = this.applicationContext.getBean(OpenEntityManagerInViewFilter.class);

    assertThat(filter).isNotNull();
}
项目:joinfaces    文件:JpaWebAutoConfigurationDisabledTest.java   
@Test(expected = NoSuchBeanDefinitionException.class)
public void testFilterDisabled() {
    this.applicationContext.getBean(OpenEntityManagerInViewFilter.class);
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:AbstractJpaAutoConfigurationTests.java   
@Bean
public OpenEntityManagerInViewFilter openEntityManagerInViewFilter() {
    return new OpenEntityManagerInViewFilter();
}
项目:spring-boot-concourse    文件:AbstractJpaAutoConfigurationTests.java   
@Bean
public OpenEntityManagerInViewFilter openEntityManagerInViewFilter() {
    return new OpenEntityManagerInViewFilter();
}
项目:contestparser    文件:AbstractJpaAutoConfigurationTests.java   
@Bean
public OpenEntityManagerInViewFilter openEntityManagerInViewFilter() {
    return new OpenEntityManagerInViewFilter();
}
项目:simplebank    文件:Application.java   
private OpenEntityManagerInViewFilter buildOpenEntityManagerFilter() {
    OpenEntityManagerInViewFilter openEntityManagerInViewFilter = new OpenEntityManagerInViewFilter();
    openEntityManagerInViewFilter.setEntityManagerFactoryBeanName("entityManagerFactory");
    return openEntityManagerInViewFilter;
}
项目:members_cuacfm    文件:WebMvcConfig.java   
/**
 * Open entity manager in view filter.
 *
 * @return the open entity manager in view filter
 */
@Bean
public OpenEntityManagerInViewFilter openEntityManagerInViewFilter() {
    return new OpenEntityManagerInViewFilter();
}