Solved

URLStreamHandler Help

Posted on 1997-04-02
2
529 Views
Last Modified: 2006-11-17
I'm trying to create a custom URLStreamHandlerFactory, but also I need to change this factory at times...specifically
in individual threads.

The API reference for JDK 1.1 says the URL.SetURLStreamHandlerFactory function can only
be called once in an application.  Does this apply
to individual threads?  Or does it really mean once
in an application?  Are there any workarounds?
0
Comment
Question by:heech
2 Comments
 
LVL 1

Accepted Solution

by:
JWBito earned 100 total points
Comment Utility
I think the decision to make the factory a write-once variable was based on the desire to make the interface as lightweight as possible.  Changing the factory on the fly would require additional synchronization and hence more processing time.

Perhaps you want to define a class (implementing URLStreamHandlerFactory) that allows a thread to register itself (with its own map scheme-to-StreamHandler).  Then when createURLStreamHandler is called on your interface, you can find what driver to use based on the thread that you're executing on.

I suppose I could elaborate if this is going in the right direction.
0
 

Author Comment

by:heech
Comment Utility
Hmm... There is a problem...

Apparently URLStreamHandlerFactory is only called once
for each specific protocol...

My solution, I think, will be to create a URLStreamHandler,
(as well as a URLStreamHandlerFactory) which _is_ called by
different threads, and will be able to return the URLConenction
as necessary.. this takes out some of the functionality
I had hoped for..but should still be acceptable.

0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now