I appreciate the quick response. 

I looked at the code of PassThroughFileSystem, and I must say it underlines my 
point here. In case someone wants to interpose on the default provider, he has 
to write all this boiler plate code. 
And unless they are aware of the PassThroughFileSystem, they will probably not 
do it right. The point being that the mechanism is not friendly for extension 
by developers.

Since delegation is the only feasible method available, I wonder whether you 
have any plans for introducing facilities that will allow extension by 
inheritance, or put some other hooks in place?

The reason I am insisting is because I think that a file system abstraction is 
a very powerful concept and I would definitely like to know whether you are 
planning to invest in this in the future.

-----Original Message-----
From: Alan Bateman [mailto:alan.bate...@oracle.com] 
Sent: יום ב 21 אוקטובר 2013 10:55
To: Pisarev, Vitaliy; nio-dev
Cc: core-libs-dev@openjdk.java.net
Subject: Re: Question about FileSystemProvider API in JDK7

On 21/10/2013 06:30, Pisarev, Vitaliy wrote:
> Hello,
>
> I was directed to this list by Brian Goetz, I am a new member and I am not 
> yet acquainted with how things go in these mailing lists.
> I am an SW Engineer and I am looking for some insight about the new 
> FileSystemProvider API. I posted a question on SO:
>
> http://stackoverflow.com/questions/19425836/tweaking-the-behavior-of-t
> he-default-file-system-in-java-7
>
> I hope this reaches you and your answer reaches me back.
>
The service provider interface allows you to replace the default provider or 
interpose on it (see the FileSystems.getDefault docs for the details on how 
this is configured). When you interpose on the default provider then you have 
the opportunity to do your customization although it can be tricky to ensure 
that you get all the delegation right. As a starting point then look at the 
PassThroughFileSystem in jdk/test tree, this is a provider used by some of the 
tests and may be what you are looking for.

If on the other hand that you are looking for something at the lower level, say 
to intercept calls to the operating system then there isn't anything in the APi 
for that.  To do customizations at that level requires using a native 
interposer library, or if Windows then it means using something like Detours 
[1].

-Alan.

[1] http://research.microsoft.com/pubs/68568/huntusenixnt99.pdf

Reply via email to