Java 7 FileSystem Providers as SPI questions
Alan.Bateman at oracle.com
Wed Jan 12 02:57:14 PST 2011
John Bryant wrote:
> I understand that FileSystem providers are extensions to the core as
> SPIs. I would like to write one for a project (its an elegant solution
> to a problem I have) but there is almost no examples or tutorials out
> on the Web. I saw one that was incomplete on a Zip file system
> provider but I need a little more help. I did manage to find the JAR
> containing the classes for the 'zipfs' and an online reference to the
> source code but its kind of muddled seeing as there isn't a giant sign
> reading, "Hey, start here! This is what you need!"
> It would be a big helped if someone knew the magic, "Start Here" and
> the "this is what you need to extend/implement" to get the ball rolling.
> Anyone willing to point me in that direction?
As Sherman said, the $JAVA_HOME/demo/nio/zipfs directory is where you'll
find the zip provider. There's a README in that directory to get you
started, and also a Demo class that allows you to copy files in/out of
zip files and do various other operations. Note that this provider is a
complete provider and this replaces the incomplete/read-only provider
that we originally had to demonstrate the provider interface. One of
docs engineer has recently created some material for the online
tutorials which should also be useful to those starting out with the zip
That said, I suspect you are actually looking for material on how to
develop your own provider. Sadly we are lacking in this regard so all I
can suggest is to start with java.nio.file.spi.FileSystemProvider and
use the zip provider as a reference (the complete source code to the
provider is in demo/nio/zipfs/src.zip). Another thing to say is that
developing a complete provider is a non-trivial task and much more work
compared to say developing a URL protocol handler.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the nio-dev