Class MemoryFileSystemFactoryBean

java.lang.Object
com.github.marschall.memoryfilesystem.MemoryFileSystemFactoryBean

public class MemoryFileSystemFactoryBean extends Object
A POJO factory bean to create memory file systems.

This class is intended to be used with Spring XML configuration. However it is not tied to Spring XML configuration. You can use it with Java configuration as well as any other dependency injection framework or even without one.

You can optionally configure the type file system that should be created (Windows, Linux, MacOS) and the name. The name shows up only when a path is converted to a URI.

A minimal Spring configuration can look something like this:


 <bean id="memoryFileSystemFactory"
    class="com.github.marschall.memoryfilesystem.MemoryFileSystemFactoryBean"/>

 <bean id="memoryFileSystem" destroy-method="close"
     factory-bean="memoryFileSystemFactory" factory-method="getObject"/>

 

You can also save the destroy-method enable @PreDestroy with:


 <bean id="memoryFileSystemFactory"
    class="com.github.marschall.memoryfilesystem.MemoryFileSystemFactoryBean"/>

 <bean id="memoryFileSystem"
     factory-bean="memoryFileSystemFactory" factory-method="getObject"/>

 <context:annotation-config/>
 
  • Field Details

  • Constructor Details

    • MemoryFileSystemFactoryBean

      public MemoryFileSystemFactoryBean()
  • Method Details

    • setName

      public void setName(String name)
      Sets the name that identifies the file system to create.

      The name must be unique across all memory file system instances.

      If the name is not set, a random one will be generated.

      Parameters:
      name - the name of the file system, this should be a purely alpha numeric string
    • setType

      public void setType(String type)
      Sets what type of file system should be created.
      Parameters:
      type - the file system type, one of "windows", "linux", "macos"
      See Also:
    • getObject

      public FileSystem getObject()
      Factory method that creates the file system.

      Make sure you invoke FileSystem.close() after you're done using it, otherwise you risk a resource leak. The easiest way to do is is to use <context:annotation-config/>.

      Returns:
      the file system