Class MemoryFileSystemFactoryBean
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 Summary
FieldsModifier and TypeFieldDescriptionstatic final StringValue forsetType(String)to create a Linux like file system.static final StringValue forsetType(String)to create a Mac OS X like file system.static final StringValue forsetType(String)to create a Windows like file system. -
Constructor Summary
Constructors -
Method Summary
-
Field Details
-
WINDOWS
Value forsetType(String)to create a Windows like file system.- See Also:
-
LINUX
Value forsetType(String)to create a Linux like file system.- See Also:
-
MACOS
Value forsetType(String)to create a Mac OS X like file system.- See Also:
-
-
Constructor Details
-
MemoryFileSystemFactoryBean
public MemoryFileSystemFactoryBean()
-
-
Method Details
-
setName
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
Sets what type of file system should be created. -
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
-