Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/arey/spring4-vfs2-support
JBoss VFS 2 support for Spring Framework 4.x
https://github.com/arey/spring4-vfs2-support
Last synced: 3 months ago
JSON representation
JBoss VFS 2 support for Spring Framework 4.x
- Host: GitHub
- URL: https://github.com/arey/spring4-vfs2-support
- Owner: arey
- Created: 2014-03-28T19:07:45.000Z (almost 11 years ago)
- Default Branch: master
- Last Pushed: 2016-03-05T09:07:46.000Z (almost 9 years ago)
- Last Synced: 2024-10-04T16:25:52.472Z (3 months ago)
- Language: Java
- Homepage:
- Size: 43.9 KB
- Stars: 12
- Watchers: 5
- Forks: 7
- Open Issues: 1
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
# JBoss VFS 2 support for Spring Framework 4.0 #
Spring Framework 4.0 removed support for JBoss AS 5's VFS variant. The Spring 4 VfsUtils class does not support any more the VFS 2 of JBoss AS 5 and JBoss 5.x EAP.
This project provides an AnnotationConfigWebApplicationContext subclass which support the VFS 2 of JBoss 5.
The JBoss5AnnotationConfigWebApplicationContext and JBoss5XmlWebApplicationContext classes worked with the Vfs2Utils class that is a simple copy/paste of the VfsUtils class of the Spring Framework 3.2.## Quick Start ##
1. Download the jar though Maven:
```xml
com.javaetmoi.core
javaetmoi-spring4-vfs2-support
1.4.1
```The Spring Batch Toolkit artefacts are available from [Maven Central](http://repo1.maven.org/maven2/com/javaetmoi/core/javaetmoi-spring4-vfs2-support/)
[![Maven Central](https://maven-badges.herokuapp.com/maven-central/com.javaetmoi.core/javaetmoi-spring4-vfs2-support/badge.svg)](https://maven-badges.herokuapp.com/maven-central/com.javaetmoi.core/javaetmoi-spring4-vfs2-support)
2. For Spring Java Config, declare the JBoss5AnnotationConfigWebApplicationContext into the web.xml
Either with the Spring ContextLoaderListener:
```contextClass
com.javaetmoi.core.spring.JBoss5AnnotationConfigWebApplicationContextcontextConfigLocation
com.example.MyAppWebConfigorg.springframework.web.context.ContextLoaderListener
```
Or with the Spring DispatcherServlet:
```mvc
org.springframework.web.servlet.DispatcherServlet
contextClass
com.javaetmoi.core.spring.JBoss5AnnotationConfigWebApplicationContext
contextConfigLocation
com.example.MyAppWebConfig
1```
3. For traditional XML configuration, declare the JBoss5XmlWebApplicationContext into the web.xml
```
contextClass
com.javaetmoi.core.spring.JBoss5XmlWebApplicationContextorg.springframework.web.context.ContextLoaderListener
```
4. Spring JPA supportThis module provides the Vfs2PersistenceUnitManager class that extends the Vfs2PersistenceUnitManager from Spring ORM
in order to use the Vfs2PathMatchingResourcePatternResolver.
How to use it:
```
@Bean
public EntityManagerFactory entityManagerFactory() {
LocalContainerEntityManagerFactoryBean em = new LocalContainerEntityManagerFactoryBean();
em.setDataSource(dataSource);
em.setPersistenceUnitName("myPersitenceUnit");
em.setPersistenceUnitManager(persistenceUnitManager());
// ...
em.afterPropertiesSet();
return em.getObject();
}@Bean
public Vfs2PersistenceUnitManager persistenceUnitManager() {
Vfs2PersistenceUnitManager pum = new Vfs2PersistenceUnitManager(applicationContext);
pum.setDefaultDataSource(dataSource);
pum.setDefaultPersistenceUnitName("myPersitenceUnit");
pum.setPackagesToScan("com.javaetmoi.demo.domain.model");
return pum;
}
```With Hibernate implementation, you have to disable the DefaultScanner by using the DisableHibernateScanner.
First, customize the ```hibernate.ejb.resource_scanner``` hibernate property:
```
```Then declare it into the ```entityManagerFactory```:
```...
```4. Spring MVC webjar support
With Spring MVC, static resources could be served from a webjar.
The Vfs2ResourceHandlerRegistry class prevents you for having the error java.lang.ClassNotFoundException: org.jboss.vfs.VFS from BaseClassLoader.How to use it:
```
@Configuration
@EnableWebMvc
public class WebConfig extends WebMvcConfigurerAdapter {@Autowired
private ApplicationContext applicationContext;
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
new Vfs2ResourceHandlerRegistry(registry, applicationContext)
.addResourceHandler("/resources/webjars/**")
.addResourceLocations("classpath:/META-INF/resources/webjars/");
}
}
```## References ##
* [French article explaining how is working this JBoss VFS 2 extension](http://javaetmoi.com/2014/04/support-vfs2-jboss5-spring4/)
* [GitHub commit by Juergen Hoeller](https://github.com/spring-projects/spring-framework/commit/ca194261a42a0a4f0c8bdc36f447e1029a7d2e3e)
* [Post on the Spring Forum](http://forum.spring.io/forum/spring-projects/container/744173-spring-4-doesn-t-support-vfs2)## Release Note ##
VersionRelease dateFeatures
1.4.2-SNAPSHOTnext version
1.4.105/03/2016JBoss5GenericXmlApplicationContext added
1.4.020/03/2015Add VFS2 support for Hibernate.
1.3.001/10/2014Add VFS2 support for Spring MVC webjars.
1.2.002/07/2014Fix added for Spring Framework 4.0.4 and 4.0.5. Add VFS2 support for JPA (Vfs2PersistenceUnitManager)
1.1.031/03/2014JBoss5XmlWebApplicationContext added
1.0.029/03/2014First release which supports Spring Framework 4.0.3
## Build Status ##
Cloudbees Jenkins : [![Build
Status](https://javaetmoi.ci.cloudbees.com/job/spring4-vfs2-support/badge/icon)](https://javaetmoi.ci.cloudbees.com/job/spring4-vfs2-support/)