Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #33872

Re: Implementing FileSystem without MANIFEST.MF/META-INF/services

Path csiph.com!news.swapon.de!eternal-september.org!feeder.eternal-september.org!mx02.eternal-september.org!.POSTED!not-for-mail
From Martin Gregorie <martin@address-in-sig.invalid>
Newsgroups comp.lang.java.programmer
Subject Re: Implementing FileSystem without MANIFEST.MF/META-INF/services
Date Wed, 24 Feb 2016 18:45:01 -0000 (UTC)
Organization A noiseless patient Spider
Lines 56
Message-ID <naktnd$9ei$1@dont-email.me> (permalink)
References <12be97a8-deb6-4684-a352-e01c3fd48285@googlegroups.com> <naj0rg$12k0$1@gioia.aioe.org> <f2327b98-10be-47ca-87c8-939228161ffb@googlegroups.com>
Mime-Version 1.0
Content-Type text/plain; charset=UTF-8
Content-Transfer-Encoding 8bit
Injection-Date Wed, 24 Feb 2016 18:45:01 -0000 (UTC)
Injection-Info mx02.eternal-september.org; posting-host="e5160e2be48f1ea550cf61512446f525"; logging-data="9682"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+z4cdZrhoP8WlcmpoblkAuWn7H0OTtMCI="
User-Agent Pan/0.140 (Chocolate Salty Balls; GIT 3663720 git://git.gnome.org/pan2)
Cancel-Lock sha1:JgT/ybfi+brTWuYxNJEsZQcrf5E=
Xref csiph.com comp.lang.java.programmer:33872

Show key headers only | View raw


On Wed, 24 Feb 2016 00:14:13 -0800, david.raver wrote:

> On Wednesday, February 24, 2016 at 2:26:32 AM UTC+1, Arne Vajhøj wrote:
>> On 2/23/2016 2:41 PM, david...@gmail.com wrote:
>> > I'm trying to set up a file system (by implementing
>> > FileSystemProvider, FileSystem, FileStore, etc.) so that later a user
>> > could only call FileSystems.getFileSystem(uri), with a specific URI
>> > (custom scheme, host, path, etc).
>> >
>> > This is normally done by putting an entry into jar's
>> > MANIFEST.MF/META-INF/services, so that a JVM - using that information
>> > - can set it up itself, but I don't have that option. I want to do it
>> > programmatically. How can this be done?
>> 
>> Class.forName ????
>> 
>> Arne
> 
> Yes, that works (it would be even simpler to just call a constructor of
> my extension of FileSystem class). But...
> 
> But it requires knowledge of class name and, more importantly, even an
> instance of class loader that has to be used to load/define a class
> (using Class.forName(String, boolean, ClassLoader)). I can't expose that
> to the user.
>
But you can provide the equivalent of a login command that prompts the 
user for the URI as well as authentication details, e.g. user name, 
password. 

> The platform would initialize everything except the FileSystem before 
>handing control to the user.

The user issues the login command, which accepts the URI and 
authentication details from the user.

Once the user has been authenticated login command would then get the 
FileSystem instance using a class name that's related to the the user-
supplied URI[1], carry out FileSystem-specific initialisation and then 
hand control back to the user.

You'd also need a logout equivalent to cleanly shut down and disconnect 
the FileSystem when the user wants to quit and/or change FilingSystems.

[1] Its your job to specify the relationship between URI and class name 
and implement a mechanism for storing them and retrieving the class name 
for any valid URI and calling Class.forName() to obtain a FileSystem 
instance. Since you've said there's a relationship between URI and class 
name but given no additional details we can't say anything more about 
that.


-- 
martin@   | Martin Gregorie
gregorie. | Essex, UK
org       |

Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Implementing FileSystem without MANIFEST.MF/META-INF/services david.raver@gmail.com - 2016-02-23 11:41 -0800
  Re: Implementing FileSystem without MANIFEST.MF/META-INF/services Arne Vajhøj <arne@vajhoej.dk> - 2016-02-23 20:26 -0500
    Re: Implementing FileSystem without MANIFEST.MF/META-INF/services david.raver@gmail.com - 2016-02-24 00:14 -0800
      Re: Implementing FileSystem without MANIFEST.MF/META-INF/services Martin Gregorie <martin@address-in-sig.invalid> - 2016-02-24 18:45 +0000
        Re: Implementing FileSystem without MANIFEST.MF/META-INF/services david.raver@gmail.com - 2016-02-24 12:31 -0800

csiph-web