public class MemoryFileSystemFactoryBean extends Object
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/>
Modifier and Type | Field | Description |
---|---|---|
static String |
LINUX |
Value for
setType(String) to create a Linux like file system. |
static String |
MACOS |
Value for
setType(String) to create a Mac OS X like file system. |
static String |
WINDOWS |
Value for
setType(String) to create a Windows like file system. |
Constructor | Description |
---|---|
MemoryFileSystemFactoryBean() |
Modifier and Type | Method | Description |
---|---|---|
FileSystem |
getObject() |
Factory method that creates the file system.
|
void |
setName(String name) |
Sets the name that identifies the file system to create.
|
void |
setType(String type) |
Sets what type of file system should be created.
|
public static final String WINDOWS
setType(String)
to create a Windows like file system.public static final String LINUX
setType(String)
to create a Linux like file system.public static final String MACOS
setType(String)
to create a Mac OS X like file system.public void setName(String name)
The name must be unique across all memory file system instances.
If the name is not set, a random one will be generated.
name
- the name of the file system, this should be a purely
alpha numeric stringpublic void setType(String type)
public FileSystem getObject()
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/>
.
Copyright © 2011–2017. All rights reserved.