org.springframework.orm.jpa.support.OpenEntityManagerInViewFilter Java Examples
The following examples show how to use
org.springframework.orm.jpa.support.OpenEntityManagerInViewFilter.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: InceptionWebInitializer.java From inception with Apache License 2.0 | 6 votes |
@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, "/*"); aServletContext.addListener(HttpSessionEventPublisher.class); }
Example #2
Source File: WebAnnoWebInitializer.java From webanno with Apache License 2.0 | 6 votes |
@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, "/*"); aServletContext.addListener(HttpSessionEventPublisher.class); }
Example #3
Source File: ActivitiUIApplication.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
@Bean public FilterRegistrationBean openEntityManagerInViewFilter() { FilterRegistrationBean<OpenEntityManagerInViewFilter> filterRegistrationBean = new FilterRegistrationBean<>(new OpenEntityManagerInViewFilter()); filterRegistrationBean.addUrlPatterns("/*"); filterRegistrationBean.setName("openEntityManagerInViewFilter"); filterRegistrationBean.setOrder(-200); // 必须在安全过滤器(-100)之前执行 filterRegistrationBean.setDispatcherTypes(EnumSet.of(DispatcherType.REQUEST, DispatcherType.FORWARD)); return filterRegistrationBean; }
Example #4
Source File: JpaWebAutoConfigurationTest.java From joinfaces with Apache License 2.0 | 5 votes |
@Test public void testInterceptorReplacedByFilter() { this.webApplicationContextRunner.run(context -> { assertThat(context).doesNotHaveBean(OpenEntityManagerInViewInterceptor.class); assertThat(context).hasSingleBean(OpenEntityManagerInViewFilter.class); }); }
Example #5
Source File: JpaWebAutoConfigurationTest.java From joinfaces with Apache License 2.0 | 5 votes |
@Test public void testDisabledByProperty() { this.webApplicationContextRunner .withPropertyValues("spring.jpa.open-in-view=false") .run(context -> { assertThat(context).doesNotHaveBean(OpenEntityManagerInViewInterceptor.class); assertThat(context).doesNotHaveBean(OpenEntityManagerInViewFilter.class); }); }
Example #6
Source File: JpaWebAutoConfigurationTest.java From joinfaces with Apache License 2.0 | 5 votes |
@Test public void testDisabledByMissingEntityManagerClass() { this.webApplicationContextRunner .withClassLoader(new FilteredClassLoader(EntityManager.class)) .run(context -> { assertThat(context).doesNotHaveBean(OpenEntityManagerInViewInterceptor.class); assertThat(context).doesNotHaveBean(OpenEntityManagerInViewFilter.class); }); }
Example #7
Source File: Application.java From we-cmdb with Apache License 2.0 | 4 votes |
@Override protected Filter[] getServletFilters() { return new Filter[] { new OpenEntityManagerInViewFilter() }; }
Example #8
Source File: Application.java From we-cmdb with Apache License 2.0 | 4 votes |
@Override protected Filter[] getServletFilters() { return new Filter[] { new OpenEntityManagerInViewFilter() }; }
Example #9
Source File: JpaWebAutoConfiguration.java From joinfaces with Apache License 2.0 | 4 votes |
@Bean @ConditionalOnMissingBean({OpenEntityManagerInViewInterceptor.class, OpenEntityManagerInViewFilter.class}) @ConditionalOnMissingFilterBean(OpenEntityManagerInViewFilter.class) public OpenEntityManagerInViewFilter openEntityManagerInViewFilter() { return new OpenEntityManagerInViewFilter(); }
Example #10
Source File: SecurityFilterConfig.java From cosmo with Apache License 2.0 | 4 votes |
@Bean public FilterRegistrationBean<?> openEntityManagerInViewFilter() { FilterRegistrationBean<?> filterBean = new FilterRegistrationBean<>(new OpenEntityManagerInViewFilter()); filterBean.addUrlPatterns(PATH_DAV); return filterBean; }
Example #11
Source File: WebMvcConfig.java From SpringBoot-Base-System with GNU Lesser General Public License v3.0 | 3 votes |
/** * Spring * 提供了FilterRegistrationBean类,此类提供setOrder方法,可以为filter设置排序值,让spring在注册web * filter之前排序后再依次注册。 * * @time 2018年4月10日 下午4:58:19. * * @version V1.0 * @return FilterRegistrationBean */ @Bean public FilterRegistrationBean registFilter() { FilterRegistrationBean registration = new FilterRegistrationBean(); registration.setFilter(new OpenEntityManagerInViewFilter()); registration.addUrlPatterns("/*"); registration.setOrder(1); return registration; }