JBoss.orgCommunity Documentation

Snowdrop 1.1

User Guide


This chapter details how to use the individual components of the package.

For using this functionality, the snowdrop-vfs.jar file needs to be added to the application.

This library supports resource scanning in JBoss' Virtual File System. When doing resource scanning, the 2.5 version of the Spring framework used to assume that the resources are either coming from a directory or a packaged jar, and treats the URLs encountered in the process of scanning resources accordingly. This assumption does not hold in JBoss' Virtual File System.

The solution to this problem was to implement a different underlying resource resolution mechanism, namely in amending the functionality of the PathMatchingResourcePatternResolver. From the user's perspective, using this different resolution mechanism is done through using one of the two ApplicationContext implementations provided by this library, which are:

In many cases, the VFSClassPathXmlApplicationContext would be instantiated on its own, using something like:

ApplicationContext context = 
  new VFSClassPathXmlApplicationContext("classpath:/context-definition-file.xml");

The XmlWebApplicationContext is not instantiated directly, though, but bootstrapped by either the ContextLoaderListener, or the DispatcherServlet. In this case, the class to be used for bootstrapping needs to be used to trigger an instantiation of the VFS-enabled context.

For changing the type of application context created by the ContextLoaderListener, use the contextClass parameter, as shown in the sample below:

For changing the type of application context created by the DispatcherServlet, use the contextClass parameter again, but this time on the DispatcherServlet definition (emphasized portion again):

<servlet>
  <servlet-name>spring-mvc-servlet</servlet-name>
  <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
  <init-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>/WEB-INF/mvc-config.xml</param-value>
  </init-param>  
  <init-param>
  <param-name>contextClass</param-name>
    <param-value>
      org.jboss.spring.vfs.context.VFSXmlWebApplicationContext
    </param-value>
  </init-param>
</servlet>

Both configurations can be seen at work in the web-scanning sample.

The role of the Spring Deployer is to allow the bootstrapping of a Spring application context, binding it in JNDI and using it for providing Spring-configured business object instances.