Path: csiph.com!news.swapon.de!eternal-september.org!feeder.eternal-september.org!mx02.eternal-september.org!.POSTED!not-for-mail From: Martin Gregorie 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: References: <12be97a8-deb6-4684-a352-e01c3fd48285@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 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 |