ObjectWeb Consortium
Search ObjectWeb Mail Archive: 

Advanced Search - Powered by Google

Mail Archive Home | oscar List | July 2005 Index

<--  Date Index  --> <--  Thread Index  -->

Problems with URLStreamHandlerService

Hi all,  (sorry for a somewhat long mail)

I searched the archives, but I can't find any mails regarding this.

I am trying to get a "artifact:" protocol working, for location-independent 
resolution of Jars and other artifacts. This is a concept used in Maven and 
other places, so that the application can be freed from distributing its own 
dependencies, having globally resolvable URLs, locally cached and (soon) 
verification of the authenticity of these artifacts.

The formal URL format is;


and will be translated (if Maven classic layout) into;


and [baseURL] is defined for one or more configured central/local 

  [baseURL] = http://www.ibiblio.org/maven
  url =  artifact:jar:log4j/log4j#1.2.9

translates into 


I implemented the DPML Transit subsystem to do this very neatly, for all 
applications, as long as they are capable of using URLs.

Now, I am in the process of making that into an OSGi bundle, so it can be 
installed easier on OSGi platforms.

OK. Back to the issue at hand;

I create a ArtifactStreamHandlerService extends 
AbstractURLStreamHandlerService, and in its constructor register it as a 

public ArtifactStreamHandlerService( BundleContext context )
    Hashtable properties = new Hashtable();
    properties.put( URLConstants.URL_HANDLER_PROTOCOL, new String[] 
{ "artifact" } );
   m_Registration = 
context.registerService( URLStreamHandlerService.class.getName(), this, 
properties );

And the only real adoption I need is the delegation method back to Transit;

public URLConnection openConnection( URL url )
    throws IOException
    return new ArtifactURLConnection( url, SecuredTransitContext.create() );

When creating a URL in another Bundle 
    URL url = new URL( "artifact:jar:test/dpml-test-teste#2912");
I get "java.net.MalformedURLException: unknown protocol: artifact"

At first, I thought I am doing something wrong, but (for some reason), I did 
simple grep on URLStreamHandlerFactory in the Oscar SVN codebase, and didn't 
find any usage, which surprised me.
So, a simple
    URL.setURLStreamHandlerFactory( new TestFactory() );

put into the start() method of my bundle, does NOT give me a 
factory already defined" as expected.

I can't figure this out. I can only see;
  1. I am using Oscar embedded, and that this is setup outside the Oscar 
     entry class.
  2. I have something setup totally wrong.
  3. Oscar does not implement chapter 8 of OSGi R3 at all.
  4. This is not "by default" and I need to enable it somehow.
  5. I don't understand the specification.

Clarifications would be appreciated.

If this is missing from Oscar, I would appreciate pointers of roughly where 
the code should go, and I will get on with implementing a patch.


P.S. For people interested in this bundle; The answer "Yes" it is available 
for free use under the Apache license. It may even be placed into the 
Incubation of Oscar itself at Apache, as I am Apache committer. For now, it 
exist at http://www.ops4j.org and anyone is welcome to join in. Also, feel 
free to contact me directly.

<--  Date Index  --> <--  Thread Index  -->

Reply via email to:

Powered by MHonArc.

Copyright © 1999-2005, ObjectWeb Consortium | contact | webmaster.