[jcifs] smb protocol handler

Michael B. Allen miallen at eskimo.com
Wed Dec 25 06:22:13 EST 2002

Very interesting. Where are the attached files?

On Tue, 24 Dec 2002 13:35:08 +0100
"Marc Hoffmann" <marc.hoffmann at mountainminds.com> wrote:

> Hi Mike,
> my name is Marc Hoffmann, working with Fujitsu EST GmbH, located in Munich.
> The company uses JCIFS for a while internally in one of their Java APIs (see
> conversation with Uwe Specht regarding closed pipes).
> The new URL design of version 0.7 introduces Java's powerful extension
> mechanism for new protocol types, but has also a serious impact on system
> properties and class loading (see e.g. "MalformedURLException" threads).
> Especially in the context of application servers this adds deployment
> hassles. Moreover, if necessary modifications of the security settings or
> system libraries are not possible this could become a "show stopper".
> Therefore I would like to suggest making the registration of the URL handler
> optional. It could explicitly triggered by an application by invoking a
> static method like "Config.registerSmbURLHandler()".
> To grant backward capability (concerning deployment) and allow standard
> deployment of e.g. web applications the internal JCIFS implementation should
> not rely on the registration of an URLStreamHandler.
> The 0.7.0b10 implementation could easily be changed to work without the need
> of the registered smb protocol. The basic idea is to explicitly pass the
> proper URLStreamHandler directly to the internally used java.net.URL
> constructors. Some testing proofed that the MalformedURLException does not
> happen, even if no system property is set and the jcifs.jar is located in
> the WEB-INF/lib of a web application only.
> I made the following modifications (source files attached):
> 1. Provide an internally used singleton instance of jcifs.smb.Handler:
>   static final URLStreamHandler SMB_HANDLER = new Handler();
> 2. Replace all URL constructors in SmbFile with the URL(URL context, String
> spec, URLStreamHandler handler) version, e.g.
>     public SmbFile( SmbFile context, String name ) throws
> MalformedURLException, UnknownHostException {
>         this( context.isWorkgroup0() ?
>             new URL(null, "smb://" + name, Handler.SMB_HANDLER) :
>             new URL( context.url, name, Handler.SMB_HANDLER),
> context.auth );
>     }
> 3. In the files SmbFileInputStream, SmbFileOutputStream, SmbNamedPipe
> replace "new SmbFile(new URL(urlstring))" by "new SmbFile(urlstring)".
> This modification would certainly avoid many error situations, especially
> for users who upgrade from older jcifs versions and do not use java.net.URL
> to identify resources at all.
> Best Regards,
> marc

A  program should be written to model the concepts of the task it
performs rather than the physical world or a process because this
maximizes  the  potential  for it to be applied to tasks that are
conceptually  similar and, more important, to tasks that have not
yet been conceived. 

More information about the jcifs mailing list