jersey2-vfs2

Apache VFS2 (Virtual File System 2) jersey injectors.

This library provides HK2 injectors and container lifecycle components for Apache’s Commons Virtual File System. This feature does not include filesystem adapters, though you can add any that you wish by using VFS2’s xml configuration.

<dependency>
    <groupId>net.krotscheck.jersey2</groupId>
    <artifactId>jersey2-vfs2</artifactId>
    <version>2.1.1</version>
</dependency>

Quickstart

First, register the feature in your application in accordance with the Jersey2 Application Model.

import net.krotscheck.jersey2.vfs2.VFS2Feature;
import org.glassfish.jersey.server.ResourceConfig;

public class YourApplication extends ResourceConfig {
    public YourApplication() {
        register(VFS2Feature.class);
    }
}

Second, inject the VFS FileSystemManager into your service.

@Path("/path")
public class MyService {

    @Inject
    public FileSystemManager fsManager;

    @GET
    @Produces(MediaType.APPLICATION_JSON)
    public Response getMethod() {
        return Response.ok().build();
    }
}

The FileSystemManager is provided within the singleton scope. Actual FileObjects are attached to a VFS FileSystem, and you must make sure to dispose of those connections over the span of your own code.

Provided Components

This feature provides the following components and component binders. Scope, Types, and Names are provided.

FileSystemManager

A VFS FileSystemManager, used as the singleton source of all filesystems. If you want closer control over the lifecycle of your FileSystems, or wich to resolve FileObjects directly, you may inject this and use it as you see fit.

  • Scope: Singleton
  • Type: org.apache.commons.vfs2.FileSystemManager
@Path("/path")
public class MyService {

    @Inject
    public FileSystemManager fsManager;

    @GET
    @Produces(MediaType.APPLICATION_JSON)
    public Response getMethod() {
        return Response.ok().build();
    }
}

Back to top

Version: 2.1.1.