Package net.sf.fikin.net.protocols.classpath

This package provides support for "classpath:" URL protocol handling.

See:
          Description

Class Summary
ClasspathStreamHandlerFactory Classloader protocol handler factory created on Oct 9, 2006
Handler URL protocol handler supporting predefined list of classloaders to load the given resource.
 

Package net.sf.fikin.net.protocols.classpath Description

This package provides support for "classpath:" URL protocol handling.

Package Specification

This protocol hanlder allows for classpath-available resource referencing via java.net.URL objects by specifying urls in the format "classpath:net/sf/fikin/ant/version.txt".

The resource is looked up by a predefined list of classloaders:

One can customize this order by setting its own classloader to ClasspathStreamHandlerFactory.primaryClassLoader.

Classloader will be used to load the resource before any method of the URL object is executed.

Simply creating an URL object of "classpath:" protocol would not cause any resource lookups.

Using this protocol handler is possible via two ways:

1. Set an application's URLStreamHandlerFactory

Place following in the beginning of your application, such as main(String[]) or other simillar place:

URL.setURLStreamHandlerFactory( new ClasspathStreamHandlerFactory() );

This method can be called at most once in a given Java Virtual Machine.

The URLStreamHandlerFactory instance is used to construct a stream protocol handler from a protocol name.

If there is a security manager, this method first calls the security manager's checkSetFactory method to ensure the operation is allowed. This could result in a SecurityException.

2. Set system property "java.protocol.handler.pkgs"

Set following value to the system property prior to execute your application: java -Djava.protocol.handler.pkgs=net.sf.fikin.net.protocols ...

If there are other values set to that propery, use "|" as an delimiter.



Copyright © 2003-2007 Nikolay Fiykov. All Rights Reserved.